mirror of
https://github.com/KhronosGroup/glslang
synced 2024-09-19 20:29:54 +00:00
7c3c50ea94
SPIR-V requires that any instruction using the result of an OpSampledImage instruction be in the same block as the OpSampledImage. This is hard to guarantee in code generation but easy to fix after the fact, by simply inserting a new OpSampledImage before the user of its result if needed, with the new instruction having the same operands as the original OpSampledImage. This change adds a new pass to spv::Builder::postProcess that does this. This might leave the original OpSampledImage instructions "orphaned" with no users of their result ID, but dead code elimination would take care of those further down the line.
22 lines
498 B
GLSL
22 lines
498 B
GLSL
#version 450
|
|
|
|
layout(set = 0, binding = 0) uniform texture2D tex0;
|
|
layout(set = 0, binding = 1) uniform sampler samp0;
|
|
layout(set = 0, binding = 2) uniform ParamBuffer {
|
|
int cond;
|
|
} paramBuffer;
|
|
|
|
layout(location = 0) out vec4 fragColor;
|
|
layout(location = 0) in flat ivec2 texCoord;
|
|
|
|
void main() {
|
|
// get input
|
|
|
|
const vec4 texel = texelFetch(sampler2D(tex0, samp0),
|
|
paramBuffer.cond == 0 ? texCoord.xy : texCoord.yx,
|
|
0);
|
|
|
|
fragColor = vec4(texel.xyz, 1.0);
|
|
|
|
}
|