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

stop relying on spirv-tools #841

Closed
dvc94ch opened this issue Jan 14, 2022 · 6 comments
Closed

stop relying on spirv-tools #841

dvc94ch opened this issue Jan 14, 2022 · 6 comments
Labels
t: enhancement A new feature or improvement to an existing one.

Comments

@dvc94ch
Copy link
Contributor

dvc94ch commented Jan 14, 2022

currently the spirv spec says that subgroups are restricted to kernels. however glsl supports subgroups in regular compute shaders. seems like the glsl spec team forgot to tell the spirv spec team to update their specs. this leads to spirv-tools complaining about an invalid decorator in the opt/validation phases which in turn leads to rust-gpu not being competitive with glsl for no real reason. removing the dependency on spirv-tools would allow supporting "defacto" standards instead of just what was bothered to be written down in a spec.

@dvc94ch dvc94ch added the t: enhancement A new feature or improvement to an existing one. label Jan 14, 2022
@khyperia
Copy link
Contributor

currently the spirv spec says that subgroups are restricted to kernels

can you show where it says that? not seeing where it says that.

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jan 14, 2022

section 3.21 builtin says that kernel, groupnonuniform and sugroupballotkhr are enabling capabilities for subgroup_size, num_subgroups, subgroup_id, subgroup_local_invocation_id, to my understanding implying that they aren't available in the GLCompute mode, the Kernel mode being something to do with opencl.

@khyperia
Copy link
Contributor

khyperia commented Jan 14, 2022

That's an or between each capability, not an and - you don't need Kernel to use SubgroupSize and friends, just GroupNonUniform. They're available in shader SPIR-V and rust-gpu, and pass spirv-val.

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jan 14, 2022

so how do I enable it? I currently get this:

error: Operand 3 of Decorate requires one of these capabilities: Kernel GroupNonUniform SubgroupBallotKHR 
         OpDecorate %subgroup_local_invocation_id BuiltIn SubgroupLocalInvocationId
  |
  = note: module `/home/dvc/cloudpeer/xuda/target/shader/target/spirv-unknown-vulkan1.2/release/deps/shader.spv.dir/module`

warning: an unknown error occurred
  |
  = note: spirv-opt failed, leaving as unoptimized
  = note: module `/home/dvc/cloudpeer/xuda/target/shader/target/spirv-unknown-vulkan1.2/release/deps/shader.spv.dir/module`

error: error:0:0 - Operand 3 of Decorate requires one of these capabilities: Kernel GroupNonUniform SubgroupBallotKHR 
         OpDecorate %subgroup_local_invocation_id BuiltIn SubgroupLocalInvocationId
  |
  = note: spirv-val failed
  = note: module `/home/dvc/cloudpeer/xuda/target/shader/target/spirv-unknown-vulkan1.2/release/deps/shader.spv.dir/module`

warning: `shader` (lib) generated 1 warning
error: could not compile `shader` due to 2 previous errors; 1 warning emitted

@khyperia
Copy link
Contributor

As the error implies, you need to enable "one of these capabilities: Kernel GroupNonUniform SubgroupBallotKHR". You can do that using the API to enable capabilities.

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Jan 14, 2022

cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t: enhancement A new feature or improvement to an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants