Cemu/src/Cafe/HW/Latte/Renderer/RendererOuputShader.h
2025-12-06 17:14:25 +01:00

75 lines
2.1 KiB
C++

#pragma once
#include "Cafe/HW/Latte/Renderer/RendererShader.h"
#include "util/math/vector2.h"
#include "Cafe/HW/Latte/Core/LatteTexture.h"
class RendererOutputShader
{
public:
enum Shader
{
kCopy,
kBicubic,
kHermit,
};
RendererOutputShader(const std::string& vertex_source, const std::string& fragment_source);
virtual ~RendererOutputShader() = default;
void SetUniformParameters(const LatteTextureView& texture_view, const Vector2i& output_res, const bool padView) const;
RendererShader* GetVertexShader() const
{
return m_vertex_shader.get();
}
RendererShader* GetFragmentShader() const
{
return m_fragment_shader.get();
}
static void InitializeStatic();
static void ShutdownStatic();
static RendererOutputShader* s_copy_shader;
static RendererOutputShader* s_copy_shader_ud;
static RendererOutputShader* s_bicubic_shader;
static RendererOutputShader* s_bicubic_shader_ud;
static RendererOutputShader* s_hermit_shader;
static RendererOutputShader* s_hermit_shader_ud;
static std::string GetOpenGlVertexSource(bool render_upside_down);
static std::string GetVulkanVertexSource(bool render_upside_down);
static std::string GetMetalVertexSource(bool render_upside_down);
static std::string PrependFragmentPreamble(const std::string& shaderSrc);
protected:
std::unique_ptr<RendererShader> m_vertex_shader;
std::unique_ptr<RendererShader> m_fragment_shader;
struct UniformLocations
{
sint32 m_loc_textureSrcResolution = -1;
sint32 m_loc_nativeResolution = -1;
sint32 m_loc_outputResolution = -1;
sint32 m_loc_applySRGBEncoding = -1;
sint32 m_loc_targetGamma = -1;
sint32 m_loc_displayGamma = -1;
} m_uniformLocations[2]{};
private:
static const std::string s_copy_shader_source;
static const std::string s_bicubic_shader_source;
static const std::string s_hermite_shader_source;
static const std::string s_bicubic_shader_source_vk;
static const std::string s_hermite_shader_source_vk;
static const std::string s_copy_shader_source_mtl;
static const std::string s_bicubic_shader_source_mtl;
static const std::string s_hermite_shader_source_mtl;
};