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

[hlsl-out] More matCx2 fixes #1989

Merged
merged 6 commits into from
Jun 27, 2022
Merged

Conversation

teoxoy
Copy link
Member

@teoxoy teoxoy commented Jun 16, 2022

fixes #1837

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

This doesn't handle the case of arrays of matrices; see my comments on the code.

We should probably remove the reference to #1837 in src/back/hlsl/mod.rs.

src/back/hlsl/writer.rs Outdated Show resolved Hide resolved
src/back/hlsl/writer.rs Outdated Show resolved Hide resolved
src/back/hlsl/writer.rs Outdated Show resolved Hide resolved
@teoxoy
Copy link
Member Author

teoxoy commented Jun 17, 2022

Fixed matCx2s nested inside global arrays however this issue is also present for structs containing matCx2 arrays.

@teoxoy teoxoy changed the title [hlsl-out] Fix matCx2 as global uniform [hlsl-out] More matCx2 fixes Jun 17, 2022
src/back/hlsl/writer.rs Outdated Show resolved Hide resolved
src/back/hlsl/writer.rs Outdated Show resolved Hide resolved
tests/in/globals.wgsl Outdated Show resolved Hide resolved
tests/out/hlsl/access.hlsl Outdated Show resolved Hide resolved
@teoxoy teoxoy requested a review from jimblandy June 22, 2022 21:52
@teoxoy
Copy link
Member Author

teoxoy commented Jun 22, 2022

@jimblandy this should now be good to go. I think we have all our matCx2 bases covered now 😅.

I added some more comments - I hope they are helpful.

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

I need to look at this again tomorrow. Comments thus far, nothing too serious:

It might be good to add __mat, __get, and __set to the list of reserved prefixes passed to Namer::reset in `hlsl::Writer::reset.

It might be worthwhile going though help.rs and similar code to look for other prefixes we've neglected to tell Namer to avoid. So far I've found ret_ (for the typedefs generated by write_wrapped_constructor_function) and Construct.

Or, maybe just start all generated names with __, and then only warn Namer about that?

tests/out/hlsl/access.hlsl Show resolved Hide resolved
src/back/hlsl/writer.rs Show resolved Hide resolved
src/back/hlsl/help.rs Show resolved Hide resolved
src/back/hlsl/help.rs Show resolved Hide resolved
src/back/hlsl/writer.rs Show resolved Hide resolved
@teoxoy
Copy link
Member Author

teoxoy commented Jun 27, 2022

Regarding the Namer, I'd say we go for

maybe just start all generated names with __, and then only warn Namer about that?

since WGSL already doesn't allow identifiers that start with two underscores.

@jimblandy
Copy link
Member

Okay - having thought on this a little more, I'm inclined to merge this as-is for the moment.

But the current design (which predates this PR) feels focused on identifying special cases. In the longer term, we need to look hard for some useful generalizations, that will make it easier to see that all the cases are being covered.

@jimblandy jimblandy merged commit 27d38aa into gfx-rs:master Jun 27, 2022
@teoxoy teoxoy deleted the hlsl-fix-global-matCx2 branch June 27, 2022 22:57
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.

Naga generates HLSL that doesn't satisfy WGSL's layout rules for global matCx2 matrices
2 participants