Skip to content

Non uniform for everything! #177

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Firestar99
Copy link
Member

@Firestar99 Firestar99 commented Dec 11, 2024

Adds the NonUniform declaration to pretty much everything, even if it's not required. I don't think this will have a huge performance impact, as Nvidia and Intel don't seem to care about this flag, their accesses are always non-uniform, and Amd's driver is really good at figuring out whether something is uniform / scalar across the workgroup / subgroup or not.

You will have to declare SpirvBuilder::capability(Capability::ShaderNonUniform) for it to work though.

Feel free to cherry-pick these commits if you do need non-uniform now and can't wait until rust-gpu has figured out a proper solution.

@LegNeato
Copy link
Collaborator

LegNeato commented May 21, 2025

I wonder if we should land this behind an off-by-default flag? Or maybe that is more trouble than it is worth.

@Firestar99
Copy link
Member Author

I'm shocked I haven't thought of this earlier... then I wouldn't have to keep updating this PR constantly

@Firestar99
Copy link
Member Author

Firestar99 commented Jun 2, 2025

@LegNeato Buffers are easy, but for images, we can't just cfg within an asm!:

asm! {
    // error[E0658]: attributes on expressions are experimental
    // error: removing an expression is not supported in this position
    #[cfg(feature = "non-uniform")]
    "OpDecorate %image NonUniform"
    ...
}

We can't put it in a separate asm! either as we need to decorate the access instruction and all it's parameters (as a precaution). The correct way would be to cfg the entire asm! and duplicate all the image access asm!, about 200 loc.

Would you mind if I just add a linking stage instead to remove all OpDecoration if the target feature ShaderNonUniform is not present? (cc @eddyb)

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