Skip to content

shader: lower 32-bit 2D compute image_store and unorm in gfx2hlsl - #2399

Merged
tedin7 merged 2 commits into
R0Y00:mainfrom
stan495:startup/compute-image-store-f32
Nov 25, 2026
Merged

tedin7 merged 2 commits into
R0Y00:mainfrom
stan495:startup/compute-image-store-f32

Conversation

@stan495

@stan495 stan495 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Lower 32-bit 2D image_store in startup compute shaders and accept the unorm integer-coordinate modifier on 2D image_store in tools/startup/gfx2hlsl.py.

  • Compute 32-bit 2D image_store: accepts dim:SQ_RSRC_IMG_2D, dmask:0xf, four consecutive data VGPRs, two full-width coordinate VGPRs, and an unmodified eight-word image descriptor from a fixed table offset. Emits asfloat(uint4(...)) to RWTexture2D<float4> under the lane's EXEC bit and publishes uav N tex2d float table P O channels 4 in the version 2 compute manifest (matching shader: translate packed D16 image stores in startup compute programs #2300).
  • unorm modifier: accepted on image_store in both compute and pixel stages, matching image_load (MIMG IMAGE_STORE always addresses unnormalized integer texel coordinates uint2(x, y)). Partial dmask, non-2D dimensions, a16, tfe, lwe, r128, image_store_mip, modified descriptors, and same-resource load/store aliasing remain refused by name.
  • Tests & CI: adds tests/startup_compute_image_store_check.py (pure-Python controls + WARP and hardware 3-mip R32G32B32A32_FLOAT GPU readback reusing #2105's source-built fixture and CPU reference, plus four negative controls), updates the old requires d16 and unorm refusal assertions in tests/startup_compute_image_store_d16_check.py and tests/startup_pixel_image_store_check.py, and wires the new check into CMakeLists.txt, .github/workflows/windows.yml, AGENTS.md, docs/experiments.md, and docs/startup-runtime.md.

Refs #2274

Evidence

  • Commit under test: ea981f1a (based on upstream/main a4900150)
  • Environment: Windows 11 Build 26200, MSVC 19.44.35228, DXC 10.0.26100.0, D3D12 debug layer enabled
    • Software adapter: Microsoft Basic Render Driver (WARP), driver 10.0.26100.9818
    • Physical adapter: AMD Radeon RX 7900 XTX, driver 32.0.32029.2010
  • Commands & observed results:
    .\out\pe-env\Scripts\python.exe -B tests/startup_compute_image_store_check.py
    .\out\pe-env\Scripts\python.exe -B tests/startup_compute_image_store_d16_check.py
    .\out\pe-env\Scripts\python.exe -B tests/startup_pixel_image_store_check.py
    .\out\pe-env\Scripts\python.exe -B tests/startup_gfx2hlsl_compute_check.py
    .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
    .\out\pe-env\Scripts\python.exe -B tests/startup_tools_lint_check.py tools/startup
    .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
    $env:XBOX2WINDOWS_ADAPTER = 7900
    cmake --build --preset release --target offscreen_check
    ctest --preset release --no-tests=error -j 1 -R '^startup_(compute_image_store|pixel_image_store)' -V
    • All 7 pure-Python / lint / docs / bidi checks passed.
    • CTest: 9/9 passed, 0 failed, 0 skipped (startup_compute_image_store, startup_compute_image_store_warp, startup_compute_image_store_hardware, startup_compute_image_store_d16, startup_compute_image_store_d16_warp, startup_compute_image_store_d16_hardware, startup_pixel_image_store_controls, startup_pixel_image_store_warp, startup_pixel_image_store_hardware).
    • Both WARP and RX 7900 XTX matched all 1,344 words across three mips (mismatches=0, debug_errors=0 debug_warnings=0) for full EXEC (unorm) and partial EXEC, and detected all four negative controls (omit store: 64 mismatches, swap R/B: 32 mismatches, swap RG/BA: 64 mismatches, drop EXEC guard: 32 mismatches).

Scope

This covers translation and standalone source-built GPU readback for 32-bit 2D image_store (with and without unorm). Slot-67 runtime UAV binding remains tracked in #2274 Part B.

@KelboLive

Copy link
Copy Markdown
Contributor

Approved — solid lowering of 32-bit 2D image_store with unorm. Full test coverage with WARP/hardware readback and negative controls. Manifest version 2 binding correct. No game files.

legacy-code-archaeologist added a commit to legacy-code-archaeologist/Xbox2Windows that referenced this pull request Nov 25, 2026
# Conflicts:
#	tests/startup_pixel_image_store_check.py
#	tools/startup/gfx2hlsl.py
legacy-code-archaeologist added a commit to legacy-code-archaeologist/Xbox2Windows that referenced this pull request Nov 25, 2026
R0Y00#2399 lowers 32-bit compute image_store and still refuses a16 there; the packed
address form is only tested in the pixel stage (startup_pixel_image_store_check).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Makto94

Makto94 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Hardware run and Windows 11 MSVC build at head ea981f1a.

Environment: Windows 11 Pro build 26300.9974, Debug (dev preset), MSVC toolset 14.44.35207 (cl 19.44.35230.0), driver 32.0.16.2101. The hardware test prints adapter=NVIDIA GeForce RTX 3070 Ti vendor=10de device=2482 and backend=hardware debug_layer=enabled, with debug_errors=0 debug_warnings=0 in every case. The runs were serial (-j1).

Build: cmake --build --preset dev exited 0. This PR changes no C++ source.

Tests:

  • ctest --preset dev --no-tests=error -j1 -R '^startup_compute_image_store(_warp)?$' -V: 2/2 passed (startup_compute_image_store, startup_compute_image_store_warp).
  • ctest --preset dev --no-tests=error -j1 -R '^startup_compute_image_store_hardware$' -V: 1/1 passed. 0 capability skips (77).
  • The other test scripts this PR changes, same head: ctest --preset dev --no-tests=error -j1 -R '^startup_(compute_image_store_d16|pixel_image_store)' -E hardware -V: 4/4 passed (startup_compute_image_store_d16, _d16_warp, startup_pixel_image_store_controls, _warp); ctest --preset dev --no-tests=error -j1 -R '^startup_(compute_image_store_d16|pixel_image_store).*_hardware$' -V: 2/2 passed (startup_pixel_image_store_hardware, startup_compute_image_store_d16_hardware), debug_errors=0 debug_warnings=0 in every case, 0 skips (77).

The hardware test dispatches 6 cases, each with groups=2 view_mip=0 compared_words=1344:

  • full EXEC (unorm): mismatches=0.
  • partial EXEC: mismatches=0.
  • Four negative controls, each printing Image store readback differs from CPU reference, so the check can fail: omit store (mismatches=64), swap R/B channels (mismatches=32), swap RG/BA pairs (mismatches=64) and drop EXEC guard (mismatches=32).

The WARP run (adapter=Microsoft Basic Render Driver, driver 10.0.26100.9818) prints the same mismatch counts for all 6 cases, with debug_errors=0 debug_warnings=0.

Not covered by this run: this run is NVIDIA only (the PR body already lists an AMD run); the compute_store_aot_gfx1013_image_store* tests were not run.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head bdcca315 (after updating with main). Comment review, no approval.

What I checked:

  • tools/startup/gfx2hlsl.py: the compute 32-bit path reuses the D16 checks (2D only, dmask 0xf, 4 data VGPRs, 2 full-width coordinate VGPRs, fixed table image, EXEC guard). unorm is accepted on image_store in both stages, like image_load. Partial dmask, non-2D, a16/tfe/lwe/r128 and aliasing stay refused by name.
  • Sibling checks: the old requires d16 and pixel unorm refusal assertions were updated, and the new check is wired in CMake (CPU and per-adapter), windows.yml (both lists), AGENTS.md and docs.
  • No other open or merged PR covers this slice (#1649 is array/3D, #2106/#2300 are D16).
  • Mutations: removing unorm from the allowed list makes the new check and the pixel check fail (Unsupported: image_store modifier unorm). Swapping channels in the emitted asfloat(uint4(...)) makes the new check fail.

Commands run locally (Linux, llvm-mc 19):

  • python3 -B tests/startup_compute_image_store_check.py --llvm-mc llvm-mc PASS
  • python3 -B tests/startup_compute_image_store_d16_check.py --llvm-mc llvm-mc PASS
  • python3 -B tests/startup_pixel_image_store_check.py --llvm-mc llvm-mc PASS
  • python3 tests/docs_links_check.py PASS, python3 tests/bidi_controls_check.py PASS
  • git diff --check origin/main...HEAD clean

Not run in this review: the WARP/hardware readback part, which needs Windows. Win2025 receipt follows separately.

AI-assisted; commands listed were executed locally.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Win2025 WARP receipt for head bdcca31 after updating with main. Targeted run: the new WARP GPU-readback test startup_compute_image_store_warp plus d16 and pixel image_store siblings, 5/5 passed in dev and in release.

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit bdcca3151cc35abe631380f8921ae1f394824dfe:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target offscreen_check -- -j 2): 4.01s (configure 0.00s)
    • Test (ctest --preset dev -R '^startup_compute_image_store(_d16)?_warp$|^startup_pixel_image_store' --parallel 2 --no-tests=error --output-on-failure): 5/5 passed (3.22s: startup_pixel_image_store_warp 0.79s, startup_pixel_image_store_controls 0.18s, startup_compute_image_store_d16_warp 1.48s, startup_pixel_image_store_hardware 1.08s, startup_compute_image_store_warp 1.55s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target offscreen_check -- -j 2): 8.03s (configure 0.00s)
    • Test (ctest --preset release -R '^startup_compute_image_store(_d16)?_warp$|^startup_pixel_image_store' --parallel 2 --no-tests=error --output-on-failure): 5/5 passed (3.78s: startup_pixel_image_store_warp 1.23s, startup_pixel_image_store_controls 0.24s, startup_compute_image_store_d16_warp 1.85s, startup_pixel_image_store_hardware 0.91s, startup_compute_image_store_warp 1.56s)
  • Windows Python checks: tests/mesh_heap_sampler_check.py ok (0.8s), tests/startup_buffer_address_check.py ok (0.5s), tests/startup_buffer_format_word3_table_check.py ok (0.1s), tests/startup_compute_image_store_check.py ok (0.6s), tests/startup_compute_image_store_d16_check.py ok (0.6s), tests/startup_compute_request_offline_check.py ok (0.5s), tests/startup_compute_translate_check.py ok (0.3s), tests/startup_flat_param_check.py ok (0.1s), tests/startup_gfx2hlsl_add_sub_co_check.py ok (0.1s), tests/startup_gfx2hlsl_add_sub_co_ci_check.py ok (0.2s), tests/startup_gfx2hlsl_bit_alu_check.py ok (0.7s), tests/startup_gfx2hlsl_capture_check.py ok (1.0s), tests/startup_gfx2hlsl_cmp16_check.py ok (0.2s), tests/startup_gfx2hlsl_compare_dst_check.py ok (0.1s), tests/startup_gfx2hlsl_compute_check.py ok (0.4s), tests/startup_gfx2hlsl_cselect_mask_check.py ok (0.1s), tests/startup_gfx2hlsl_cvt_alu_check.py ok (0.1s), tests/startup_gfx2hlsl_cvt_off_f32_i4_check.py ok (0.3s), tests/startup_gfx2hlsl_f32_lg_check.py ok (1.3s), tests/startup_gfx2hlsl_f32_nan_check.py ok (5.3s), tests/startup_gfx2hlsl_getpc_refusal_check.py ok (0.1s), tests/startup_gfx2hlsl_handler_arity_check.py ok (0.1s), tests/startup_gfx2hlsl_image_arity_check.py ok (0.1s), tests/startup_gfx2hlsl_image_get_lod_check.py ok (0.1s), tests/startup_gfx2hlsl_int_med3_check.py ok (0.1s), tests/startup_gfx2hlsl_join_symbols_check.py ok (0.2s), tests/startup_gfx2hlsl_loop_constants_check.py ok (0.1s), tests/startup_gfx2hlsl_mask_overwrite_check.py ok (0.1s), tests/startup_gfx2hlsl_operand_count_check.py ok (0.3s), tests/startup_gfx2hlsl_pack_absdiff_check.py ok (2.5s), tests/startup_gfx2hlsl_readfirstlane_recompute_check.py ok (0.1s), tests/startup_gfx2hlsl_readfirstlane_uniform_check.py ok (0.1s), tests/startup_gfx2hlsl_refusals_check.py ok (0.5s), tests/startup_gfx2hlsl_root_check.py ok (0.7s), tests/startup_gfx2hlsl_sad_check.py ok (0.3s), tests/startup_gfx2hlsl_saveexec_same_reg_check.py ok (0.1s), tests/startup_gfx2hlsl_scalar_arity_check.py ok (0.2s), tests/startup_gfx2hlsl_scalar_brev_fold_check.py ok (0.1s), tests/startup_gfx2hlsl_scalar_m0_check.py ok (0.1s), tests/startup_gfx2hlsl_scalar_table_arity_check.py ok (0.2s), tests/startup_gfx2hlsl_sdwa_cvt_check.py ok (0.2s), tests/startup_gfx2hlsl_sgpr_spill_check.py ok (0.1s), tests/startup_gfx2hlsl_shift64_check.py ok (0.1s), tests/startup_gfx2hlsl_sload_const_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_smem_offset_check.py ok (0.1s), tests/startup_gfx2hlsl_sop2_complement_check.py ok (5.4s), tests/startup_gfx2hlsl_sopk_accum_check.py ok (0.8s), tests/startup_gfx2hlsl_sopk_signext_check.py ok (0.1s), tests/startup_gfx2hlsl_swap_check.py ok (0.3s), tests/startup_gfx2hlsl_vopc_sdwa_check.py ok (4.1s), tests/startup_gfx2hlsl_waitcnt_depctr_check.py ok (0.1s), tests/startup_gfx2hlsl_watch_check.py ok (2.4s), tests/startup_image_2d_array_check.py ok (0.2s), tests/startup_image_3d_check.py ok (0.1s), tests/startup_image_gather_lz_check.py ok (0.5s), tests/startup_image_load_d16_check.py ok (0.8s), tests/startup_image_sample_a16_check.py ok (0.1s), tests/startup_image_sample_b_check.py ok (0.1s), tests/startup_image_sample_c_check.py ok (0.2s), tests/startup_image_sample_l_check.py ok (0.2s), tests/startup_image_sample_lod_check.py ok (0.6s), tests/startup_inline_sampler_check.py ok (0.1s), tests/startup_mesh57_skeleton_check.py ok (0.2s), tests/startup_run_ps1_check.py ok (9.4s), tests/startup_run_sh_check.py skipped (0.1s), tests/startup_sampler_heap_check.py ok (0.1s), tests/startup_shader_cache_rekey_check.py ok (3.8s), tests/startup_smem_address_check.py ok (0.8s), tests/startup_stream_fetch_check.py ok (0.5s), tests/startup_stream_interface_check.py ok (0.9s), tests/startup_translator_check.py ok (0.6s)
  • sccache: -239/-471 hits; wall 74.6s

AI-assisted; commands listed were executed locally.

@tedin7
tedin7 merged commit e26ade7 into R0Y00:main Nov 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants