atomicAdd doesn't work on shared variables

Hey,

I am currently writing a mesh shader and trying to use atomicAdd on a shared int variable. It compiles just fine, but I am getting a GL_INVALID_OPERATION error at runtime. Does anyone have any idea why that is? It doesn’t produce an error if I use a Storage Buffer and call atomicAdd on a buffer variable. The docs clearly states that I can use atomicAdd on shared variables too.

This is a code snippet I created to test if atomicAdd works. If atomicAdd is used I get a runtime error and no triangle is rendered. If I comment it out the triangle renders just fine. And if I use it on a buffer variable (not in the code) the triangle renders too. As you can see I already enabled all atomic extensions to test it on different datatypes, but none work with shared variables.

#version 460 core
#extension GL_NV_mesh_shader : require
#extension GL_NV_shader_atomic_int64 : enable
#extension GL_NV_shader_atomic_float : enable
#extension GL_NV_shader_atomic_float64 : enable
#extension GL_NV_shader_atomic_fp16_vector : enable
#extension GL_NV_gpu_shader5 : enable

layout(local_size_x = 32, local_size_y = 1, local_size_z = 1) in;
layout(triangles, max_vertices = 3, max_primitives = 1) out;

shared int i; 

void main(){
	uint id = gl_LocalInvocationID.x;
	
	if(id == 0)
		i = 0;
	
	atomicAdd(i, 1);
	
	gl_MeshVerticesNV[0].gl_Position = vec4(0.0f, 0.0f, 0.0f, 1.0f);
	gl_MeshVerticesNV[1].gl_Position = vec4(0.5f, 1.0f, 0.0f, 1.0f);
	gl_MeshVerticesNV[2].gl_Position = vec4(1.0f, 0.0f, 0.0f, 1.0f);
	
	gl_PrimitiveIndicesNV[0] = 0;
	gl_PrimitiveIndicesNV[1] = 1;
	gl_PrimitiveIndicesNV[2] = 2;
	
	gl_PrimitiveCountNV = 1;
}

I’d really appreciate someone pointing me in the right direction here. :smiley: