shader: lower gfx1030 explicit-gradient pixel sampling #1500
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1507"
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 stan495 on 2026-11-24T13:18:18Z.
Summary
Lower
image_sample_d,image_sample_d_o,image_sample_d_g16, andimage_sample_d_o_g16toSampleGradfor the wave64 gfx1030 pixel AOT profile. Use contiguous 32-bit 2D UVs, fulldmask:0xf, full-width slopes or two packed binary16 gradient words, and optional known signed XY offsets in[-8, 7]. Offsets assume integer mip sampling. Explicit gradients need defined operands, not quad-provenance UVs. NSA, A16, D16, other dimensions and other gradient variants remain refused.Builds on #1451 and preserves the comparison and LOD behavior from #1487 and #1445. The diff includes only the gradient behavior and its fixtures.
Verification
Tested clean head
6edd861d84c27c9b9cd837a8dd2dcb3767fa87d9.CTest: 18 passed, 0 failed, 0 skipped. Each adapter compares all four instructions with CPU references on a two-mip partial draw, including untouched pixels, and a four-mip full draw. Both offset variants also match the spatial ramp. Both passing gradient records contain all four forms. At
(0,0), zero gradients change green to red (channel 0 expected00000000, actual3f800000), and zero offset changes the first ramp red value (expected3d808000, actual00000000). Rejections include sparse masks, wrong address width, undefined and pending operands, unsupported modes, and out-of-range offsets.Windows 11 build
26300.9974; Intel Arc B39032.0.101.8509; Microsoft WARP10.0.26100.9818. Debug layer unavailable on both.All LLVM checks passed. The gradient check validates assembly, disassembly, synthetic-container CLI HLSL round trips, and independent LLVM G16 operand codegen. Draws execute translated desktop DXIL.
git diff --checkpassed.git merge-tree --write-tree refs/remotes/origin/main HEADpassed againstbc43e6659ea2971a6cd82bc4baecd685e13f251c, also with #1504 applied first. Merge-tree is a separate check, not an integrated execution run.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T14:09:24Z.
Review: COMMENTED
Technical review of commit
6edd861d84c27c9b9cd837a8dd2dcb3767fa87d9:Code & fixture audit
tools/pixel_aot.pycleanly extends 2Dimage_samplelowering toimage_sample_d,image_sample_d_o,image_sample_d_g16, andimage_sample_d_o_g16(dmask:0xf), mapping gradients toSampleGradand unpacking G16 half-float pairs withwiden16(h)/widen16(h >> 16)on unsigneduintoperands.tests/pixel_sample_gradient_check.pycovers lowering, independentllcG16 operand-order codegen, negative controls (width mismatch, NSA form, non-0xfdmask, unsupported modifiers/dimensions, undefined/pending operands, out-of-range offset), andFORM_COVERAGE_RECORDintegration.Verification
tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check, andgit merge-tree --write-tree origin/main HEADall pass.tests/pixel_sample_gradient_check.py binary(withllvm-mc-19,llvm-objcopy-19,libLLVM.so.19.1,llc-19),tests/pixel_aot_check.py,tests/pixel_sample_offset_check.py binary,tests/pixel_get_lod_check.py binary, andtests/pixel_compare_sample_check.py binaryall passed.--preset dev): builtoffscreen_check(4.23s);ctest --preset dev -R '^pixel_aot_sample_gradient_' --no-tests=error: 2/2 passed (pixel_aot_sample_gradient_warp,pixel_aot_sample_gradient_hardware)./O2(--preset release): builtoffscreen_check(1.44s);ctest --preset release -R '^pixel_aot_sample_gradient_' --no-tests=error: 2/2 passed (pixel_aot_sample_gradient_warp,pixel_aot_sample_gradient_hardware).tests/form_coverage_check.py: passed.Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T14:53:19Z.
Explicit gradients are genuinely exercised — dropping them or swapping the slopes both fail
Independent reviewer, not the author. Reviewed
6edd861d; nothing pushed to the branch. Mutations were made locally intools/pixel_aot.py, reverted between each; working tree is clean.Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11, LLVM gfx1013 tooling
available.
As submitted:
Mutation 1 — the call becomes
Sample, gradients droppedMutation 2 — the two slopes swapped
So the fixture distinguishes not only "gradient present" but which axis went where, which is what an explicit-gradient
lowering needs: a swapped pair still produces a plausible but wrong image.
A note on my own method
My first attempt at mutation 2 reported no match while mutation 1 was still applied, so the failure it showed was
mutation 1's, not the swap's. I reverted, confirmed a clean tree, and re-ran the swap on its own before recording the
result above. Mentioning it because the two runs look identical in the output and only the redone one means anything.
Verdict
Reviewed
6edd861d. Builds clean, both gradient cases pass on WARP and on a physical adapter, and two independentmutations in the emitted HLSL call are caught. No objection from me.