fix(naga): Improve validation of non-constructible types#8873
fix(naga): Improve validation of non-constructible types#8873jimblandy merged 3 commits intogfx-rs:trunkfrom
Conversation
db3ba50 to
8136b91
Compare
d8cb680 to
c35777b
Compare
There was a problem hiding this comment.
It looks to me like the changes in construction.rs need to be reimplemented for the post-#8386 world. In particular, I don't think it's true any more that:
the non-constructible types not excluded by
!is_dynamically_sizedare rejected by the parser.
I apologize for not reviewing this more promptly, since that resulted in throwing the rewrite back at you. But given the changes in #8386, this would have needed to be rewritten one way or another.
|
I don't think this necessarily needs major changes after #8386. It's true that the parser doesn't reject everything that it did before. In particular, the zero-value I think the question is, how much effort do we want to undertake to catch these cases in the frontend for the sake of generating better error messages? I could add something in |
|
Okay. Let's get this branch rebased on current trunk, and then I'll review it. |
c35777b to
fa5fb3c
Compare
fa5fb3c to
5c80722
Compare
|
I deleted a test that assumed |
|
It seems like all the CTS tests added to |
|
I was wishing we could keep the front end simple and just generate invalid WGSL that the validator can complain about, but now I think I understand why If lowering Unfortunately, that gets us a mediocre error whose span points at So the early type-checking on |
|
@andyleiserson I went ahead and added a |
I am leaving #7393 open to improve the handling of this. (And it's linked from the comment on this check in the front-end.)
Yes. There are some improvements to the CTS tests in gpuweb/cts#4550, see the description of that PR for explanation of why the CTS was passing before. There's also the directed tests added by this PR, which distinguish between things that are rejected by the frontend and that are rejected by the validator (which the CTS does not).
I don't see it, did you push this change? |
Indeed, I had forgotten to push it. Now visible as 64f86c0 |
24a9f7d to
a5b8afe
Compare
|
Oh, I see what I did: I gave the jj-generated branch name a more legible name for my own purposes, and then misconfigured it. |
Fixes gfx-rs#4720 Fixes the test cases in gfx-rs#7393, but not the issue itself
Add a new method `TypeInner::is_constructible`, that determines whether WGSL considers a type [constructible]. Use this to generate errors in the WGSL front end. Assert in validation that it matches the judgment of `Validator::validate_type`. [constructible]: https://gpuweb.github.io/gpuweb/wgsl/#constructible-types
a5b8afe to
ae0852b
Compare
|
In ae0852b I refined
|
|
LGTM. I think in the latest version, my change to make I think it still makes sense to have return true for override-sized arrays, though, because that way it's more likely to get appropriate attention on the override case for new uses that might get added in the future. |
Somewhat a follow-up to #8741. Fixes #4720, and fixes the test cases in #7393, but not the issue itself.
After studying the spec more and the related CTS test cases, I think the necessary zero-value validation can be simplified to "type must be constructible". So this changes the zero-value validation from #8741 to operate that way.
Also adds other validation in the WGSL front-end for non-constructible types in places they are not permitted.
This change is adjacent to the template-list discovery change (#8386), and may have some conflicts, but as best I could tell the two changes don't directly overlap.
Testing
Enables CTS tests and adds naga
wgsl_errorsandvalidationtests.Squash or Rebase? Squash
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.CHANGELOG.mdentry.