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

Using glslc to compile a shader containing atomicAdd causes a bug #1140

Closed
JonathanWoollett-Light opened this issue Oct 16, 2020 · 2 comments
Assignees

Comments

@JonathanWoollett-Light
Copy link

JonathanWoollett-Light commented Oct 16, 2020

I discovered a bug which lead any shader using atomicAdd to be unable to compile from SPIR-V when using wgpu-rs (gfx-rs/wgpu-rs#564).

Eventually after using SPIRV-Tools-master-windows-x64-Release\bin\spirv-val.exe (from https://github.com/KhronosGroup/SPIRV-Tools) to check the .spv file and it producing:

C:\Users\jonat>C:\Users\jonat\Desktop\SPIRV-Tools-master-windows-x64-Release\bin\spirv-val.exe C:\Users\jonat\Projects\test-project\spir-v\atomicArraySum.spv
error: line 8: Invalid capability operand: 6033
error: line 8: Invalid capability operand: 6033

It was suggested (gfx-rs/wgpu-rs#564 (comment)) the bug likely originates from an error in the tool used to compile the GLSL to SPIR-V (C:/VulkanSDK/1.2.148.1/Bin/glslc).

Since I beleive this is the repo for glslc I thought it best to open this issue here.

Comment from the issue which contains link to test project (importantly the GLSL .comp file and resultant SPIR-V .spv file): gfx-rs/wgpu-rs#564 (comment)

Compilation of the GLSL to SPIR-V has been done by running:

C:/VulkanSDK/1.2.148.1/Bin/glslc C:/Users/jonat/Projects/test-project/glsl/atomicArraySum.comp -o C:/Users/jonat/Projects/test-project/spir-v/atomicArraySum.spv --target-env=vulkan1.0

(--target-env=vulkan1.1 has also been tried)

There is a bunch of info in the original issue (gfx-rs/wgpu-rs#564), but I would recommend reading from the bottom up since it is quite long and the stuff near the bottom is most relevant.

I also considered opening an issue in the https://github.com/KhronosGroup/glslang repo but decided against it for now.

@JonathanWoollett-Light JonathanWoollett-Light changed the title When using glslc to compile a shader containing atomicAdd causes a bug Using glslc to compile a shader containing atomicAdd causes a bug Oct 16, 2020
@zoddicus
Copy link
Collaborator

Running on ToT checkouts of shaderc and spirv-tools I am unable to reproduce this on Linux.

The specific error you are seeing appears to be for a relatively new extension, so I suspect there is a version issue somewhere along the way, i.e. some tools have support for this extension and others do not.

I am not sure if there is much for shaderc to do, but I am going to send this over to dneto@ since he is more familiar with package/release process for the ecosystem, so might have some thoughts.

@dneto0
Copy link
Collaborator

dneto0 commented Nov 2, 2020

I agree with @zoddicus

Your copy of spirv-val is old. It was built without support for SPV_EXT_shader_atomic_float_add, and so it doesn't know about OpCapability AtomicFloat32AddEXT

spirv-val comes from the SPIRV-Tools project. If you built SPIRV-Tools locally, be sure to rebuild it with an updated copy of SPIRV-Headers, as that is where it gets most of its information about the set of valid tokens (and extensions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants