Repository navigation
startup: lower pixel-stage image_store to a typed UAV store - #2155
Conversation
gfx2hlsl refused image_store in every stage (R0Y00#1996 item F). In a pixel stage, image_store with dim:SQ_RSRC_IMG_2D and dmask:0xf now becomes w<n>[uint2(x, y)] = asfloat(uint4(data)) on a RWTexture2D<float4> at its own u register, under the lane's exec bit, and the manifest becomes version 2 with "uav <index> tex2d table <table> <offset>". Semantics: MIMG opcode 0x08 (LLVM AMDGPU MIMGInstructions.td, IMAGE_STORE defined through MIMG_Store): VDATA is the source, VADDR the integer texel address (x, y for dim 2D), SRSRC the image descriptor, and the DMASK channels are written in order from consecutive VDATA registers. Mesa ACO (visit_image_store) emits the same form with DMASK from the write mask. A typed UAV store writes every channel, so only DMASK 0xf is exact; a partial mask, other dimensions, d16, a16, tfe, lwe, r128, unorm, image_store_mip, a store outside a pixel stage and a load and store of the same image are refused by name. glc, slc and dlc are accepted. The translated graphics path does not bind UAVs yet: d3d12_draw.inl logs and does not use a translation whose manifest has a uav line, instead of rejecting it as an invalid sampler-heap line. startup_pixel_image_store_check.py decodes the hand-assembled program with disasm_rdna2, checks the translation, the refusals, and that the program is refused again with the lowering removed. The draw stores four values at texel (1, 2) of a 4x4 image through offscreen_check --startup-image-store, reads all 16 texels back, and checks that deleting the store or exchanging x and y is detected. Refs R0Y00#1996 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tedin7
left a comment
There was a problem hiding this comment.
Review of head f14d392d3acf065f2f130bc876f17a4b397249b6 (non-blocking comment, no approval).
Scope: pixel-stage image_store lowered to a RWTexture2D<float4> store (gfx2hlsl), manifest v2 uav line, runtime refusal for uav manifests, new Python controls and a desktop draw readback test, docs.
Checked:
- CI on this head: Windows build and test pass, Linux Python checks pass, gfx1013 fixtures pass.
- Mergeable, title neutral, no clean-room concerns seen in the diff.
- The lowering matches the ISA shape: VDATA is four consecutive VGPRs, the address is x and y, and the store runs under exec. Refusing 1D, 3D, array, partial masks,
image_store_mip, non-pixel stages, and load+store of the same image is sensible. - The runtime logs and skips a translation with a
uavline, so nothing is bound wrongly.
Findings:
- P1: none.
- P2: the
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. - Nit:
stored_images()uses__dict__.setdefaultto cover pipelines built without__init__. Givinguavsa class-level default or fixing the test constructors would be clearer. - Nit: the docs bullet has a short broken line ("The cache-policy" wraps oddly); cosmetic.
Mutations run (then git checkout -- .):
- Swapped x and y in the store address:
startup_pixel_image_store_check.pyexits 1, so the test kills it. - Disabled the dmask guard: the test still exits 0, so it survives (the P2 above).
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 skipping
AI-assisted; commands listed were executed locally.
The two encoded partial-mask controls only asserted that image_store was refused. The decoder 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 passed. Each now asserts the dmask reason, and a new control calls the handler with v[4:7] and dmask 0x7, which only the mask guard can refuse; another passes dmask 0xf with three data registers and asserts the data reason. With the guard replaced by `if False:` the check fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lback Pipelines that tests assemble without __init__ store to no image. A class attribute of None now says so; the first store creates the instance's own map. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, the guard finding was right: the two encoded partial-mask controls passed for the wrong reason. The disassembler sizes VDATA from the mask ( What changed, in three commits on top of f14d392:
None of these controls is registered with Mutation: with With the guard restored, the check passes. Commands and results: out/pe-env/Scripts/python.exe -B tests/startup_pixel_image_store_check.py
ctest --preset dev --no-tests=error -R '^startup_pixel_image_store_' -V
ctest --preset release --no-tests=error -R '^startup_pixel_image_store_' -VWindows 10 19045, head 96c1a55:
All AI-assisted (Claude Code). |
tedin7
left a comment
There was a problem hiding this comment.
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
- The refusals match the description: partial DMASK, non-2D dim, bad modifiers, wrong data/address register count, non-pixel stage, and a load plus a store of the same image. The load/store conflict is enforced in both orders (
resourceanduav). - Manifest: version 2 only when a store exists, version 1 otherwise (covered at
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
- P1: none.
- P2: the exec guard is not covered. I replaced
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). - nit:
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: clean- Mutation 1: DMASK check replaced with
if False:: the check failed (killed). - Mutation 2: exec guard removed : the check still passed (survived, see P2).
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.cpp and CI Windows is green.
AI-assisted; commands listed were executed locally.
int(masks[0], 0) raised ValueError on mask text that is not an integer;
it is now an Unsupported refusal ("not an integer"), with a control.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two variants put v_cmpx_eq_u32 before the store so exec is not known at translation time. The controls assert that the emitted store is guarded by the lane's exec bit, and the draw mode reads the image back: with the lane on the texel is written, with every lane off it keeps its starting value, and the exec-off shader with the guard removed must write it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Both findings were right. Two commits on top of 96c1a55:
Mutations (each applied alone, then restored):
The two sibling emits already have their own coverage. Each was mutated alone and the full Python set was rerun:
None of the CTest entries uses Commands: Results on Windows 10 19045, head 7ee19fa:
AI-assisted (Claude Code). |
tedin7
left a comment
There was a problem hiding this comment.
AI-assisted; commands listed were executed locally.
Re-review of head 7ee19fa945ed5c347a54cdb8efa63bfae1403b94 (comment only). Previous review was on 96c1a55b; 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
- P2 (exec guard untested): fixed.
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. - nit (malformed dmask): fixed.
op_image_storenow raisesUnsupported('image_store with dmask 0xz: not an integer'), and the check covers it.
Findings
- P1: none.
- P2: none.
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: clean- Mutation A: exec guard removed from the store emit (
gfx2hlsl.py:1511) : the check failed (killed; the new assertion fires). - Mutation B: DMASK required value changed from 0xf to 0xf0 : the check failed (killed).
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.
|
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. |
|
Ran head
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 AI-assisted. |
Conflicts were additions on both sides, kept in full: main's d16srv manifest reading and writing next to the uav lines, main's image_load_d16 operation and declaration next to the image store ones, and main's Pipeline class attributes next to uavs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ComputePipeline (R0Y00#2182) maps buffer descriptors to u indices in self.uavs and declares them itself; the inherited common() and manifest() read stored_images() as pixel-stage image entries, which a compute program cannot have. startup_gfx2hlsl_compute_check.py fails without this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The controls printed the first stderr line as the reason, which on a machine with several adapters is an adapter notice. They now print the texel_mismatch report they already assert on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The one conflict was next to each other in gfx2hlsl.py: main's new sampler(..., lod_limits=False) signature, kept after this branch's stored_images() and uav() methods. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the three hardware reports: RX 9070 XT, Quadro M1000M and Intel HD 530. They cover adapters I could not test here.
Results on Windows 10 19045 (WARP; RTX 3060, driver 32.0.15.9636), head 44b1036: ctest --preset dev --no-tests=error -R '^startup_pixel_image_store_' -V
ctest --preset release --no-tests=error -R '^startup_pixel_image_store_' -V
AI-assisted (Claude Code). |
tedin7
left a comment
There was a problem hiding this comment.
AI-assisted; commands listed were executed locally.
Re-review of head 44b103638a0e3b1790ff4e1bf61b1d268935715d (comment only). Previous review was on 7ee19fa9. 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()).- P2 (test gap): that override is not guarded. Mutation A below removed it and every check I ran still passed.
- P1: none.
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: clean- Mutation A: delete
ComputePipeline.stored_imagesoverride : SURVIVED (image-store check, compute_heap_store_check and compute_entry_layout_check all still pass). - Mutation B: manifest version always 1 : killed (
targets 0/ check fails). - Mutation C: drop the read/store conflict test in
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 uav line and the manifest header stays version 1 (extend tests/compute_heap_store_check.py).
AI-assisted; commands listed were executed locally.
The compute stage's buffer stores live in self.uavs (descriptor key -> u index), which the shared common() and manifest() must not read as R0Y00#2155's image stores. The control asserts stored_images() is empty before any output is built, then no RWTexture2D declaration, the `x2w-manifest 2` / `stage cs` header and the single kind-less uav line. With ComputePipeline.stored_images removed it fails at that assertion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. The override is covered, but by two checks you did not run. I repeated your mutation on 44b1036 (deleted
Both fail in the inherited I took your suggestion anyway, since a TypeError deep in
With the override removed, the check now stops at that first assertion: 63 Python checks pass, 0 failures:
The change is test-only and touches nothing the draw tests use, so I did not rerun CTest. The branch still merges cleanly with AI-assisted (Claude Code). |
tedin7
left a comment
There was a problem hiding this comment.
AI-assisted; commands listed were executed locally.
Re-review of head 949497eb4d5521cf6fdbdeeb1f2a52810279585f (comment only). Previous review was on 44b10363. The only new commit is 949497eb, which changes tests/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 that a.stored_images() == {} while a.uavs is non-empty. It also asserts that the HLSL has no RWTexture2D line, that the manifest starts with x2w-manifest 2 / stage cs, and that the only uav line is uav 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: clean- Mutation A, deleting the
ComputePipeline.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.
Refs R0Y00#1996 (item F). load_translation reads the 'uav N tex2d table P O' line that gfx2hlsl.py writes for a pixel-stage image_store instead of dropping the translation. The translated root signature gets a UAV range after the SRVs in its view table, and each draw makes the view from the unordered-access view the title created at that table entry, on mip 0 of a 2D texture. Version 2 manifests (the ones with uav lines) are read again; each uav line is bound or refused by name, and the raw buffer line of the vertex-stage stores (R0Y00#2059) stays refused. Refused by name, nothing bound in place of the view: other line forms (including a view qualifier or a channels field, as in the compute line) when the manifest is loaded; at draw time no table, an entry outside the table, an entry without a view, a view that is not a UAV, a resource without ALLOW_UNORDERED_ACCESS, other resource or view dimensions, mips and planes, integer, sRGB and non-colour formats, no typed UAV store, and a texture that is also an SRV, a render target or the depth texture of the draw. These checks run before any view of the draw is written. Indirect draws refuse a translation with a uav line. tests/startup_pixel_uav_check.py draws the source-built program of R0Y00#2155 through the runtime and reads back every word of four sentinel textures. AI-assisted.
* startup: bind pixel-stage UAVs from the title's descriptor table Refs #1996 (item F). load_translation reads the 'uav N tex2d table P O' line that gfx2hlsl.py writes for a pixel-stage image_store instead of dropping the translation. The translated root signature gets a UAV range after the SRVs in its view table, and each draw makes the view from the unordered-access view the title created at that table entry, on mip 0 of a 2D texture. Version 2 manifests (the ones with uav lines) are read again; each uav line is bound or refused by name, and the raw buffer line of the vertex-stage stores (#2059) stays refused. Refused by name, nothing bound in place of the view: other line forms (including a view qualifier or a channels field, as in the compute line) when the manifest is loaded; at draw time no table, an entry outside the table, an entry without a view, a view that is not a UAV, a resource without ALLOW_UNORDERED_ACCESS, other resource or view dimensions, mips and planes, integer, sRGB and non-colour formats, no typed UAV store, and a texture that is also an SRV, a render target or the depth texture of the draw. These checks run before any view of the draw is written. Indirect draws refuse a translation with a uav line. tests/startup_pixel_uav_check.py draws the source-built program of #2155 through the runtime and reads back every word of four sentinel textures. AI-assisted. * test: pixel UAV no-ua case expects the empty-entry refusal now that skipped UAVs record no view --------- Co-authored-by: tedin7 <tommasoderosa94@gmail.com>
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