startup: lower pixel-stage image_store to a typed UAV store #2147
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2155"
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 rasptum on 2026-11-25T01:48:55Z.
Refs #1996 (item F).
Today
tools/startup/gfx2hlsl.pyhas noimage_storehandler, so the instruction is refused in every stage.Translator
image_storewithdim:SQ_RSRC_IMG_2Danddmask:0xfnow becomesw<n>[uint2(x, y)] = asfloat(uint4(data))on aRWTexture2D<float4> w<n> : register(u<n>).uav <index> tex2d table <table> <offset>. Programs without a store keep version 1.MIMGInstructions.td(IMAGE_STORE, defined throughMIMG_Store). VDATA is the source, VADDR the integer texel address (x, y for dim 2D) and SRSRC the image descriptor. The DMASK channels are written in order from consecutive VDATA registers.visit_image_storeemits the same form, with DMASK taken from the write mask.glc,slc,dlc.d16,a16,tfe,lwe,r128,unormand the reserved bit;image_store_mip;Runtime: the translated graphics path does not bind UAVs yet.
d3d12_draw.inlnow logs and skips a translation whose manifest has auavline. Before, such a line was rejected as an invalid sampler-heap line. Binding the view, with a UAV range in the translated root signature and a view made from the title's image descriptor, is a separate follow-up.Fixture:
tests/startup_pixel_image_store_check.py, a hand-assembled gfx1013 pixel program with no bytes from any retail software. It loads a descriptor from table 0, stores 1.0, 2.0, 3.0 and 4.0 at texel (1, 2), and exports the same values.tools/disasm_rdna2.py.binary <llvm-mc>reassembles the source and compares, but I could not run that here because no llvm-mc is available.op_image_storeremoved, the program is refused again.offscreen_check --startup-image-store, new filetests/startup_image_store.cpp) compiles the translation with DXC and draws one pixel. It reads back all 16 texels of a 4x4 R32G32B32A32_FLOAT image that starts at -1.0.Overlap: #2059 (vertex-stage
buffer_store_*) also adds auav <slot> table <param> <offset>line underx2w-manifest 2, for aRWByteAddressBuffer. This PR's line names its kind (tex2d) so the two forms stay distinguishable. If both land, they need one shareduregister numbering; this PR numbers stored images from u0.Test (Windows 10 19045, NVIDIA GeForce RTX 3060, driver 32.0.15.9636, and WARP; debug layer enabled):
startup_pixel_image_store_{controls,warp,hardware}pass; the draw reports texel (1, 2) written and the other 15 untouched, with both mutants detected and no debug-layer errors.--preset release): 12 passed, 0 failed, 0 skipped.tests/startup_gfx2hlsl_*_check.pyandtests/startup_translator_check.pyall pass, together with the new check and the image 3D / mip / 2D-array checks: 41 scripts, 0 failures.tests/docs_links_check.pyandtests/bidi_controls_check.pyalso pass.🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T02:08:14Z.
Review: COMMENTED
Review of head
f14d392d3acf065f2f130bc876f17a4b397249b6(non-blocking comment, no approval).Scope: pixel-stage
image_storelowered to aRWTexture2D<float4>store (gfx2hlsl), manifest v2uavline, runtime refusal foruavmanifests, new Python controls and a desktop draw readback test, docs.Checked:
image_store_mip, non-pixel stages, and load+store of the same image is sensible.uavline, so nothing is bound wrongly.Findings:
dmask != 0xfguard (tools/startup/gfx2hlsl.py, inop_image_store) is not killed by the tests. I replaced the condition withif False:andtests/startup_pixel_image_store_check.pystill passed. The "dmask 0x7" and "dmask 0x1" controls are refused earlier by the "four VGPRs expected" check, because the patched encoding also changes the data register count. Suggest a control that keepsv[4:7]with a partial dmask (callop_image_storedirectly with['v[4:7]','v[0:1]','s[16:23]']anddmask:0x7) so the guard itself is exercised. The refusal text names the wrong reason in the current controls.stored_images()uses__dict__.setdefaultto cover pipelines built without__init__. Givinguavsa class-level default or fixing the test constructors would be clearer.Mutations run (then
git checkout -- .):startup_pixel_image_store_check.pyexits 1, so the test kills it.Not run: Win2025 WARP/hardware draw (
startup_pixel_image_store_warp/hardware) was not run locally. I rely on the Windows CI job being green. I did not confirm that job includes these ctest names.Commands executed locally in the worktree:
python3 -B tests/startup_pixel_image_store_check.py-> Self-test passedpython3 tests/docs_links_check.py-> Checked 18 Markdown files and 398 linkspython3 tests/bidi_controls_check.py-> no bidirectional controlsgit diff --check origin/main...HEAD-> cleangh pr checks 2155-> all pass or skippingAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-25T02:59:10Z.
Thanks, the guard finding was right: the two encoded partial-mask controls passed for the wrong reason. The disassembler sizes VDATA from the mask (
v[4:6],v4), so with the dmask guard disabled the data-register check still refused them, and the controls only asserted thatimage_storewas refused.What changed, in three commits on top of
f14d392d:733bd134(test). The encodeddmask 0x7/dmask 0x1controls now assert the dmask reason ("a typed UAV store writes all four channels"). A new control callsop_image_storewithv[4:7]anddmask:0x7, so only the mask guard can refuse it. Another passesdmask:0xfwith three data registers and asserts the data reason ("four VGPRs expected"), so each check is pinned to its own message.352bae3d(nit).Pipeline.uavsis now a class attribute defaulting toNone. The first store creates the instance's own map, and the__dict__.setdefaultfallback is gone. Pipelines that the existing checks assemble without__init__keep working unchanged.96c1a55b(nit). The docs bullet is rewrapped.None of these controls is registered with
WILL_FAIL. The CTest entries for this PR are plain pass/fail, with 77 kept as the capability skip for the hardware draw.Mutation: with
if int(masks[0], 0) != 0xf:replaced byif False:,tests/startup_pixel_image_store_check.pyfails with:With the guard restored, the check passes.
Commands and results:
Windows 10 19045, head
96c1a55b:controls,warpon Microsoft Basic Render Driver,hardwareon an NVIDIA GeForce RTX 3060).All
tests/startup_gfx2hlsl_*_check.py,tests/startup_translator_check.pyand the image 3D / mip / 2D-array checks pass: 41 scripts, 0 failures.tests/docs_links_check.pypasses.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:02:29Z.
Review: COMMENTED
Review of head
96c1a55b381d3b3f464c857f571b8fdd5106d425(comment only).State: mergeable, not draft, title neutral, CI green (Linux checks, gfx1013 fixtures, Windows build and test). Read:
tools/startup/gfx2hlsl.py(op_image_store,Pipeline.uav/resource/manifest),src/startup_stubs/d3d12_draw.inl, the new check and docs.What I checked
resourceanduav).tests/startup_pixel_image_store_check.py:143). The runtime ignores the version number, but it refuses anyuavline, so a translation that stores is never used. That is the safe choice until UAV binding exists.Findings
self.emit(body if self.exec_known else 'if (exec & 1) ' + body)withself.emit(body)(this also hit the two sibling emits, same line text) andtests/startup_pixel_image_store_check.pystill passed. So a store under a partial exec mask could lose its guard without any test failing. Please add one case with a non-constant exec and assert the guard in the output (and, if possible, in the WARP readback).int(masks[0], 0)raisesValueErroron a malformed mask text rather thanUnsupported. Low risk since the assembler produces it, but atrywould give a named refusal.Commands run locally (worktree on the PR head)
python3 tests/startup_pixel_image_store_check.py: passpython3 tests/docs_links_check.py: pass (18 files, 398 links)python3 tests/bidi_controls_check.py: pass (1441 files)git diff --check origin/main...HEAD: cleanif False:: the check failed (killed).gh pr checks 2155: all required jobs pass.Windows WARP was not re-run by me. The change adds a test under
tests/startup_image_store.cppand CI Windows is green.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:26:15Z.
Review: COMMENTED
AI-assisted; commands listed were executed locally.
Re-review of head
7ee19fa945ed5c347a54cdb8efa63bfae1403b94(comment only). Previous review was on96c1a55b; two commits since (2aa673d5,7ee19fa9).State: mergeable, not draft, title neutral, CI green (Linux checks, gfx1013 fixtures, Windows build and test; /O2 and chart skipped).
Previous findings
tests/startup_pixel_image_store_check.pynow adds twov_cmpx_eq_u32variants (exec on / exec off), asserts theif (exec & 1)guard on the store line only, asserts no guard when exec is known, and in draw mode reads texels back for exec on, exec off, and an unguarded negative control.op_image_storenow raisesUnsupported('image_store with dmask 0xz: not an integer'), and the check covers it.Findings
Commands run locally (worktree on the PR head)
python3 tests/startup_pixel_image_store_check.py: pass (includes the new exec-guard and malformed-dmask controls)python3 tests/docs_links_check.py: pass (18 files, 398 links)python3 tests/bidi_controls_check.py: pass (1441 files)git diff --check origin/main...HEAD: cleangfx2hlsl.py:1511) : the check failed (killed; the new assertion fires).gh pr checks 2155: all required jobs pass.Windows WARP was not re-run by me; the new draw-mode cases run in the PR's Windows CI job, which is green.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-25T03:20:38Z.
Thanks. Both findings were right. Two commits on top of
96c1a55b:2aa673d5(nit). Mask text that is not an integer is now a named refusal:image_store with dmask 0xz: not an integer. Before, it was aValueErrorfromint(masks[0], 0). A control passesdmask:0xztoop_image_storeand asserts the exact message.7ee19fa9(P2). The exec guard is now tested. Two variants putv_cmpx_eq_u32_e32 <k>, v0(VOPC, hand-encoded and decoded back) before the store, so exec is not known at translation time:exec = ((0x0000000ku == v0) ? 1u : 0u);andif (exec & 1) w0[uint2(v0, v1)] = ...in the emitted HLSL, with the store line emitted once. They also assert the unguarded form for the original program, whose exec is the entry mask.k = 1the lane stays on, and texel (1, 2) gets the four values.k = 2every lane is off, and texel (1, 2) keeps its starting value (bf800000x4).texel_mismatch x=1 y=2 expected=bf800000,bf800000,bf800000,bf800000 actual=3f800000,40000000,40400000,40800000.Mutations (each applied alone, then restored):
self.emit(body)at all three sites:tests/startup_pixel_image_store_check.pyfails at the guarded-store assertion.image_storesite only: the check fails.ValueError: invalid literal for int() with base 0: '0xz'.The two sibling emits already have their own coverage. Each was mutated alone and the full Python set was rerun:
op_v_swap_b32: onlytests/startup_gfx2hlsl_swap_check.pyfails ("unknown exec guards the swap").shift64, used byv_lshrrev_b64and friends): onlytests/startup_gfx2hlsl_shift64_check.pyfails ("exec-masked v_lshrrev_b64 guards both destination registers").None of the CTest entries uses
WILL_FAIL. 77 is still only the capability skip for the hardware draw.Commands:
Results on Windows 10 19045, head
7ee19fa9:controls.warpon Microsoft Basic Render Driver.hardwareon an NVIDIA GeForce RTX 3060.tests/startup_gfx2hlsl_*_check.py,tests/startup_translator_check.py,tests/startup_image_*_check.py, this check andtests/docs_links_check.pypass. That is 46 scripts, 0 failures.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-25T03:56:34Z.
Draw run on hardware — RX 9070 XT, driver 32.0.32029.2010:
So execution masking and the untouched-texel rule both hold on the card, and removing the guard makes the check fail rather than pass by accident.
Limits: AMD only, no NVIDIA here.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T05:43:15Z.
Ran head
7ee19fa9on three adapters. All pass. Windows 11 build 26100, debug layer unavailable.startup_pixel_image_store_controlsstartup_pixel_image_store_warpstartup_pixel_image_store_hardware(XBOX2WINDOWS_ADAPTER=Quadro)startup_pixel_image_store_hardware(XBOX2WINDOWS_ADAPTER=Intel)On every adapter texel (1, 2) was written, the other 15 texels were left untouched, and both exec-on and exec-off drew as expected. All three controls failed as intended.
One cosmetic point. On the Intel run, each control printed
fails as expected (XBOX2WINDOWS_ADAPTER: skipping NVIDIA Quadro M1000M). The check itself is correct: it requires thetexel_mismatch …needle in stderr (tests/startup_pixel_image_store_check.py:224and:241). The printed reason, however, isrun.stderr.strip().splitlines()[0], and when the adapter is filtered,offscreen_checkwrites its adapter-skip notice first. Printing the line that containstexel_mismatchwould keep the log meaningful on multi-GPU machines.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:19:51Z.
Review: COMMENTED
AI-assisted; commands listed were executed locally.
Re-review of head
44b103638a0e3b1790ff4e1bf61b1d268935715d(comment only). Previous review was on7ee19fa9. Since then:6456bbbc(compute pipelines keep buffer UAVs out of the pixel-stage image list),81ca8985(names the texel_mismatch line in the controls), and two merges of main.State: mergeable, not draft, title neutral. CI at the time of review: Linux checks pass; gfx1013 fixtures and Windows build/test pending; /O2 skipped. I did not re-run Windows WARP; the draw-mode cases run in the PR's Windows job, so please wait for it to go green before Ready.
Previous findings: none open (exec guard and malformed dmask were fixed earlier and still pass).
New in this head
ComputePipeline.stored_images()returning{}(tools/startup/gfx2hlsl.py:3527) is correct.ComputePipeline.uavsmaps buffer descriptors to u indices, so without the overridePipeline.stored_images()would hand that map to the image paths (common()/manifest()).Commands run locally (worktree on the PR head)
python3 tests/startup_pixel_image_store_check.py: passpython3 tests/compute_heap_store_check.py: passpython3 tests/compute_entry_layout_check.py: passpython3 tests/docs_links_check.py: pass (18 files, 418 links)python3 tests/bidi_controls_check.py: pass (1522 files)git diff --check origin/main...HEAD: cleanComputePipeline.stored_imagesoverride : SURVIVED (image-store check, compute_heap_store_check and compute_entry_layout_check all still pass).targets 0/ check fails).Pipeline.uav: killed (accepted: ('both read and stored',)).Suggestion for P2: add one control that builds a compute program with a buffer store and asserts its manifest has no
uavline and the manifest header stays version 1 (extendtests/compute_heap_store_check.py).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:38:40Z.
Review: COMMENTED
AI-assisted; commands listed were executed locally.
Re-review of head
949497eb4d5521cf6fdbdeeb1f2a52810279585f(comment only). Previous review was on44b10363. The only new commit is949497eb, which changestests/startup_gfx2hlsl_compute_check.py(+7 lines).State: mergeable, not draft, title neutral. CI at review time: Linux Python checks pass. The Windows build/test and gfx1013 fixtures were still pending. I did not re-run Windows WARP. Please wait for the Windows job to go green before Ready.
Previous P2 (unguarded
ComputePipeline.stored_images()override): resolved.check_controls()now asserts thata.stored_images() == {}whilea.uavsis non-empty. It also asserts that the HLSL has noRWTexture2Dline, that the manifest starts withx2w-manifest 2/stage cs, and that the onlyuavline isuav 0 table 1 16.Findings: P1 none, P2 none, nit none.
Commands run locally (worktree on the PR head)
python3 tests/startup_gfx2hlsl_compute_check.py: passpython3 tests/startup_pixel_image_store_check.py: passpython3 tests/docs_links_check.py: pass (18 files, 418 links)python3 tests/bidi_controls_check.py: pass (1522 files)git diff --check origin/main...HEAD: cleanComputePipeline.stored_imagesoverride intools/startup/gfx2hlsl.py: now KILLED.startup_gfx2hlsl_compute_check.pyfails withAssertionError: ({(('table', 1), 16): 0}, {(('table', 1), 16): 0}). In the previous head this mutation survived. I restored the file withgit checkout -- ..AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-25T07:18:29Z.
Thanks for the three hardware reports: RX 9070 XT, Quadro M1000M and Intel HD 530. They cover adapters I could not test here.
mainhad moved, so I merged it into the branch instead of rebasing. The reviewed commits stay as they were. Four commits on top of7ee19fa9:932b4c21(merge ofmain). The conflicts ind3d12_draw.inl,tests/desktop_gpu.h,tests/offscreen_check.cppandtools/startup/gfx2hlsl.pywere additions on both sides, and all of them are kept:main'sd16srvmanifest reading and writing next to theuavlines;--startup-image-load-d16operation next to--startup-image-store;Pipelineclass attributes next touavs.git diff origin/main...HEADremoves one line ofmain's: the fixedx2w-manifest 1, which this PR makes 1 or 2.6456bbbc(fix).mainnow has #2182'sComputePipeline, which usesself.uavsas descriptor key touindex (an int) for its buffer stores. It inheritscommon()andmanifest(), and those readstored_images()as this PR's pixel-stage image entries. Sotests/startup_gfx2hlsl_compute_check.pyfailed withTypeError: 'int' object is not subscriptable.ComputePipeline.stored_images()now returns{}: a compute program has no pixel-stage image stores, and it declares and lists its buffer UAVs itself. The compute check fails without this commit and passes with it.81ca8985(from the tester's comment). The draw controls printed the first stderr line as the reason, which on a machine with several adapters is an adapter notice. They now print thetexel_mismatchline they already assert on, for exampletexel_mismatch x=1 y=2 expected=bf800000,... actual=3f800000,....44b10363(a second merge ofmain, at5a3ed6ac).mainmoved again during the checks. The only conflict was ingfx2hlsl.py: #2051's newsampler(..., lod_limits=False)signature sits right after this branch'sstored_images()anduav(). Both are kept, and again only thex2w-manifest 1line ofmain's is replaced.Results on Windows 10 19045 (WARP; RTX 3060, driver 32.0.15.9636), head
44b10363:tests/startup_gfx2hlsl_*_check.py(includingstartup_gfx2hlsl_compute_check.py),tests/startup_translator_check.py,tests/startup_image_*_check.py,tests/startup_pixel_image_store_check.pyandtests/docs_links_check.py.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-25T07:36:17Z.
Thanks. The override is covered, but by two checks you did not run.
I repeated your mutation on
44b10363(deletedComputePipeline.stored_images).tests/startup_pixel_image_store_check.py,tests/compute_heap_store_check.pyandtests/compute_entry_layout_check.pystill pass, as you saw. Two existing checks fail, both run by CI's platform-independent Python job:tests/startup_gfx2hlsl_compute_check.pytests/startup_compute_translate_check.pyBoth fail in the inherited
Pipeline.common():I took your suggestion anyway, since a TypeError deep in
common()does not say what broke.949497ebadds a control intests/startup_gfx2hlsl_compute_check.py, where the compute manifest is already asserted. It sits ahead of the existing exact-manifest assertion and checks four things on the buffer-store program A:stored_images()is empty whileself.uavsholds the buffer store. This is checked before any HLSL or manifest is built.RWTexture2D.x2w-manifest 2/stage cs.uavline is #2182's kind-lessuav 0 table 1 16.With the override removed, the check now stops at that first assertion:
AssertionError: ({(('table', 1), 16): 0}, {(('table', 1), 16): 0}), sostored_images()returned the compute buffer map. With the override restored, it passes.63 Python checks pass, 0 failures:
tests/startup_gfx2hlsl_*_check.py;tests/startup_translator_check.py,tests/startup_image_*_check.py,tests/startup_pixel_image_store_check.py,tests/docs_links_check.py;tests/startup_compute_translate_check.py,tests/compute_heap_store_check.py,tests/compute_entry_layout_check.py.The change is test-only and touches nothing the draw tests use, so I did not rerun CTest. The branch still merges cleanly with
main.AI-assisted (Claude Code).