Repository navigation
Shaders: pixel DPP8 within a quad reads through quad operations; common quad patterns take one - #2817
Conversation
|
Verified
|
kotekompotek
left a comment
There was a problem hiding this comment.
Verified: the intra-quad test (sel>>3i ^ i) & 4 == 0 is exactly 'selected lane shares lane i's bit 2' — stays in its 4-lane quad — and the two fast-path tables are right: broadcasts (0x00/55/AA/FF) → quadReadLaneAt at p&3; partner exchanges 0xB1/0x4E/0x1B → quadOp directions 0/1/2 via (p&3)-1; 0xE4 identity → x. Cross-quad DPP8 in PS correctly degrades to the cross_lane refusal rather than a wrong quad op, and differing per-quad permutations are safe since pattern: None for DPP8 keeps the per-lane src select path. The hardware helper-lane test at a triangle edge is the right coverage. LGTM.
Shaders: port four translator fixes from upstream (Marvisak#2813, Marvisak#2812, Marvisak#2816, Marvisak#2817)
…on quad patterns take one A pixel program's DPP8 was always a cross-lane operation outside compute, so a shader using one was refused, even where every lane picks a lane of its own quad (the case quad reads can serve, helper lanes included). Such a DPP8 now takes the quad path, as quad_perm already does; DPP8 that reads across quads stays refused. Quad reads (pixel and mesh programs) read each of the four lanes and selected among them. A pattern every quad uses alike now takes one operation: the identity none, a broadcast of one lane one QuadReadLaneAt, and an exchange across x, across y or the diagonal one QuadOp. New tests (emit/quad_tests.rs): every quad permutation through ds_swizzle_b32 and DPP, and an in-quad DPP8, translate and pass the DXIL validator, and a cross-quad DPP8 is refused; two triangles sharing a diagonal, drawn on the hardware adapter and WARP, read helper lanes' coordinates through broadcasts and exchanges as the console's whole-quad mode does. Ported from DexNom/VIctory@921d8d3 (recorded there under the author name "Codex"), whose quad-pattern lowering this is; the tests are reworked from that commit's for this tree's harness, the exchange case added. Co-authored-by: DexNom <29156494+DexNom@users.noreply.github.com>
2fee03c to
6e2215e
Compare
Port of the 0xkn0wh3r3 Marvisak#2817 delta onto this tree (hunk1, pixel quad reads reaching helpers, is already landed; Marvisak#2817 does not apply cleanly). Only the delta taken: - quad_pick takes the quad permutation every quad uses: the identity returns the value, a broadcast of one lane is one QuadReadLaneAt, an exchange across x/y/diagonal is one QuadOp. ds_swizzle and DPP quad_perm call sites pass their constant patterns. - DPP8 where every lane picks a lane of its own quad now takes the quad path (as quad_perm does) instead of being refused; DPP8 reading across quads stays refused. - New quad_tests: every quad permutation through ds_swizzle/DPP plus an in-quad DPP8 translate and pass the DXIL validator, a cross-quad DPP8 is refused, and broadcasts/exchanges read helper coordinates along a shared triangle edge (hardware/WARP where present, skipped otherwise).
|
Automated triage for the maintainers. In pixel programs, CI: passing. Generated by Claude Code |
Dukestar69
left a comment
There was a problem hiding this comment.
Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090 + WARP, dxil.dll validator active):
cargo test -p victory-shader --lib emit::quad_tests: 2 passed, 0 failed (pixel_quad_swizzles_validate_and_dpp8_cannot_cross_quadsandpixel_quad_reads_take_helper_coordinates_at_a_shared_triangle_edgepass on RTX 5090 hardware and WARP).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 192 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
…ke one quad operation A pixel program's DPP8 was always a cross-lane operation outside compute, so a shader using one was refused, even where every lane picks a lane of its own quad. Such a DPP8 now counts as quad-local, as quad_perm already does; DPP8 that reads across quads stays refused. Quad reads (mesh programs here) read each of the four lanes and selected among them. A pattern every quad uses alike now takes one operation: the identity none, a broadcast of one lane one QuadReadLaneAt, and an exchange across x, across y or the diagonal one QuadOp. Ported from Marvisak#2817 (2fee03c), itself from DexNom/VIctory@921d8d3. Upstream also routes pixel quad reads through quad operations so they reach helper lanes (from a larger upstream accuracy commit this tree does not have); that part and its GPU tests are not ported, so pixel quad-local reads here still go through wave reads. The tests are new for this tree's harness and run on every platform. Co-authored-by: DexNom <29156494+DexNom@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
DPP8 in pixel programs.
dpp()counted onlyquad_permas quad-local. A DPP8 in a pixel shader always went throughcross_lane(false)and was refused ("a cross-lane operation outside compute"). That happened even when every lane picks a lane of its own quad, which quad reads can serve (helper lanes included). Such a DPP8 is now quad-local and takes the quad path, asquad_permdoes. A DPP8 that reads across quads stays refused.Single-op quad patterns.
quad_pickread all four lanes withQuadReadLaneAtand selected among them. When the instruction gives a pattern that every quad uses (ds_swizzle quad mode, DPPquad_perm), common cases now lower to one operation:[0,1,2,3]: no operation0x00,0x55,0xAA,0xFF): oneQuadReadLaneAt0xB1), across y (0x4E) or the diagonal (0x1B): oneQuadOp(opcode 123, directions 0/1/2)Other patterns, and DPP8, keep the four-read selection.
Where it came from
Ported from DexNom's fork: the quad-pattern and DPP8 lowering is from DexNom/VIctory@921d8d3 ("Repair pixel quad sampling, …"), credited with
Co-authored-by: DexNom. In their fork that commit is recorded under the author name "Codex".I adapted the code to this tree. Here, helper-lane quad reads already exist (
helpers_read), andcross_lanealready accepts quad-local reads in pixel programs. That commit's other changes don't apply to this tree:Logas base 2 and applies the clamp.Tested
New
emit/quad_tests.rs, reworked from that commit's tests for this tree's harness:pixel_quad_swizzles_validate_and_dpp8_cannot_cross_quads: every quad permutation throughds_swizzle_b32and DPP, and an in-quad DPP8 whose two quads use different permutations, translate and passdxil.dll. A DPP8 where lane 0 reads lane 7 is refused. On current main the in-quad DPP8 is refused, so this test fails there.pixel_quad_reads_take_helper_coordinates_at_a_shared_triangle_edge: two triangles share the diagonal of a 16×16 target. Each covers some pixels as helpers of the quads the diagonal crosses. Broadcasts and the three exchanges (byds_swizzle_b32and by DPP) must return the helper lanes'SV_Positioncoordinates. Checked on the hardware adapter (RTX 5070 Ti) and on WARP. As a check that the test catches mistakes, I temporarily mapped the exchange directions wrongly, and all 256 pixels then failed on both adapters.cargo test -p victory-shaderon Windows 11 with an RTX 5070 Ti: 300 passed. Four tests fail identically on unmodified main on this machine, so they're unrelated:heap_direct_texture_reads_mark_their_heap_index(access violation), twostride_testsheap-buffer reads andgathers_at_a_level_match_the_hardware.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.Not tested
quad_pickand now get the same fast paths, but this PR doesn't add a mesh-shader test.crosslane_testspass with this change on the RTX 5070 Ti, including its inactive-source checks for ds_swizzle, DPP16 and DPP8.