Atomic access to Shader Storage Buffers fails linking

Hi there,

I’m working with OpenGL 4.3 (GTX 680, driver version 306.63) and want to use the Shader Storage Buffers atomically.

Using the following shaders, the linking fails but I do not have a clue, why that is and how to fix it:
Vertex:


#version 430
layout(location = 0) in vec3 vertexPos;
void main()
{
	gl_Position.xyz = vertexPos;
}

Fragment:


#version 430

in vec4 gl_FragCoord;
out vec4 gl_FragColor;
uniform unsigned int width;

layout(binding = 1) buffer List
{
	unsigned int entry[];
}list;

void main(void)
{
    uvec2 p = uvec2(gl_FragCoord.xy);
    uint index = p.x + p.y*width;
    unsigned int a = 5;
    atomicExchange(list.entry[index], a);
}

So, I have a shader storage buffer containing as many ‘entry’ values as the buffer can hold when bound.
Every shader calculates the index of where to write into the buffer using linearizing the fragment position.
Then, I want to replace the value in the buffer with ‘a’ atomically.
When I write ‘list.entry[index] = a’, it links and works fine.
But when I use the atomic operation, it compiles(!) but fails to link with no message.
I need the atomic operation for an lock free list implementation.
I have not tried this with compute shaders as I need the data generated by the rasterizer.
The example above is the most minimalistic one producing the error.

Can anyone help me with this? Is there something I did wrong or missed?
Thanks in advance,
daniel

fails to link with no message

Anytime that happens, it’s the driver’s fault. There should be nothing you can do with a shader that causes it to emit a link failure and not update the info-log.

Admittedly not likely the source of your problem:



gl_Position.xyz = vertexPos;

why is gl_Position.w not set?

Thanks, so I’ll have to wait for NVIDIA…

@kRogue:
a) It’s a pass-through-shader for full screen quads without any transformation.
b) Because it works without .w :wink:

Daniel

Thanks, so I’ll have to wait for NVIDIA…

@kRogue:
a) It’s a pass-through-shader for full screen quads without any transformation.
b) Because it works without .w :wink:

Daniel

@Danielkr:
make sure you try to read the info log straight after linking without an additional validate in between.
Validate overwrites the info log message, which may be a reason why you get an empty log message.

Try the latest driver which is 310.33

Unfortunately, driver 310.33 does not solve the problem.
I discovered that the following works:


layout(binding = 1) buffer List
{
	unsigned int entry[];
};
 
void main(void)
{
    uvec2 p = uvec2(gl_FragCoord.xy);
    uint index = p.x + p.y*width;
    unsigned int a = 5;
    atomicExchange(entry[index], a);
}

Note, that I simply removed ‘list’ in the buffer declaration and use ‘entry’ directly.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.