Skip to content

[naga wgsl-in] Implement any() and all() during const evaluation #7166

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

Merged
merged 1 commit into from
Feb 17, 2025

Conversation

jamienicol
Copy link
Contributor

@jamienicol jamienicol commented Feb 17, 2025

Connections
Part of #4507 . When testing CTS changes for #7035 I noticed we still get quite a few failures in the webgpu:shader,validation,const_assert,const_assert:constant_expression_assert:* group due to this.

Description
any() and all() should be evaluated at constant time.

eg naga should transform this shader:

var a = any(vec2(false, true));
var b = all(vec2(false, true));

to

var a: bool = true;
var b: bool = false;

Note this already works for the scalar versions of these function as we handle that specially in the WGSL frontend (in commit 3bd2834). This makes us handle vectors args too.

Testing
Added snapshot tests

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

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

LGTM, minus a question.

@ErichDonGubler ErichDonGubler self-assigned this Feb 17, 2025
@ErichDonGubler ErichDonGubler merged commit d625d08 into gfx-rs:trunk Feb 17, 2025
34 checks passed
@jamienicol jamienicol deleted the const-any-all branch February 17, 2025 19:16
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.

3 participants