xshader: a guarded mesh half result does not read the launch bits no reader takes #268
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/268"
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 NickStallman on 2026-11-26T20:23:31Z.
What was refused: 99 ProjectScarlett mesh programs, with
unsupported mesh launch register v7(59) orv6(40). That is every request in those two groups.Cause: each program first writes the register with a VOP1
v_cvt_f16_f32, and some write v8 the same way. On RDNA2 a 16-bit result writes bits 15:0 and keeps 31:16.live_intakes the registers read before they are written in program order, so it counts that write as a read of the launch value in v6, v7 or v8. In fact no result takes those bits. Every later reader is av_cvt_f32_f16or av_pack_b32_f16without op_sel, which reads bits 15:0 only. In some programs av_cvt_f32_f16replaces the whole register before the vertex exports read it.In all 99 programs the write sits inside the vertex-count guard:
s_mov_b64 s[44:45], exec; v_cmpx_gt_u32 s46, v0; s_cbranch_execztos_mov_b64 exec, s[44:45].s46(ors38) is the vertex countmesh_exportsalready recognises. So lanes past the count, which keep the full launch value, never execute the write or any reader.Change:
kept_half_unread(program, reg, exports)accepts a launch register only when that holds. The proof covers the whole program, export sequence included, and is relative tolive_in's program order: EXEC saves and restores pair up in that order, and each branch is checked against it.exports.verticesagainstexports.lane_index, and neither register is rewritten after it.v_cmpx_*,s_and_saveexec_b64) or returns to a value saved since the block opened. Inside the block, that value must have been saved after the guard.s_cbranch_execz, which is taken only when no lane is active.MeshExportsnow records where they start (vertex_start); nothing else inmesh_exports.rschanges.Measured on the recorded ProjectScarlett requests, CPU only, without the game, against
mainat68e79b7. The command wastools/triage_scarlett_shaders.py <requests> --xshader <branch> --baseline <main> --aggregate-only. The archive grew during the run, because a game run was recording: 24,848 requests for the triage, 24,866 for the byte comparison.mainmesh_launch: 59 v7, 40 v6), 0 regressed. The 96 failures are the.wave32requests, which the triage tool cannot snapshot (invalid_input);mainfails them too..wave32included, gave byte-identical HLSL and profile for all 22,970 requests thatmaintranslates, and the same message for all 1,797 that both refuse.ms_6_6,-E main) and pass DXV.68e79b7is covered by unit tests only.Tests: unit tests in
tests/hlsl/mesh.rs:mesh_exports::recognize, with v7 read by the position export. The same program with the guard on s48 is refused.68e79b7(guard on the shared count against the lane). Refused there for a guard on another register or lane, a count rewritten before the exports, a read after the block, ads_swizzle_b32of the register, and a read in the primitive part.s_cbranch_scc0from before the 16-bit write to after the full write.s_and_saveexec_b64before the write, with EXEC restored after the full write.v_cmpx.s_mov_b64 exec, -1inside the block.cargo test --locked --target x86_64-unknown-linux-gnuintools/shader-compiler: 380 + 2 passed.python -m unittest discover -s tests -q: 380 tests, OK (18 skipped).python tuxbox.py checkpassed on this branch: passed on the earlier base (below); re-running on the rebase.python tuxbox.py check --adapter 1002:13c0 --proton … --prefix … --windows-dxc …passed, 112 gates. That covers Lanes and the fixtures, the D3D12 regression controls and the translator GPU checks.facfaab. Since then, it has been rebased onto68e79b7, whose mesh export changes it now builds on. Full checks on the rebased commit are running, and I'll update these lines when they finish.Lanes / translator GPU check: none, for three reasons.
tools/check_translator_gpu.pyruns compute programs only.shader_fixture.py,raster_fixture.py) are compute, vertex and pixel programs.check_frosty_mesh.pyand thed3d12-meshsuite dispatch desktop DXIL mesh shaders.check_frosty_nanite_mesh.pyneeds Frosty's retail archive.mesh_exports::recognizeandmesh_bindings::read: the full GS_ALLOC_REQ and export sequence, PSV mesh info, PSG1, a position signature and a MeshLayout binding table. It would also need a mesh pipeline with pixel readback in Lanes.mainsuch a scenario would fail only becausexshaderrefuses the program, and the unit tests already show that. The emitted code is unchanged, and its kept bits start at zero as before. A GPU readback could not tell zero from launch bits that, by the proof, never reach an output.🤖 Generated with Claude Code
Imported from brcly/TuxBox. Originally posted by Valdi320 on 2026-11-26T21:06:07Z.
Independent synthetic GPU check of #268 integrated with #266 and #272:
github.com/Valdi320/TuxBox@b9d796e8ee. Added 3 guarded FP16->FP32 position-export fixtures (3/67/128 vertices). The previous compiler at86cd032refuses each with 'unsupported mesh launch register v7'; the combined compiler translates all three. RTX 4080 / GE-Proton11-14: 28/28 draws, 1792/1792 exact readback words (including 6 new half-register draws, full and clipped scissor). All six non-GPU groups passed before adding the small Python fixture unit test, which also passes. Scope is actual translated geometry on desktop D3D12, not Xbox root replacement or retail shader equivalence.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-26T21:14:49Z.
Rebased onto
68e79b7. The only conflict was intests/hlsl/mesh.rs, where both changes appended tests. Both are kept, and the single-count fixture is now aconstso another test can reuse it.kept_half_unreadis unchanged:s_cmpk_gt_u32on the count isn't taken as a write. Removing that exclusion makes the new test fail.New test: the guarded shape ahead of the single-count sequence is accepted. It's refused for:
ds_swizzle_b32of the register;Re-measured against
68e79b7: 99 recovered, 0 regressed, and every other output byte-identical. The numbers are in the description. None of the 99 uses the single-count shape. The full GPU checks in the description ran on the old base. They're running again on the rebase on AMD and NVIDIA, and I'll update the description when they finish.Imported from brcly/TuxBox. Originally posted by NickStallman on 2026-11-26T21:20:32Z.
Thanks @Valdi320, that covers what I couldn't: a translated mesh program drawing on the GPU. The three guarded fixtures are a good shape for a Lanes scenario if mesh pipelines get one.
Imported from brcly/TuxBox. Originally posted by Valdi320 on 2026-11-26T21:27:48Z.
Following your suggestion, I replaced the records-only desktop mesh fixture in the combined #266/#268/#272 verification branch with synthetic RDNA2 NGG (67 vertices, guarded half-to-float position exports). The worker must now compile BOTH mesh and pixel stages against the reflected root; the gate checks that every loaded stage digest matches a worker receipt and rejects rootless/stand-in paths.
github.com/Valdi320/TuxBox@c0a663e1afSame rebuilt provider and Lanes executable, RTX 4080 / GE-Proton11-14, isolated prefixes, null pipelines disabled: A/B with compiler
86cd032(before #268) vs combined compiler: raster-tables and raster-samplers pass both; mesh-samplers and mesh-sampler-single fail with missing mesh shader before, pass after. All six no-GPU groups passed, including updated negative tests. The final C++ change is comments only. This is a combined test branch, not a standalone PR or a title replay. Native AMD verification and rebase against your newest head remain outstanding. Thanks for the suggestion.