Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Naga emits wrong HLSL for atomicMax() on u64 buffer #5893

Closed
JMS55 opened this issue Jun 30, 2024 · 1 comment · Fixed by #5952
Closed

Naga emits wrong HLSL for atomicMax() on u64 buffer #5893

JMS55 opened this issue Jun 30, 2024 · 1 comment · Fixed by #5952
Labels
area: naga back-end Outputs of naga shader conversion lang: HLSL D3D Shading Language naga Shader Translator type: bug Something isn't working

Comments

@JMS55
Copy link
Contributor

JMS55 commented Jun 30, 2024

Description
Naga should be emitting buffer.InterlockedMax64, not buffer.InterlockedMax.

This only applies to RWByteAddressBuffer according to the spec.

This issue also applies to the other atomic functions.

Repro steps

@group(0) @binding(0) var<storage, read_write> buf: atomic<u64>;

atomicMax(&buf, 3147483647lu);

Platform
Naga rev 82210e1c

@JMS55
Copy link
Contributor Author

JMS55 commented Jul 1, 2024

Changing

write!(self.out, "{var_name}.Interlocked{fun_str}(")?;

To

let width = match func_ctx.resolve_type(value, &module.types) {
    TypeInner::Scalar(Scalar { width: 8, .. }) => "64",
    _ => "",
};
write!(self.out, "{var_name}.Interlocked{fun_str}{width}(")?;

I think fixes it. Probably needs a test, and consideration for how it will work for texture atomics.

@teoxoy teoxoy added type: bug Something isn't working area: naga back-end Outputs of naga shader conversion naga Shader Translator lang: HLSL D3D Shading Language labels Jul 1, 2024
@JMS55 JMS55 mentioned this issue Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga back-end Outputs of naga shader conversion lang: HLSL D3D Shading Language naga Shader Translator type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants