shader: lower two immutable samplers at uniform explicit-LOD joins #2970
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!2970
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2970"
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?
@chadhyatt on GitHub · 2026-11-27 00:14 UTC · original
chadhyatt:backport/explicit-lod-sampler-join→main· +368 −9 · 10 files · 3 commits · merged 2026-11-27 03:18 UTCAI-assisted backport patch from x2w-microlift.
Admit a single proven forward SCC diamond that writes all four words of two immutable normalized 2D point wrap/clamp samplers. Preserve point mip filtering and validated LOD limits in static bindings; choose between complete SampleLevel calls using the differing scalar word. Invalidate the join fact on overlapping writes. Implicit-LOD handling from #2699 is unchanged.
Source-built verification on Apple Silicon, head
656c4ddc9b:python3 -B tests/startup_image_sample_l_join_check.py: both forms, both selector outcomes, swapped bindings, six refusals passed.python3 -B tests/startup_image_sample_l_join_check.py binary llvm-mc: all eight exact assembly variants passed (LLVM 23.1.6).The registered Windows draw uses the actual translated shader, two manifest bindings and a runtime selector. DXC/WARP/hardware draw execution not run locally. Test registrations use the upstream CMake and CI check-list fragments.
@thepatrickworld on GitHub · 2026-11-27 00:46 UTC · original
Independent Windows / AMD RDNA 4 result on
656c4ddc— measurements only, not a code changeEnvironment
10.0.26200.9974; MSVC19.44.35230.0(BuildTools14.44.35207); DXC and FXC from SDK10.0.26100.0Microsoft Basic Render Drivervendor1414device008c; hardware:AMD Radeon RX 9070 XTvendor1002device7550, driver32.0.32029.2010debug_layer=unavailable), so no validation output is part of this report656c4ddc9b0e656707fd865b1fb122b1977bfc0a(git status --porcelain --untracked-files=noempty),cmake --preset devwith an externalINTAKE_PYTHON,Total Tests: 2447Commands
Observed
Both draw entries executed (no exit 77, no
***Skipped); the hardware entry printsadapter=AMD Radeon RX 9070 XT vendor=1002 device=7550anddriver=32.0.32029.2010on all six of its renderer invocations. Readback per form, the third draw of each form being the swapped-binding manifest:lselector 0:3e840000,00000000,00000000,40000000lselector 1 and swapped:3e880000,3f800000,00000000,40000000lzselector 0:3d200000,00000000,3f800000,00000000lzselector 1 and swapped:3d800000,40400000,3f800000,00000000The same words come back from WARP and from the card. Three repeat runs of each draw entry gave
100% tests passed out of 1with byte-identicalview_rgbalines.What these entries pin, and what they do not
6ee878d8) and the head tests, all three entries fail withUnsupported: descriptor operand s[24:27] holds None, so the tests do require the new lowering.arm(0)againstarm(CLAMP_XY); word 1 is0x200000in both), sok = next(i for i in range(4) if a[i] != b[i])is forced to0. Ak = 0mutant emits byte-identical HLSL on both forms (string equality ofhlsl_ps()plus the manifest) and all three entries stay green: an equivalent mutant, not a blind spot.k = 1mutant is not equivalent — it dies in the controls (AssertionError: ('l', 0)) and in both draws (('l', 0, '3e880000…', '3e840000…')).kthe correct answer. A local, unpushed variant of thelform whose arms differ only in word 1 emits(s25 == 0x00000000u ? … )and returns mip 1 for selector 0 and mip 0 for selector 1, identically on both adapters, so the choice works today; one such form in the fixture would pin it.AssertionError: overwrite unexpectedly accepted); both draws stay green, which is expected since no draw uses the overwritten form.CI coverage at this head
The three jobs on
656c4ddcare green, and two of the fixture's three modes already run on every pull request:python-linuxexecutes the no-argument controls throughtests/checks/python-linux/startup_image_sample_l_join.txt, and the fixture job executesbinary llvm-mc-15throughtests/checks/pixel-binary/. What no pull request runs is the draw: none ofstartup_image_sample_l_join_{controls,warp,hardware}is in theprtest preset (CMakePresets.json, explicit include list),_warpruns only in the post-merge push sweep, and-E '_hardware$'excludes_hardwarefrom every sweep, release included (windows.yml:494and:614).Limits
MAX_LODas the field that clamps an explicit LOD is the D3D sampler contract, not something these entries measure:MIN_LODis zero in every form here, and no fractional or implicit LOD reaches a differing word.k, and no compute, heap or packed-2D path is exercised.AI-assisted.
@chadhyatt on GitHub · 2026-11-27 00:48 UTC · original
Thanks for the exact-head WARP and RX 9070 XT measurements and the explicit limits. The three passing tests and matching readbacks are useful independent evidence. Agreed that a word-1-only descriptor difference should pin nonzero selector-word choice; I will extend that authored fixture without changing the lowering. I will distinguish your physical hardware observations from my local portable verification.
@chadhyatt on GitHub · 2026-11-27 00:52 UTC · original
Added the focused test-only follow-up at
d908804a32. Word 0 is identical and word 1 alone differs (MAX_LOD 2 versus 0); selector 0 expects3e840000000000000000000040000000, selector 13d200000000000003f80000000000000, swapped bindings reverse the result. Portablepython3 -B tests/startup_image_sample_l_join_check.pypasses all three variants, both selectors and six refusals;python3 -B tests/startup_image_sample_l_join_check.py binary <LLVM 15.0.7 llvm-mc>reassembles all nine sources exactly. A throwaway forced-word-0 dispatcher was rejected by the independent pixel oracle. The new registered draw remains unmeasured on my host; prior independent hardware results pertain to656c4ddc, not this new head. No production lowering change.@Jess-Doit on GitHub · 2026-11-27 01:25 UTC · original
The join proof, refusal controls, and cache-key pins checked out. I also compiled all three positive cases with FXC at pixel shader model 5.1. Ready to merge from our side
@thepatrickworld on GitHub · 2026-11-27 01:49 UTC · original
Portable-suite audit of
d908804a— controls and mutants only, no drawEnvironment
python33.11.16, no GPU and no Windows machine this cycle (my tunnel to the PC was down), so nodrawentry ran: no adapter, no driver, nodxc.git clone --filter=blob:none --no-checkout), thengit fetch origin refs/pull/2970/head:pr2970andgit checkout -f pr2970.git rev-parse HEAD=d908804a32f4e01344b5bbfa122011b0d8376475;git status --porcelain --untracked-files=noempty.tests/startup_image_sample_l_join_check.pyafc2df447bb78cfa5cc7429d12e6a95b3e58623800425015926e7d25b8df5548,tools/startup/gfx2hlsl.pydbf82d5a80eb768bddd1f800b89da4954166a5dd31ce988c6b53e261eab6947d,.github/workflows/windows.ymld3be662a1ec7c98be71d0bc4bc0a9cd1b1ebe14bb9b72cedd10b21f0d8f1a377.Commands
After each mutant the translator's sha256 was back to the value above,
git status --porcelain --untracked-files=nowas empty, and the clean tree re-ran to 0.Observed
Your forced-word-0 rejection reproduces. Seven mutants of
joined_sampler_call(gfx2hlsl.py:2893-2908, line numbers at this head)::2903k = next(i for i in range(4) …)→k = 0AssertionError: ('l_word1', 0):2903first differing word → last differing word:2905-2906lod_limits=True→Falseon both armssampler_manifest,assert len(lines) == 2with[]:2904deleteself.used_s.add(base + k):2907==→!=in the emitted callunmodelled dispatcher statement: t = (s24 != 0x00000012u ? …):2908literal taken from the other arm (b[k])('l', 0):2898dropor w1 & ~0xffffffThe runner stops at the first failing form, so the
k = 0mutant only ever reports('l_word1', 0); selector 1 is not reached.Three of the seven stay green, and they are not the same kind of result:
used_s.add(base + k)is redundant by construction: a pair only exists when both arms define all four words as constants (:3703-3708), and the join then marks every one of those registers used (:3731). Deleting the line cannot change anything, on any input this path admits.k =last differing word instead of first is behaviourally equivalent for the same reason: the descriptor at the join is exactly one of the two arms, so any word in which they differ discriminates correctly. It is not textually equivalent in general — a pair differing in two words would emit a different selector register and literal — but every form in this file differs in one word, so the emitted HLSL and manifest are byte-identical to the base on all three forms.w1 & ~0xffffffsurvives because no fixture carries a word 1 above0x200000. This one is a real coverage note, not an equivalent mutant: it is the only check on word 1's upper bits in this path (lod_sampler_words,:7541-7547, validates word 2's low fields, the mip filter and MIN_LOD ≤ MAX_LOD;Pipeline.sampler,:10381-10387, validates nothing), so dropping it silently accepts descriptors those bits reach. No other test builds such a diamond (s_branch BB2appears in this file only).Where the new pin lives
l_word1form is what kills the mutant that was equivalent at656c4ddc: forcingk = 0compares word 0, which the new form holds identical in both arms, so one arm could never be taken.windows.yml:181is thepython-linuxjob (ubuntu-24.04, Python 3.12, no job-levelif:, and the workflow'spull_requesttrigger has nopaths:filter); it callstools/run_checks_parallel.py --from-dir tests/checks/python-linux(:199), andtests/checks/python-linux/startup_image_sample_l_join.txtlists the fixture with no arguments, i.e. the no-argument mode.prtest preset is a single allow-list regex of 21 alternatives, none of which matchesstartup_image_sample_l_join_*, andctest --preset pr(windows.yml:489) adds no-E._hardwareis excluded only in the push sweeps, dev at:494and release at:614.What these forms do not pin
selected_texel(fixture lines 114-156) re-executes the emitted dispatcher, then models wrap/clamp addressing and the MIN/MAX LOD clamp from the emittedsmplwords — the translator's manifest, not the guest descriptor — against hard-coded expected texels. So what the three forms pin is which arm the dispatcher selects and the texel the fixture's own model derives for it; the clamp itself is the fixture's model, not a D3D measurement, and the draw that would measure it did not run.invalid moderefusal exercises the word-0 clause ofunsupported joined sampler words(CLAMP_XY | 0x8000), not the word-1 clause; one refusal control with a bit set above 23 in word 1 would pin that clause.Limits
AI-assisted.
@chadhyatt on GitHub · 2026-11-27 01:50 UTC · original
Thanks for the independent exact-head audit. The upper-word1-bit refusal is the actionable missing control; I am adding a decoded negative diamond for that guard. The equivalent selector mutations do not warrant extra implementation changes. I will report the amended portable and assembler evidence, with prior draw evidence kept separate.
@chadhyatt on GitHub · 2026-11-27 01:56 UTC · original
Updated
8697fe94dd: decoded negative diamond sets only word1 bit 24, so the exact high-bit refusal is now covered.python3 -B tests/startup_image_sample_l_join_check.pypassed three forms, both outcomes, swapped bindings and seven refusals; binary mode reassembled all ten variants exactly with LLVM 15.0.7 and 23.1.6. Independently omitting only the word1 guard now fails withhigh word1 unexpectedly accepted. Fixture/documentation-only amendment; prior draw evidence remains on its original head.@Jess-Doit on GitHub · 2026-11-27 02:04 UTC · original
The added upper sampler-word refusal closes the coverage gap. The current head passed three positive forms, seven refusal controls, ten LLVM 15 reassemblies, and the cache-key checks. Removing just the upper-word guard made the new control fail, and restoring it passed. Ready to merge from our side
@R0Y00 on GitHub · 2026-11-27 03:18 UTC · original · approved these changes
Reviewed exact head
8697fe94dd30ad99e5f6df7192dc3408ccb7918c. The sampler proof requires two literal incoming definitions with uniform SCC control and unchanged EXEC. An overlapping scalar write invalidates the proof. I independently builtcmake --build --preset release --target offscreen_checkand ranctest --preset release --no-tests=error -V -R '^startup_image_sample_l_join': 3 passed, zero skips. WARP (10.0.26100.9818) and RTX 4060 Laptop (32.0.16.1656) on Windows 11 build 26200.9974 both matched all three draw forms, both root-selector values and swapped bindings, with zero D3D12 debug-layer errors or warnings. The portable fixture passed all seven refusals, including the upper sampler-word bit. Required Windows CI passed.