GLSL
GLSL copied to clipboard
GL_EXT_subgroupuniform_qualifier and flow control rejoining
cc @sheredom
Consider this example:
subgroupuniformEXT int x;
if ((gl_InvocationID & 1) != 0) {
x = 0
} else {
x = 1
}
use x;
Both assignments can be correctly decorated as Uniform in the SPIR-V, but when the if and else blocks rejoin there would be an OpPhi in the SPIR-V that is not Uniform. It seems like the GLSL extension spec doesn't clarify what happens in this case. Is it an error? Undefined behavior? Does the frontend compiler stop propagating Uniform when flow control rejoins?
Yeah undefined behaviour seems like the natural thing here. I really don't want the compiler to work out that the uniformity the user requested has been broken, because that puts a lot of extra complexity into the compiler stack, and there may be legitimate cases where the if statement isn't obviously uniform, but we want the user to be able to tell us that x should be considered to be uniform nonetheless.