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

Rewrite and Fix Remaining Padding Bugs #35

Merged
merged 16 commits into from
Oct 17, 2021
Merged

Conversation

LPGhatguy
Copy link
Owner

@LPGhatguy LPGhatguy commented Oct 13, 2021

Closes #29.

It's been awhile since I've dug into this problem. In this PR, I rewrote Crevice almost completely to fix all the remaining layout bugs and tighten up the test suite to be much more effective.

I think that some of our snapshot tests ended up incorrect for whatever reason, so I've replaced them with a macro that generates offset_of! assertions. I think this will be much more clear and encourage test authors to read through the spec and reason about results instead of committing snapshots as-is.

Generated structs now have padding after each field instead of before. This lets us pad at the end of structs consistently. As part of that refactor, I improved the clarity of the derive macro code dramatically. It should be a lot easier to follow.

Also done during this PR is tightening of names with the crate's traits. The associated type on AsStd{140,430} is now called Output. I may rename these traits to IntoStd{140,430} to make them less semantically awkward, and then propagate that through all the method names.

All in all, this implementation has little in common with the old one and hopefully has fewer bugs.

@LPGhatguy LPGhatguy changed the title Rewrite Tests and Fix Remaining Padding Bugs Rewrite and Fix Remaining Padding Bugs Oct 17, 2021
@LPGhatguy LPGhatguy marked this pull request as ready for review October 17, 2021 06:32
@LPGhatguy
Copy link
Owner Author

Success! I found three bugs in Naga doing this:

@LPGhatguy
Copy link
Owner Author

Looking good, time to merge and move onto the next round of work.

@LPGhatguy LPGhatguy merged commit 8ddab3e into main Oct 17, 2021
@LPGhatguy LPGhatguy deleted the rewrite-tests-fix-padding branch October 17, 2021 19:06
leod pushed a commit to leod/crevice that referenced this pull request Jun 3, 2023
* Cleaner validation tests

* Introduce memoffset

* New tests using manual offset checking

* yeah that test is broken too

* Rename AsStdX::StdXType to AsStdX::Output for sanity

* Rename test file

* Revamp and merge test suites

* Squish tests more, make wgpu portion not run by default

* Rewrite Crevice from the ground up, suddenly passing all the tests

* Add primitive test for mat3

* Add a bare mat4 test

* Fix std430 derive and add it to tests

* Use actual struct alignment instead of min alignment for trailing padding

* Start testing (and fix) std430

* Add and disable tests to work around wgpu
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.

Round Up Size of All Structures to Structure Alignment
1 participant