google / google/shaderc

shaderc internal error using atomics on an inout function parameter

Open
#1,063 2 comments 0 reactions 1 assignee Claimed by @dneto0 View on GitHub
bug
Dominant language
C++
Stars
2.2k
Forks
445
Avg merge
11h 6m
Merged PRs (30d)
6

Description

Hey, I have the following glsl function:

```
bool add_particle(inout ParticleBufferHeader header, out uint index) {
index = atomicAdd(header.count, 1);
if (index >= header.capacity) {
return false;
} else {
atomicMax(
header.update_workgroups,
1 + index / PARTICLE_UPDATE_LOCAL_SIZE
);
return true;
}
}
```

that causes this error in shaderc:

```
shaderc: internal error: compilation succeeded but failed to optimize: AtomicIAdd: Function storage class forbidden when the Shader capability is declared.
%74 = OpAtomicIAdd %uint %71 %uint_1 %uint_0 %uint_1
```

*only* when compiling with optimization. I'm not sure whether this is legal in glsl or not, if I change this function to a macro and call it directly on the SSBO field then the error disappears, this is only when trying to call atomics on an inout parameter.

I'm using shaderc through rust through the shaderc-rs crate, so I believe the version here of shaderc is 06b6db68ff7e20d4f097a132dd56a1c6482e8c25. I'm sorry this isn't a more isolated example, if necessary I can make one available.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.