-
Notifications
You must be signed in to change notification settings - Fork 100
wgsl: Add validation tests for vector access of abstract types #3708
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe as a followup, but it would be good to check the expression type (same thing for the concrete tests), by using an explicit type for
r(const r : T = V[0];).Unlike the concrete tests, the abstract tests would need to consider that
abstract-intcan convert toabstract-float, but the reverse is not true.Uh oh!
There was an error while loading. Please reload this page.
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 think I might be missing something about how abstracts in WGSL work.
I thought you couldn't explicitly type abstract int and float in WGSL, i.e. there is no way to write
const r: AbstractFloat, it can only be inferred from the assignment.And they are always constant (or override) experessions, so I cannot do something like
let r = 0; r = V[0];to check that V[0] is an AbstractInt, because though the initializer literal is a AI, it will be converted on the assignement to r to be an i32, due to the use oflet.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.
You're right that you can't explicitly write an abstract numeric, and I see why what I wrote is confusing.
Twould be a concrete type -i32,u32,f32etc. I was trying to point out thatabstract-intcould be used for any of these, butabstract-floatwould only work forf32.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.
Maybe it would be better done as a second statement:
That would mean you still test that
rgets the inferred abstract type.You also wouldn't need to change all these individual cases, just add another statement underneath the templated case one.
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 understand now. I have filed #3709 and will implement in a follow up CL.
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.
Thinking about this, is adding a
const C : T = r;statement what we want?This wouldn't be testing the direct conversion of the swizzle of an abstract type to a concrete type (
swizzle(vec<AI>) -> vec<i32>), but the conversion of vectors after the swizzle (swizzle(vec<AI>) -> vec<AI> -> vec<u32>).I think we should already have coverage of converting an abstract vector down to a concrete one elsewhere.
For swizzle/access testingI think what we want is tests like
const r : vec2<u32> = vec2(0, 0).yz;, which explictly test that a swizzle can be directly stored into a convertible type.Does that sound correct?
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.
Currently we have nothing testing that the inferred type of
ris as expected. The second assignment to a concrete type would validate that the inferred type is as expected.