shader: lower explicit level-zero texture sampling #315
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/320"
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 Vonsek on 2026-11-21T21:59:16Z.
Change
Lower the single-sample gfx1013
image_sample_lz2D RGBA form to HLSLSampleLevelat level zero. Both halves of an interpolation must share the same tracked mask. Entry-mask coordinates can feed the explicit-LOD sample. Implicit samples still require whole-quad coordinates.This changes the pixel lowerer in
tools/pixel_aot.pyand adds a two-mip case to the existing offscreen BC7 check. The RGB mask in #303, affine helper-lane coordinates in #283, partial VM waits in #176 and magnified BC7 tail checks in #313 cover separate behavior.Verification
Tested
85095f9after merging upstream1292d15into this branch. Windows build 26200.9974, Microsoft WARP 10.0.26100.9818 and RTX 5080 driver 32.0.16.1692. The D3D12 debug layer was unavailable.All six CTests passed without capability skips. The bidi, form coverage and whitespace checks passed.
The initial source-built fixture failed with
Unknown interpolation context. LLVM 15 now assembles and decodes it to the same HLSL produced from source instruction text. The Windows assembler wrapper invokesclang -cc1as -triple amdgcn--amdpal -target-cpu gfx1013 -filetype obj. Controls reject a mix of execution masks within one interpolation pair and implicit sampling from entry-only coordinates.Evidence and follow-up
The MIT-licensed fixture uses the repository's source-built copy shader and two solid BC7 mips. The explicit sample matches level zero across 16 pixels and 64 channels on both adapters. Under the same texture view and viewport, the implicit sample matches mip 1 and fails against the mip-0 reference at (0, 0). Reproduction guide
In a read-only local check, the normal CLI on
1292d15rejected three candidate records during interpolation. This branch translated all three and DXC compiled them without diagnostics. They contained two distinct native programs. Both matched an independent 16-pixel CPU reference on WARP and RTX 5080 with a synthetic two-mip texture and a point-clamp sampler. A wrong mip failed first at (0, 0) and transposed UV failed first at (2, 0), as predicted. The archive digest was unchanged. The original pipeline and resources remain unverified.This contribution was AI-assisted.
Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T21:59:24Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
85095f9ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-21T22:37:30Z.
Independent verification of this PR on Windows 10, where the D3D12 debug layer is available and the in-box WARP is the old 10.0.19041 build. Short version: the new explicit level-zero case and all of its controls behave as described on three backends, with
debug_errors=0 debug_warnings=0on every draw. I found nothing caused by this PR.Environment
85095f9(PR head). Comparison baseline:1292d15, the merge base withmain, built the same way.requirements-dev.txt.devpreset, in-box D3D12 runtime): Microsoft Basic Render Driver 10.0.19041.5794 (Shader Model 6.2) and NVIDIA GeForce RTX 3060, driver 32.0.15.9636.-DOFFSCREEN_AGILITY_620_DIR=<Agility SDK 1.620.2> -DOFFSCREEN_WARP_DIR=<Microsoft.Direct3D.WARP 1.0.22 x64>): WARP 1.0.22.0 and the same RTX 3060.debug_layer=enabledon all three backends in both builds.Commands
Because
bc7_draw_warpalready fails onmainwith the in-box WARP (see below), I also ran eachoffscreen_check.exe <backend> --check-bc7 / --check-bc7-mip1 / --check-bc7-tailinvocation oftests/bc7_draw_check.pyseparately with a local driver that does not stop at the first failure: 29 sub-cases on this branch, 24 at1292d15.Results
pixel_aot_*bc7_draw_*1292d15, not in the new casedocs_linksandpso_readiness_checkpassed in both builds. No capability skips among the six listed tests.The new case, per backend (identical on all three):
Sample, 8x8 texture, 4x4 viewport, mip-1 reference: pass. The implicit sample selects mip 1.SampleLevel(..., 0.0f), same view and viewport, mip-0 reference: pass.Sampleagainst the mip-0 reference exits 1 withpixel_mismatch x=0 y=0(expected 0.995605, 0, 0, 0.995605; actual 0, 0.995605, 0, 0.995605).pixel_mismatch x=0 y=0, with the colors the other way around. So the explicit draw is not passing by accident of the reference.--check-bc7draw exactly, so level-0 texel addressing matches the implicit path, not only the level choice.Translator controls (these run inside
pixel_aot_check.pyin bothdrawandbinarymode, and I printed the outcomes separately):image_sample_lzfrom entry-mask coordinates: translated totex.SampleLevel(samp, float2(uv.x, uv.y), 0.0f).image_samplefrom entry-only coordinates: rejected,ValueError: Unsupported texture coordinate.ValueError: Unpaired interpolation.1292d15all three raiseUnknown interpolation context, which matches the PR description.LLVM 15.0.7 binary round trip: exit 0 on this branch (and on
1292d15, with one fixture fewer). My assembler stand-in callsclang --target=amdgcn--amdpal -mcpu=gfx1013 -c -x assembler, notclang -cc1as, so this is the same assembler through a slightly different driver path.bidi_controls_check.py,form_coverage_check.pyandgit diff --check: all exit 0.The in-box WARP failure is not from this PR
bc7_draw_warpfails on WARP 10.0.19041.5794 in two sub-cases, both aftercheck_lod_zerohas already passed:--check-bc7-tail <copy.cso> 11 --base-size 4096 4 ...:pixel_mismatch x=2044 y=0--check-bc7-tail <copy.cso> 11 --base-size 4 4096 ...:pixel_mismatch x=0 y=2044The same two sub-cases fail with the same first mismatch at
1292d15, and the other 22 shared sub-cases give the same result on both commits. This is the magnified tail behavior of the old WARP that #313 addressed. #313 merged after this run, so the two sub-cases should pass once this branch includesmain; I have not rerun that combination. All 29 sub-cases behave as expected on WARP 1.0.22 and on the RTX 3060.Full suite
85095f9bc7_draw_warp,gpu_alias_lookup_writes_warp1292d1585095f9bvh_wave64_warp,wave_shuffle_warp1292d15All four failures also fail at the merge base with the same first mismatch, so none is new with this PR.
gpu_alias_lookup_writes_warpreportsrecord=1 field=64 expected=0001f5a0 actual=0007d680on both commits. The two wave tests are #145.Skips, identical on both commits. Build A:
bvh_wave64_hardware,wave_shuffle_hardware,dxr_query_warp,dxr_update_warp,dxr_facing_warp,bvh_buffer_ops_warp,bvh_reads_warp,bvh_waves_warp,bvh_wave64_warp,bvh_hits_warp,bvh_differential_warp,bvh_atomics_warp,bvh_numeric_warp,bvh_packed_warp,wave_shuffle_warp,shader_metadata_probe,dxil_retarget_probe. Build B:bvh_wave64_hardware,shader_metadata_probe,dxil_retarget_probe.One timing note: in the first full run of build B,
bvh_wave64_warphit its 45 s timeout on both commits while other GPU jobs were running on this machine. Rerun alone and in a second full run it fails in 0.06 s with the #145 mismatch (record=0 field=25). It does not touch this PR's code. Also,pixel_aot_hardwaretook between 24 s and 43 s here against its 60 s timeout, depending on load.Adapter dependence in the new path
I looked for it on the old WARP specifically, since that adapter has differed from Windows 11 WARP in sampling paths before. I found none: level selection for implicit
Sampleon the 4x4 viewport (mip 1) and forSampleLevelat 0 (mip 0) is the same on WARP 10.0.19041, WARP 1.0.22 and the RTX 3060, bit-exact in all 64 channels.As a local diagnostic only, I rebuilt
offscreen_checkwith the static sampler changed fromFILTER_MIN_MAG_MIP_POINTtoFILTER_MIN_MAG_MIP_LINEARand repeated the four draws. Results were unchanged on all three backends. That is a weak check, since both mips are solid colors and the implicit LOD is exactly 1.0, so it only shows that linear filtering does not blend levels in this configuration.Not checked
clang -cc1aswrapper form used by the author.AI-assisted (Claude Code). The Windows results were measured locally.