-
Notifications
You must be signed in to change notification settings - Fork 928
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
[naga] Support pipeline overrides in the WGSL backend #6310
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to help the naga reviewers: the testing looks good on this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel confident that the behavior intended to be allowed here is correct, but I don't feel confident that we're rejecting improper programs. I'm not very familiar with override
s to begin with. @jimblandy, could we maybe pair on this, so I can get your thoughts?
@jimblandy: I intend to merge this in the next 24 hours, unless you have an objection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than adding limited support for some operations to back::wgsl::writer
, you should just make write_output_wgsl
in naga/tests/snapshots.rs
call naga::back::pipeline_constants::process_overrides
, the way the other write_output_foo
functions do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going a bit further than my previous comment:
I don't think this PR is the right approach. Naga backends should assume that overrides' values have been provided, and the module has been rewritten so that all overrides appear as constants instead. So rather than the approach taken here, I think the WGSL backend should handle overrides the same way the other backends do:
if !module.overrides.is_empty() {
return Err(Error::Override);
}
As explained in the prior review, it should be the caller's responsibility to call pipeline_constants::process_overrides
and eliminate all overrides from the module before passing it to the backend.
To verify I understand, the intent is that modules with pipeline overrides should not be translated from one language to another? They must instead be substituted with concrete values. That precludes some use cases, including mine, but I can understand not wanting to take on that maintenance burden. If that understanding is correct, I can close this PR. |
Connections
#4484
Description
The WGSL backend currently does not support pipeline overrides (i.e.
override foo: f32
). These are included in the latest WGSL spec, this PR adds support for them by:override
declarations inwgsl::Writer
.Override
expressions inwgsl::Writer
.Unary
andBinary
constant expressions inwgsl::Writer
.This last step was necessary because the existing "overrides" snapshot test exercises the functionality, but it isn't currently implemented for the WGSL backend.
Testing
The first commit in this PR enables the existing "overrides" snapshot tests for the WGSL target which I verified fails. The following commits update the backend such that it passes and generates semantically equivalent WGSL to the input.
Ran:
Checklist
cargo fmt
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.