Repository navigation
shader: lower pixel image descriptor size fields read as numbers - #3225
SimSalabimse wants to merge 4 commits into
Conversation
KelboLive
left a comment
There was a problem hiding this comment.
Review of PR #3225 — shader: lower pixel image descriptor size fields read as numbers
Summary
This PR adds support for lowering exact GFX10 image descriptor size fields (width, height, depth) as numeric values in the pixel stage HLSL translator. The implementation is well-scoped and correct.
Changes reviewed
tools/startup/gfx2hlsl.py: NewIMAGE_FIELDSdictionary mapping(word_index, instruction, control)→(field_name, expression). Newimage_field_expr()method to match scalar ops against known size-field patterns.image_spantracking in Stage class follows descriptor data across register moves. Helper function generation for GetDimensions calls at the Pipeline level.tests/startup_gfx2hlsl_image_desc_word_check.py: Comprehensive test suite — 10 accepted cases (width/height/depth for tex1d/tex2d/tex2da/tex3d), plus refused cases covering wrong words, wrong operations, vertex stage, buffer descriptors, m0 usage, and modified descriptor words.- Build/config files: CMakeLists.txt adds the test; .github/workflows/windows.yml includes it in CI; AGENTS.md documents the command; docs/experiments.md documents the feature with reproduction steps.
Assessment
- The implementation is well-scoped: only exact GFX10 size-field patterns are accepted, everything else stays refused.
- The
image_spantracking correctly follows descriptor data acrosss_mov_b32moves, which is important for correctness when registers are reused. - Test coverage is thorough — both positive (accepted translations) and negative (refused cases), plus the "without_field_expr" control that verifies every accepted case fails when the feature is removed.
- The comments reference Mesa radv_image.c for traceability of the field layout.
Minor notes
IMAGE_DIM_HASdictionary is defined but never used — could be removed or used as an assertion guard, though its absence doesn't affect correctness since refusal logic already handles this via per-dimension checks (e.g., refusing depth for 1D/2D/tex2da).IMAGE_DIM_NAMEdictionary is also defined but unused — same assessment as above.
Verdict: Approve
pigalot
left a comment
There was a problem hiding this comment.
I reviewed e264b8c7 merged over current main 58e3183a. The merge is clean (tree d99811ce) and git diff --cached --check is clean.
What I traced.
- The field table: it matches the GFX10 image descriptor layout. WIDTH−1 is split as word 1 bits 31:30 plus word 2 bits 11:0, HEIGHT−1 is word 2 bits 27:14, and DEPTH−1 is word 4 bits 12:0. Each
s_bfe_u32control,s_and_b32mask ands_lshr_b32shift inIMAGE_FIELDSextracts exactly that field. - The templates: each one rebuilds those bits from
GetDimensions(0), so the& 3,>> 2,& 0x3fffand<< 14/<< 30forms are right. - The CI and
AGENTS.mdedits: they only register the new check.
Finding: the image dimension is assigned per register, not per descriptor load.
-
What happens:
note_image_descriptors()scans the whole program once and gives each SGPR thedim:of any image instruction that uses it.image_word()then checks only that the register currently holds some 8-dword load. So a size-field read of one descriptor gets its dimension from an image instruction that samples a different descriptor loaded into the same registers. -
Probe: it uses the
lzfixture from your check. Before the fixture's owns_load_dwordx8 s[16:23], s[8:9], 0x0, I prepend:s_load_dwordx8 s[16:23], s[8:9], 0x20 s_waitcnt lgkmcnt(0) s_and_b32 s10, s18, 0xfffand then add
v_mov_b32_e32 v4, s10after the image instruction (splice(WORDS['lz'], ('v_mov_b32_e32 v4, s10',), 'after-image')). -
Result:
Pipeline(VS_WORDS, code, root_blob(flags=0))accepts it. It emitss10 = ((img_width_tex2d(r0) - 1u) >> 2);, and the manifest hassrv 0 tex2d table 0 32next tosrv 1 tex2d table 0 0. -
Why it matters: the descriptor at table offset 32 is never used by an image instruction, yet it is bound as a
Texture2Donly because the reload at offset 0 is sampled withdim:SQ_RSRC_IMG_2D. If that slot holds a 3D or 1D image, or a buffer, the bound view type is wrong, and the size read is wrong with it. Your docstring says "a load with no image instruction" stays refused. This is that case, reached through register reuse. -
Suggested direction (unconfirmed): key the dimension by the descriptor load the image instruction actually reads, for example
(sym[1], sym[2] + 4 * (sym[3] & ~7))from thedescsymbol at the image instruction. Then require the field read's symbol to match it. The probe above would make a good negative control.
What I ran.
python -B tests/<name>.pyforstartup_gfx2hlsl_image_desc_word_check,startup_image_sample_l_check,startup_gfx2hlsl_cselect_descnum_check,startup_gfx2hlsl_load_desc_check,startup_gfx2hlsl_scalar_m0_checkandstartup_gfx2hlsl_image_get_lod_check: all exit 0.python -B tests/startup_tools_lint_check.py tools/startup: PASS.ctest --test-dir out/build/dev --no-tests=error -j 8 -R '^startup_gfx2hlsl_' -E '(_warp|_hardware|startup_audio)': 153 of the 154 registered tests pass. The one failure is a test from another PR that was still registered in my build directory. Its file is not in this tree.
Non-blocking. The checks compare HLSL text only. No draw shows that GetDimensions(0) on the view the stand-in creates for srv N tex2d|tex1d|tex2da|tex3d returns the descriptor's size. That holds only under the base-mip contract the docs describe.
Verdict: changes requested on e264b8c7 for the per-register dimension.
Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; translator checks only, no GPU run.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on e264b8c7.
This reply was AI-assisted.
R0Y00
left a comment
There was a problem hiding this comment.
I reproduced the same provenance bug in the opposite instruction order on e264b8c7 over main c7215add (trial tree 313b5535). The existing descriptor-field Python suite passes, and the following source-built pair adds a distinction a fix should preserve.
In the lz fixture, copy s18 to s28 before image_sample, which uses the descriptor from table byte offset 0. After image_sample, reload s[16:23] from table byte offset 32 and wait. Extract s_and_b32 s10, s28, 0xfff in the positive case or use s18 in the negative case, then move s10 to v4.
The copied value correctly emits img_width_tex2d(r0) and one SRV at offset 0. The reloaded s18 incorrectly emits img_width_tex2d(r1) and a second SRV at offset 32, even though no image instruction uses that descriptor. Keep the copied-descriptor case accepted and refuse the later unobserved reload. This complements the existing before-image repro and guards against a fix that rejects valid copies whenever a register is reused.
|
After the provenance fix, a useful dimension-specific control is a non-square 3D texture with a view starting above resource mip 0. The VIctory #3613 gather test depends on the first accessible mip's dimensions, so it is a good separate example of why resource and view sizes must be distinguished. Compare the lowered |
pigalot
left a comment
There was a problem hiding this comment.
Retested 4f75193e integrated over current main 32221f1a.
Conflict with main. The merge now conflicts in tools/startup/gfx2hlsl.py, in Pipeline's SRV declaration loop. #2960 added 'texcube': 'TextureCube<float4>' to the same type map that this branch follows with the img_<component>_<kind> helper loop. For testing, I kept main's line and added this branch's helper loop under it (tree 5bf8a8d1, git diff --cached --check clean).
- That conflict is textual only. This branch's
IMAGE_DIMhas noSQ_RSRC_IMG_CUBEentry, so a cube-sampled descriptor gets no key inimage_desc_dim, and its size-field reads stay refused. - The branch needs a
mainmerge before it can land.
My changes request on e264b8c7 (dimension per register): addressed. note_image_descriptors() now keys the dimension by the descriptor load the image instruction reads, image_desc_key = (source, byte offset of the 8-dword image). It requires all eight operand words to be that load, unmodified. image_word() looks up the field read's own symbol.
- My probe, the offset-32 load into
s[16:23]before the fixture's load, read throughs_and_b32 s10, s18, 0xfff: now refused (numeric use of s10 holding descnum). It is in the check asearly. - R0Y00's order, a reload after the sample: the reloaded
s18refuses, and the copys28taken before the reload is still accepted, with one SRV,srv 0 tex2d table 0 0. Both are in the check (reloaded,kept). - The plain same-descriptor case is still accepted.
What I ran.
- Build: full
dev. - Tests:
ctest --test-dir out/build/dev --no-tests=error -j 8 -R '(^startup_gfx2hlsl_|image|cube)' -E '(_hardware$|startup_audio)'gives 346 tests: 338 pass, 0 fail and 8 are capability skips (native_image_store_exact_width_warp_*,native_image_atomic_warpandnative_image_cache_flags_cs_warp). - Lint:
python -B tests/startup_tools_lint_check.py tools/startuppasses.
Mutants of tools/startup/gfx2hlsl.py, each run against tests/startup_gfx2hlsl_image_desc_word_check.py after an unmutated baseline that passes:
| Mutant | Result |
|---|---|
image_word takes any keyed load's dimension (per-register borrowing back) |
killed (early) |
| key aligned to 4 dwords, not 8 | killed (3D depth refused) |
| two dimensions on one key keep the first | fails, though on a different assertion (used as tex2d and tex3d) |
| key drops the dword index | survives |
the 8-word same check is replaced by key is not None |
survives |
a scalar write other than a load or s_mov keeps the word's symbol in the pre-scan |
survives |
| the branch early-return is removed | survives |
the pre-scan ignores offset: |
survives |
the pre-scan s_mov drops the copy |
survives |
| the pre-scan load keeps the old words | survives |
Restored afterwards; git diff --quiet is clean.
Non-blocking. The fix itself is pinned. The pre-scan's own guards are not: each surviving mutant widens what gets a key, and no control fails.
- What would be unsound if removed:
- Dword index: the second image of an
s_load_dwordx16would borrow the first image's dimension. - The 8-word
samecheck: a mixed or modified operand would still be keyed. - Other scalar writes: a word overwritten by arithmetic would keep its descriptor symbol.
- The branch refusal: the linear pre-scan would follow a path that isn't taken.
- Dword index: the second image of an
- Controls that would pin them: a near-miss for each, for example:
- an
x16load whose two halves are sampled with differentdim:; - an image operand with one word replaced by
s_mov_b32 s17, 0; - an
s_add_u32 s16, s16, 0before the sample; - a forward
s_cbranch_scc0around the load.
- an
- The two remaining survivors only refuse more: dropping the
s_movcopy or keeping the old words.
Verdict: the per-register finding is addressed on 4f75193e. Approve on 4f75193e as reviewed. It needs a main merge for the #2960 conflict before it can land, and the merged head needs another look then. This supersedes my changes-requested review on e264b8c7.
Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; translator checks only, no GPU run.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 4f75193e.
This reply was AI-assisted.
|
I pushed a merge of current Conflict resolved. The only conflict was in What I ran on
Because I made this merge, my approval on This reply was AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
I reran the descriptor-word, 2D-array, 3D, image-arity and startup-tool lint checks on 735924db. The existing provenance cases passed, and the merge retains the cube declaration.
There is still an unsupported case entering the ordinary draw path. The experiment and image_field_expr both scope the lowering to views that start at resource mip 0. The generated helper always queries GetDimensions(0u, ...), while the manifest emits an ordinary texture SRV. In d3d12_draw.inl, the texture path copies the recorded SRV descriptor and passes it to CreateShaderResourceView without checking MostDetailedMip for this translation. Shader mip 0 is then the shifted view's first mip if the recorded view starts above resource mip 0. The current fixture checks the HLSL string and provenance, so it does not establish equivalence to the guest descriptor fields for that binding.
Please enforce the documented base-mip requirement for translations that read these fields, or demonstrate equivalent descriptor values for a shifted view. A source-built non-square texture bound once at resource mip 0 and once with MostDetailedMip=1 should distinguish the two. Keep the check scoped to numeric descriptor reads so ordinary sampling through a shifted view still works.
pigalot
left a comment
There was a problem hiding this comment.
Re-reviewed the merge of main into this branch at 735924db (parents 4f75193e and main 240e0fb9). git diff --check origin/main...735924db is clean.
Resolution. git show --remerge-diff 735924db shows one conflict hunk, in Pipeline SRV declarations in tools/startup/gfx2hlsl.py. The merge keeps main's 'texcube': 'TextureCube<float4>' entry from #2960 and this branch's img_<component>_<kind> helper loop. Nothing else changed. I also checked that the two sides don't meet: the branch's IMAGE_DIM map has no SQ_RSRC_IMG_CUBE. A cube descriptor therefore never enters image_desc_dim, so its size fields stay on the existing path. The new IMAGE_DIM_HAS / IMAGE_DIM_TYPE / IMAGE_DIM_READ lookups can't raise KeyError on texcube.
What I ran. I built offscreen_check in dev and release and ran ctest --test-dir out/build/<preset> --no-tests=error -R '^startup_(gfx2hlsl_.*|image_.*)$', with the _hardware tests at -j 1:
- 307 tests without hardware pass in Debug and Release
/O2, includingstartup_gfx2hlsl_image_desc_word_controlsandstartup_image_cube_controls. - 134 hardware tests pass, including
startup_image_cube_hardware.
Control and mutants on the resolved lines. Each was run against startup_gfx2hlsl_image_desc_word_controls and startup_image_cube_{controls,warp,hardware}:
| Change | Result |
|---|---|
tools/startup/gfx2hlsl.py back to main 240e0fb9 (control) |
the descriptor-word check fails ("numeric use of s10 holding descnum"); the cube tests pass |
resolution drops main's texcube SRV entry |
all three cube tests fail |
| resolution drops this branch's helper loop | the descriptor-word check fails (width lo bfe); the cube tests pass |
Restored afterwards; git diff --quiet is clean.
Open request. R0Y00's changes request on 735924db still applies, and the merge doesn't touch it. I read the code and it agrees with that request. The helper always calls GetDimensions(0u, ...) on the SRV the draw path creates from the recorded descriptor. With MostDetailedMip=1, that returns the size of the view's first mip. The descriptor's width and height fields still describe the resource's mip 0. I haven't run the shifted-view case, so this rests on reading only.
Verdict: the merge resolution is correct. No approval while R0Y00's request is open.
Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; SDK 10.0.28000.0 dxc.exe (the one CTest picked up); Python 3.12.10.
This reply was AI-assisted.
|
Thanks both. I keyed the image dimension by the descriptor load the image instruction actually reads, not by the register. The key is the source and the byte offset of that 8-dword image, and the field read's symbol has to match it. So a load at offset 32 into the same SGPRs no longer borrows the dimension from a sample of the offset-0 load. Both orders are in the check now. The offset-32 load, the wait and the Retested 4f75193 on Windows: image_desc_word passed twice, startup_gfx2hlsl_ 386/386 passed. AI-Assisted |
|
Thanks for the provenance fix. pigalot's per-register request is addressed on this head, and the field masks match the GFX10 layout and the translator's own
Two non-blocking points:
Environment: Linux, Python 3.13.5, translator checks only, no build or GPU run. This comment was AI-assisted. |
|
Retested efb89b9 on the Windows test PC (NVIDIA, 32-lane waves) after merging current main. The gfx2hlsl.py merge with the resource-heap change is resolved. Size-field reads mark the SRV passed 10/10 twice, exit 0. passed 4/4 once, exit 0. passed 388/388 once, exit 0. AI-Assisted |
Leyukaka
left a comment
There was a problem hiding this comment.
Read efb89b92 as a diff against main c3259f27. git merge-tree --write-tree is clean and git diff --check is clean. Nothing was built or run; everything below is from reading.
Base-mip request on 735924db: partly fixed
- The refusal exists.
image_dim_calladds the SRV toimage_size_srvs, the manifest emitsimagedim %d, anddraw_translatedreturns false on
if (tr->image_size_srvs.requires(i) && !image_size_view_starts_at_resource_mip0(desc))(d3d12_draw.inl:2940). It only applies to marked SRVs, so a shifted view that is only sampled still binds. - Only the Python side is tested:
'\nimagedim 0\n' in manifeston the accepted fields,'imagedim' not in sample_manifest, and'imagedim 1' not in manifest. - Nothing under
tests/refers toImageSizeSrvs,image_size_srvsorimage_size_mip. Removing theMostDetailedMiprefusal, or makingread_manifest_linereturn false for every line, fails no test. - The requested control, one non-square texture bound at resource mip 0 and again with
MostDetailedMip=1, is not in the PR. tests/startup_d16_image_format_check.cppalready tests the parser of the similard16srvline (duplicate, leading zero, out of range). The same form would coverimagedim.
Earlier review points: fixed
- Merge with
main:image_field_expris called after the resource-heaps_add_u32path has returned ("After the resource-heap add returns: a pixel size field is not that pointer add."). - Swapped shift:
if base in ('s_bfe_u32', 's_lshr_b32') and i != 0:makes it opaque, and the check hasrefused(use('lz', 's_lshr_b32 s10, 0x1e, s17'), 's_lshr_b32 of image descriptor word 1').
Finding: on a direct draw, a marked SRV can still bind null
- The mip check is inside
if (texture && record.desc_bytes >= 40), so it is skipped when there is no texture. In the same looptextureis or becomesnullptrwhen:- the view token is unknown (
resourceis null, line 2936); packed_viewreturnsrefused(line 2963);upload_texturefails (line 2984);- the recorded
ViewDimensiondoes not match the shader (line 3000).
- the view token is unknown (
- Only
if (indirect && !texture)(line 3008) refuses. A direct draw continues toCreateShaderResourceView(texture, ...)with a null resource (line 3028). - The helper then calls
GetDimensions(0u, ...)on a null view, which does not return the descriptor's size. If it reports 0,(({0} - 1u) & 0x3fffu)gives0x3fff,(({0} - 1u) & 3u)gives3, and(({0} - 1u) >> 2)gives0x3fffffff, which is wider than the 12-bit field. - A sample from a null view already reads zeros. A size field read is different: it returns a wrong number where the translator promised the descriptor's value.
- Suggested: refuse the draw when
tr->image_size_srvs.requires(i) && !texture, next to theMostDetailedMipcase.
Test coverage
startup_gfx2hlsl_image_desc_word_controlsis registered inCMakeLists.txt, but theprtest preset filter inCMakePresets.jsondoes not include it. Thed3d12_draw.inlchange is compiled there and not tested.
Comment on efb89b92: the shifted-view refusal is in place but has no test, and a null binding of a marked SRV still reaches a direct draw.
efb89b9 to
0364b66
Compare
|
Review of Leyukaka's two items are fixed. The decision now lives in
SHOULD
This change only affects AI-assisted. |
A pixel stage can read the exact GFX10 width, height and 3D depth fields of an image descriptor as numbers. Other words and uses stay refused. Fixes part of R0Y00#2022 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
A pixel size-field read uses the dimension of the descriptor load the image instruction reads. Another load into the same SGPRs does not borrow it. A copy of the sampled words still does. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
s_lshr_b32 of a size field lowers only when the descriptor word is the value being shifted. A size-field SRV is marked imagedim, and the draw path refuses that view when MostDetailedMip is not 0. Sampling a shifted view that does not read a size field is unchanged. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
A marked SRV is refused when MostDetailedMip is not 0 and when the direct draw would bind no texture. The imagedim parser and both refusals are covered without a device. An unmarked sample is unchanged. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
0364b66 to
1820f87
Compare
|
Windows test PC (MSVC, 5/5 passed, ctest exit 0.
The branch is rebased onto main AI-Assisted |
pigalot
left a comment
There was a problem hiding this comment.
Retested 1820f876 integrated over main c04e0dd6 (tree c78a8fed). The merge is clean and git diff --cached --check is clean.
A correction first. On 2026-11-28 I wrote here that another reviewer would check the merged head 735924db. That was wrong: this account reviewed 735924db itself the same day, and I'm reviewing this head myself now. The branch has been rewritten since, so my merge commit 735924db is no longer in it. All four commits on this head are the author's.
Earlier findings at this head.
- Dimension per register (my request on
e264b8c7): still addressed. Theearly,keptandreloadedcases are in the check and pass. A mutant that letsimage_wordtake any keyed load's dimension fails onearly. - Swapped shift (JohnConnorNPC): addressed.
s_lshr_b32 s10, 0x1e, s17is refused. Narrowing the operand-order guard back tos_bfe_u32fails the check. - Null marked SRV on a direct draw (Leyukaka): addressed in the code.
image_size_bind()is called after every path that setstexture = nullptr, and it returnsrefuse_nullbefore it looks at the descriptor. - Base mip (R0Y00's request on
735924db): enforced in the code, but not shown by a test. See the finding.
What I traced.
image_size_bind()readsdesc.Texture2D.MostDetailedMip. That is the first union field of every texture view the manifest can mark (srv.kind1 to 5), and a view of another dimension has already been turned into a null texture by then. Without a recorded 40-byte descriptor the view is created with a null descriptor, which starts at mip 0, soproceedis right there.- The manifest index is the position in
tr->srvs(load_translationonly appendssrv iwheni == tr.srvs.size()), somarks(i)tests the SRV the translator marked. - Translator probes with the check's own helpers: a size field written to
m0is refused;s_and_b32 s10, 0xfff, s18(constant first) ands_lshr_b32 s10, s17, 30(inline constant) lower to the same expressions as the fixture forms;s_lshr_b32 s10, s17, 62is refused.
Finding: nothing reaches the new refusal in draw_translated.
- Mutant. In
src/startup_stubs/d3d12_draw.inlI replacedtr->image_size_srvs.marks(i)withfalse, made theimagedimmanifest branch accept every line without reading it, and dropped theimage_size_srvs.valid_for_srvs()check. That removes the whole feature from the runtime. - Result. I rebuilt
offscreen_check,d3d12_xs_shim,startup_indirect_draw_indexedandstartup_image_size_mip_check, then ranctest --test-dir out/build/dev --no-tests=error -j 8 -R '(^startup_gfx2hlsl_|image|cube|^startup_indirect_|mip)' -E '(_hardware$|startup_audio)': 419 tests selected, 0 failed. - Why.
imagedimappears only in the Python check (manifest text) and intests/startup_image_size_mip_check.cpp(the header alone). No test loads a manifest with animagedimline into the runtime, and no test draws through a marked SRV. - The unit test's wording. It prints
non-square 8 x 4 mip 0 allowed, MostDetailedMip 1 refused. The 8 and 4 are two constants compared with themselves. No texture or view exists in that test, so it does not distinguish a mip-0 view from a shifted one in the way R0Y00's request describes. It also doesn't show thatGetDimensions(0)on a mip-0 view gives the descriptor's fields: that still rests on the HLSL text. - Suggested direction (unconfirmed).
tests/startup_indirect_draw_indexed.cppalready loads hand-written manifests (srv 0 tex2d table 0 0), records views withMostDetailedMip=1, and asserts refusal reasons from the census (sampled_texture_mismatch). A case there withimagedim 0and a non-square texture would do it: the mip-0 view draws, theMostDetailedMip=1view reportsimage_size_mip, and the same shifted view without theimagedimline still draws. A failing control is the call-site mutant above. A pixel fixture that returns the lowered width and height from the mip-0 draw would also show the equivalence.
What I ran.
- Builds: full
devandrelease/O2. - Tests:
ctest --test-dir out/build/<preset> --no-tests=error -j 8 -R '(^startup_gfx2hlsl_|image|cube|^startup_indirect_|^startup_tools_lint$)' -E '(_hardware$|startup_audio)'gives 414 tests in each preset: 403 pass, 0 fail and 11 are capability skips (native_image_*_warp).startup_image_size_mip, its three controls andstartup_gfx2hlsl_image_desc_word_controlspass in both. - Hardware:
ctest --test-dir out/build/dev --no-tests=error -j 1 -R '^(startup_indirect_.*|startup_image_.*)_hardware$'with the debug layer on: 47 of 47 pass, no skips. - On
mainc04e0dd6the two new tests are not registered. Withimage_field_exprstubbed to returnNone, the Python check fails atnumeric use of s10 holding descnum. - Real-title run of this head against the baseline: pass.
Mutants. Each ran after an unmutated baseline that passes; files were restored afterwards and git diff --quiet is clean.
tools/startup/gfx2hlsl.py against tests/startup_gfx2hlsl_image_desc_word_check.py:
| Mutant | Result |
|---|---|
image_field_expr returns None |
killed |
operand-order guard covers s_bfe_u32 only, or is removed |
killed (both) |
| a size read does not mark the SRV | killed |
the manifest drops imagedim lines |
killed |
every SRV is marked imagedim |
killed |
| the mark is index + 1 | killed |
depth template mask 0x1fff to 0xfff |
killed |
helper calls GetDimensions(1u, ...) |
killed |
image_word takes any keyed load's dimension |
killed (early) |
depth allowed on tex2d |
killed (KeyError) |
| key drops the dword index | survives |
the 8-word same check becomes key is not None |
survives |
| the pre-scan's branch early return is removed | survives |
the pre-scan ignores offset: |
survives |
| the pre-scan keeps a symbol across other scalar writes | survives |
the not pair and dst[1] == dst[2] condition on the value path is dropped |
survives |
| the value path sets no SCC | survives |
image_word accepts a 4-dword load's span |
survives |
src/startup_stubs/image_size_mip.h against startup_image_size_mip and its controls:
| Mutant | Result |
|---|---|
refuse_mip dropped |
killed |
refuse_null dropped |
killed |
| mip refused without a recorded descriptor | killed |
| unmarked SRV checked too | killed |
| leading zero accepted | killed |
| duplicate accepted | killed |
| mark past the SRV count accepted | killed |
| kind check dropped, kind 5 rejected, kind 0 accepted | killed (all three) |
digits.size() > 2 becomes > 3 |
survives |
src/startup_stubs/d3d12_draw.inl: the call-site mutant in the finding survives. I found no equivalent mutants.
Non-blocking.
- The first five surviving translator mutants are the ones from my review of
4f75193e. The near-miss controls I listed there would still pin them: anx16load sampled with twodim:, an operand with one word replaced, ans_add_u32on a word before the sample, and a forward branch around the load. - A size field read with an
sccconsumer and a three-digitimagedim 031line have no case. indirect_refusal_code::image_size_nullcan't be reported: on an indirect draw,if (indirect && !texture)returnssampled_texture_unbindablefirst. Onlyimage_size_mipis reachable there.AGENTS.mdasks for new notes indocs/experiments/<topic>.mdand onetests/cmake/<family>.cmakeper family; this PR adds todocs/experiments.mdandCMakeLists.txt.
Verdict: changes requested on 1820f876. The refusal R0Y00 asked for is in the code and reads correctly, but the runtime wiring can be removed without failing a test. R0Y00's changes request on 735924db is still open as well.
Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088, Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; debug layer on for the hardware tests.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 1820f876.
This reply was AI-assisted.
Pixel shaders can now read the size fields of an image descriptor as numbers.
In gfx2hlsl, a pixel stage that uses an 8-dword image descriptor can extract width, height, and (for a 3D image) depth with the exact
s_bfe_u32,s_and_b32, ors_lshr_b32for that field. Those lower toGetDimensions(0)on the texture the image instruction already binds. Width is the usual split: word 1 bits 31:30 and word 2 bits 11:0, stored as width minus one. Height is word 2 bits 27:14. Depth is word 4 bits 12:0 and only for 3D.A whole word, any other word or field, a shift of word 2 that also keeps the resource-level bit, depth on a 1D, 2D, or 2D-array image, height on a 1D image, a modified word, and
m0still refuse, and the message says which word or op. Buffer descriptors and the compute and vertex stages are unchanged.A marked SRV is refused when
MostDetailedMipis not 0 and when the direct draw would bind no texture.image_size_bind()insrc/startup_stubs/image_size_mip.hmakes that decision. An unmarked sample is unchanged.startup_image_size_mipcovers a non-square 8 x 4 view at resource mip 0, the same view atMostDetailedMip1, a marked SRV with no texture, and the imagedim parser. The threeWILL_FAILcontrols drop the mip refusal, drop the null refusal, or reject valid imagedim lines. Theprpreset now also runsstartup_gfx2hlsl_image_desc_word_controlsandstartup_image_size_mip.Verification
Commit
1820f8763ce4488848e6701ab35edf17c72910bb, rebased onto mainaf1cab5ceb7b9ecbe06acf358b5b6477c265de9b. The branch is 5 commits behind current mainc04e0dd6e9b73cf7ecd096ef71aa3e9115035e3cand still merges cleanly.Windows test PC (MSVC,
--preset dev,-j 1). Build exit 0. Then:5 of 5 passed, ctest exit 0. The three
startup_image_size_mip_*_controltests areWILL_FAILand failed as required.Not in this head: the
_controltests still override the helper's result inside the test rather than mutatingsrc/, and there is no device draw at mip 0 and atMostDetailedMip=1.Fixes part of #2022
AI-assisted (Cursor)