Shaders: pixel DPP8 within a quad reads through quad operations; common quad patterns take one #2817
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2817
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2817"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 21:19 UTC · original
0xkn0wh3r3:shader/pixel-quad-dpp8-and-single-op-patterns→main· +331 −7 · 3 files · 1 commits · openWhat
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.@fuzeofficlal on GitHub · 2026-11-25 21:30 UTC · original
Verified
2fee03ceon Windows 11 (RTX 5090 + WARP + Windows SDK10.0.26100.0dxil.dll):cargo xtask policy: 184 files ok;cargo clippy -p victory-shader --all-targets -- -D warnings(default &--features host): 0 warnings.emit::quad_tests,emit::diff_tests,emit::flow_tests): 8/8 passed (pixel helper-lane quad checks pass on both RTX 5090 and WARP with 0 pixel error across 256 pixels).dxil.dll: 269 passed, 0 failed (3 ignored, 3 pre-existing hardware-onlysynthetic_testsfiltered).(0..8).all(|i| ((sel >> (3 * i)) ^ i) & 4 == 0)cleanly separates in-quad vs cross-quad DPP8 (cross-quad still rejected in pixel shaders), andquad_pickmaps0xE4,0x00/0x55/0xAA/0xFF(quadReadLaneAt), and0xB1/0x4E/0x1B(quadOp) accurately. (Tiny nit:quad_picksetsflags::WAVE_OPSbefore the0xE4identity early return, which is harmless.)git merge-treeagainstorigin/main13f91caand #2783.@Marvisak on GitHub · 2026-11-26 02:20 UTC · original
Automated triage for the maintainers.
In pixel programs,
dpp()now treats a DPP8 whose every lane picks a lane of its own quad as quad-local, and serves it through quad reads. A DPP8 that crosses quads is still refused.quad_picklowers the common quad patterns to one operation: identity, the four broadcasts throughQuadReadLaneAt, and the X/Y/diagonal exchanges (0xB1/0x4E/0x1B) throughQuadOpwith directions 0/1/2. I checked the pattern-to-direction mapping and the DPP8 quad test (bit 2 of each 3-bit selector equal to bit 2 of its lane). Other patterns keep the four-read path. The newquad_tests.rsvalidates throughdxil.dll.CI: passing.
Generated by Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.