Fixing depth clashing and struct padding
This commit is contained in:
1 parent
ff2e4e642d
commit
3317705d9c
4 files changed
+55
-12
No files matched your search
@@ -32,14 +32,27 @@ class UIPass : public RenderPass {
|
||||
float y;
|
||||
float w;
|
||||
float h;
|
||||
Vector color;
|
||||
// Layout is locked 1:1 to the Slang std430 struct (UIPass.slang::RenderElementStyle).
|
||||
// Offsets (both sides): x/y/w/h @0/4/8/12, color @16 (12B, 16B-aligned in std430),
|
||||
// opacity @28, z @32, textureIndex @36, uvOffset @40, uvSize @48, pad @56, sizeof=64.
|
||||
//
|
||||
// The trailing `pad` (Vector2) is LOAD-BEARING: the Slang std430 struct is 16B-aligned
|
||||
// (because of the float3), so its stride is sizeof=64. On platforms where the C++ side
|
||||
// aligns to 4 (alignof(glm::vec3)==4), the natural sizeof would be 56 and the CPU would
|
||||
// pack elements at 56B — desyncing element 1's data against the GPU's 64B stride and
|
||||
// corrupting every field from uvSize onward. `pad` forces sizeof==64 on ALL platforms.
|
||||
//
|
||||
// Do NOT reorder, remove, or shrink `pad`, and do NOT insert fields between existing ones
|
||||
// without updating BOTH this struct AND the Slang struct AND re-verifying the offsets
|
||||
// (slangc + spirv-dis, and a static_assert on the C++ side if available).
|
||||
Vector color; // glm::vec3 (12B; std430 aligns it to 16B, C++ aligns per ABI)
|
||||
float opacity = 1;
|
||||
float z = 0;
|
||||
uint32 textureIndex = std::numeric_limits<uint32>::max();
|
||||
// UV rect for textured quads (glyphs: their rect in the font atlas); unused for untextured quads
|
||||
Vector2 uvOffset = Vector2(0);
|
||||
Vector2 uvSize = Vector2(1);
|
||||
Vector2 pad;
|
||||
Vector2 pad; // do not remove — see layout comment above
|
||||
};
|
||||
|
||||
Gfx::RenderTargetAttachment colorAttachment;
|
||||
|
||||
Reference in new issue
Block a user