Use texel fetch instead of normalized sampling for subpass.

Cleaner output code, and matches more directly to how subpass reads work.
This commit is contained in:
Hans-Kristian Arntzen 2016-05-05 09:19:38 +02:00
parent 926916d745
commit 9d4b5c0c59
2 changed files with 3 additions and 3 deletions

View File

@ -9,6 +9,6 @@ layout(location = 0) out vec4 FragColor;
void main()
{
FragColor = (texture(uSubpass0, gl_FragCoord.xy / vec2(textureSize(uSubpass0, 0).xy)) + texture(uSubpass1, gl_FragCoord.xy / vec2(textureSize(uSubpass1, 0).xy)));
FragColor = (texelFetch(uSubpass0, ivec2(gl_FragCoord.xy), 0) + texelFetch(uSubpass1, ivec2(gl_FragCoord.xy), 0));
}

View File

@ -3104,8 +3104,8 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
{
// Implement subpass loads via texture barrier style sampling.
// Fairly ugly, but should essentially work as a fallback for desktop.
imgexpr = join("texture(", to_expression(ops[2]),
", gl_FragCoord.xy / vec2(textureSize(", to_expression(ops[2]), ", 0).xy))");
imgexpr = join("texelFetch(", to_expression(ops[2]),
", ivec2(gl_FragCoord.xy), 0)");
pure = true;
}
else