diff --git a/src/util/shadergen.cpp b/src/util/shadergen.cpp index 0b6ab97ec..e778181bd 100644 --- a/src/util/shadergen.cpp +++ b/src/util/shadergen.cpp @@ -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