d3d12: decode meshlet-coded indices in title-memory BLAS builds (stacked on #320) #375

Merged
Jerkin42 merged 6 commits from upstream-pr/375 into main 2026-11-28 14:41:16 +00:00
Jerkin42 commented 2026-11-28 06:25:43 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by Jerkin42 on 2026-11-28T06:25:43Z.


Summary

Stacked on #320 (gtb-sbe's guest-memory acceleration structures). This branch is #320's head (561b805) plus two commits, 7886a3c and c800b90. Only those are new here, so please review it after #320 lands. I'll rebase once it does.

ProjectScarlett's own bottom-level builds name index format 53, which D3D12 does not define. guest_addresses::geometry sized any index format other than R16_UINT or R32_UINT as 0 bytes. As a result, the title's address was never resolved and reached the host build as an index buffer. vkd3d-proton reads such a format as R32_UINT at that address. NickStallman measured this on #320 (comment): 581 distinct raw BLAS index addresses about 12 minutes into the story, followed by an Xid 13.

Format 53 is a meshlet-coded stream:

  • a header: 0x80000000 | meshlets, the triangle count, one more word;
  • one 16-byte record per meshlet, whose first two words give the offset of the meshlet's u16 vertex list;
  • one word per triangle: meshlet << 21 | c << 14 | b << 7 | a, three positions in that list;
  • the vertex lists.

This commit:

  • decodes the stream on the CPU (commands/build_raytracing/meshlet_indices.rs) into R32_UINT indices in an upload buffer that the list retains;
  • sizes the vertex range by the largest decoded index;
  • decodes only a stream in title memory, where the CPU reads it at its own address; an address the host already knows is a GPU address, so the build is refused there;
  • refuses the build (E_NOTIMPL, which #320 already skips) when the stream does not match the build's index count or cannot be read;
  • refuses any other index format the host cannot read, instead of passing the address through.

Notes:

  • The stream is read with ReadProcessMemory at record time, so a page that cannot be read refuses the build rather than faulting. In ProjectScarlett the static geometry is written by the CPU before its builds are recorded.
  • The prebuild query still passes format 53 to the host. vkd3d-proton sizes it as R32_UINT with the same index count, which is the triangle count the decoded build has, so the destination and scratch the title allocated fit.
  • Not included: the packed 8-byte positions these builds also use (R32G32_FLOAT, stride 8, with a 32-byte header holding origin, axis order and scale). That layout is also valid D3D12, so it needed a reliable way to tell the two apart. The console builder's leaf kernel provides one (it has no plain two-float path for that format), so it is now #376, stacked on this PR.

The decoding was validated offline against captured ProjectScarlett builds before this port: paired-leaf score 1.0000 on 61,973 pairs against the console's own leaves. In game, a local build with this decoder, plus the packed-position decode and a check that vertex ranges are committed, was the first of our title-memory build runs without a GPU page fault. This PR has not been run in game on its own.

Tested

  • The checks relevant to this change passed
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below
  • Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: NVIDIA still needs to run them.

No Lanes scenario: Lanes has no title-memory BLAS case to extend, and #320's BLAS reference builds from native buffers. The decoder is a pure function over the stream's bytes, covered by unit tests in tests/commands/meshlet_indices.rs:

  • two meshlets decode to their list indices;
  • the high bit of the first record word reaches the list offset;
  • streams that do not match the build are refused: wrong index count, missing coded flag, a triangle naming a missing meshlet, a list cut short.

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:

python tuxbox.py check
  passed   Build the shader compiler, Python tests, Shader compiler tests, DXBC tests,
           XG layout tests, D3D12 Windows typecheck, Build,
           D3D12 regression controls, Shader translator on the GPU
  FAILED   Lanes and fixtures on the GPU: 147 PASS, 1 FAIL (invalid-route, which fails the same way on main on this machine)

Checks

No evidence JSON changes.

🤖 Generated with Claude Code

<!-- greyfinch-sync:brcly/TuxBox:issue:5537439128 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/375). Originally posted by [Jerkin42](https://github.com/Jerkin42) on 2026-11-28T06:25:43Z. --- ## Summary **Stacked on #320** (gtb-sbe's guest-memory acceleration structures). This branch is #320's head (561b805) plus two commits, 7886a3c and c800b90. Only those are new here, so please review it after #320 lands. I'll rebase once it does. ProjectScarlett's own bottom-level builds name index format 53, which D3D12 does not define. `guest_addresses::geometry` sized any index format other than R16_UINT or R32_UINT as 0 bytes. As a result, the title's address was never resolved and reached the host build as an index buffer. vkd3d-proton reads such a format as R32_UINT at that address. NickStallman measured this on #320 ([comment](https://github.com/brcly/TuxBox/pull/320#issuecomment-7235146468)): 581 distinct raw BLAS index addresses about 12 minutes into the story, followed by an Xid 13. Format 53 is a meshlet-coded stream: - a header: `0x80000000 | meshlets`, the triangle count, one more word; - one 16-byte record per meshlet, whose first two words give the offset of the meshlet's u16 vertex list; - one word per triangle: `meshlet << 21 | c << 14 | b << 7 | a`, three positions in that list; - the vertex lists. This commit: - decodes the stream on the CPU (`commands/build_raytracing/meshlet_indices.rs`) into R32_UINT indices in an upload buffer that the list retains; - sizes the vertex range by the largest decoded index; - decodes only a stream in title memory, where the CPU reads it at its own address; an address the host already knows is a GPU address, so the build is refused there; - refuses the build (E_NOTIMPL, which #320 already skips) when the stream does not match the build's index count or cannot be read; - refuses any other index format the host cannot read, instead of passing the address through. Notes: - The stream is read with ReadProcessMemory at record time, so a page that cannot be read refuses the build rather than faulting. In ProjectScarlett the static geometry is written by the CPU before its builds are recorded. - The prebuild query still passes format 53 to the host. vkd3d-proton sizes it as R32_UINT with the same index count, which is the triangle count the decoded build has, so the destination and scratch the title allocated fit. - Not included: the packed 8-byte positions these builds also use (R32G32_FLOAT, stride 8, with a 32-byte header holding origin, axis order and scale). That layout is also valid D3D12, so it needed a reliable way to tell the two apart. The console builder's leaf kernel provides one (it has no plain two-float path for that format), so it is now #376, stacked on this PR. The decoding was validated offline against captured ProjectScarlett builds before this port: paired-leaf score 1.0000 on 61,973 pairs against the console's own leaves. In game, a local build with this decoder, plus the packed-position decode and a check that vertex ranges are committed, was the first of our title-memory build runs without a GPU page fault. This PR has not been run in game on its own. ## Tested - [x] The checks relevant to this change passed - [x] Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below - [ ] Where the table calls for AMD and NVIDIA, they passed on both. Otherwise, say which vendor still needs to run them: **NVIDIA still needs to run them.** No Lanes scenario: Lanes has no title-memory BLAS case to extend, and #320's BLAS reference builds from native buffers. The decoder is a pure function over the stream's bytes, covered by unit tests in `tests/commands/meshlet_indices.rs`: - two meshlets decode to their list indices; - the high bit of the first record word reaches the list offset; - streams that do not match the build are refused: wrong index count, missing coded flag, a triangle naming a missing meshlet, a list cut short. 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: ```text python tuxbox.py check passed Build the shader compiler, Python tests, Shader compiler tests, DXBC tests, XG layout tests, D3D12 Windows typecheck, Build, D3D12 regression controls, Shader translator on the GPU FAILED Lanes and fixtures on the GPU: 147 PASS, 1 FAIL (invalid-route, which fails the same way on main on this machine) ``` ## Checks No evidence JSON changes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
brcly/TuxBox!375
No description provided.