Skip to content
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

[wgsl-in] Fail on repeated attributes #2428

Merged
merged 2 commits into from
Aug 13, 2023

Conversation

fornwall
Copy link
Contributor

Fixes #2425.

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 some nits!

src/front/wgsl/error.rs Outdated Show resolved Hide resolved
src/front/wgsl/tests.rs Outdated Show resolved Hide resolved
@teoxoy
Copy link
Member

teoxoy commented Aug 11, 2023

There are more attributes that this validation should cover. I think all attributes can't be repeated (the spec mentions to look for exceptions to this rule for each attribute but at a first glance I can't see any such exception).

@fornwall
Copy link
Contributor Author

There are more attributes that this validation should cover. I think all attributes can't be repeated (the spec mentions to look for exceptions to this rule for each attribute but at a first glance I can't see any such exception).

Thanks @teoxoy ! I've added additional attributes in 1a7c3ab

workgroup_size is missing. I'm planning to do that in a separate PR (to propose changing EntryPoint.workgroup_size from [u32; 3] to Option<[u32; 3]>, which will also fix #2271). Since that is a bigger change touching all backends and frontends, is that ok?

@fornwall
Copy link
Contributor Author

fornwall commented Aug 11, 2023

Rebased to fix merge conflicts in src/front/wgsl/tests.rs. Also squashed the three commits into one, as the second two commits iterations on the first.

@teoxoy
Copy link
Member

teoxoy commented Aug 11, 2023

Sounds good!

Given that all the attributes are an Option<Something>, I feel like a more robust solution would be to introduce a newtype that once you set its inner Option via a set method, you'll keep getting the repeated attributes error on subsequent set calls. Thoughts?

@fornwall
Copy link
Contributor Author

Given that all the attributes are an Option<Something>, I feel like a more robust solution would be to introduce a newtype that once you set its inner Option via a set method, you'll keep getting the repeated attributes error on subsequent set calls. Thoughts?

Sounds like a good idea, I'll try it out!

@fornwall
Copy link
Contributor Author

Given that all the attributes are an Option, I feel like a more robust solution would be to introduce a newtype that once you set its inner Option via a set method, you'll keep getting the repeated attributes error on subsequent set calls. Thoughts?

@teoxoy Like this: f09f9f7?

Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for making the change!

@teoxoy
Copy link
Member

teoxoy commented Aug 11, 2023

@ErichDonGubler want to give this another look? 👀

@ErichDonGubler
Copy link
Member

Feeling silly that my unfamiliarity with WGSL led me to miss other attributes, but otherwise, this LGTM. Could we file an issue for getting enum-exhaustive coverage for these attributes for testing before we merge? I think that that's the only preference I want to call out.

@fornwall
Copy link
Contributor Author

Could we file an issue for getting enum-exhaustive coverage for these attributes for testing before we merge? I think that that's the only preference I want to call out.

Thanks @ErichDonGubler! Have added gfx-rs/wgpu#4567 as a follow up issue for that, and #2434 for the @workgroup_size remaining attribute (which is a bit bigger, since making workgroup_size an Option will touch more parts).

@teoxoy
Copy link
Member

teoxoy commented Aug 13, 2023

Thanks! Will merge this then.

@teoxoy teoxoy merged commit 7a19f3a into gfx-rs:master Aug 13, 2023
6 checks passed
@fornwall fornwall deleted the repeated-attributes branch August 13, 2023 21:31
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.

[wgsl-in] attributes appearing more than once are not rejected
3 participants