shader: lower image_sample_lz, image_sample_l and image_sample_b in pixel_aot #504
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/510"
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 PrivacyOnion on 2026-11-22T08:36:37Z.
## Summary
tools/pixel_aot.pyto lowerimage_sample_lz,image_sample_l, andimage_sample_b(dmask:0xf dim:SQ_RSRC_IMG_2D) alongsideimage_sample:image_sample_lz(v[u:v]) ->tex.SampleLevel(samp, float2(u, v), 0.0f)image_sample_l(v[u:lod]) ->tex.SampleLevel(samp, float2(u, v), lod)image_sample_b(v[bias:v], bias first per RDNA2 MIMG address component order) ->tex.SampleBias(samp, float2(u, v), bias)image_sample_lz,image_sample_l) to consume constant or ALU-computed coordinates without requiring whole-quad interpolation, while keeping helper-lane quad-coordinate validation on implicit-derivative variants (image_sample,image_sample_b).tests/pixel_sample_lod_check.pyand registerpixel_aot_sample_lod_warpandpixel_aot_sample_lod_hardwareinCMakeLists.txt(withFORM_COVERAGE_RECORDandSKIP_RETURN_CODE 77on hardware):image_sample_b, and unwaitedvmcnt(0)sample dependencies.--check-pixel-quad-lod) with mutation controls provingimage_sample_lzstays on mip 0 under 4x UV scaling,image_sample_lselects mip 1 whenlod=1.0, andimage_sample_bshifts implicit mip 0 to mip 1 whenbias=1.0.--check-pixel-case), including non-WQM constant-buffer UVs onimage_sample_lzand UV-swap mutation control onimage_sample_b.Verification
10.0.26100.0, D3D12 debug layer enabledNVIDIA GeForce RTX 5070(vendor=10de device=2f04,driver=32.0.16.1664)Microsoft Basic Render Driver(vendor=1414 device=008c,driver=10.0.26100.9818)ctest --preset dev --no-tests=error -R "^(pixel_aot_sample_lod_warp|pixel_aot_sample_lod_hardware|pixel_aot_three_way_warp)$" -V-> 3/3 PASSED (max_absolute_error=0,debug_errors=0 debug_warnings=0on both WARP and RTX 5070)out/pe-env/Scripts/python.exe -B tests/rdna2_tools_check.py-> OK (29 tests, 1 skipped)out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py-> PASSout/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py-> PASSout/pe-env/Scripts/python.exe -B tests/docs_links_check.py-> PASSImported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-22T18:16:17Z.
@PrivacyOnion Independent AMD (RDNA4) result on
fb0315a, plus coverage observations. Measurements only, no code change.Environment
debug_layer=unavailable(Tools.Graphics.DirectXisNotPresenthere — your RTX 5070 run had the layer on, so this is the one axis I cannot reproduce)fb0315a.Commands
Observed
11 tests, 11 passed, 0 failed, 0 skipped, of which the new pair:
max_absolute_error=0, no non-zero line at all.pixel_aot_sample_lod_hardwareon the RX 9070 XT: 7 per-draw counters, three atpixels=64 channels=256and four atpixels=4096 channels=16384, all zero. The harness prints no case label, so these cannot be attributed to named cases; the three expected-mismatch mutations leave no counter line, which is why 7 lines are logged for the 10 GPU cases in the diff.Coverage observations
The lowering itself is right, and I verified the part that is claimable from the diff:
bias = sample_coord(coord_regs[0])thenuv = coord_regs[1:], so bias really is the first address register, matching the ISA. What follows is about what the suite proves, not about the code being wrong.swap_uvonly swapsattr0.xandattr0.yinbase_prefix, i.e.v8andv9. No control moves a coordinate into the bias slot or the bias out ofv7. Detection of an order bug would only come frombias1/bias_rampfailing incidentally.floorfromnearest, and no case has a fractional LOD (0.5, 1.49) or an out-of-range LOD (−3.0, 4.0 against 2 mips). So neither the trilinear blend nor the clamp is exercised, andSampleBiasis semantically covered by exactly one case (bias1)._bnever runs with ALU-computed or uniform UVs.bias_programusesbase_prefix()withoutquad_scale, so thev_fma-on-interpolator-plus-bias path — the one real Series X shaders use — has no case.bad_lod_depcovers a LOD reading an in-flight sample destination, but there is no equivalent for a_bbias taken from an unwaitedimage_sample_lz, nor for a bias read beforelgkmcnt(0).Also: this PR is in conflict
GitHub reports
mergeable: false,mergeable_state: dirtyagainstmain, and #506 touches the sametools/pixel_aot.pyregion, so whichever lands second needs a rebase. This run measured a head that cannot merge as-is; the numbers above should be re-read against the rebased head.AI-assisted; runs executed locally. The coverage observations come from a separate code review and were re-verified against the diff (address-slot decoding,
swap_uvscope) before posting.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T10:25:36Z.
I resolved the conflict after #506 and pushed
bb1eb94to your branch. This keeps the partial-dmask and descriptor-offset behavior from #506, plus your explicit LOD and bias cases and all four render negative controls. The LOD/bias and dmask checks both passed on WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, Windows build 26200.9974, with the debug layer enabled. The Python pixel controls, form coverage, PSO readiness and docs links passed as well. Waiting for the current-head CI.Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-23T14:58:21Z.
Post-merge check on
cea1d92: the conflict resolution merged two sample grammars, and the new fixture exercises only one of them. Measurements plus translation probes.Environment and observed
The merge is not a copy of the reviewed head
The resolution folded #506's grammar into this one: the sample regex at
tools/pixel_aot.py:2382now acceptsimage_sample(?:_lz|_l|_b)?, a single-VGPR or a range destination, anddmask:0x([1-9a-f]). On top of that,:2385pinsdmask:0xffor the three new variants. Two consequences:_lz/_l/_b,popcount(dmask)is always 4, so the single-VGPR destination branch inherited from #506 (:2389) is unreachable for them. A legal single-channel_lis refused, and the message namesimage_samplerather than the variant:image_sample_l v[12:14], v[8:10], … dmask:0x7→Multi-channel image_sample requires a VGPR range destination.dmask:0xfin all six of its programs and never a single-VGPR destination, so neither merged grammar is exercised by it. The interaction #506 and #510 disagreed about is exactly what the test does not touch.What holds
Probed through
translate()atcea1d92:_land_lzaccept constant-buffer UVs (lz_constant_uv_program→SampleLevel(samp, float2(params[0].x, params[0].y), 0.0f)),_brejects them (Unsupported texture coordinate), bias iscoord[0]before uv (SampleBias(samp, float2(uv.x, uv.y), alu15)), and the LOD iscoord[2]— pinned for real by the 1.0 → 0.0 mutation control. On the adapter both draws pass, withthree_wayand the #506dmaskpair still green beside them.Two test-strength notes
vmcnt(0)" rejections (tests/pixel_sample_lod_check.py:136-138) actually fail withUnsupported pack operand, not the reason their comment names; only thebad_lod_depcase (:140-150) reachesSample used before vmcnt wait.must_rejectaccepts anyValueError/KeyError(tests/pixel_aot_check.py:230), whileexpect_value_error(:238) exists to prevent exactly this.dmask:0xfguard and thecoords.stop > 256bound (tools/pixel_aot.py:2401) are pinned by no case: removing either leaves all nine rejections rejecting for other reasons.One permissiveness note, faithful rather than wrong:
image_sample_l v[12:15], v[7:9]— a_b-shaped address range — is accepted and becomesSampleLevel(samp, float2(alu15, uv.x), uv.y), i.e. the interpolated v turns into the LOD. For a real_linstruction the address order is fixed by the ISA, so this is not a miscompile; it just means nothing rejects the shape and no case names it.AI-assisted; runs executed locally. The translation probes and the grammar analysis come from a separate review pass and were re-run here against
cea1d92.