translator: check 3D image sampling with a source-built draw #1237
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1244"
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 Jess-Doit on 2026-11-24T05:06:58Z.
Change
Refs #1149. This is the first of the two fixtures claimed there.
tools/startup/gfx2hlsl.pytranslatesimage_samplewithdim:SQ_RSRC_IMG_3Dinto aTexture3D<float4>sampled with afloat3coordinate, but nothing checked it. This adds a source-built check, with no translator change.The fixture is a gfx1013 pixel stage in
tests/startup_image_3d_check.py, recorded as words and as assembly. It:s_mov_b32;s9);dim:SQ_RSRC_IMG_3Dand exports the result.Checks
Translation (pure Python, no arguments)
Texture3D<float4> r0 : register(t0),r0.Sample(q0, float3(F(v0), F(v1), F(v2)))withv2 = ud1, and the manifest linessrv 0 tex3d table 0 0andsmp 0 0x0 0x0 0x0 0x0.Texture2Dandfloat2(F(v0), F(v1)), withsrv 0 tex2d.dim:SQ_RSRC_IMG_1Dis refused (image dimension SQ_RSRC_IMG_1D).binary <llvm-mc>: the 3D, 2D and 1D sources reassemble to the recorded words. This is added to the gfx1013 CI job.draw <dxc> <offscreen_check> <adapter> [fxc]: compiles the translated stage with DXCps_6_0, and with FXCps_5_1when available, then draws one pixel throughoffscreen_check --startup-image-3d(tests/startup_image_3d.cpp).Texture: 2×2×2
R32G32B32A32_FLOAT. Texel (x, y, z) holds ((1 + x + 2y + 4z) / 8, x, y, z), so the readback names the texel. Sampling uses a static point sampler with wrap addressing.Cases: z = 0.25, 0.75 and 1.75 must read texels (1, 0, 0), (1, 0, 1) and (1, 0, 1); the last one wraps. All four channels are compared bit for bit.
Negative controls on the translated HLSL:
Each must fail with exactly that texel.
Verification
Tested
6d9935be(on0e995c19) on Windows 10 22H219045.6456with a GTX 1060 6 GB (10de:1c03, driver32.0.15.6094) and in-box WARP (1414:008c,10.0.19041.5794). The D3D12 debug layer was enabled and reported 0 errors and 0 warnings on every draw, including the controls.Debug and Release each passed 3/3 (
startup_image_3d_{controls,warp,hardware}), with no skips. On both adapters, with both compilers:The binary check passed with a local LLVM 23.1.6
llvm-mc. CI runs it with LLVM 15.The second #1149 fixture,
s_bfm_b32inline-sampler folding, will follow separately.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:17:31Z.
Review: COMMENTED
Reviewed commit
6d9935be(Linux host — Windowsoffscreen_checkbuild andstartup_image_3d_{warp,hardware}draw tests were not executed locally).Code & Edge-Case Audit
tools/startup/gfx2hlsl.py: unchanged; this PR adds a source-built fixture, desktop readback harness, CI entries, and docs forimage_samplewithdim:SQ_RSRC_IMG_3D.tests/startup_image_3d_check.py:PS_SOURCE,SOURCE_2D, andSOURCE_1DmatchPS_WORDS,WORDS_2D, andWORDS_1Dunderllvm-mc-19 -arch=amdgcn -mcpu=gfx1013.dim:SQ_RSRC_IMG_3Dlowers toTexture3D<float4> r0 : register(t0);sampled withr0.Sample(q0, float3(F(v0), F(v1), F(v2)))wherev2 = ud1(root constant 1),dmask:0xf, and manifestsrv 0 tex3d table 0 0. Changing onlydimtoSQ_RSRC_IMG_2Dlowers toTexture2D<float4>withfloat2(F(v0), F(v1)), anddim:SQ_RSRC_IMG_1DraisesUnsupported: image dimension SQ_RSRC_IMG_1D.tests/startup_image_3d.cpp&tests/offscreen_check.cpp:R32G32B32A32_FLOATTexture3Dwith dyadic-rational texels((1 + x + 2y + 4z) / 8, x, y, z)and compares exact IEEE-754 bits (std::memcmp) forz = 0.25,0.75, and1.75(wrap to slice 1), plus two negative-control mutants (z fixed to slice 0,x and z exchanged).AGENTS.md/docs/startup-runtime.md: title-neutral and consistent with the implementation.Checks Run (Linux / Python / LLVM-19)
git diff --check origin/main...HEAD: pass (0 issues)/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: pass (16 Markdown files, 280 links)/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: pass (1051 files)/root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py: pass/root/.local/share/x2w-rev-venv/bin/python -B tests/startup_image_3d_check.py: pass (dim 3D,dim 2D,dim 1Dcontrols)/root/.local/share/x2w-rev-venv/bin/python -B tests/startup_image_3d_check.py binary /usr/bin/llvm-mc-19: pass (fixture words match llvm-mc)/root/.local/share/x2w-rev-venv/bin/python -B tests/startup_sampler_heap_check.py&binary /usr/bin/llvm-mc-19: pass/root/.local/share/x2w-rev-venv/bin/python -B tests/startup_uniform_lane_check.py: passLLVM_LIB=/usr/lib/llvm-19/lib/libLLVM-19.so /root/.local/share/x2w-rev-venv/bin/python -B tests/compute_store_check.py binary /usr/bin/llvm-mc-19 /usr/bin/llvm-objcopy-19 /usr/lib/llvm-19/lib/libLLVM-19.so: pass (exit 0)ctest -R "^startup_image_3d_": not run locally.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T05:20:50Z.
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
6d9935be496f009f0107f95cf149098d1ba18465:--preset dev):cmake --build --preset dev --target offscreen_check -- -j 6):24.56s(configure1.86s)ctest --preset dev -R '^startup_image_3d_(controls|warp)$' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (1.24s:startup_image_3d_controls0.19s,startup_image_3d_warp1.16s)/O2(--preset release):cmake --build --preset release --target offscreen_check -- -j 6):28.41s(configure1.76s)ctest --preset release -R '^startup_image_3d_(controls|warp)$' --parallel 4 --no-tests=error --output-on-failure): 2/2 passed (1.09s:startup_image_3d_controls0.22s,startup_image_3d_warp0.99s)Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T05:27:43Z.
Merged current main (
7a4043e4) into the branch asb74f9b91to clear the conflicts with #1237 intests/desktop_gpu.handtests/offscreen_check.cpp. Both sides were kept: #1237's newcheck_startup_sampler_heapsignature and op arity, plus this PR's--startup-image-3dop. There is no change to this PR's own files.Retested
b74f9b91on the same host (Windows 10 22H219045.6456, GTX 1060 6 GB, driver32.0.15.6094, and in-box WARP10.0.19041.5794, with the debug layer enabled):Debug and Release each passed 8/8 with no skips:
startup_image_3d_{controls,warp,hardware}and #1237'sstartup_sampler_heap_{controls,warp,hardware,wrapped_warp,wrapped_hardware}. Readbacks and control failures match the PR body.