Commit 677d45e
committed
SDSL: fix matrix size miscalculation in StructuredBuffer layout
MatrixType in TypeSizeInBuffer had a stray * 4 in the StructuredBuffer branch, so float4x4 reported 256 bytes instead of 64. Any RWStructuredBuffer<struct-with-matrix> would have emitted a broken ArrayStride — luckily the only real user is InstanceTransform, a float4x4 inside its own struct, and that path wasn't validated by a unit test.
Replace the formula with std430 strict matrix layout: each column (ColumnMajor) or row (RowMajor) is padded to its std430 base alignment. Covers non-square matrices correctly under Vulkan relaxed block layout.
Adds CSMatrix.sdsl regression test covering RWStructuredBuffer<Transform> where Transform = { float4x4 Matrix; float3 Scale }.1 parent 7462e7d commit 677d45e
2 files changed
Lines changed: 50 additions & 2 deletions
File tree
- sources/shaders
- Stride.Shaders.Parsers/Spirv/Building
- assets/SDSL/ComputeTests
Lines changed: 26 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | | - | |
| 50 | + | |
46 | 51 | | |
47 | | - | |
| 52 | + | |
48 | 53 | | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
53 | 58 | | |
54 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
55 | 79 | | |
56 | 80 | | |
57 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments