GPU/HW: Fix shader sampling with MSAA on

This commit is contained in:
Stenzek 2024-05-03 13:24:32 +10:00
parent 1185f8f6aa
commit e3b0050ca1
No known key found for this signature in database
1 changed files with 11 additions and 6 deletions

View File

@ -590,8 +590,10 @@ void ShaderGen::DeclareFragmentEntryPoint(
#ifdef ENABLE_VULKAN
if (m_render_api == RenderAPI::Vulkan)
{
ss << "layout(input_attachment_index = 0, set = 2, binding = 0) uniform subpassInput u_input_rt;\n";
ss << "#define LAST_FRAG_COLOR subpassLoad(u_input_rt)\n";
ss << "layout(input_attachment_index = 0, set = 2, binding = 0) uniform "
<< (msaa ? "subpassInputMS" : "subpassInput") << " u_input_rt; \n";
ss << "#define LAST_FRAG_COLOR " << (msaa ? "subpassLoad(u_input_rt, gl_SampleID)" : "subpassLoad(u_input_rt)")
<< "\n";
}
#endif
#ifdef __APPLE__
@ -600,13 +602,16 @@ void ShaderGen::DeclareFragmentEntryPoint(
if (m_supports_framebuffer_fetch)
{
// Set doesn't matter, because it's transformed to color0.
ss << "layout(input_attachment_index = 0, set = 2, binding = 0) uniform subpassInput u_input_rt;\n";
ss << "#define LAST_FRAG_COLOR subpassLoad(u_input_rt)\n";
ss << "layout(input_attachment_index = 0, set = 2, binding = 0) uniform "
<< (msaa ? "subpassInputMS" : "subpassInput") << " u_input_rt; \n";
ss << "#define LAST_FRAG_COLOR "
<< (msaa ? "subpassLoad(u_input_rt, gl_SampleID)" : "subpassLoad(u_input_rt)") << "\n";
}
else
{
ss << "layout(set = 2, binding = 0) uniform texture2D u_input_rt;\n";
ss << "#define LAST_FRAG_COLOR texelFetch(u_input_rt, int2(gl_FragCoord.xy), 0)\n";
ss << "layout(set = 2, binding = 0) uniform " << (msaa ? "texture2D" : "texture2DMS") << "u_input_rt;\n";
ss << "#define LAST_FRAG_COLOR texelFetch(u_input_rt, int2(gl_FragCoord.xy), " << (msaa ? "gl_SampleID" : "0")
<< ")\n";
}
}
#endif