-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a couple of thin validations to avoid footguns
After spending several hours last week getting tripped up on very silly issues I have decided to add validations that hope to protect myself from bad GLSL uniform alignment and bind groups not being reboud on resize if they rely on resources which get recreated on resize. The first of which is a much harder thing to validate from my perspective, so in the hopes of not adding too much overhead to playing with the uniforms I have decided to require each to implement an arbitrary trait, `AlignedGLSL`, that defines the `validate_alignment` function whenever a uniform is registered. At the moment all these functions do is `assert_eq!` between a constant value I manually input and the output of `std::mem::size_of` for each uniform. At the very least, this should keep alignment at my forethought when editing these uniforms and catch *most* cases of updating the structs without considering alignment. The edge case which could be painful is reworking the struct into a malaligned state but same overall size. The second validation which is bit more well done in terms of actual validation is for `surface_bound` bind groups as I call them. As long as I remember to include any new `surface_bound` bind groups in the relevant `bind_group` calls there ought to be a very obvious panicking if a resize happens and a previously bound `surface_bound_bind_group` manages to not get rebound.
- Loading branch information
1 parent
06fa6dc
commit 7765f7f
Showing
9 changed files
with
161 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ bytemuck = "1.4" | |
|
||
[dependencies.wgpu] | ||
version = "0.12" | ||
features = ["spirv"] | ||
features = ["spirv"] |
This file contains 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 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 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 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 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 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 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 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