fix: output shader issues

This commit is contained in:
Samuliak 2024-11-19 19:55:54 +01:00
parent cabf56851e
commit fda2f40640
No known key found for this signature in database

View File

@ -1,5 +1,6 @@
#include "Cafe/HW/Latte/Renderer/RendererOuputShader.h" #include "Cafe/HW/Latte/Renderer/RendererOuputShader.h"
#include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h" #include "Cafe/HW/Latte/Renderer/OpenGL/OpenGLRenderer.h"
#include "HW/Latte/Renderer/Renderer.h"
const std::string RendererOutputShader::s_copy_shader_source = const std::string RendererOutputShader::s_copy_shader_source =
R"( R"(
@ -244,7 +245,11 @@ fragment float4 main0(VertexOut in [[stage_in]], texture2d<float> textureSrc [[t
RendererOutputShader::RendererOutputShader(const std::string& vertex_source, const std::string& fragment_source) RendererOutputShader::RendererOutputShader(const std::string& vertex_source, const std::string& fragment_source)
{ {
auto finalFragmentSrc = PrependFragmentPreamble(fragment_source); std::string finalFragmentSrc;
if (g_renderer->GetType() == RendererAPI::Metal)
finalFragmentSrc = fragment_source;
else
finalFragmentSrc = PrependFragmentPreamble(fragment_source);
m_vertex_shader = g_renderer->shader_create(RendererShader::ShaderType::kVertex, 0, 0, vertex_source, false, false); m_vertex_shader = g_renderer->shader_create(RendererShader::ShaderType::kVertex, 0, 0, vertex_source, false, false);
m_fragment_shader = g_renderer->shader_create(RendererShader::ShaderType::kFragment, 0, 0, finalFragmentSrc, false, false); m_fragment_shader = g_renderer->shader_create(RendererShader::ShaderType::kFragment, 0, 0, finalFragmentSrc, false, false);
@ -470,6 +475,22 @@ layout(location = 0) out vec4 colorOut0;
} }
void RendererOutputShader::InitializeStatic() void RendererOutputShader::InitializeStatic()
{ {
if (g_renderer->GetType() == RendererAPI::Metal)
{
std::string vertex_source = GetMetalVertexSource(false);
std::string vertex_source_ud = GetMetalVertexSource(true);
s_copy_shader = new RendererOutputShader(vertex_source, s_copy_shader_source_mtl);
s_copy_shader_ud = new RendererOutputShader(vertex_source_ud, s_copy_shader_source_mtl);
s_bicubic_shader = new RendererOutputShader(vertex_source, s_bicubic_shader_source_mtl);
s_bicubic_shader_ud = new RendererOutputShader(vertex_source_ud, s_bicubic_shader_source_mtl);
s_hermit_shader = new RendererOutputShader(vertex_source, s_hermite_shader_source_mtl);
s_hermit_shader_ud = new RendererOutputShader(vertex_source_ud, s_hermite_shader_source_mtl);
}
else
{
std::string vertex_source, vertex_source_ud; std::string vertex_source, vertex_source_ud;
// vertex shader // vertex shader
if (g_renderer->GetType() == RendererAPI::OpenGL) if (g_renderer->GetType() == RendererAPI::OpenGL)
@ -490,4 +511,5 @@ void RendererOutputShader::InitializeStatic()
s_hermit_shader = new RendererOutputShader(vertex_source, s_hermite_shader_source); s_hermit_shader = new RendererOutputShader(vertex_source, s_hermite_shader_source);
s_hermit_shader_ud = new RendererOutputShader(vertex_source_ud, s_hermite_shader_source); s_hermit_shader_ud = new RendererOutputShader(vertex_source_ud, s_hermite_shader_source);
}
} }