Can anybody help check why this computer shader results in APPCRASH on my GT440 GPU, Windows 7 64bit?
I don’t think there is any problem about this shader code.
#version 450 core
layout (local_size_x = 16, local_size_y = 16) in;
layout (binding = 0, rgba8ui) uniform uimage2D output_image;
layout (binding = 1, r32ui) uniform volatile coherent uimage2D image0;
layout (binding = 2, r32ui) uniform volatile coherent uimage2D image1;
void main(void)
{
// thread 0 of each work group clears a portion of output image
if (gl_LocalInvocationIndex == 0) {
uvec2 start = gl_WorkGroupSize.xy * gl_WorkGroupID.xy;
for (uint j = start.y; j < start.y + gl_WorkGroupSize.y; ++j)
for (uint i = start.x; i < start.x + gl_WorkGroupSize.x; ++i)
imageStore(output_image, ivec2(i, j), uvec4(0));
}
barrier();
if (gl_GlobalInvocationID.x % 2 == 0) {
// store to image0, then image1
imageStore(image0, ivec2(gl_GlobalInvocationID.xy), uvec4(1));
imageStore(image1, ivec2(gl_GlobalInvocationID.xy), uvec4(1));
}
else {
ivec2 coord = ivec2(gl_GlobalInvocationID.xy) - ivec2(1, 0);
// wait for image1 to be set
uint flag;
do {
flag = imageLoad(image1, coord).x;
}
while (flag != 1);
// check if image0 is set
uint color = imageLoad(image0, coord).x * 255;
// write output image
imageStore(output_image, coord, uvec4(flag));
imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), uvec4(color));
}
}