I have the following fragment shader code:
in vec4 gl_FragCoord;
out vec4 out_col;
uniform layout(binding = 0, offset = 0) atomic_uint ac;
uniform layout(r32i) iimageBuffer head_buffer;
uniform layout(rgba32f) imageBuffer color_buffer;
uniform layout(r32i) iimageBuffer next_buffer;
void main()
{
int id = int(gl_FragCoord.x + gl_FragCoord.y * 1024);
uint index = atomicCounterIncrement(ac);
int oldHeader = imageAtomicExchange(head_buffer, id, int(index));
imageStore(next_buffer, int(index), ivec4(oldHeader, 0, 0, 0)); // <----- !!! !!!
imageStore(color_buffer, int(index), vec4(diffuse().rgb, gl_FragCoord.z));
out_col = vec4(1.0, 1.0, 1.0, 1.0);
}
When passing the value to be set to imageStore() as ivec4
imageStore(next_buffer, int(index), ivec4(oldHeader, 0, 0, 0));
there is no error message.
When passing the value to be set to imageStore() as int
imageStore(next_buffer, int(index), oldHeader);
there is the following OpenGL error message at runtime:
0(89) : error C7011: implicit cast from “int” to “ivec4”
BUT WHY - I thought “next_buffer” would be an “r32i” (=integer) buffer?
What am I doing wrong?