Flickering when accessing texture by offset
Posted
by
TravisG
on Game Development
See other posts from Game Development
or by TravisG
Published on 2013-11-08T16:44:53Z
Indexed on
2013/11/08
22:18 UTC
Read the original article
Hit count: 317
opengl
|compute-shader
I have this simple compute shader that basically just takes the input from one image and writes it to another. Both images are 128/128/128 in size and glDispatchCompute is called with (128/8,128/8,128/8). The source images are cleared to 0 before this compute shader is executed, so no undefined values should be floating around in there.
(I have the appropriate memory barrier on the C++ side set before the 3D texture is accessed).
This version works fine:
#version 430
layout (location = 0, rgba16f) uniform image3D ping;
layout (location = 1, rgba16f) uniform image3D pong;
layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
void main()
{
ivec3 sampleCoord = gl_GlobalInvocationID.xyz;
imageStore(pong, imageLoad(ping,sampleCoord));
}
Reading values from pong shows that it's just a copy, as intended. However, when I load data from ping with an offset:
#version 430
layout (location = 0, rgba16f) uniform image3D ping;
layout (location = 1, rgba16f) uniform image3D pong;
layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
void main()
{
ivec3 sampleCoord = gl_GlobalInvocationID.xyz;
imageStore(pong, imageLoad(ping,sampleCoord+ivec3(1,0,0)));
}
The data that is written to pong seems to depend on the order of execution of the threads within the work groups, which makes no sense to me. When reading from the pong texture, visible flickering occurs in some spots on the texture.
What am I doing wrong here?
© Game Development or respective owner