Skip to content

remove has_capability() checks#531

Merged
Firestar99 merged 3 commits into
mainfrom
remove_has_capability
Jul 13, 2026
Merged

remove has_capability() checks#531
Firestar99 merged 3 commits into
mainfrom
remove_has_capability

Conversation

@Firestar99

@Firestar99 Firestar99 commented Feb 18, 2026

Copy link
Copy Markdown
Member
  • remove BuilderSpirv::has_capability(&self, capability: Capability) -> bool, you can no longer check whether some capability is enabled. Progress towards RFC: link-time capabilities #388
  • add compiletests for non_uniform removal by post-link pass (previously partially gated behind has_capability check)

@Firestar99 Firestar99 force-pushed the remove_has_capability branch 3 times, most recently from c38ccd4 to 784c8c8 Compare February 19, 2026 10:05
@Firestar99 Firestar99 marked this pull request as ready for review February 19, 2026 10:10
@Firestar99 Firestar99 force-pushed the remove_has_capability branch 2 times, most recently from ddbc0c2 to 3874f69 Compare April 8, 2026 11:20
Comment on lines -53 to +56
if self.builder.has_capability(Capability::ShaderNonUniform) {
// apply NonUniform to the operation and the index
self.emit()
.decorate(ptr.def(self), Decoration::NonUniform, []);
self.emit()
.decorate(actual_index, Decoration::NonUniform, []);
}
// apply NonUniform to the operation and the index
self.emit()
.decorate(ptr.def(self), Decoration::NonUniform, []);
self.emit()
.decorate(actual_index, Decoration::NonUniform, []);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test using this feature, but not enabling ShaderNonUniform?

It should trigger a validation error from the new SPIR-T-based validation pass, if I'm not mistaken.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, works without any issues. I seem to have added tests for everything except ByteAddressableBuffer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, I am talking about a test that lacks the ShaderNonUniform capability, and therefore results in an error. If it compiles successfully and contains NonUniform decorations, without the necessary capability, that's a bug IMO.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the tests this PR adds, there's a ByteAddressableBuffer variant with NonUniform capability, and a ByteAddressableBufferUniform variant without, all disassembled so you can diff that and see the the uniform variant missing the OpDecoration %x NonUniform

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you removed the condition that gates NonUniform on ShaderNonUniform, and the decoration should always be emitted now... is something else removing the NonUniform decorations?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, here a linker pass that removes all NonUniform decorations, which has been added in #177 1.5 years ago. I wanted it so I could write just one image access asm! block with all the needed NonUniform decorations, since you can't conditionally exclude an asm line.

Comment thread crates/rustc_codegen_spirv/src/builder/builder_methods.rs Outdated
@Firestar99 Firestar99 force-pushed the remove_has_capability branch from 3874f69 to 98b816b Compare July 13, 2026 09:37
@Firestar99 Firestar99 force-pushed the remove_has_capability branch from 98b816b to 2ee060d Compare July 13, 2026 10:06
@Firestar99 Firestar99 added this pull request to the merge queue Jul 13, 2026
Merged via the queue into main with commit ad79728 Jul 13, 2026
39 of 41 checks passed
@Firestar99 Firestar99 deleted the remove_has_capability branch July 13, 2026 14:28
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

Successfully merging this pull request may close these issues.

2 participants