View Full Version : Image atomic addition in a compute shader

02-04-2015, 05:22 AM

I have the following compute shader:

#version 430

layout(std430, binding=0) buffer wks{
ivec2 w[];

layout(r32i, binding=1) uniform writeonly iimage2D pathTex;

layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;

void main(){
imageAtomicAdd(pathTex, w[0], 1); // line 12

That gives me this error:

0(12) : error C1317: qualified actual parameter #1 cannot be converted to less qualified parameter ("im")

I can't find what I'm doing wrong according to the OpenGL wiki (https://www.opengl.org/wiki/Image_Load_Store#Atomic_math)

Alfonse Reinheart
02-04-2015, 07:02 AM
What happens if you replace the texture coordinate with a constant value (like ivec2(0, 0))?

02-05-2015, 05:15 AM
I got an answer:

According to the GLSL 4.50 spec, imageAtomicAdd() requires a image variable with the coherent memory qualifier.

This makes sense because an atomic add needs to read the old value, add a value to it, and write back the result. Therefore, it needs to be able to both read and write the image.

To make this work, you need to change the declaration to:

layout(r32i, binding=1) uniform coherent iimage2D pathTex;

As the name indicates, writeonly will only work for image operations that exclusively write to the image, like imageStore().

Thanks for your time anyway!

honey singh
02-24-2015, 10:59 PM
Friends i see your question here. But i do not understand last answer that you say "You Got Answer". But i am not understand how can you calculate it ?