Repository navigation
startup: lower 1D image sampling with an explicit level - #1722
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
There was a problem hiding this comment.
💡 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
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
tedin7
left a comment
There was a problem hiding this comment.
Review of PR #1722 (11a5a0197513b92709d9ab3ffa38374850941cc7).
Findings
- P1 — Existing regression test
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:UpdateFile "tests/startup_image_sample_l_check.py", line 228, in controls refused('dim1d', 'unverified 1D image sample address or modifiers') File "tests/startup_image_sample_l_check.py", line 186, in refused raise AssertionError('%s was accepted' % name) AssertionError: dim1d was acceptedtests/startup_image_sample_l_check.pyto expect 1Dimage_sample_lto lower toTexture1D/SampleLevel(..., F(v0), F(v1))instead of refusingdim1d.
What looks good
- In
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).- Local mutation check: changing
'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. - Win2025 (
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)$'):- Debug (
dev): 9/10 passed (startup_gfx2hlsl_image_1dpassed); 1 failed (322 - startup_image_sample_l), exit code 1. - Release (
/O2): not reached because the Debugctestphase failed.
- Debug (
AI-assisted; commands listed were executed locally.
Review on R0Y00#1722 (P1, found by both Codex and tedin7): tests/startup_image_sample_l_check.py still asserted that a 1D image_sample_l is refused, which the lowering now accepts. The case now checks the Texture1D declaration and the SampleLevel(smp, F(v0), F(v1)) call shape instead, and the controls print no longer lists 1D as refused. Full startup_image*/startup_gfx2hlsl* family passes in dev (18/18) and the two affected tests pass in release.
|
Fixed in
one_d = stage('dim1d')
assert 'Texture1D<float4>' in one_d
assert re.search(r'SampleLevel\(\w+, F\(v0\), F\(v1\)\)', one_d)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 AI-assisted (Claude Code). |
tedin7
left a comment
There was a problem hiding this comment.
Re-review of PR #1722 (fcdb6187baba8d6be4dce3145ae4a9db09ab8c34).
Findings
No blocking issues found; the previous P1 on tests/startup_image_sample_l_check.py:228 is 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.- Clean
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.- Linux:
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.
- Local mutations on
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).- Allowing
'unorm'in the 1D modifier allowlist:tests/startup_gfx2hlsl_image_1d_check.pyfailed ona unorm 1D sample_lz stays refused: MISMATCH(exit code 1).
- Win2025 (
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)$'):- Debug (
--preset dev): build5.26s, 14/14 passed (5.29s). - Release
/O2(--preset release): build3.24s, 14/14 passed (5.20s).
- Debug (
AI-assisted; commands listed were executed locally.
There was a problem hiding this comment.
Review of head 08e9a8ab6c81ee672bf82d9fe653d50c1def4b27 (a merge of main into the branch on top of 11a5a019 and fcdb6187). My earlier re-review was on fcdb6187; 08e9a8ab only 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 emitted Texture1D.SampleLevel text 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)
- 1D now accepts
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). - Modifiers:
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).- The test's encoder matches the assembler:
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.- Mutations of
gfx2hlsl.py, each restored:
| Mutation | image_1d check | image_sample_l check |
|---|---|---|
'l': 2 -> 'l': 3 |
fails | fails |
level taken from cs[0] instead of cs[-1] |
fails | fails |
| 1D modifier loop removed | fails (unorm case) | passes |
cache bits also allowed on the plain 1D sample |
passes | passes |
1D empty dmask accepted (or not dmask dropped) |
passes | passes |
dlc/glc/slc refused on 1D lz/l |
passes | passes |
Findings
- P2, test gap: the three surviving mutations above. The PR text says the implicit 1D form is unchanged, and the new guard decides cache bits and dmask; none of that is pinned. Suggested cases in
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.) - P3: the refusal message changed from
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. - P3, wording: docs and test docstring say "first main-game loading-screen cache"; AGENTS.md asks for title-neutral text.
- Not verified by me: the census counts (local cache), and that the emitted
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.
|
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 ( 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 P3 refusal message: noted — the message is now named per form ( 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:
I am adding exactly those three cases to 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 AI-assisted (Claude Code). |
|
All three P2 gaps are now pinned in The encoder gained the MIMG cache fields, taken from the MIMG modifier decoding in New cases: The Fail-first, your three mutations: Debug On your remaining points: the emitted AI-assisted (Claude Code). |
Review on R0Y00#1722 (P2): three mutations survived the test because no case encoded them - cache bits allowed on the plain 1D sample, an empty dmask accepted, and cache bits refused on the lz/l forms. The encoder now carries the MIMG cache fields (glc w0[13], slc w0[25], dlc w0[7], from the MIMG modifier decoding, not the MUBUF positions). New cases: a glc 1D sample stays refused, a 1D sample_lz with dmask:0 is refused, and glc/slc/dlc on the 1D lz and l forms lower to the same text as without them. Fail-first: each of the three mutations now fails its case.
tedin7
left a comment
There was a problem hiding this comment.
Re-review of PR #1722 at a7776750517c92d548f6ea0dbe608a88c9948c2f. The branch moved past bb12bd75 while I was checking: bb12bd75 is its parent, and the new tip adds one commit on top of it. My previous review was at 08e9a8ab.
Verdict: no P1, no P2. The earlier P2 is closed.
What changed since my review (5acd3364 merges main, then bb12bd75 and a7776750)
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.- Still open, as before: P3 the refusal text changed (
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.py against startup_gfx2hlsl_image_1d_check.py (each restored with git checkout -- ., tree clean afterwards)
| Mutation | Result |
|---|---|
cache bits also allowed on the plain 1D sample |
fails (was surviving) |
| 1D empty dmask accepted | fails (was surviving) |
dlc/glc/slc refused on 1D lz/l |
fails (was surviving) |
level taken from cs[0] instead of cs[-1] |
fails |
'l': 2 -> 'l': 3 |
fails |
All three mutations that survived before now fail.
Not run: a Windows build and CTest, and DXC/FXC on the emitted Texture1D lines.
AI-assisted; commands listed were executed locally.
|
@triggered02 could you rebase this branch onto current GitHub reports head Files that conflict with current
Commands run locally: Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally. |
|
Rebased onto current
Two of the five I closed rather than rebased, because their content is already on
AI-assisted (Claude Code). |
|
@triggered02 could you rebase this branch onto current GitHub reports head Files that conflict with current
Commands run locally: Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally. |
b96eb6b to
f2be229
Compare
|
Re-created cleanly onto
Measured checks
Not established
AI-assisted (Gemini). |
# Conflicts: # CMakeLists.txt # docs/experiments.md # tests/startup_image_sample_l_check.py
…#1722 R0Y00#1722 names the sample kind in the 1D refusal; main's startup_image_sample_d_check still expects the 'sample' wording for image_sample_d on a 1D image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f2be229 to
c06a91d
Compare
R0Y00
left a comment
There was a problem hiding this comment.
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.
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).