shader: prove uniform compute image_load for v_readfirstlane_b32 in gfx2hlsl #2848
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2848
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2848/head"
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?
@R0D4X on GitHub · 2026-11-26 13:29 UTC · original
R0D4X:feat/readfirstlane-uniform-image-load→main· +181 −0 · 3 files · 1 commits · closed without mergingPart of #2644 (T5). Refs #2274, #1723.
Root Cause / Motivation
In
tools/startup/gfx2hlsl.py, computeimage_loadandimage_load_mipdid not propagate uniformity to their destination VGPRs even when reading through a uniform read-only descriptor at uniform coordinates in an entry block with knownexec. Downstreamv_readfirstlane_b32reads of those loaded channels were therefore refused withv_readfirstlane_b32 requires a proven uniform source.Summary
tools/startup/gfx2hlsl.py):self.has_image_writes(image_store*/image_atomic*) on the stage inStage.translate().Stage.uniform_image_load_dsts()and hook it inStage.one()for compute (cs)image_loadandimage_load_mipin the entry block with knownexecwhennot self.has_image_writes:SQ_RSRC_IMG_2D,SQ_RSRC_IMG_2D_ARRAY,SQ_RSRC_IMG_3D), non-emptydmask, allowed modifiers (refusingd16), exact coordinate count with every coordinate register proven uniform, an 8-SGPR static read-onlytable/rootdescriptor with consecutive descriptor words and no varying SGPRs, and exact destination register count matchingpopcount(dmask).dmaskinself.uniform_v(and clears staleuniform_exprentries for them).image_store*orimage_atomic*(even to a different descriptor), varying coordinates, unknownexec, pixel stages, or registers outsidedmaskstay refused.tests/startup_gfx2hlsl_readfirstlane_uniform_check.py):2D dmask:0xflanes 0 and 3, partialdmask:0x5,2D_ARRAY,3D,image_load_mip,a16) and 6 refusal controls (varying X/mip coordinate, stage withimage_storeto another descriptor, register outsidedmask:0x5, unknownexec, pixel stage).tests/startup_compute_dispatch_texture_check.py):uniform_image_load: dispatches a translated compute shader throughstartup_stream_consumer(dispatch-sampled-2x1) that loads texel(1, 0)(red1.0) viaimage_load, broadcasts it withv_readfirstlane_b32 s20, v12, and XORss20into Case A's output (320/320 words match).1to0reads texel(0, 0)(red0.0) and differs at all 288 written words.Before / After
v_readfirstlane_b32reading a VGPR loaded by a uniform computeimage_load/image_load_mipwas refused as unproven.image_load/image_load_mipin stages with no image writes marks its exactdmaskdestination VGPRs as uniform, translating and matching GPU readback on WARP and hardware while keeping unsafe forms refused.Verification
2799020e(based on8c9f168f)10.0.26300.9974), MSVC19.44.35230, Windows SDK10.0.26100.0, DXC1.9.2602.17, D3D12 debug layer enabledMicrosoft Basic Render Driver(1414:008c), driver10.0.26100.9818NVIDIA GeForce RTX 5080(10de:2c02), driver32.0.16.2124Commands and measured results (0 failures, 0 skips):
git diff --check,startup_gfx2hlsl_readfirstlane_uniform_check.py,startup_gfx2hlsl_readfirstlane_recompute_check.py,startup_gfx2hlsl_readfirstlane_load_recompute_check.py,startup_compute_readfirstlane_check.py,startup_translator_check.py,docs_links_check.py,bidi_controls_check.py): PASSctest --preset dev --no-tests=error -j 1 -R '^(startup_tools_lint|startup_gfx2hlsl_readfirstlane_uniform|startup_compute_dispatch_texture_)' -V: 4/4 passed (debug layer: enabled, no error messageon WARP and RTX 5080)ctest --preset release --no-tests=error -j 1 -R '^(startup_gfx2hlsl_readfirstlane_uniform|startup_compute_dispatch_texture_)' -V: 3/3 passed (14.30 sec,debug layer: enabled, no error messageon WARP and RTX 5080)drop_image_load_hook,drop_has_image_writes_guard,drop_uniform_coord_check): 3/3 caught (rc=1) and reverted cleanly.Evidence Scope
devandreleaseDXCcs_6_0GPU dispatches + coordinate-mutation control on WARP and RTX 5080 with D3D12 debug layer enabled, andtools/disasm_rdna2.pydecode of all spliced instruction words.AI-assisted; source-built fixtures only.
@tedin7 on GitHub · 2026-11-26 13:31 UTC · original
@R0D4X thank you for this, and for the careful test cases.
This PR covers the same slice as the earlier #2842 by @stan495: compute
image_loadat uniform coordinates proven uniform forv_readfirstlane_b32(#2644 T5). Both change the same uniformity proof intools/startup/gfx2hlsl.pyfor the same instruction pair. The project keeps the older PR when two cover the same case, so I am closing this one in favour of #2842, which is in review now.Some of your cases look like they are not in #2842 yet: the 2D-array
image_load, the partialdmask:0x5load, and the lane-3 readback. They would be welcome as a follow-up on top of #2842 once it lands, or as a suggestion in the #2842 thread. If you think this PR covers something #2842 does not, say so here and it can be reopened.AI-assisted; commands listed were executed locally.
Pull request closed