shader: allow safe entry interpolation in pixel loops (Part of #3814) #3831
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3831"
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 R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T07:57:20Z.
Allows safe entry attribute interpolation (
v_interp_mov_f32flat fetches and same-blockv_interp_p1_f32/v_interp_p2_f32pairs whose entry barycentrics are preserved on all reaching CFG paths) after branches in looping pixel shaders, clearing"looping graphics shader uses an entry input operation after a branch"(~315 pixel stages in #3814, including the main second wall exposed by #3815).Part of #3814. Refs #3640, #3641, #3703, #3815.
(Opened as Draft per #3514 until an active review slot frees.)
Summary
src/gfx1013_direct_graphics.inl(emit_graphics_loops):read.pc > last_loop_edgelinear scan with an exact CFG dataflow overg.overwritten_inputs(recording all lowered VGPR writes per block, includingv_interp_p1_f32and implicitv_swap_b32destinations, and propagating them across all CFG edges including back-edges).v_interp_mov_f32loads before, inside, and after loops (subject to the existing selector/attribute checks ingraphics.interpolate).v_interp_p1_f32/v_interp_p2_f32pairs in any pixel loop block whenever no in-block prefix write and no reaching CFG path (including loop back-edges) clobbers the barycentric source VGPR. Allows P1 to overwrite its own source after consuming it when no path returns to that read, while refusing if P1 overwrites P2's source or a back-edge returns to the read.Encoding::Fetch,op == 3, cross-block split P1/P2 pairs, non-barycentric sources, and invalid flat selectors strictly refused.tests/native_pixel_loop_entry_inputs_check.py+tests/cmake/native_pixel_loop_entry_inputs.cmake+docs/experiments/native-pixel-loop-entry-inputs.md:native_pixel_loop_entry_inputs_controls(runs automatically in theprCTest preset): 4 positive shapes (CMPX if/else join before loop, smooth interpolation inside loop, flat loads before/inside/after loop, smooth P1 self-overwrite after loop) + 9 fail-closed refusal controls (loop clobbers I/J after pair, loop P1 overwrites own source, pre-loop arm clobber,v_swap_b32clobber, P1 clobbers P2 source, split pair, non-barycentric source, invalid flat selector).native_pixel_loop_entry_inputs_warp&native_pixel_loop_entry_inputs_hardware: four 8×2 draws on WARP and RTX 5080, each paired with a wrong-trip-count mismatch control (all 16 pixels differ).Verification
Host: Windows 11 (
10.0.26200.9974), MSVC19.44.35230(C++20/W4, zero new warnings), DXC1.9.2602.17, inbox WARP (10.0.26100.9818), NVIDIA GeForce RTX 5080 (32.0.16.2140; D3D12 debug layer unavailable). Baseorigin/mainf365f125.ctest --preset pr --no-tests=error -R "^native_pixel_loop_entry_inputs_controls$": 1/1 passed.dev) & Release (release): 15/15 passed in both configs (native_pixel_loop_entry_inputs_{controls,warp,hardware},native_pixel_cmpx_*,native_pixel_compare_mask_*,native_pixel_dxil,native_graphics_wqm_*,native_direct_container), zero skips.tests/bidi_controls_check.py,tests/docs_links_check.py,git diff --check origin/main..HEAD: all clean.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:05:41Z.
Review: APPROVED
Reviewed
7f029c4e(draft) by reading the diff; not built or run.Verdict: approve. The CFG dataflow is a sound replacement for the old "after the last back edge" scan, and it fails closed. No MUST.
ps86census onf365f125before and after would give the real gain (follow-up is fine).after_graphics_write→overwritten_inputs(gfx1013_direct_graphics.inl:1912), including load destinations and bothv_swap_b32operands. So dropping the explicit Image/MUBUF/LDS ranges of the oldentry_barycentricloses nothing. The set is cleared per block (:1587), sowritten[label]is that block's own writes.:66,:1608).src == base + (op==1)). Each is recorded separately, so a clobber of only J is still caught. MOV has no VGPR source.interpolateloads the attribute from the input signature (load(generic(...))) and uses I/J only as provenance. Interpolating inside a loop with lane-varying trip counts therefore needs no derivatives or helper lanes.Fetchand op 3 stay refused.Tests:
_controls(4 shapes, 9 refusals, including a back-edge clobber,v_swap_b32and P1 overwriting P2's source) is in theprfilter._warp/_hardwarehave wrong-trip-count controls and ran only locally.Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T09:34:21Z.
Promoted to Ready for review now that #3806 and #3826 merged (keeping at 5/5 non-draft PRs per #3514). Re-checked
CLEAN / MERGEABLEagainstorigin/main(45c809ab) with all CI checks green.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T10:07:23Z.
Review: APPROVED
Independent Windows Debug result at
7f029c4e:ctest --preset dev --no-tests=error -j 1 -R '^native_pixel_loop_entry_inputs_(controls|warp|hardware)$' --output-on-failurepassed 3/3. The control-flow refusals and both pixel readbacks passed. Windows 11 26300.9974, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, with the offscreen fixture's D3D12 debug layer enabled.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T10:34:33Z.
Census follow-up for the SHOULD in my review:
f365f125+ this PR alone, same capture and method as #3814 (6,436 distinct pixel stages). Counts only. None lost, no validation failures.looping graphics shader uses an entry input operation after a branchf365f125f365f125+ #3831All 315 now stop at the same next wall,
graphics readfirstlane requires a wave-uniform reaching value, so the interpolation part is cleared and the loop'sv_readfirstlaneis what remains.