I’m having some issues while compiling a compute shader with the following code:
… // extensions declarations + includes + uniform buffers
uniform int LOD;
uniform int GRADS;
void main(void){
const ivec2 block = ivec2(gl_GlobalInvocationID.x / 2, gl_GlobalInvocationID.y) / (BASE_SPHERICAL_LIGHTING_BLOCk_SIZE>>LOD);layout(rgba16f) image2D dstImg =
layout(rgba16f) image2D(GRADS>0 ?
svo.lods[0].lightProbes.convolved_grads[LOD].img :
svo.lods[0].lightProbes.convolved_coeffs[LOD].img);sampler2D lightProbes = sampler2D(GRADS>0 ?
svo.lods[0].lightProbes.grads[LOD].tex :
svo.lods[0].lightProbes.coeffs[LOD].tex);if(isLightProbeAllocated(block, lightProbes)){ // this always returns true at runtime
vec3 v = convolve_light_probe(LOD, lightProbes); // non-zero return value
imageStore(dstImg, ivec2(gl_GlobalInvocationID), vec4(v, 0.0f));
}else{
imageStore(dstImg, ivec2(gl_GlobalInvocationID), vec4(1, 1, 1, 0.0f)); // this is never called
}}
which does not work: dstImg contains only zeroes after execution.
However, the program works once the else statement is removed, even though the else statement is never called at runtime:
if(isLightProbeAllocated(block, lightProbes)){ // this always returns true at runtime
vec3 v = convolve_light_probe(LOD, lightProbes); // non-zero return value
imageStore(dstImg, ivec2(gl_GlobalInvocationID), vec4(v, 0.0f));
}
Long story short, removing the else statement makes it work even though this path of the code is not used at runtime anyway.
I’m suspecting a compiler bug. What should I do?
Driver version is 520.61.05 on ubuntu 18.04 with an rtx A6000.