Repository navigation
Conversation
Compute programs read an image descriptor's width (word 1 bits 30-31 and word 2 & 0x3fff), base level (word 3 bits 12-15) and a word-1 null check with scalar ALU ops. For a 2D table texture SRV the program samples, the direct translator now replaces those four reads with entry words (udsrc imgwidth / imgbase) that the stand-in fills from the bound view, and the null check with a constant. Other descriptor word reads keep their refusal. Refs R0Y00#3224, R0Y00#3023 AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Leyukaka
left a comment
There was a problem hiding this comment.
Diff-only review of b33ca9c (not built, not run).
Must fix. The Linux Python job is red: tests/startup_triage_run_check.py reports five source reasons missing from COMPUTE_DISPATCH_REASONS (tools/startup/triage_run.py:71): an entry value source is unknown, an image field entry value names a view that is not a texture input, an image field source has a format whose descriptor extent is not its width, an image field source is not an input texture, more than 32 entry values. The PR does not touch that file.
Should. The fixture only uses s_cmp_eq_u32. The s_cmp_lg_* and _i32 forms (src/gfx1013_direct_compute.inl:3213-3216, the null_lg fold at :3413) are never assembled, and no branch consumes the SCC written for the replaced s_bfe_u32/s_and_b32 (:3416). One more fixture line with s_cmp_lg_u32 s25, 0 would cover the other constant.
Should. "With src/ reverted, the three new tests fail" counts native_compute_manifest_reasons, which then stops compiling (no image_fields member). CONTRIBUTING.md:100: a build error is not a catch. A one-line mutation of a mask or of a null-check constant (inl:3405-3413) would show what the tests catch.
The src change itself looks correct: the three masks match the fields described (inl:3405-3409), and the null-check fold is backed by the runtime refusing an input texture with no token or no desktop texture before the fill (src/startup_stubs/d3d12_compute_dispatch.inl:928-930).
Conflicts with #3498 in tests/native_compute_manifest_reasons.cpp (case list and final count); whichever lands second rebases.
…asons Review of R0Y00#3500 (Leyukaka): startup_triage_run_check found five new source reasons missing. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. The must-fix is in e37bd1a: the five reasons are in AI-assisted. |
… shoulds) (PC-Joshua)
The image field fixture now also assembles s_cmp_lg_u32 word 1, 0 with a branch over a store, and two field reads (base, width_hi) each followed by s_cbranch_scc0 over a store, so the SCC the translator writes for a replaced read is consumed. Base 0 on the undescribed view covers the SCC 0 path. A mutant now replaces only the first line it names, since s_cbranch_scc0 4 occurs twice. AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Leyukaka both shoulds are in b04c1a7. Fixture. It now also assembles One-line mutations in
The first two only show on hardware: WARP runs the HLSL stand-in, not the translator's DXIL. After the restore, AI-assisted. |
Leyukaka
left a comment
There was a problem hiding this comment.
Diff-only re-review of b04c1a7 (not built, not run). The earlier points are addressed: the five reasons are in tools/startup/triage_run.py (:119, :125-127, :228); the fixture now assembles s_cmp_lg_u32 s25, 0 and two field reads whose SCC is consumed by s_cbranch_scc0 (words 4-6); the revert question is answered by the four src mutations listed in the comment (not reproduced here).
Nits: the _i32 compare forms are still not assembled, and the PR body still says the three new tests fail with src/ reverted.
Only blocker: conflict with main (ff9dcef) in tests/startup_stream_consumer.cpp, in the "output at byte 32" condition. Keep both sides, joined by ||: main's (records32 && std::strcmp(records32, "1") == 0) and this PR's mode.rfind("dispatch-texdim-fields", 0) == 0. The other files auto-merge.
Will approve once rebased and CI is green (no checks reported on this head).
…ptor-fields # Conflicts: # tests/startup_stream_consumer.cpp
s_cmp_eq_i32 and s_cmp_lg_i32 word 1, 0 each branch over a store that runs for a non-empty view (words 7 and 8). AI-assisted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Leyukaka merged Local, after the merge: AI-assisted. |
Leyukaka
left a comment
There was a problem hiding this comment.
Re-read at 2902e50 (diff only, not built here). The merge of main in tests/startup_stream_consumer.cpp keeps both conditions: the dispatch-texdim-fields prefix and main's X2W_TEST_RECORDS32=1 check, joined by ||.
The new words decode as intended: 198000bf is SOPC op 0 s_cmp_eq_i32 s25, 0 and 198001bf is op 1 s_cmp_lg_i32 s25, 0, each followed by a 2-dword branch over one buffer_store_dword (offsets 28 and 32), so the _i32 names accepted at gfx1013_direct_compute.inl:3282-3285 are now exercised.
The body now lists the four one-line src mutations instead of the earlier sentence, and CI is green on this head. Approving.
Not-Saii
left a comment
There was a problem hiding this comment.
Review of 2902e50: a static read and an isolated sandbox build and run (details at the end).
The earlier review points are addressed at this head:
- the five runtime reasons are in
tools/startup/triage_run.py; - the fixture now assembles
s_cmp_lg_u32and the_i32forms, with branches that consume the SCC of the replaced reads; - the body lists one-line mutations instead of the revert;
- the merge with main keeps both byte-32 conditions, joined with
||.
Logic
I read the translator, manifest, cache and runtime changes. They look correct:
-
Bit fields. The
s_bfe_u32immediates decode as offset/width pairs:0x2001e= bits 31:30,0x4000c= bits 15:12,0x90014(the control) = bits 28:20. These match the public gfx10 image descriptor:- word 1: the 9-bit format at 28:20 and width_lo at 31:30;
- word 2: width_hi at the bottom;
- word 3: BASE_LEVEL at 15:12.
The repo has no other decode of image width or base level, so I checked against the public layout, not against existing code. For any D3D12 2D width ≤ 16384,
(width - 1) >> 2≤ 4095. So the0x3fffmask and the translator's(w >> 2) & 16383agree whether width_hi is 12 or 14 bits wide. -
SCC. For the replaced
s_bfe_u32/s_and_b32, SCC isresult != 0(src/gfx1013_direct_compute.inl:3485), which is the ISA definition. Folding the null check to a constant is backed by the runtime: it refuses an input that has no token or no desktop texture before the fill. -
Word order.
initialize_constants(:375-378),bind_image_fields(:3320) and the manifest and in-process orderings all walk the samestd::mapin key order, after the stride words. The entry-word layout therefore matches on both routes. -
In-place overwrite.
binding()already refuses a non-contiguous descriptor. A program that overwrites a descriptor word in place with one of these reads and then samples the descriptor is still refused. -
Source enum. The new
Sourcevalues sit beforeoutput_word3, so the>= output_word3split between inputs and outputs is unchanged. The manifest name table (src/startup_stubs/d3d12_compute_dispatch.inl:330-331) mapss + 1to the enum in order. -
Cache. The
.csirlayout changes without an output revision bump, which is safe.slot67_digestand the container identity both start withX2W_NATIVE_SHADER_REVISION, a hash that coversdirect_compute_cache.cppandgfx1013_direct_compute.inl. An old payload is therefore never looked up under the new key. -
Format refusal. The DXGI ranges are right: 5–8 (R32G32B32), 70–84 (BC1–BC5), 94–99 (BC6H–BC7).
Findings
None of these block merging.
SHOULD 1: evidence fields in the PR body. The body names "RTX 3080 and WARP", but it does not give:
- the commit those runs used;
- the driver version;
- the Windows build;
- the debug-layer status;
- the exact
ctest --preset dev …command (the comments give only-Rpatterns).
AGENTS.md "Evidence" asks for all of these. Please add them for the final head.
SHOULD 2: CI does not run any of this PR's tests. The PR run on 2902e50 (run 46317728773) passed, but:
- The Windows job ran the
prpreset (82/82). The preset matches none ofstartup_compute_dispatch_image_fields_{controls,warp,hardware}ornative_compute_manifest_reasons, and the log has noimage_fieldsline. - The Linux job ran
tests/startup_triage_run_check.py(0 failed).
The b04c1a7 comment says the width_hi mutation is caught "by controls (compile, also in CI)". That is not true of this PR's CI. Please fix that wording, or, if the preset owners agree, add startup_compute_dispatch_image_fields_controls and native_compute_manifest_reasons to the pr preset. Neither needs WARP or a GPU: the first needs only compile_dxil and DXC, which the Windows PR job already builds.
NIT 1: the fixture's binary mode runs nowhere in CI. startup_compute_dispatch_image_fields_check.py binary is not in the CHECKS list of the LLVM 15 job (.github/workflows/windows.yml:41). I assembled all 45 recorded encodings with LLVM 15.0.7 for gfx1013 (42 program lines and 3 mutant replacements), and every one matches. Adding the line there would keep that true.
NIT 2: the run tests fail instead of skipping when the debug layer is not installed. tests/startup_compute_dispatch_image_fields_check.py:273 asserts that the layer was enabled. On a host without the Graphics Tools SDK layers, _warp and _hardware fail at that line, and the sections after it never run. This follows startup_compute_dispatch_cube_check.py:206, so it is optional here. (The sandbox below had the layer, so it was not hit.)
NIT 3: some paths have no test, beyond those the body already lists:
- the three new translator refusals:
more than 32 entry words with image fields,an image descriptor field has no sampled textureand... more than one texture binding; - a program whose only use of the slot is the null check (an entry with no words);
- a warm-cache decode of the new
.csirfield. Publishing twice over the same cache and rerunningcheck_manifestwould cover it.
What each test proves
-
startup_compute_dispatch_image_fields_controls(compile only):- the fixture publishes natively with
ud 4,udsrc 2 imgwidth 0,udsrc 3 imgbase 0andsrv 0 tex2d table 1 64; - the
0x3ffmask, the format-field bfe and the program without the image op each keep theunbound numeric SGPRrefusal; - the scc1 mutant still publishes.
This shows the matcher is narrow. It runs nothing.
- the fixture publishes natively with
-
startup_compute_dispatch_image_fields_warp: an HLSL stand-in replaces the published.cs.cso. The test covers:- the manifest reader;
- the runtime fill: mip-0 width − 1, and MostDetailedMip (0 when the view has no description);
- the two rewritten-manifest refusals.
It does not run the translator's DXIL.
-
startup_compute_dispatch_image_fields_hardware: runs the translated wave32 DXIL end to end, including the null-check constants and the SCC consumers (words 4–8). It also runs the scc1 control, which shows the store is live, and the in-process route. -
native_compute_manifest_reasons: the formatter's new lines and its refusals (buffer SRV, 1D, 2D array, missing SRV, unknown field, more than 32 words).
Mutation
A one-line revert of the fix, applied to a scratch copy only: in src/gfx1013_direct_compute.inl:5272, the prepare_image_fields(); call was commented out.
- The rebuild check passed:
compile_dxil.exeandnative_compute_manifest_reasons.exewere relinked, so the mutant was built (no build error). startup_compute_dispatch_image_fields_controls,_warpand_hardwareall failed at publish, with the translator'snative compute +0x20: unbound numeric SGPR s25refusal.- The other six tests passed.
- After restoring the head file (sha256 matches head) and rebuilding, all 9 passed again.
Sandbox run (AGENTS.md fields)
- Commit: head
2902e500895ac2cd82bfa1c38e4048c42ca3eed5, exported withgit archive, merge base2ff74a6ac3. The sandbox had networking disabled and the tree mapped read-only. - OS: Windows 11 Enterprise 10.0.26100 (build 26100), inside Windows Sandbox.
- Adapter: NVIDIA GeForce RTX 4090 through the sandbox vGPU. The driver reported inside the sandbox is 10.0.26100.1150 (the virtual adapter's WMI driver). WARP 1.0.22 is app-local, from the build's WARP directory.
- Debug layer: enabled, with no error message in any fixture. The Graphics Tools SDK layers were installed in the sandbox, the
D3D12GetDebugInterfaceprobe returnedhr=0x00000000, andX2W_D3D12_DEBUG=1was set. The build was configured with the Agility SDK 1.620 directory. - Toolchain: MSVC 14.44, CMake 3.31.6, Debug, Python 3.14.8.
- Commands:
cmake --preset dev -DX2W_WITH_OPUS=OFF -DINTAKE_PYTHON=<venv python> -DOFFSCREEN_AGILITY_620_DIR=<agility> -DOFFSCREEN_WARP_DIR=<warp> cmake --build --preset dev --target compile_dxil startup_stream_consumer offscreen_check native_compute_manifest_reasons ctest --preset dev --no-tests=error --output-on-failure -V -R '^(startup_compute_dispatch_image_fields_(controls|warp|hardware)|native_compute_manifest_reasons|startup_compute_dispatch_texture_dims_(warp|hardware)|startup_compute_dispatch_cube_(controls|warp|hardware))$' - Head results: 9 passed, 0 failed, 0 skipped (77).
- Passed:
native_compute_manifest_reasons,startup_compute_dispatch_image_fields_{controls,warp,hardware},startup_compute_dispatch_cube_{controls,warp,hardware},startup_compute_dispatch_texture_dims_{warp,hardware}. - The cube and texture_dims tests are regression checks for the changed consumer branch.
- On hardware the fixture printed: width 8 (mip 0, not the view's 4), base 1, the empty-check store skipped, texel 105.0; with
s_cbranch_scc1word 2 is 0xdeadbeef; the in-process route filled the same words (4 entry values, 1 input, 1 output); the rewritten manifests were refused with the output untouched.
- Passed:
- Mutant results: 6 passed, 3 failed (the three
image_fieldstests, as expected), 0 skipped. - Restored results: 9 passed, 0 failed, 0 skipped.
- CI: CI ran none of this PR's ctest tests, only
tests/startup_triage_run_check.pyon Linux (see SHOULD 2).
Approving. The SHOULDs are about evidence and CI coverage, not behavior.
|
@JB2WIN this one has two approvals and green checks, but it now conflicts with |
Refs #3224 (claimed in #3224 (comment)), #3023.
Compute programs read fields of a table image descriptor with scalar ALU ops. The direct translator refused those reads as
unbound numeric SGPR sN. The read chain I found in the local cohort (category tags only):s_bfe_u32word 1,0x2001e: width low bits;s_and_b32word 2,0x3fff: width high bits;s_bfe_u32word 3,0x4000c: base level;s_cmp_eq/lg_*word 1 against inline 0: a null check.Bit positions come from the public AMD PAL driver (MIT): the
gfx10member ofsq_img_rsrc_tingfx10_sq_ko_reg.h, andDevice::SetImageSrdDims(width_lo = (width - 1) & 3; width_hi = (width - 1) >> 2). No console SDK material.What changes, for a 2D
texture_srvthat the program also samples:udsrc N imgwidth Sandudsrc N imgbase S. Any view other than one 2D texture SRV is refused by name.input_image_width/input_image_basebeforeoutput_word3. They are filled from the bound view: the resource's mip-0 width - 1, and the described view's MostDetailedMip (0 when undescribed). 96-bit and BC formats are refused, and the fill switch gets adefaultthat refuses.NativeComputePipelinerefuses these words instead of dropping them.Impact on main
0ff17e2c, local 2,689-request cohort,compile_dxil --refusals: only 2 requests move (unbound numeric SGPR169 to 167; translated stays 827). Most programs with this chain now stop at the resource-heap refusal first. This is mainly the next blocker for the #3023 heap-texture route, where the same chain follows the GPU-selected texture load.Tests (RTX 3080 and WARP):
startup_compute_dispatch_image_fields_{controls,warp,hardware}. The consumer modedispatch-texdim-fieldsuses an R32_FLOAT 8x4 texture with 3 mips, each mip uploaded, viewed as TEXTURE2D from mip 1. Expected: width 8 (mip 0, not the view's 4), base 1, null-check store skipped,image_load(1,1) = 105.0. An undescribed view gives width 8, base 0, texel 9.0.0x3ff, bfe0x90014(the format field) and a program without the image op keep their refusal. Manifests rewritten to a buffer source or a missing SRV are refused and leave the output untouched..cs.cso. WARP therefore checks the manifest, reader and fill; the translated math and null check run on hardware only. The hardware run also checks the in-process route (X2W_NATIVE_SHADERS).native_compute_manifest_reasons: the new lines, plus refusals for a buffer SRV, 1D, 2D array, a missing SRV, an unknown field, and more than 32 entry words.startup_compute_dispatch|native_compute_manifest|native_compile_dxil|direct_compute|startup_compute_token(2 WARP skips as on main).srcmutations, each caught:null_lgSCC 1 -> 0 and the field SCCne->eq(hardware run), the width_hi match0x3fff->0x3ff(compile controls), the width_lo mask 3 -> 1 (hardware run). Details in the review thread.prCTest preset, like the other texture-dims tests.Not tested: the 96-bit/BC and non-2D refusals in the runtime fill, the
NativeComputePipelinerefusal, and a warm-cache read of the new cache field. A tiled-address SRV's desktop texture is assumed to have the title's width. The assumption is the unpadded mip-0 extent (a padded view would differ).AI-assisted.
🤖 Generated with Claude Code