native: read 2D table texture width and base level from entry words #3500
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3500"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T18:24:16Z.
Refs #3224 (claimed in https://github.com/R0Y00/Xbox2Windows/issues/3224#issuecomment-7259450865), #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
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T18:38:27Z.
Review: CHANGES_REQUESTED
Diff-only review of
b33ca9cb(not built, not run).Must fix. The Linux Python job is red:
tests/startup_triage_run_check.pyreports five source reasons missing fromCOMPUTE_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. Thes_cmp_lg_*and_i32forms (src/gfx1013_direct_compute.inl:3213-3216, thenull_lgfold at:3413) are never assembled, and no branch consumes the SCC written for the replaceds_bfe_u32/s_and_b32(:3416). One more fixture line withs_cmp_lg_u32 s25, 0would cover the other constant.Should. "With
src/reverted, the three new tests fail" countsnative_compute_manifest_reasons, which then stops compiling (noimage_fieldsmember). CONTRIBUTING.md💯 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.Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T21:13:35Z.
Thanks. The must-fix is in
e37bd1ad: the five reasons are inCOMPUTE_DISPATCH_REASONS, andtests/startup_triage_run_check.pypasses locally (0 failed). The two shoulds (ans_cmp_lg_u32line plus a branch on the replaced SCC in the fixture, and a one-line mutation check instead of the build-break revert) are next on this branch.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T21:37:53Z.
@Leyukaka both shoulds are in
b04c1a7f.Fixture. It now also assembles
s_cmp_lg_u32 s25, 0with a branch over a store (word 4), and a base read and a width_hi read, each followed bys_cbranch_scc0over a store (words 5 and 6). So the SCC of a replaced read is consumed. Base 0 on the undescribed view covers the SCC 0 path. The width_hi read is only seen with SCC 1, because both views have width 8.One-line mutations in
src/gfx1013_direct_compute.inl, each rebuilt and run (local RTX 3080, hardware adapter):null_lgwrites SCC"0"instead of"1"cmp("eq", ...)instead of"ne"0x3ffinstead of0x3fff"1"instead of"3"The first two only show on hardware: WARP runs the HLSL stand-in, not the translator's DXIL. After the restore,
ctest -R 'image_fields|manifest_reasons|triage_run'passes 7/7.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T21:59:01Z.
Review: COMMENTED
Diff-only re-review of
b04c1a7f(not built, not run). The earlier points are addressed: the five reasons are intools/startup/triage_run.py(:119, :125-127, :228); the fixture now assembless_cmp_lg_u32 s25, 0and two field reads whose SCC is consumed bys_cbranch_scc0(words 4-6); the revert question is answered by the foursrcmutations listed in the comment (not reproduced here).Nits: the
_i32compare forms are still not assembled, and the PR body still says the three new tests fail withsrc/reverted.Only blocker: conflict with main (
ff9dcef0) intests/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'smode.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).
Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-11-29T22:26:02Z.
@Leyukaka merged
mainin39cbf13b(no rebase, so your earlier review comments keep their anchors). Intests/startup_stream_consumer.cppI kept both conditions, joined with||.2902e500adds the_i32forms:s_cmp_eq_i32ands_cmp_lg_i32word 1, 0, each with a branch over a store (words 7 and 8). The PR body now lists the mutations instead of the revert.Local, after the merge:
ctest -R 'startup_compute|image_fields|manifest_reasons|triage_run'passes 210/210. The 10 skips are the WARP wave32 cases, as onmain.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-29T22:32:12Z.
Review: APPROVED
Re-read at
2902e500(diff only, not built here). The merge of main intests/startup_stream_consumer.cppkeeps both conditions: thedispatch-texdim-fieldsprefix and main'sX2W_TEST_RECORDS32=1check, joined by||.The new words decode as intended:
198000bfis SOPC op 0s_cmp_eq_i32 s25, 0and198001bfis op 1s_cmp_lg_i32 s25, 0, each followed by a 2-dword branch over onebuffer_store_dword(offsets 28 and 32), so the_i32names accepted atgfx1013_direct_compute.inl:3282-3285are now exercised.The body now lists the four one-line
srcmutations instead of the earlier sentence, and CI is green on this head. Approving.Imported from R0Y00/Xbox2Windows. Originally posted by Not-Saii on 2026-11-29T23:53:13Z.
Review: APPROVED
Review of
2902e500: a static read and an isolated sandbox build and run (details at the end).The earlier review points are addressed at this head:
tools/startup/triage_run.py;s_cmp_lg_u32and the_i32forms, with branches that consume the SCC of the replaced reads;||.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: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:
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
2902e500(run 46317728773) passed, but: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.tests/startup_triage_run_check.py(0 failed).The
b04c1a7fcomment 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, addstartup_compute_dispatch_image_fields_controlsandnative_compute_manifest_reasonsto theprpreset. Neither needs WARP or a GPU: the first needs onlycompile_dxiland DXC, which the Windows PR job already builds.NIT 1: the fixture's
binarymode runs nowhere in CI.startup_compute_dispatch_image_fields_check.py binaryis not in theCHECKSlist 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:273asserts that the layer was enabled. On a host without the Graphics Tools SDK layers,_warpand_hardwarefail at that line, and the sections after it never run. This followsstartup_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:
more than 32 entry words with image fields,an image descriptor field has no sampled textureand... more than one texture binding;.csirfield. Publishing twice over the same cache and rerunningcheck_manifestwould cover it.What each test proves
startup_compute_dispatch_image_fields_controls(compile only):ud 4,udsrc 2 imgwidth 0,udsrc 3 imgbase 0andsrv 0 tex2d table 1 64;0x3ffmask, the format-field bfe and the program without the image op each keep theunbound numeric SGPRrefusal;This shows the matcher is narrow. It runs nothing.
startup_compute_dispatch_image_fields_warp: an HLSL stand-in replaces the published.cs.cso. The test covers: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, theprepare_image_fields();call was commented out.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.Sandbox run (AGENTS.md fields)
2902e500895ac2cd82bfa1c38e4048c42ca3eed5, exported withgit archive, merge base2ff74a6ac3. The sandbox had networking disabled and the tree mapped read-only.D3D12GetDebugInterfaceprobe returnedhr=0x00000000, andX2W_D3D12_DEBUG=1was set. The build was configured with the Agility SDK 1.620 directory.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}.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.image_fieldstests, as expected), 0 skipped.tests/startup_triage_run_check.pyon Linux (see SHOULD 2).Approving. The SHOULDs are about evidence and CI coverage, not behavior.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-02T07:13:24Z.
@JB2WIN this one has two approvals and green checks, but it now conflicts with
mainand has fallen quite far behind. Do you plan to rebase it? If you would rather not, we are happy to carry the rebase for you, keeping your commits as they are. Either way works for us.Imported from R0Y00/Xbox2Windows. Originally posted by JB2WIN on 2026-12-02T18:56:45Z.
@Leyukaka thanks, merged
main46d465d9inb4f7b6a7(a merge again, no rebase, so the review anchors stay). The conflicts came from main's cache visitor andstride_sources:image_fieldsis now incache_fields, the round-trip fixture andvalidate_shader, and the image words still follow the stride words in the translator, manifest and runtime.Local, RTX 3080:
ctest -R 'image_fields|manifest|direct_cache|native_compute|startup_compute|triage_run'gives 256/265. The 9 failures (startup_compute_dispatch_input_*,input_view_token_*,root_srv_dispatch_*,root_uav_native_warp,snapshot_order_*) fail the same way onmain46d465d9without this branch.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T19:10:54Z.
Review: APPROVED
Re-reviewed
b4f7b6a7after the cache visitor merge. Both stride sources and image fields survive serialization. The native revision is a hash of the changed source files, so the earlier frontend blobs do not use the new layout. Independent MSVC Debug on Windows 11 build 26300 passedctest --preset dev --no-tests=error -V -j 1 -R '^startup_compute_dispatch_image_fields_(controls|warp|hardware)$'(3/3). WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 matched width 8, base mip 1, the skipped store and texel 105.0 with the debug layer enabled. The twonative_direct_cacheand twonative_compute_manifest_reasonschecks also passed.