startup: lower 1D image sampling with an explicit level #1715
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1722"
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 triggered02 on 2026-11-24T17:49:34Z.
Fixes #1721. Fifth group from the loading-screen refusal census (#870): 2 of 29 shaders.
Change
A 1D image has one coordinate, and
image_sample_lz/image_sample_lcarry the explicit level in the next address dword. Only the implicit-levelimage_samplewas accepted for 1D, so the explicit-level forms were refused:Texture1D.SampleLeveltakes exactly one float location, which is what theonebranch already built, so this needed the guard to admit the forms rather than a new lowering.Boundaries kept, each refused by name: a 1D
image_load(different address packing), a 1Dsample_lzwith more address dwords than the form takes, and modifiers that change the address or result layout (unorm,r128,a16,d16, …). The implicit-level 1D form and every 2D form emit byte-identical text to before.Test
startup_gfx2hlsl_image_1dbuilds MIMG encodings from the checked-in decoder's layout (0b111100prefix, opcode[24:18]/bit 0, dmask[11:8], dimension[5:3], NSA count[2:1]), decodes them, then translates — no game-derived bytes.Fail-first: restoring the old 1D guard fails the test with
Unsupported: unverified 1D image sample address or modifiers.Census A/B (local, aggregates only)
Refusals grouped as
SQ_RSRC_IMG_1Dgo 1 → 0 (the current cache holds one; the stored census had two), and that shader progresses tov_readfirstlane_b32 requires a proven uniform source.What this does not establish
image_loadaddress packing, 1D array forms and 1D gathers stay refused.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:51:22Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
11a5a01975ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:55:27Z.
Review: COMMENTED
Review of PR #1722 (
11a5a0197513b92709d9ab3ffa38374850941cc7).Findings
startup_image_sample_lfails (tests/startup_image_sample_l_check.py:228):tests/startup_image_sample_l_check.pydefines'dim1d': 'image_sample_l v[4:7], v[0:1], s[16:23], s[24:27] dmask:0xf dim:SQ_RSRC_IMG_1D'(line 60) and assertsrefused('dim1d', 'unverified 1D image sample address or modifiers')at line 228. Becausetools/startup/gfx2hlsl.pynow lowers 1Dimage_sample_lwith 2 address registers (u, lod),stage('dim1d')is accepted andstartup_image_sample_lfails on both Linux and Win2025 Debug: Updatetests/startup_image_sample_l_check.pyto expect 1Dimage_sample_lto lower toTexture1D/SampleLevel(..., F(v0), F(v1))instead of refusingdim1d.What looks good
tools/startup/gfx2hlsl.py, 1Dimage_sample_lz(1 address dword, level0) and 1Dimage_sample_l(2 address dwords[u, lod]) lower toTexture1D<float4>.SampleLevel(...), whileimage_sample(1D implicit level),image_load, extra address dwords, and modifiers such asunormremain refused.llvm-mc-19 -triple=amdgcn-- -mcpu=gfx1030 -show-encodingencodings forimage_sample_lz(dmask:0xf, with/withoutglc,unorm) andimage_sample_l(dmask:0x7) onSQ_RSRC_IMG_1Ddecode and lower/refuse as expected ingfx2hlsl.py.Local checks & Win2025 verification
python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py prep-verify 1722 --dir /tmp/rev-x2w-82/1722 --json:git_diff_check,docs_links_check,bidi_controls_check,py_compileall passed.python3 -B tests/startup_gfx2hlsl_image_1d_check.py:PASS(10/10 checks).python3 -B tests/startup_image_sample_l_check.py: FAIL (AssertionError: dim1d was accepted, exit code 1).'l': 2to'l': 3intools/startup/gfx2hlsl.pycausedtests/startup_gfx2hlsl_image_1d_check.pyto fail withgfx2hlsl.Unsupported: unverified 1D image l address or modifiers(exit code 1); restored viagit checkout -- ., after whichstartup_gfx2hlsl_image_1d_check.pypassed again.x2w_pipe.py win2025 1722with focused startup targets and--regex '^(startup_gfx2hlsl_image_1d|startup_image_sample_l|startup_image_sample_c|startup_gfx2hlsl_capture|startup_gfx2hlsl_sdwa|startup_gfx2hlsl_smem_offset|startup_gfx2hlsl_bit_alu_controls|startup_gfx2hlsl_bit_alu_warp|startup_translator|startup_stubs)$'):dev): 9/10 passed (startup_gfx2hlsl_image_1dpassed); 1 failed (322 - startup_image_sample_l), exit code 1./O2): not reached because the Debugctestphase failed.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:49:48Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
11a5a01ℹ️ 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 triggered02 on 2026-11-24T17:58:37Z.
Fixed in
fcdb6187.tests/startup_image_sample_l_check.pystill asserted the 1D refusal. That case now checks the lowering instead:and the controls print no longer lists 1D among the refused forms.
Verified with the whole family this time, not just the new test:
You are right that this was catchable from the diff — the existing test names the very case I changed, and my ctest regex only matched
^startup_gfx2hlsl. The rule I took from it: for a change ingfx2hlsl.py, run every ctest family that reaches it, not the new test's prefix.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T17:51:22Z.
Code review location:
tools/startup/gfx2hlsl.py; line 710The existing
startup_image_sample_ltest still expects a 1Dimage_sample_lto be refused (tests/startup_image_sample_l_check.py:228), so it now fails withAssertionError: dim1d was accepted. Replace that refusal with an assertion for the new 1D lowering while keeping the other refusal controls intact.AGENTS.md reference: AGENTS.md:L30-L30
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:03:05Z.
Review: COMMENTED
Re-review of PR #1722 (
fcdb6187baba8d6be4dce3145ae4a9db09ab8c34).Findings
No blocking issues found; the previous P1 on
tests/startup_image_sample_l_check.py:228is resolved.What looks good
tests/startup_image_sample_l_check.py:192-196now verifies thatdim1dlowers toTexture1D<float4>withSampleLevel(..., F(v0), F(v1))instead of expecting a refusal.tools/startup/gfx2hlsl.py:708-731handles 1Dimage_sample(1 addr dword),image_sample_lz(1 addr dword, level0), andimage_sample_l(2 addr dwords[x, lod]), allowingdlc/glc/slconly onlz/land keepingimage_load, extra address dwords, emptydmask, and layout-changing modifiers (unorm,r128,a16,d16, etc.) refused.llvm-mc-19 -triple=amdgcn-- -mcpu=gfx1030 -show-encodingroundtrip throughgfx2hlsl.decodefor 1Dimage_sample_lzandimage_sample_l.Checks & verification
python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py prep-verify 1722 --dir /tmp/rev-x2w-83/1722 --json:git_diff_check,docs_links_check,bidi_controls_check,py_compile(3 files) all passed.python3 -B tests/startup_gfx2hlsl_image_1d_check.py:PASS(10/10 checks).python3 -B tests/startup_image_sample_l_check.py: passed.python3 -B tests/startup_image_sample_c_check.py: passed.llvm-mc-19 -triple=amdgcn-- -mcpu=gfx1030 -show-encoding+gfx2hlsl.decode: 1Dimage_sample_lz(0x00,0x0f,0x9c,0xf0,0x00,0x04,0x62,0x00) andimage_sample_l(0x00,0x07,0x90,0xf0,0x00,0x04,0x62,0x00) decoded as expected.tools/startup/gfx2hlsl.py(restored viagit checkout -- tools/startup/gfx2hlsl.pyafter each):'l': 2->'l': 3: bothtests/startup_gfx2hlsl_image_1d_check.pyandtests/startup_image_sample_l_check.pyfailed withgfx2hlsl.Unsupported: unverified 1D image l address or modifiers(exit code 1).'unorm'in the 1D modifier allowlist:tests/startup_gfx2hlsl_image_1d_check.pyfailed ona unorm 1D sample_lz stays refused: MISMATCH(exit code 1).x2w_pipe.py win2025 1722 --targets cpu_shim_startup,cpu_shim_startup_guest,cpu_shim_startup_lifted,d3d12_xs_shim --regex '^(startup_gfx2hlsl_image_1d|startup_image_sample_l|startup_image_sample_c|startup_gfx2hlsl_capture|startup_gfx2hlsl_sdwa|startup_gfx2hlsl_smem_offset|startup_gfx2hlsl_bit_alu_controls|startup_gfx2hlsl_bit_alu_warp|startup_image_2d_array_controls|startup_image_2d_array_warp|startup_image_3d_controls|startup_image_3d_warp|startup_translator|startup_stubs)$'):--preset dev): build5.26s, 14/14 passed (5.29s)./O2(--preset release): build3.24s, 14/14 passed (5.20s).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:19:43Z.
Review: COMMENTED
Review of head
08e9a8ab6c81ee672bf82d9fe653d50c1def4b27(a merge of main into the branch on top of11a5a019andfcdb6187). My earlier re-review was onfcdb6187;08e9a8abonly merges main, so the diff against main is the same two commits.Verdict: no blocking finding. The lowering is right as far as I can check without a shader compiler. There are three untested boundaries (P2 below); each is a one-line test.
Linux limits. Linux x86_64 only. No CMake configure and no
ctest, no Windows, no GPU, and no DXC or FXC on this machine, so the emittedTexture1D.SampleLeveltext is compared as text and never compiled. I could not run the pipeline's Windows helper from here. The PR has no draw test; it is translator-only, which fits the change, but nothing in it proves the HLSL compiles.Reading of the change (
tools/startup/gfx2hlsl.py:737-745,:757)sample(1 address dword),lz(1) andl(2, x then level); any other form, a wrong dword count or an empty dmask is refused by name. 1Dimage_loadandimage_load_mipstay refused (expected is None).dim:/dmask:always;dlc/glc/slconly onlz/l; everything else (unorm,r128,a16,d16,tfe,lwe, reserved bits) is refused. The plain 1Dsamplekeeps the old rule, so it still refuses cache bits as before.l:expected = 4 if three else (2 if one else 3), thenlod = cs[-1], souvisF(v0)and the levelF(v1);lzsamples at level 0.SampleLevel(sampler, float, float)is the rightTexture1Doverload, andtex1dbinding already exists on main (#1630).llvm-mc-19 -triple=amdgcn -mcpu=gfx1030 -show-encodinggives[0x00,0x0f,0x9c,0xf0,0x00,0x04,0x62,0x00]for the 1Dimage_sample_lz,[0x00,0x07,0x90,0xf0,...]forimage_sample_land[0x00,0x03,0x80,0xf0,...]forimage_sample, equal to whatencode_mimgbuilds (opcode0x27/0x24/0x20, same vaddr/vdata/srsrc/ssamp words).What I ran on this head (worktree at the exact SHA; clean after every mutation)
startup_gfx2hlsl_image_1d_check.py,startup_image_sample_l_check.pyand the other sevenstartup_gfx2hlsl_*_check.pyscripts: all exit 0.git diff --check origin/main...HEADclean;docs_links_check.py17 files / 366 links;bidi_controls_check.pyclean.gfx2hlsl.py, each restored:'l': 2->'l': 3cs[0]instead ofcs[-1]sampleor not dmaskdropped)dlc/glc/slcrefused on 1Dlz/lFindings
tests/startup_gfx2hlsl_image_1d_check.py: a 1Dimage_samplewithglcstays refused; a 1Dimage_sample_lzwithdmask:0is refused; a 1Dimage_sample_lzandimage_sample_lwithglc/dlc/slclower to the same text as without. (encode_mimghas no cache-bit parameter yet; the bytes can be taken fromllvm-mc-19 -triple=amdgcn -mcpu=gfx1030 -show-encodingfor the same instruction withglc,slcordlcadded.)unverified 1D image sample address or modifierstounverified 1D image <how> address or modifiersand adds1D image <how> modifier <m>. Nothing in the repo greps the old text (grep -rn "unverified 1D" tests tools docsfinds only the new line), buttools/startup/triage_run.pygroups unknown shader reasons under "other", so a census that used the old string will move. Fine, just worth knowing for the A/B in #870.Texture1Dtext compiles with DXC and FXC. A one-off compile of the two emitted lines on Windows would settle that.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T19:30:19Z.
Review: COMMENTED
Re-review of PR #1722 at
a7776750517c92d548f6ea0dbe608a88c9948c2f. The branch moved pastbb12bd75while I was checking:bb12bd75is its parent, and the new tip adds one commit on top of it. My previous review was at08e9a8ab.Verdict: no P1, no P2. The earlier P2 is closed.
What changed since my review (
5acd3364merges main, thenbb12bd75anda7776750)bb12bd75(wording): the paragraph indocs/experiments.mdand the docstring intests/startup_gfx2hlsl_image_1d_check.pynow say "the first loading-screen cache". P3 wording: closed.a7776750(tests only):encode_mimggetsglc,slcanddlc(word 0 bits 13, 25 and 7, which are the MIMG positions in the encoding I checked earlier), and section 7 adds a glc 1Dimage_samplethat stays refused, a 1Dimage_sample_lzwithdmask:0that is refused, and glc/slc/dlc on 1D lz and l that lower to the same text as the plain form.tools/startup/gfx2hlsl.pyis unchanged by it. P2 test gap: closed, see the mutations.unverified 1D image <how> address or modifiers), nothing in the repo greps the old text; and the emittedTexture1D.SampleLeveltext is not compiled by me.Commands run locally on Linux (worktree at the exact SHA)
python3 -B tests/startup_gfx2hlsl_image_1d_check.py: passes, 18 lines "ok" then PASS.python3 -B tests/startup_image_sample_l_check.pyandtests/startup_image_sample_c_check.py: pass. All 13tests/startup_gfx2hlsl_*_check.pyscripts exit 0.python3 -B tests/docs_links_check.py(18 files, 370 links),python3 -B tests/bidi_controls_check.py(1323 files): pass.git diff --check origin/main...HEAD: clean.Local mutations of
gfx2hlsl.pyagainststartup_gfx2hlsl_image_1d_check.py(each restored withgit checkout -- ., tree clean afterwards)sampledlc/glc/slcrefused on 1Dlz/lcs[0]instead ofcs[-1]'l': 2->'l': 3All three mutations that survived before now fail.
Not run: a Windows build and CTest, and DXC/FXC on the emitted
Texture1Dlines.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T19:23:44Z.
Thanks — and you were right about the P1 on the earlier head; that was my test inheriting a stale expectation and it is fixed.
Status on this head (
bb12bd75): I merged currentmain(82749f0f, after #1699 landed) into the branch; theCMakeLists.txtanddocs/experiments.mdconflicts were resolved keeping both sides. The PR is mergeable again.P3 wording: fixed in the paragraph this branch adds and in the test docstring — it now says "in the first loading-screen cache" rather than "first main-game loading-screen cache". The remaining
main-gameoccurrences indocs/experiments.mdare in the older #1705/#1709 paragraphs, not part of this PR, so I left them alone rather than widen the diff.P3 refusal message: noted — the message is now named per form (
unverified 1D image <how> address or modifiers, plus1D image <how> modifier <m>), so anything that grouped the old single string will move. That is intended (a census consumer should see which form and which modifier), but I agree it is worth knowing for the #870 A/B.P2 — accepted, and it is the same finding you raised on #1793 and #1798: my tests compare text, not values. The three mutations that survived are real gaps:
samplesamplewithglcdmask:0dlc/glc/slcrefused on 1Dlz/lI am adding exactly those three cases to
startup_gfx2hlsl_image_1d_check.pyin the next commit (encoder gains the cache-bit fields), so the branch pins the guard rather than the text. I will reply here when it is pushed.For #1798 and #1793 I have already replaced the text checks with a value-level pattern: a Python reference plus a small evaluator that runs the emitted helper body over a grid (68,626 binary32 patterns for
class32, and the same approach formul_hi_u32against(a*b) >> 32). That is the right shape for these, and it is what caught the mutation you demonstrated.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T19:27:51Z.
All three P2 gaps are now pinned in
HEAD(startup_gfx2hlsl_image_1d_check.py), and each of your mutations fails.The encoder gained the MIMG cache fields, taken from the MIMG modifier decoding in
tools/disasm_rdna2.py(glc=w0[13],slc=w0[25],dlc=w0[7]) — deliberately not the MUBUF positions from the shared buffer decoder, which are different bits.New cases:
The
lowers like the plain onecases compare the full emitted text for equality, so a cache bit that changed the lowering would fail, and a cache bit that raised would fail too.Fail-first, your three mutations:
Debug
startup_gfx2hlsl_image_1d,startup_image_sample_landstartup_translator3/3, releasestartup_gfx2hlsl_image_1dPassed.On your remaining points: the emitted
Texture1D.SampleLeveltext still has not been through DXC or FXC here (no shader compiler on this machine either), so that limitation stands and your "translator-only, nothing proves it compiles" reading is accurate. The census counts also remain unverified from my side.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:53:42Z.
@triggered02 could you rebase this branch onto current
mainand force-push?GitHub reports head
a7776750as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(cf97bee1):docs/experiments.mdtools/startup/gfx2hlsl.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T13:24:15Z.
Rebased onto current
mainand force-pushed.#1821(src_scc): mergedmainin, resolved theCMakeLists.txtregistration conflict keeping both sides, head is5dc597c1.startup_gfx2hlsl_src_sccandstartup_translatorpass.#1778(modifier-free): head7a72fab0. Mergingmainsurfaced a real behaviour change —v_interp_mov_f32now decodes the parameter selector asp10, p20, p0and refusesp10/p20because they need per-vertex attribute values. My test used the oldp0encoding, which now decodes asp10, so it failed. Fixed the fixture (src1 = 2forp0) and added checks thatp10andp20are refused rather than read asp0.startup_gfx2hlsl_modifier_freeandstartup_translatorpass.#1722(1D sampling): headb96eb6b7; the only conflict was an olderdocs/experiments.mdparagraph you had since rewritten, so I keptmain's version of it and dropped my wording-only change there.startup_gfx2hlsl_image_1d,startup_image_sample_landstartup_translatorpass.Two of the five I closed rather than rebased, because their content is already on
mainor duplicated:mainalready has theclass16helper, thev_cmp_class_f16/v_cmpx_class_f16dispatch andtests/startup_gfx2hlsl_cmp_class_f16_check.py, so the branch was integrated directly and the PR was redundant.v_mul_hi_u32): duplicated by #1747, which is earlier and carriesbinary/drawmodes with a hardware draw under fxc and dxc. I commented there with the two things worth porting from mine (the instruction-byte construction note and the edge-case list) and deferred to that PR.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:24:43Z.
@triggered02 could you rebase this branch onto current
mainand force-push?GitHub reports head
b96eb6b7as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(214ed093):docs/experiments.mdtools/startup/gfx2hlsl.pyCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T16:17:41Z.
Re-created cleanly onto
origin/main(7092683a) as a single commit (f2be229c) to clear the merge conflict, and synced two tests with currentmain:tests/startup_gfx2hlsl_image_1d_check.py: updated its test stub to match currentmainsampler validation (lod_unvalidated = set(),lod_limits=Falseonsampler(), zeroed constant sampler words('const', 0)).tests/startup_image_sample_b_check.py: updated thedim1drefusal string from'unverified 1D image sample address or modifiers'to'unverified 1D image b address or modifiers'to matchunverified 1D image %s address or modifiersinStage.image.tests/startup_image_sample_l_check.py,CMakeLists.txt, anddocs/experiments.md(own clean##section) remain intact.Measured checks
tests/startup_gfx2hlsl_image_1d_check.py(18/18ok),startup_image_sample_l_check.py,startup_image_sample_b_check.py,startup_image_sample_c_check.py,startup_translator_check.py, plus 11 additional startup image/translator checks (tools/run_checks_parallel.py): 18/18 passed.tests/docs_links_check.py(466 links),tests/bidi_controls_check.py,git diff --check origin/main: clean.'l': 2→'l': 3, allowingglcon plain 1Dsample, and droppingor not dmask): all 3 failstartup_gfx2hlsl_image_1d_check.py(exit 1).Not established
Texture1D.SampleLevelHLSL.AI-assisted (Gemini).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T02:35:46Z.
Review: COMMENTED
Pushed the exact LOD draw and integrated main. Release CTest passed 7/7 with the 1D controls, adjacent 3D tests and both draw backends. WARP and RTX 4060 Laptop read mip zero for sample_lz at inputs one and two, and correctly selected mip one and mip two for sample_l. The fixed-zero shader read mip zero where mip two was expected on both backends. No capability skips or debug-layer messages in those draws. The new CTests are startup_gfx2hlsl_image_1d_warp and startup_gfx2hlsl_image_1d_hardware.