Fixing depth clashing and struct padding

This commit is contained in:
Dynamitos committed 2026-11-05 22:31:04 +01:00
1 parent ff2e4e642d
commit 3317705d9c
4 files changed
+55 -12

No files matched your search

+5 -4
View File
@@ -4,9 +4,7 @@ import Common;
// CPU side by UIPass as SE_DESCRIPTOR_TYPE_STORAGE_BUFFER). We read it here as a plain SSBO so
// every value (x/y/w/h, color, opacity, uvOffset/uvSize, textureIndex) is EXACT — not barycentric
// interpolated the way the old code passed it as a STYLE vertex attribute (which corrupted the
// transparency and shifted glyphs). The C++ RenderElementStyle layout (glm: vec3=12B, vec2=8B)
// is byte-identical to this slang struct (float3=12B, float2=8B); Slang's default SSBO packing
// (offsets 0,4,8,12,16,28,32,36,40,48,52) matches it 1:1.
// transparency and shifted glyphs).
struct RenderElementStyle
{
float x;
@@ -63,7 +61,10 @@ VertexOutput vertexMain(uint vertexId : SV_VertexID, uint instanceId : SV_Instan
coordinates[vertexId].x * pViewParams.invScreenDimensions.x * 2.0 - 1.0,
1.0 - coordinates[vertexId].y * pViewParams.invScreenDimensions.y * 2.0
);
output.position = float4(ndc, 1 - style.z, 1.0);
// style.z is ALREADY the final depth: the CPU maps the tree depth (render.level) into [0,1]
// and REVERSES it for the depth buffer's SE_COMPARE_OP_GREATER (nearer = LARGER). Write it
// verbatim — do NOT negate it again (the old `1 - style.z` double-inverted the depth).
output.position = float4(ndc, style.z, 1.0);
output.texCoords = coordinates[vertexId].zw; // quad-local uv, interpolated per-fragment
output.instanceId = instanceId; // uint varying: exact per-fragment (not interpolated)
return output;