shader: lower pixel image descriptor size fields read as numbers #3227
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!3227
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3225"
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?
@SimSalabimse on GitHub · 2026-11-27 23:37 UTC · original
SimSalabimse:cursor/ps-desc-word-numeric→main· +776 −12 · 11 files · 12 commits · openPixel 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)
@KelboLive on GitHub · 2026-11-27 23:41 UTC · original · approved these changes
Review of PR #3227 — 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.Assessment
image_spantracking correctly follows descriptor data acrosss_mov_b32moves, which is important for correctness when registers are reused.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 on GitHub · 2026-11-27 23:41 UTC · original · requested changes
I reviewed
e264b8c7merged over currentmain58e3183a. The merge is clean (treed99811ce) andgit diff --cached --checkis clean.What I traced.
s_bfe_u32control,s_and_b32mask ands_lshr_b32shift inIMAGE_FIELDSextracts exactly that field.GetDimensions(0), so the& 3,>> 2,& 0x3fffand<< 14/<< 30forms are right.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:and 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 forsrv N tex2d|tex1d|tex2da|tex3dreturns the descriptor's size. That holds only under the base-mip contract the docs describe.Verdict: changes requested on
e264b8c7for 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 fixturesandRun platform-independent Python checks on Linuxpass one264b8c7.This reply was AI-assisted.
@R0Y00 on GitHub · 2026-11-27 23:54 UTC · original · reviewed
I reproduced the same provenance bug in the opposite instruction order on
e264b8c7overmainc7215add(trial tree313b5535). The existing descriptor-field Python suite passes, and the following source-built pair adds a distinction a fix should preserve.In the
lzfixture, copys18tos28beforeimage_sample, which uses the descriptor from table byte offset 0. Afterimage_sample, reloads[16:23]from table byte offset 32 and wait. Extracts_and_b32 s10, s28, 0xfffin the positive case or uses18in the negative case, then moves10tov4.The copied value correctly emits
img_width_tex2d(r0)and one SRV at offset 0. The reloadeds18incorrectly emitsimg_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.@akimfomin on GitHub · 2026-11-28 01:33 UTC · original
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
GetDimensions(0)against the guest descriptor's width/height/depth fields for both base-mip and shifted cases. This is a proposed synthetic check, not proof of a mismatch.@pigalot on GitHub · 2026-11-28 04:25 UTC · original · approved these changes
Retested
4f75193eintegrated over currentmain32221f1a.Conflict with
main. The merge now conflicts intools/startup/gfx2hlsl.py, inPipeline's SRV declaration loop. #2960 added'texcube': 'TextureCube<float4>'to the same type map that this branch follows with theimg_<component>_<kind>helper loop. For testing, I keptmain's line and added this branch's helper loop under it (tree5bf8a8d1,git diff --cached --checkclean).IMAGE_DIMhas noSQ_RSRC_IMG_CUBEentry, so a cube-sampled descriptor gets no key inimage_desc_dim, and its size-field reads stay refused.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.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.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).What I ran.
dev.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).python -B tests/startup_tools_lint_check.py tools/startuppasses.Mutants of
tools/startup/gfx2hlsl.py, each run againsttests/startup_gfx2hlsl_image_desc_word_check.pyafter an unmutated baseline that passes:image_wordtakes any keyed load's dimension (per-register borrowing back)early)used as tex2d and tex3d)samecheck is replaced bykey is not Nones_movkeeps the word's symbol in the pre-scanoffset:s_movdrops the copyRestored afterwards;
git diff --quietis 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.
s_load_dwordx16would borrow the first image's dimension.samecheck: a mixed or modified operand would still be keyed.x16load whose two halves are sampled with differentdim:;s_mov_b32 s17, 0;s_add_u32 s16, s16, 0before the sample;s_cbranch_scc0around the load.s_movcopy or keeping the old words.Verdict: the per-register finding is addressed on
4f75193e. Approve on4f75193eas reviewed. It needs amainmerge for the #2960 conflict before it can land, and the merged head needs another look then. This supersedes my changes-requested review one264b8c7.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 fixturesandRun platform-independent Python checks on Linuxpass on4f75193e.This reply was AI-assisted.
@pigalot on GitHub · 2026-11-28 04:43 UTC · original
I pushed a merge of current
main240e0fb9into this branch as735924db. It is a merge commit on top of4f75193e, with no rebase or force-push.Conflict resolved. The only conflict was in
tools/startup/gfx2hlsl.py, inPipeline's SRV declaration loop. #2960 added'texcube': 'TextureCube<float4>'to the type map. I kept that line and this branch'simg_<component>_<kind>helper loop after it. Nothing else changed in the resolution. This branch'sIMAGE_DIMhas no cube entry, so a cube-sampled descriptor's size fields stay refused.What I ran on
735924db.devandrelease/O2.ctest --test-dir out/build/<preset> --no-tests=error -j 8 -R '(^startup_gfx2hlsl_|image|cube)' -E '(_hardware$|startup_audio)'gives 346 tests in each preset: 338 pass, 0 fail and 8 are capability skips (native_image_*_warp).python -B tests/startup_gfx2hlsl_image_desc_word_check.pypasses. My earlier probe still refuses both reload orderings and accepts the copied-descriptor case.ctest --test-dir out/build/dev --no-tests=error -j 8 -E '(startup_audio|_hardware$)'gives 2032 tests: 1973 pass, 0 fail and 59 are capability skips.Because I made this merge, my approval on
4f75193edoesn't cover735924db. Another reviewer will check the merged head.This reply was AI-assisted.
@R0Y00 on GitHub · 2026-11-28 05:03 UTC · original · requested changes
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_exprboth scope the lowering to views that start at resource mip 0. The generated helper always queriesGetDimensions(0u, ...), while the manifest emits an ordinary texture SRV. Ind3d12_draw.inl, the texture path copies the recorded SRV descriptor and passes it toCreateShaderResourceViewwithout checkingMostDetailedMipfor 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=1should distinguish the two. Keep the check scoped to numeric descriptor reads so ordinary sampling through a shifted view still works.@pigalot on GitHub · 2026-11-28 06:07 UTC · original · reviewed
Re-reviewed the merge of
maininto this branch at735924db(parents4f75193eandmain240e0fb9).git diff --check origin/main...735924dbis clean.Resolution.
git show --remerge-diff 735924dbshows one conflict hunk, inPipelineSRV declarations intools/startup/gfx2hlsl.py. The merge keepsmain's'texcube': 'TextureCube<float4>'entry from #2960 and this branch'simg_<component>_<kind>helper loop. Nothing else changed. I also checked that the two sides don't meet: the branch'sIMAGE_DIMmap has noSQ_RSRC_IMG_CUBE. A cube descriptor therefore never entersimage_desc_dim, so its size fields stay on the existing path. The newIMAGE_DIM_HAS/IMAGE_DIM_TYPE/IMAGE_DIM_READlookups can't raiseKeyErrorontexcube.What I ran. I built
offscreen_checkindevandreleaseand ranctest --test-dir out/build/<preset> --no-tests=error -R '^startup_(gfx2hlsl_.*|image_.*)$', with the_hardwaretests at-j 1:/O2, includingstartup_gfx2hlsl_image_desc_word_controlsandstartup_image_cube_controls.startup_image_cube_hardware.Control and mutants on the resolved lines. Each was run against
startup_gfx2hlsl_image_desc_word_controlsandstartup_image_cube_{controls,warp,hardware}:tools/startup/gfx2hlsl.pyback tomain240e0fb9(control)main'stexcubeSRV entrywidth lo bfe); the cube tests passRestored afterwards;
git diff --quietis clean.Open request. R0Y00's changes request on
735924dbstill applies, and the merge doesn't touch it. I read the code and it agrees with that request. The helper always callsGetDimensions(0u, ...)on the SRV the draw path creates from the recorded descriptor. WithMostDetailedMip=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.
@SimSalabimse on GitHub · 2026-11-28 06:25 UTC · original
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
andofs18before the fixture's own offset-0 load get refused. Copyings18tos28before the sample and then reloadings[16:23]from offset 32 still accepts theandofs28as the one SRV at offset 0, and refuses theandof the reloadeds18.IMAGE_DIM_HASandIMAGE_DIM_NAMEare used for the dimension check and the refusal text now.Retested
4f75193eon Windows: image_desc_word passed twice, startup_gfx2hlsl_ 386/386 passed.AI-Assisted
@JohnConnorNPC on GitHub · 2026-11-28 07:13 UTC · original
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
s_bfe_u32template. I reviewed735924db, merged over currentmain, and three issues still need fixing before this can land:main.git merge-tree --write-tree origin/main 735924dbexits 1 withCONFLICT (content): Merge conflict in tools/startup/gfx2hlsl.py. All three hunks are against #2861 (resheap): the new methods, the descriptor-ALUs_add_u32path and the SRV declaration loop. When I kept both sides, with main's lines first, this PR's check, the image sample_l, cselect_descnum, load_desc, scalar_m0, image_get_lod, cube, 2d_array and 3d checks,startup_compute_waterfall_heap_check.pyandstartup_tools_lint_check.py tools/startupall exit 0. Please mergemainand confirm thatimage_field_exprstill runs after the resheaps_add_u32early return.tex.GetDimensions(0u, ...). Insrc/startup_stubs/d3d12_draw.inl, the texture path runsstd::memcpy(&desc, record.desc, 40)and never checksMostDetailedMip, so a view that starts at mip 1 returns that mip's size and not the descriptor's mip-0 fields. Please refuse these field reads unless the view starts at mip 0, or add the non-square mip-0 vsMostDetailedMip=1control that was requested.s_lshr_b32 s10, 30, s17(the descriptor word as the shift amount) is accepted as WIDTH_LO. I spliced it into thelzfixture with the check's ownuse()andps(), and both this head and the merge emits10 = ((img_width_tex2d(r0) - 1u) & 3u);. The translator's template is's_lshr_b32': ('{0} >> ({1} & 31)', so the real value is30 >> (word1 & 31). Onlys_bfe_u32has the operand-order guard (if base == 's_bfe_u32' and i != 0). Applying it to the shift as well, plus a refusal control for the swapped form, would fix this.Two non-blocking points:
gfx2hlsl.pyagainststartup_gfx2hlsl_image_desc_word_check.pyon the merge. Stubbingimage_field_exprand droppingdims[key] = Noneboth fail the check. It still passes (exit 0) with the operand-order guard disabled, withimage_desc_keyreturning(sym[1], sym[2])(no dword index), and with the branch early return innote_image_descriptorsremoved. pigalot's near-miss controls from the earlier review would pin these: an x16 load with twodim:, and ans_cbranch_scc0around the load.tests/startup_gfx2hlsl_image_desc_word_check.py (ok, 0.5s), and the Windows job'sctest --preset prlog never mentionsimage_desc_word.Environment: Linux, Python 3.13.5, translator checks only, no build or GPU run.
This comment was AI-assisted.
@SimSalabimse on GitHub · 2026-11-28 11:04 UTC · original
Retested
efb89b92e6on 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
imagedim, and the draw path refuses that view when MostDetailedMip is not 0.s_lshr_b32of a size field lowers only when the descriptor word is the value being shifted, not the shift amount. That covers JohnConnorNPC's three items (merge, base mip, shift operand order). Noimage_desc_wordhardware/draw tests are registered; coverage there isstartup_gfx2hlsl_image_desc_word_controls.passed 10/10 twice, exit 0.
passed 4/4 once, exit 0.
passed 388/388 once, exit 0.
AI-Assisted
@Leyukaka on GitHub · 2026-11-29 10:10 UTC · original · reviewed
Read
efb89b92as a diff againstmainc3259f27.git merge-tree --write-treeis clean andgit diff --checkis clean. Nothing was built or run; everything below is from reading.Base-mip request on
735924db: partly fixedimage_dim_calladds the SRV toimage_size_srvs, the manifest emitsimagedim %d, anddraw_translatedreturns false onif (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.'\nimagedim 0\n' in manifeston the accepted fields,'imagedim' not in sample_manifest, and'imagedim 1' not in manifest.tests/refers toImageSizeSrvs,image_size_srvsorimage_size_mip. Removing theMostDetailedMiprefusal, or makingread_manifest_linereturn false for every line, fails no test.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
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.").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
if (texture && record.desc_bytes >= 40), so it is skipped when there is no texture. In the same looptextureis or becomesnullptrwhen:resourceis null, line 2936);packed_viewreturnsrefused(line 2963);upload_texturefails (line 2984);ViewDimensiondoes not match the shader (line 3000).if (indirect && !texture)(line 3008) refuses. A direct draw continues toCreateShaderResourceView(texture, ...)with a null resource (line 3028).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.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.efb89b92e6to0364b6690d@JohnConnorNPC on GitHub · 2026-11-29 12:55 UTC · original
Review of
0364b669(merge-base = main77d1ba4d). Verdict: hold for R0Y00's change request on735924db. In my reading it is addressed: the PR takes R0Y00's first option and enforces the base-mip rule. Only R0Y00 can clear it.Leyukaka's two items are fixed. The decision now lives in
image_size_mip.hasimage_size_bind(). It refuses a marked SRV with no texture (refuse_null) and one whose recorded view hasMostDetailedMip != 0(refuse_mip), and the call moved after every path that setstexture = nullptr, so a null texture is refused whateverdescholds. The paths that keep a texture and rewritedesc(the packed stand-in) change only the format. What I ran (Linux, g++ 14, Python 3.13):g++ -std=c++17 -Isrc tests/startup_image_size_mip_check.cpp→ rc 0,non-square 8 x 4 mip 0 allowed, MostDetailedMip 1 refused, null marked SRV refused, imagedim parser verified.--mutate drop-mip,drop-nullandreject-lineseach exit 1.tests/startup_gfx2hlsl_image_desc_word_check.py→ rc 0.prpreset:Test #587: startup_image_size_mip ... Passed,Test #967: startup_gfx2hlsl_image_desc_word_controls ... Passed,100% tests passed out of 86.SHOULD
_controltests override the helper's result inside the test (bind()mapsrefuse_mip/refuse_nullback toproceed). They show the test would notice a changed result, but they don't mutatesrc/. Nothing reaches the call site either:git grep -n image_size_bind 0364b669 -- testsfinds only the unit test. Replacingtr->image_size_srvs.marks(i)indraw_translatedwithfalsewould pass every test. R0Y00's suggested device control (one non-square texture through a draw at mip 0 and atMostDetailedMip=1) would pin the wiring.This change only affects
-Translateruns: pixel manifests aren't loaded withX2W_NATIVE_SHADERS_ONLY=1, the launcher default since #3451.AI-assisted.
0364b6690dto1820f8763c@SimSalabimse on GitHub · 2026-11-29 13:10 UTC · original
Windows test PC (MSVC,
--preset dev,-j 1), at1820f8763ce4488848e6701ab35edf17c72910bb.cmake --build --preset devexit 0.5/5 passed, ctest exit 0.
startup_image_size_mip: non-square 8 x 4 mip 0 allowed,MostDetailedMip1 refused, null marked SRV refused, imagedim parser verified.startup_image_size_mip_drop_mip_control(WILL_FAIL):MostDetailedMip1 of 8 x 4 was not refused.startup_image_size_mip_drop_null_control(WILL_FAIL): marked SRV with no texture was not refused.startup_image_size_mip_reject_lines_control(WILL_FAIL): imagedim 0 or 31 refused.startup_gfx2hlsl_image_desc_word_controls: pixel image descriptor size fields: width, height and 3D depth lowered; other words refused.The branch is rebased onto main
af1cab5c. It is 5 commits behind current mainc04e0dd6and still merges cleanly. 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.AI-Assisted
@pigalot on GitHub · 2026-11-29 13:27 UTC · original · requested changes
Retested
1820f876integrated overmainc04e0dd6(treec78a8fed). The merge is clean andgit diff --cached --checkis 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 reviewed735924dbitself the same day, and I'm reviewing this head myself now. The branch has been rewritten since, so my merge commit735924dbis no longer in it. All four commits on this head are the author's.Earlier findings at this head.
e264b8c7): still addressed. Theearly,keptandreloadedcases are in the check and pass. A mutant that letsimage_wordtake any keyed load's dimension fails onearly.s_lshr_b32 s10, 0x1e, s17is refused. Narrowing the operand-order guard back tos_bfe_u32fails the check.image_size_bind()is called after every path that setstexture = nullptr, and it returnsrefuse_nullbefore it looks at the descriptor.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.tr->srvs(load_translationonly appendssrv iwheni == tr.srvs.size()), somarks(i)tests the SRV the translator marked.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.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.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.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.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.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.
devandrelease/O2.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.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.mainc04e0dd6the two new tests are not registered. Withimage_field_exprstubbed to returnNone, the Python check fails atnumeric use of s10 holding descnum.Mutants. Each ran after an unmutated baseline that passes; files were restored afterwards and
git diff --quietis clean.tools/startup/gfx2hlsl.pyagainsttests/startup_gfx2hlsl_image_desc_word_check.py:image_field_exprreturnsNones_bfe_u32only, or is removedimagedimlinesimagedim0x1fffto0xfffGetDimensions(1u, ...)image_wordtakes any keyed load's dimensionearly)tex2dKeyError)samecheck becomeskey is not Noneoffset:not pair and dst[1] == dst[2]condition on the value path is droppedimage_wordaccepts a 4-dword load's spansrc/startup_stubs/image_size_mip.hagainststartup_image_size_mipand its controls:refuse_mipdroppedrefuse_nulldroppeddigits.size() > 2becomes> 3src/startup_stubs/d3d12_draw.inl: the call-site mutant in the finding survives. I found no equivalent mutants.Non-blocking.
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.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 on735924dbis 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 fixturesandRun platform-independent Python checks on Linuxpass on1820f876.This reply was AI-assisted.
@R0Y00 on GitHub · 2026-12-02 19:45 UTC · original · reviewed
Current head
0e130ff3passed all five focused Windows/MSVC Debug checks selected byctest --preset dev --no-tests=error -j 1 -V -R '^startup_image_size_mip|^startup_gfx2hlsl_image_desc_word_controls$'. The current change still covers parser and bind decisions in isolation. The requested runtime case remains open: load animagedimmanifest, read back the dimension of a non-square mip-0 view and demonstrate the shifted-view refusal while the unmarked control still draws. The trial merge now conflicts only inCMakePresets.json.@SimSalabimse on GitHub · 2026-12-02 20:25 UTC · original
Reply to #3227:
Merged current
maininto this branch. The only conflict wasCMakePresets.json: I keptstartup_image_size_mip_checkin the build targets andstartup_gfx2hlsl_image_desc_word_controlsandstartup_image_size_mip*in the PR test selection. This push only merges main; the requested runtime imagedim case is a separate change and is not included here.Run on the Windows test PC (Debug build of the merged head, GPU tests one at a time), selection
image_desc|image_size|startup_image|gfx2hlsl_image|standin: 65 of 66 pass. The one failure isstandin_exports_check(d3d12_xs entries 84 != 83), which fails the same way on currentmainand does not involve this PR's files.AI-Assisted
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.