So, I have a Compute Shader that needs to take a texture and copy it to another texture with a few changes. I confirmed that the textures are connected and that the data can be recorded using RenderDoc, which is a debugging tool for graphics. The problem is that inside the shader, the variable gl_GlobalInvocationID created by OpenGL does not work properly.
Here is my call to the computational shader: (Texture Height - 480)
glDispatchCompute(1, this->m_texture_height, 1);
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
And here I have my computational shader:
#version 440
#extension GL_ARB_compute_shader : enable
#extension GL_ARB_shader_image_load_store : enable
layout (rgba8, binding=0) uniform image2D texture_source0;
layout (rgba8, binding=1) uniform image2D texture_target0;
layout (local_size_x=640 , local_size_y=1 , local_size_z=1) in;
void main() {
ivec2 txlPos;
vec4 result;
txlPos = ivec2(gl_GlobalInvocationID.xy);
result = imageLoad(texture_source0, txlPos);
barrier();
result = vec4(txlPos, 0.0, 1.0);
imageStore(texture_target0, txlPos, result);
}
, , 1pxl 1pxl . - - , , txlPos .
- ? gl_GlobalInvokationID , .