d3d12: decode packed positions in title-memory BLAS builds (stacked on #375) #376
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/376"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from brcly/TuxBox. Originally posted by Jerkin42 on 2026-11-28T06:39:58Z.
Summary
Stacked on #375, which is stacked on #320. Only the last two commits,
02f9e10anda474745, are new here; the rest is #320 and #375. I'll rebase as those land.ProjectScarlett's own bottom-level builds also give their vertices as R32G32_FLOAT, as 8-byte records. These aren't two floats per vertex: the console's acceleration-structure builder has no two-component float position path. Its leaf kernel compares the vertex format against DXGI codes (6, 10, 11, 13, 16, 24, 28, 31, 34, 35). For 16 (R32G32_FLOAT) it loads a 32-byte header from just before the vertex buffer and decodes 8-byte records. It checks no stride and has no other path for that format. A host build reads the same bytes as two floats per vertex.
The layout:
StartAddress - 32: origin (3 floats), axis order (u32), scale (3 floats), one unused word;a = lo >> 8,b = (hi & 0xffff) << 8 | (lo & 0xff),c = hi >> 16;q * scale + origin, then the axis order arranges them: 0 gives (c, b, a), 1 gives (b, c, a), others (a, b, c);Transform3x4still applies afterwards.This commit decodes them on the CPU (
commands/build_raytracing/packed_positions.rs) into R32G32B32_FLOAT positions in an upload buffer the list retains. It does so only when the header and every record are title memory: as in #375, an address the host already knows is a GPU address, and the build is refused there. A header with a non-finite origin or scale, or a range that cannot be read, also refuses the build.Stride (
a474745). The title passes a vertex stride of0x8008for these 8-byte records; the builder reads the stride through a 14-bit field, so only the low 14 bits count. The import span and the decode both useStrideInBytes & 0x3fff. With the raw stride, a 180-vertex import spanned 5.8 MB and XMem refused it withERROR_INVALID_ADDRESS, and a small mesh on mapped pages was decoded from the wrong bytes. @NickStallman measured this on an RTX 5090: at stride 8, 1,124 of 1,124 vertices of 36 logged geometries fall inside their scene bounds, and the 64 "geometry 0x800701e7" skips on the rehydration path went to 0.Prebuild sizes do not change: the vertex format and stride only change how positions are fetched, not the number of primitives.
Validation: the same decoding put every one of 152 captured ProjectScarlett structures inside its scene bounds, checked offline before this port. This PR has not been run in game on its own.
Tested
No Lanes scenario, for the same reason as #375: there is no title-memory BLAS case to extend. The decoder is a pure function over the header and record bytes, covered by unit tests in
tests/commands/packed_positions.rs:These tests compile in the Windows typecheck. I also ran them on Linux by building the module on its own: 3 passed.
GPU, driver and backend: AMD RX 9060 XT, Mesa RADV 26.1.8, Linux 7.3.1, Proton Experimental (private rootful Xwayland)
Commands run and their results:
Checks
No evidence JSON changes.
🤖 Generated with Claude Code
Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-28T09:45:45Z.
@Jerkin42, a finding on the packed 8-byte positions this PR decodes. Measured in ProjectScarlett on an RTX 5090 (620.70.10), with this PR merged locally.
The title gives these geometries a vertex stride of
0x8008(32,776), but the data is 8-byte records.0x8008), we decoded the positions at both the raw stride and its low 14 bits, and compared them with the structure header's scene bounds (+0x10/+0x1c).0x8008: all 36 ranges run into pages the title never mapped.0x800701e7(ERROR_INVALID_ADDRESS). A small mesh that stays on mapped pages is decoded silently from the wrong bytes instead.StrideInBytes & 0x3fff), the 64 "geometry 0x800701e7" skips we saw on the rehydration path in an earlier run went to 0.Inferred, not verified: the console reads the stride through a 14-bit field, so the high bits are ignored there.
We'll include the mask, with a unit test that fails without it, in the rehydration PR we're stacking on this one. You may prefer to take it into this PR directly, since it affects ordinary builds too.
Imported from brcly/TuxBox. Originally posted by Jerkin42 on 2026-11-28T09:55:21Z.
Thank you, @NickStallman, that's a clear result. I've taken the mask into this PR in
a474745: the packed-position path now usesStrideInBytes & 0x3ffffor both the import span and the decode. There's a unit test for0x8008→ 8, and the decoder's tests pass. I left other formats' strides alone, since your measurement covers only this one.Your rehydration PR can then rely on it from here. If you want a test that fails without the mask on your side,
stride(0x8008)inpacked_positions.rsis the place to hook it.