PostProcessing: Fix for Metal renderer

This commit is contained in:
Stenzek 2023-11-04 20:28:45 +10:00
parent 9d88a373bd
commit ca5b07acff
No known key found for this signature in database
4 changed files with 19 additions and 17 deletions

View file

@ -699,8 +699,6 @@ bool PostProcessing::Apply(GPUFramebuffer* final_target, s32 final_left, s32 fin
if (!CheckTargets(target_format, target_width, target_height)) if (!CheckTargets(target_format, target_width, target_height))
return false; return false;
g_gpu_device->SetViewportAndScissor(final_left, final_top, final_width, final_height);
GPUTexture* input = s_input_texture.get(); GPUTexture* input = s_input_texture.get();
GPUFramebuffer* input_fb = s_input_framebuffer.get(); GPUFramebuffer* input_fb = s_input_framebuffer.get();
GPUTexture* output = s_output_texture.get(); GPUTexture* output = s_output_texture.get();

View file

@ -1281,10 +1281,23 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUFramebuffer* f
for (const Pass& pass : m_passes) for (const Pass& pass : m_passes)
{ {
GL_SCOPE_FMT("Draw pass {}", pass.name.c_str()); GL_SCOPE_FMT("Draw pass {}", pass.name.c_str());
GL_INS_FMT("Render Target: ID {} [{}]", pass.render_target, GetTextureNameForID(pass.render_target)); GL_INS_FMT("Render Target: ID {} [{}]", pass.render_target, GetTextureNameForID(pass.render_target));
GPUFramebuffer* output_fb = GetFramebufferByID(pass.render_target, input, final_target); GPUFramebuffer* output_fb = GetFramebufferByID(pass.render_target, input, final_target);
g_gpu_device->SetFramebuffer(output_fb);
if (!output_fb)
{
// Drawing to final buffer.
if (!g_gpu_device->BeginPresent(false))
{
GL_POP();
return false;
}
}
else
{
g_gpu_device->SetFramebuffer(output_fb);
}
g_gpu_device->SetPipeline(pass.pipeline.get()); g_gpu_device->SetPipeline(pass.pipeline.get());
// Set all inputs first, before the render pass starts. // Set all inputs first, before the render pass starts.
@ -1292,7 +1305,7 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUFramebuffer* f
for (const Sampler& sampler : pass.samplers) for (const Sampler& sampler : pass.samplers)
{ {
GL_INS_FMT("Texture Sampler {}: ID {} [{}]", sampler.slot, sampler.texture_id, GL_INS_FMT("Texture Sampler {}: ID {} [{}]", sampler.slot, sampler.texture_id,
GetTextureNameForID(sampler.texture_id)); GetTextureNameForID(sampler.texture_id));
g_gpu_device->SetTextureSampler(sampler.slot, GetTextureByID(sampler.texture_id, input, final_target), g_gpu_device->SetTextureSampler(sampler.slot, GetTextureByID(sampler.texture_id, input, final_target),
sampler.sampler); sampler.sampler);
bound_textures[sampler.slot] = true; bound_textures[sampler.slot] = true;
@ -1306,16 +1319,6 @@ bool PostProcessing::ReShadeFXShader::Apply(GPUTexture* input, GPUFramebuffer* f
g_gpu_device->SetTextureSampler(i, nullptr, nullptr); g_gpu_device->SetTextureSampler(i, nullptr, nullptr);
} }
if (!output_fb)
{
// Drawing to final buffer.
if (!g_gpu_device->BeginPresent(false))
{
GL_POP();
return false;
}
}
g_gpu_device->Draw(pass.num_vertices, 0); g_gpu_device->Draw(pass.num_vertices, 0);
} }

View file

@ -176,6 +176,7 @@ bool PostProcessing::GLSLShader::Apply(GPUTexture* input, GPUFramebuffer* final_
g_gpu_device->SetPipeline(m_pipeline.get()); g_gpu_device->SetPipeline(m_pipeline.get());
g_gpu_device->SetTextureSampler(0, input, m_sampler.get()); g_gpu_device->SetTextureSampler(0, input, m_sampler.get());
g_gpu_device->SetViewportAndScissor(final_left, final_top, final_width, final_height);
const u32 uniforms_size = GetUniformsSize(); const u32 uniforms_size = GetUniformsSize();
void* uniforms = g_gpu_device->MapUniformBuffer(uniforms_size); void* uniforms = g_gpu_device->MapUniformBuffer(uniforms_size);
@ -377,7 +378,7 @@ static float4 o_col0;
{ {
if (m_use_glsl_interface_blocks) if (m_use_glsl_interface_blocks)
{ {
if (IsVulkan()) if (IsVulkan() || IsMetal())
ss << "layout(location = 0) "; ss << "layout(location = 0) ";
ss << "in VertexData {\n"; ss << "in VertexData {\n";

View file

@ -19,7 +19,7 @@ ShaderGen::ShaderGen(RenderAPI render_api, bool supports_dual_source_blend)
m_spirv(render_api == RenderAPI::Vulkan || render_api == RenderAPI::Metal), m_spirv(render_api == RenderAPI::Vulkan || render_api == RenderAPI::Metal),
m_supports_dual_source_blend(supports_dual_source_blend), m_use_glsl_interface_blocks(false) m_supports_dual_source_blend(supports_dual_source_blend), m_use_glsl_interface_blocks(false)
{ {
#if defined(ENABLE_OPENGL) || defined(ENABLE_VULKAN) #if defined(ENABLE_OPENGL) || defined(ENABLE_VULKAN) || defined(__APPLE__)
if (m_glsl) if (m_glsl)
{ {
#ifdef ENABLE_OPENGL #ifdef ENABLE_OPENGL