phase(N.5) Task 7 fixup: BatchData Pack=8 for ulong alignment
Code quality review caught that BatchData uses Pack=4 but contains a ulong field. With the current field order (TextureHandle first), offset 0 is always 8-byte aligned so std430 works. But adding a 4-byte field before TextureHandle without bumping Pack would silently misalign the GPU struct. Pack=8 makes the alignment requirement explicit and adds a comment documenting expected std430 offsets. No runtime change — current offsets (0/8/12) are identical under both Pack values for this field order. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
86c471d2d1
commit
1b6995d2df
1 changed files with 7 additions and 1 deletions
|
|
@ -80,7 +80,13 @@ public sealed unsafe class WbDrawDispatcher : IDisposable
|
|||
private int _transparentByteOffset;
|
||||
#pragma warning restore CS0169
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
// std430 layout: ulong TextureHandle (uvec2) at offset 0, uint TextureLayer
|
||||
// at offset 8, uint Flags at offset 12. Total 16 bytes.
|
||||
// Pack=8 (not 4) because std430's uvec2 requires 8-byte alignment — Pack=4
|
||||
// works today by accident (TextureHandle is the first field, so offset 0 is
|
||||
// always 8-byte aligned), but adding a 4-byte field before TextureHandle
|
||||
// without bumping Pack would silently misalign the GPU struct.
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 8)]
|
||||
private struct BatchData
|
||||
{
|
||||
public ulong TextureHandle; // bindless handle (uvec2 in GLSL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue