gfx-rs / wgpu

A cross-platform, safe, pure-Rust graphics API.
https://wgpu.rs
Apache License 2.0
11.5k stars 857 forks source link

[glsl-in] Atomics support #4372

Open fintelia opened 2 years ago

fintelia commented 2 years ago

Naga's GLSL frontend does not currently handle atomic operations. For example, this shader:

#version 460 core

layout(std430, binding = 0) buffer Buffer {
    uint x;
} buf;

void main() {
    atomicAdd(buf.x, 1);
}

Produces this error:

error: Unknown function 'atomicAdd'
  ┌─ shader.comp:8:5
  │
8 │     atomicAdd(buf.x, 1);
  │     ^^^^^^^^^^^^^^^^^^^

(I couldn't find an existing tracking issue for this, though gfx-rs/naga#1154 and gfx-rs/naga#929 are related.)

schell commented 1 year ago

Would adding atomics for glsl mean that spirv gets atomics automatically?

cwfitzgerald commented 1 year ago

No. The frontends are generally completely separate bits of code.