-
Notifications
You must be signed in to change notification settings - Fork 7
TypeLayout Rework #19
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
Open
chronicl
wants to merge
182
commits into
RayMarch:v2.0.0-beta.1
Choose a base branch
from
chronicl:layout2
base: v2.0.0-beta.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 28 commits
Commits
Show all changes
182 commits
Select commit
Hold shift + click to select a range
f2b51c1
MVP type layout 2
chronicl 4b7e4a4
Add gpu_repr(uniform) to layout example
chronicl 2a9a4ed
Add GpuStore: GpuAligned back
chronicl 4619d60
Cleanup type layout Vertex
chronicl fb24c94
Fix example
chronicl 8222864
Rebase
chronicl 8420a3c
Small import change
chronicl 6ce7e49
Fix example name
chronicl c5b9088
PackedVector to ir type conversion
chronicl bdcf157
Remove alignment rounding duplication
chronicl f3690d0
Add byte_size and align for LayoutableType
chronicl e255e1b
Make default use_color false
chronicl 3f1dcf7
Decouple gpu_layout from GpuLayout
chronicl e19e85b
Move Display impl of ScalarType
chronicl e2f41cd
Make TryFrom<Layoutabletype> for StoreType fallible started
chronicl 1aecb7e
Make ContainsPackedVecError simple
chronicl 38b535e
Test LayoutableType -> StoreType conversion
chronicl f49aa5b
Make align of all types 1 when Repr::Packed
chronicl 1d3aadc
Fix shame::Struct layout trait impls
chronicl ea6f659
Move LayoutCalculator
chronicl c4456f2
Split TypeLayout<Repr> into TypeLayout and GpuTypeLayout<Repr>
chronicl b11e5a3
Fix FieldLayout construction from LayoutableType
chronicl c22bfa7
Change GpuLayout impl of PackedVec
chronicl 6dc9776
Change gpu_layout
chronicl 3d8ddb4
Fix FieldLayout runtime sized array construction
chronicl 02dd2c5
Cleanup and FieldOffsets redone
chronicl 23af34a
Fix repr_c_struct_layout
chronicl 6c3d170
Some comment cleanup
chronicl a9abd26
.
77f7b40
.
cba751c
.
0dc1ed8
.
3b5a7d6
Make ReprCField.alignment a U32PowerOf2
db74edb
Cleanup repr_c_struct_layout
6c9da5f
GpuRepr clarification documented
673c007
.
603a213
.
8c2adb3
.
6276218
.
e6b32b8
.
85f82cb
.
4517791
.
443d7a4
.
8eeaf46
.
244ae45
.
f09ea4c
.
33cb347
.
ee4c23d
.
0f90123
.
622fe48
.
43afa0f
.
86d4530
.
8c8be8d
.
26b658f
.
c115a7d
.
9bd22b0
.
a7ecc38
.
0fdc397
.
b644315
.
c8ade95
.
1ecb223
.
7d5426d
.
41ae4a6
.
b9bae54
.
ba5e534
.
4ce2fdc
.
6d15f81
.
d3c039a
.
863078d
.
1f0844b
.
bc3770a
detailed duplicate field fame check moved to ir::SizedStruct
1250b70
.
857f026
.
77811ee
.
7c9cee0
.
90fccad
.
ea1d2f1
.
401116c
.
c9181ac
.
8ef3f04
.
cd8c5c0
.
98fbad5
.
9c3c9a1
.
5d6d7f6
.
880bb13
.
ff439a9
.
0577202
.
54a2abd
.
2afb911
.
a1ca4a3
.
213f70b
.
1fd0957
.
ffcb834
.
002d58a
.
92ae245
.
660036c
.
3db727d
.
16f1fda
api_showcase glam comment fix
RayMarch 2e99da1
`GpuTypeLayout` comment adjustment
RayMarch 78e3d09
`LayoutableConversionError` edit
RayMarch 0ebfac6
make `Vector` layout depend on repr
RayMarch 766562a
.
9dda47c
.
74b9105
merge LayoutableType with Layoutable
9916bd0
.
c597929
.
5136b45
.
86e2440
.
3e63802
.
09356ea
.
c9353ba
.
f02a993
.
08ec712
.
4cc7b47
.
16db762
.
a1c4ac6
.
91e1e2f
.
a732486
.
1b48501
.
1bcda70
.
590cd00
.
8ad86f4
.
d628f76
.
1dbe3ad
.
074a206
Fix array stride for uniform layout rules
79938ca
Fix array stride for uniform layout rules
ad4a86a
Move type layout example into GpuTypeLayout docs
fd23627
.
bffd8b5
Add unit tests to align_size.rs layout calculations
a35b602
Move adjust_struct_alignment_for_repr into LayoutCalculator
ddf6379
Add unit tests for TypeLayout::new_layout_for
5372cd5
cleanup align size tests
chronicl 8f561e0
Make clippy happy
chronicl 255fb80
Rename LayoutCalculator -> StructLayoutCalculator
chronicl defb6fa
Make Repr::Packed ignore custom_min_align attributes and catch simult…
chronicl 737522c
.
chronicl 49692f5
New TypeLayoutCompatibleWith<AddressSpace> type and layout comparison…
chronicl 27e89f7
layout comparison / mismatch errors improved
chronicl 1610c20
layout mismatch cleanup and some comments
chronicl f256447
improve layout mismatch error, rename Repr::Storage -> Repr::Wgsl
chronicl 68f81a8
rename LayoutableType -> TypeLayoutRecipe, layoutable -> recipe
chronicl 519b662
cleanup
chronicl 23981f2
layout mismatch cleanup
chronicl 8b36dd4
layout mismatch test prints
chronicl 4480b93
TypeLayoutCompatibleWith tests started
chronicl 4460799
TypeLayoutCompatibleWith done
chronicl b78cba8
disable print in tests
chronicl 96e16cd
new layout mismatch test
chronicl d154c34
remove unused to_string methods
chronicl d1a2eec
rearange method
chronicl c272489
more tests and docs
chronicl beffd64
comment improved
chronicl 291cc26
Replace compatible_with::AddressSpace with existing BufferAddressSpace
chronicl ab5182d
making `U32PowerOf2` part of public api
RayMarch c492a1f
rust 1.90.0 fix
RayMarch b35b8f3
added `rust_layout_with_shame_semantics` helper
RayMarch cd7c16d
fix warnings
RayMarch fb3137c
preparing changes to `TypeLayout`s size/align mutation api
RayMarch 8d9c9de
changes to `TypeLayout`'s size/align mutation api part 1
RayMarch 6968f7e
changes to `TypeLayout`'s size/align mutation api part 2
RayMarch 5440609
added panic that we need to resolve later
RayMarch 7ff81fc
replace `unreachable!()` in error display
RayMarch d7a320c
rename `LayoutInfo` -> `LayoutInfoFlags`
RayMarch 77bb06a
#[track_caller] for cpu_layout and gpu_layout
RayMarch 61aa3dc
make `TypeLayout`'s `Debug` impl use `Display` formatting
RayMarch de6fb93
fixed CpuLayout mismatch error
RayMarch 5b46ef0
changed stride docs
RayMarch 2249b52
minor changes
RayMarch 49ab78f
change duplicate field name error display
RayMarch f020d73
made layout::ScalarType part of the public interface
RayMarch a6287c7
adjust duplicate struct field name display
RayMarch 14cf916
change `TopLevelMismatch` error messages
RayMarch c878874
switching left/right in error message
RayMarch 40f2cdd
rewrote `StructMismatch::FieldLayout` message
RayMarch 7fac545
change `BufferAddressSpaceEnum` `Display` impl
RayMarch 523a64a
adjust comment
RayMarch 69b429d
added cpu stride from size identity function for clarity
RayMarch 2f95a65
change stride_check argument
RayMarch a82a571
added `Repr` arg to `get_attribs_and_stride`
RayMarch 830077a
make `cpu_type_name_and_layout` for `PackedVec` be `None`
RayMarch e1bede7
changed `NoXYZ` trait implementor note
RayMarch 9e071c7
impl `From<StructureFieldNamesMustBeUnique>`
RayMarch 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [package] | ||
| name = "type_layout" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [dependencies] | ||
| shame = { path = "../../shame/" } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #![allow(dead_code, unused)] | ||
| //! Demonstration of the TypeLayout and TypeLayout Builder API. | ||
|
|
||
| use layout::{repr, Repr, SizedStruct}; | ||
| use shame::{ | ||
| any::{ | ||
| self, | ||
| layout::{ | ||
| self, FieldOptions, LayoutableSized, Len, RuntimeSizedArrayField, ScalarType, SizedField, SizedType, | ||
| UnsizedStruct, Vector, GpuTypeLayout, | ||
| }, | ||
| U32PowerOf2, | ||
| }, | ||
| boolx1, f32x1, f32x2, f32x3, f32x4, gpu_layout, Array, GpuLayout, GpuSized, TypeLayout, VertexAttribute, | ||
RayMarch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| VertexLayout, | ||
| }; | ||
|
|
||
| fn main() { | ||
RayMarch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // We'll start by replicating this struct using `any::layout` types. | ||
| #[derive(GpuLayout)] | ||
| struct Vertex { | ||
| position: f32x3, | ||
| normal: f32x3, | ||
| uv: f32x2, | ||
| } | ||
|
|
||
| // SizedStruct::new immediately takes the first field of the struct, because | ||
| // structs need to have at least one field. | ||
| let sized_struct = SizedStruct::new("Vertex", "position", f32x3::layoutable_type_sized()) | ||
| .extend("normal", f32x3::layoutable_type_sized()) | ||
| .extend("uv", f32x1::layoutable_type_sized()); | ||
|
|
||
| let storage = GpuTypeLayout::<repr::Storage>::new(sized_struct.clone()); | ||
| let packed = GpuTypeLayout::<repr::Packed>::new(sized_struct); | ||
| assert_ne!(storage.layout(), packed.layout()); | ||
|
|
||
| // Does not exist: | ||
| // let uniform = GpuTypeLayout::<repr::Uniform>::new(sized_struct.clone()); | ||
|
|
||
| // However we can try to upgrade a GpuTypeLayout::<repr::Storage> | ||
| let uniform = GpuTypeLayout::<repr::Uniform>::try_from(storage.clone()).unwrap(); | ||
RayMarch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // Which if it succeeds, guarantees: | ||
| assert_eq!(storage.layout(), uniform.layout()); | ||
|
|
||
| // // Let's end on a pretty error message | ||
| let mut sized_struct = SizedStruct::new("D", "a", f32x2::layoutable_type_sized()) | ||
| // This has align of 4 for storage and align of 16 for uniform. | ||
RayMarch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| .extend("b", Array::<f32x1, shame::Size<1>>::layoutable_type_sized()); | ||
|
|
||
| let storage = GpuTypeLayout::<repr::Storage>::new(sized_struct.clone()); | ||
| let uniform_result = GpuTypeLayout::<repr::Uniform>::try_from(storage.clone()); | ||
| match uniform_result { | ||
| Err(e) => println!("This error is a showcase:\n{}", e), | ||
| Ok(u_layout) => println!("It unexpectedly worked, ohh no."), | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.