Repository navigation
xshader: a guarded mesh half result does not read the launch bits no reader takes - #268
Conversation
…reader takes 99 ProjectScarlett mesh programs were refused with "unsupported mesh launch register v7" (59) or "v6" (40). Each first writes the register with a VOP1 v_cvt_f16_f32, and some write v8 the same way. On RDNA2 that writes bits 15:0 and keeps 31:16, so `live_in`, which takes registers read before they are written in program order, counts the write as a read of the launch value. Every later reader is a v_cvt_f32_f16 or a v_pack_b32_f16 without op_sel, which reads bits 15:0 only. In some programs a v_cvt_f32_f16 then replaces the whole register before the vertex exports read it. `kept_half_unread` proves that for each such register, over the whole program including the export sequence, in `live_in`'s program order. The 16-bit write must sit in the block the vertex-count guard opens: s_mov_b64 s[n:n+1], exec; v_cmpx_gt_u32 count, lane; s_cbranch_execz to s_mov_b64 exec, s[n:n+1]. `count` and `lane` are the registers the export sequence tests, and neither changes after the guard. The guard is the last EXEC change before the write. Up to the export sequence EXEC only narrows or returns to a value saved since the block opened, and inside the block to one saved after the guard. No branch crosses the guard or the write except the guard's own, taken when no lane is active. So every lane that reads the register has executed the write. After the block nothing touches the register before the vertex exports, which test the same count against the same lane; the export recognizer now records where they begin. Each later reader takes the low half, until a full write that no path leaves early or comes back into, and no register range may hold the register without naming it. Any other shape is still refused. The translation starts the kept bits at zero, as before. When one register holds both counts, as the recognizer now also accepts, the vertex exports still test that register against the lane, so a guard on it keeps the same lanes. The check never reads the primitive count. A read in the primitive part is still refused, though its lanes are then the guard's. Over the recorded ProjectScarlett requests (24,848, and 24,866 for the byte comparison, as a game run was adding to them), against 68e79b7: the 99 translate, compile with Linux DXC 1.8.2505.1 and pass DXV. All 22,970 requests main translates give byte-identical output, and every other refusal is unchanged. No GPU run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent synthetic GPU check of #268 integrated with #266 and #272: https://github.com/Valdi320/TuxBox/tree/b9d796e8ee8147ee4a36c4353f979f17d11ee238. Added 3 guarded FP16->FP32 position-export fixtures (3/67/128 vertices). The previous compiler at 86cd032 refuses 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. |
e3262e0 to
e56f9ee
Compare
|
Rebased onto 68e79b7. The only conflict was in
New test: the guarded shape ahead of the single-count sequence is accepted. It's refused for:
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. |
|
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. |
# Conflicts: # tools/shader-compiler/src/tests/hlsl/mesh.rs
|
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. https://github.com/Valdi320/TuxBox/tree/c0a663e1af986335f52370dc1f49b5859fc3ac9b Same 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. |
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
mainat 68e79b7. 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.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.ds_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 onto 68e79b7, 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