Skip to content

Declare dynamic storage image indexing in translated SPIR-V - #3187

Merged
ItsNotRexed merged 917 commits into
ItsNotRexed:mainfrom
whattheflop:fix/storage-array-index-capability
Nov 23, 2026
Merged

ItsNotRexed merged 917 commits into
ItsNotRexed:mainfrom
whattheflop:fix/storage-array-index-capability

Conversation

@whattheflop

Copy link
Copy Markdown
Contributor

Depends on: #3045

This AI-assisted follow-up implements the existing coordination claim. It targets upstream main, so its comparison includes the pending #3045 commits until the parent lands. The storage-only changes are the single commit on top of e14290a4b90dbe5985e7a4c7e4628cf2b878bd99.

Changes

  • Emit StorageImageArrayDynamicIndexing and list shaderStorageImageArrayDynamicIndexing in index.json when the T# hash result indexes a storage image array. This covers typed stores, coherent typed loads, and the 2D and 3D OpImageTexelPointer paths, including compare-exchange. Plain typed loads continue to use sampled aliases. Vulkan VUID 10130.
  • Gate the storage feature before module creation in vk_pipeline_check, using the same skip accounting as sampled indexing. The store and bindless test harnesses request the storage feature when their modules declare it and report unsupported devices. Production D3D12 already enables the core feature for bindless.

Verification

  • Windows x64 with uv CPython 3.12.13, MSVC 19.38 and Vulkan SDK 1.4.363.0. 4,148 semantic tests, 78 focused pytest tests with 57 subtests, and Python compile and CLI smoke checks passed.
  • On the original parent head, both assembler backends translated 16/16 synthetic modules and passed spirv-val for Vulkan 1.2 and 1.3. Fourteen modules gained only the storage capability declaration. The sampled-only and constant-register controls were byte-identical. A constant storage descriptor control also validated without the dynamic capability.
  • On the updated parent head, both backends revalidated storage-only, mixed, sampled-only and constant-register cases with the expected index.json features. Both controls remained byte-identical. The checker regression covers both features at the worker call site.
  • Built vk_pipeline_check, vk_store_test, vk_bindless_test, vk_texture_test, vk_sampler_test and shader_library_test. The vk_pipeline_check_cli and shader_library CTests passed. Verification used synthetic inputs and CPU/source checks throughout. Two optional valid-index cases that enter Vulkan were left out.

@whattheflop

Copy link
Copy Markdown
Contributor Author

AI-assisted native integration check for #3187 at a9dd2919, including the vk_store_test host-readback barrier from #3190 at f0a74afe. Scratch tree d4d58eae0bd822d33f7b398222d8e285307b950b built with MSVC 19.38 and Vulkan SDK 1.4.363.0. The stock builder translated the three synthetic fixtures without any SPIR-V edits. All passed spirv-val for Vulkan 1.2 and 1.3. All declare storage-image dynamic indexing, and cs_imgload also declares sampled-image dynamic indexing.

On Windows 11, RTX 3080 (616.64) and Radeon iGPU (25.10.30.02) each passed cs_imgstore (normal mode), cs_imgload (load) and cs_imgatomic3d (words). Each case checked all 192 texels or words, including all 64 volume words in words mode. Khronos 1.4.363 confirmed Core Checks and Synchronization active with zero warnings or errors in all six runs. The loader logs confirmed one intended ICD per process. Synthetic fixtures only.

@da1chan9ha0

Copy link
Copy Markdown

Independent Vulkan GPU check of a9dd291912e1251d357b5925e27e1cdb8fa35063 on GeForce RTX 4070 Laptop GPU, NVIDIA 621.24, Vulkan 1.4.357, Windows 11 build 26300. Both sampled and storage image array dynamic indexing are supported on this device. LLVM 23.1.5 and SPIRV-Tools v2026.4.

  • 7/7 GPU cases passed with the official runner. To follow up on the synchronization in RT-200: Synchronize Vulkan storage-image test readback with host reads #3190, I repeated the run with local transfer-write → host-read barriers after the relevant copies in vk_store_test, vk_bindless_test, and vk_sampler_test. The translator and shaders were unchanged. The extra coverage includes ps_imgatomic (0/256 incorrect storage texels, 0/4096 incorrect render-target pixels), cs_imgatomic, and the mixed-load cs_imgload_d16. The sampled-only ps_ssharp control passed all eight descriptor cases.
  • All eight distinct shader modules assembled and passed Vulkan 1.2 SPIR-V validation. Against dependency head e14290a4b90dbe5985e7a4c7e4628cf2b878bd99, the six storage-using shaders added only OpCapability StorageImageArrayDynamicIndexing in the SPIR-V assembly and the corresponding feature in index.json. The sampled-only fragment and its companion vertex shader were byte-identical. The dependency head was used for the offline comparison.

The focused CPU suite also passed 6/6. The GPU checks cover the supported-feature branch on this device. Runtime validation layers were unavailable for this run. AI-assisted verification.

@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested a9dd291 on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass.

Python/semantic tests:

  • python3 -m pytest tests/semantic/test_sampled_dynamic_index.py -q — 6 passed, 26 subtests passed
  • python3 -m pytest tests/test_vk_pipeline_check_index.py tests/test_ab_control_flow.py tests/test_image_load_typed.py -q — 67 passed, 7 skipped, 57 subtests passed

Full GPU suite (built PR runtime in a separate build dir due to runtime test C++ changes, then ran suite against that build):

  • python3 -I scripts/run_gpu_tests.py --build /home/deck/leonida-work/pr3187-build — 175/189 passed, 14 skipped, 0 failed. Skips are the expected D3D12-owned skips on this Deck.

Note: tested PR head as submitted (PR description lists dependency on #3045).

AI-assisted (OpenCode).

@whattheflop

Copy link
Copy Markdown
Contributor Author

AI-assisted native recheck after the upstream reconciliation. Scratch tree 479099bd89abb89d9ee4c446be2962fb1103a9cb combines #3187 ee0d2c51 with the #3190 readback barrier f0a74afe. The unmodified stock cs_imgstore, cs_imgload, and cs_imgatomic3d modules passed Vulkan 1.2 and 1.3 spirv-val and each matched all 192 checked values on both the RTX 3080 (616.64) and Radeon iGPU (25.10.30.02). The volume path checked all 64 words. Khronos 1.4.363 reported core and synchronization active with zero warnings or errors in all six runs. Same synthetic controls as the earlier review, rerun on the exact refreshed code.

@kacper-serewis kacper-serewis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI-assisted independent CPU review of ee0d2c5 found no blocker; #3045 remains first in merge order. Across29 synthetic cases, storage capability/feature metadata appeared exactly for dynamic storage-array indexing, covering typed stores/coherent loads in four dimensions,2D/3D atomics/cmpswap,mixed/sampled-only/constant controls. Literal descriptors resolved via runtime lookup correctly retain dynamic indexing. Both Python and SDK assemblers passed Vulkan1.2/1.3 validation:116/116 outputs;21 typed-load tests pass. Checker source-order regression and accounting trace confirm missing features skip before module read/creation, with one completion and no module-success/failure increments. CPU source/test verification only, noGPU or archives.

@crastinator

Copy link
Copy Markdown
Contributor

Tested a9dd291 merged into main 16282101 (clean merge) on AMD Radeon RX 6700 XT (Navi 22, gfx1031, subgroup 32..64), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5, GCC 16.2.1, llvm-mc 23.1.5: pass.

  • Whole run_gpu_tests.py: 175/189 native, 175/189 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 37/37.
  • tests/semantic/test_sampled_dynamic_index.py, tests/test_ab_control_flow.py, tests/test_image_load_typed.py, tests/test_vk_pipeline_check_index.py: 80 passed, 83 subtests passed.

No game files. AI-assisted (Claude Code).

@JRamos1993

JRamos1993 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested a9dd291 (on main 1628210) on an RTX 5090 (driver 616.92), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363, RelWithDebInfo:

  • Full ctest: 130/130.
  • scripts/run_gpu_tests.py: 143/189 passed, 46 skipped, 0 failed, the same as main 1628210. All 194 test shaders translate and pass spirv-val.

AI-assisted (Claude Code).

@TreXito

TreXito commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested ee0d2c51 (the head rebased onto f847748c) on NVIDIA GeForce RTX 3060 Ti (Ampere, subgroup 32..32), driver 580.173.02 (Vulkan 1.4.312), Linux (Ubuntu 26.04 container on a TrueNAS 26.0 host): pass. The checks above are on a9dd2919, so this is the first GPU run of the rebased head.

Linux runtime built from the branch (CMake + Ninja, GCC, RelWithDebInfo), with the changed vk_store_test, vk_texture_test, vk_bindless_test, vk_sampler_test and vk_pipeline_check:

  • python3 -I scripts/run_gpu_tests.py, whole suite, fresh --work: 152/199 passed, 46 skipped, identical per test to main f847748c on the same GPU. The one failure on both is ps_sdwa_f16_const, the NVIDIA f16 denormal flush that rdna2spirv: widen f16 denormal operands without UnpackHalf2x16 (NVIDIA reads them as 0) #3220 / rdna2spirv: declare DenormPreserve 16 so a driver keeps f16 denormals (SHADER-526) #3040 fix.
  • The image tests pass: cs_store, ps_tex (bindless, 24 draws, 0 bad pixels), ps_texture_sample, ps_texture_sample_d16, ps_texture_mip0, and ps_texture_{bias,grad,grad_cl}_a16.
  • build.py: 204 shaders, 204 translated, 204 pass spirv-val.
  • ctest on the Linux build: 41/41 passed, as on main f847748c (41/41). That includes vk_pipeline_check_cli.
  • Tools: llvm-mc 21.1.8, SPIRV-Tools 2026.1, glslang 16.2.0, CMake 4.2.3, Python 3.14.4. Validation layers not installed in this container, so this isn't a LEONIDA_VK_VALIDATION=1 run.

AI-assisted (Claude Code). Synthetic test shaders only, no game files.

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the storage-indexing delta at ee0d2c5117d1f2c061fa03549aa7562160395097.

  • test_sampled_dynamic_index.py via unittest discovery — 6 tests passed.
  • test_image_load_typed.py — 21 passed, 2 skipped.
  • test_vk_pipeline_check_index.py — 1 passed, 1 skipped.
  • No game files used. I did not compile the C++ targets or rerun GPU/runtime tests; the PR discussion contains independent CPU and GPU validation.

I found no correctness issue in the storage-capability declaration and gating paths. This PR depends on #3045, which is still open, and GitHub checks were pending at review time; this approval covers the storage delta after that dependency is incorporated.

ItsNotRexed and others added 4 commits November 22, 2026 17:06
- design.md: escape the literal pipes that split contract-table rows again, and merge the 76 repeated topics into
  one row each (sentence by sentence; no number dropped).
- d3d12_vulkan.md: one milestone row per ID (the most complete of each), and LEONIDA_ARENA_LOG documented with the
  arena high-water report (D3D-55).
- navmesh.md: one item 4 and 5 under Remaining unknowns (the +0xB8 footprint and octree-key wording).
- sandbox.md: name vk_sandbox's source file; i18n index: one pt-BR row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- replay_cpu_bench: ItsNotRexed#3693 moved a draw's render targets and vertex buffers into Draw::views (D3D-391); the bench
  builds a DrawViews block instead of writing the old inline arrays.
- xgameruntime_user_test links file_system.cpp, which now defines rt::fs::game_dir that xgameruntime.cpp calls.
- check_sparse_queue_family: a vkCreateInstance refused because the api_dump/validation layer is not installed is
  the documented "layer absent" skip (77), not a failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit 718f105, reversing
changes made to 9aa16b2.
@whattheflop

Copy link
Copy Markdown
Contributor Author

AI-assisted CPU integration check with upstream 03b09a0 after #4278. #3045 and this stacked head each merged cleanly in scratch. Both MSVC checker builds and large_module_gate / vk_pipeline_check_cli CTests passed, plus eight checker-index tests per tree. A stubbed worker probe passed 11 cases per tree: missing sampled or storage support skips before acquiring a budget ticket or attempting module creation. The combined tree also passed 80 descriptor, control-flow and typed-image tests. No Vulkan device or game files.

ItsNotRexed and others added 4 commits November 22, 2026 21:10
- test_bary_fallback: ItsNotRexed#3647 (BUILD-1046) made a missing input folder exit 2 with "does not exist"; the test from
  ItsNotRexed#1379 still expected exit 1.
- test_format_decode_branch: the f16 reference uses the interpreter's pinned half_to_float (a NaN half widens to
  the canonical quiet NaN) instead of struct's '<e', whose NaN payload changed in Python 3.14 (CPython gh-130317).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges that each passed alone but clash together:
- v_cmp_class_f64: the earlier cmp_class_f64 (685d16e) (operand-form checks, test_cmp_class_f64) and the later f64 branch
  in cmp_class both handled the opcode; f64 goes to cmp_class_f64 again, f16 stays in cmp_class.
- rdna2spirv CLI tests: spirv-as/spirv-val now run in the output folder with the staging file's bare name, so
  the test doubles resolve it against cwd; assemble_spirv decodes the output only when it is bytes. (The doubles
  had been writing .spirv-*.tmp files into the repository root.)
- ps_w64 fixtures (TEST-722): an 18th fixture (ps_w64_a_discard) landed; its killed lanes export nothing and
  keep the clear value.
- first_light: a run without an OBJ removes mesh.bin, and harness_env reads manifest["files"]; batch_glb's stats
  name failures and dropped textures; run_gpu_tests reports a frame never written as a missing readback
  (TEST-837).
- make_game TRANSLATION_SOURCES and runtime.yml's paths include spirv_opt.py and report_paths.py (and
  wave64_emulate_opt.py), which the translator imports.
Repo rules: stdout guard on six tools; encoding on two opens (gen_gdk_runtime_classes' helper is read_utf8);
newline on one write; anim_skeleton_match's joaat encodes like hashdict.joaat; test_feature_scan's new test is
listed with the others its globals() runner reaches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit ce318cd, reversing
changes made to a78f170.
# Conflicts:
#	docs/runtime_imports.md
#	runtime/CMakeLists.txt
#	runtime/shims/xgameruntime.cpp
#	runtime/test/xmem_test.cpp
#	tools/rdna2spirv.py
ItsNotRexed and others added 4 commits November 22, 2026 22:30
- rdna2spirv: %fmt_size_tab (main's typed-load size table) registers its length and entry constants when a load
  first uses it; created at assembly, %c128 came after the OpTypeArray naming it and spirv-val refused
  buffer_store_format_d16 modules (test_u16_high_half).
- test_vs_packed_inputs matches main's wording of the same SHADER-644 rule ("mixed component types").
- test_mutations: the v_mul_legacy_f32 anchor follows the SHADER-340 flushes (it had stopped matching on main).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ItsNotRexed#2887 added the fixture to the M2 build; with no entry in OTHER_HARNESS the GPU suite reported it as
"no checker defined".

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

Copy link
Copy Markdown
Contributor Author

Round-43 reconciliation is up at ccb572e3, based on #3045 dad0da40. The storage delta retains upstream’s current image-atomic lowering and checks the storage feature before a module enters the driver.

On Windows with uv CPython 3.12.13, 161 focused pytest tests and 332 subtests passed. Three LLVM-dependent tests skipped. Five CPU CTests passed and gta6rt linked. Across 56 synthetic cases including typed loads, stores and atomics, both assemblers’ outputs passed spirv-val for Vulkan 1.2 and 1.3. The checker feature gate was exercised without a Vulkan device. The current upstream 2d3369a4 merges cleanly. CPU and SPIR-V verification only. AI-assisted.

@Kev-Ball

Copy link
Copy Markdown

Tested ccb572e3 on an NVIDIA GeForce RTX 3080 Ti (32-lane subgroups), driver 620.73.04, CachyOS Linux 7.3.5-2-cachyos. I rebuilt the Vulkan harnesses from this revision and selected the NVIDIA device explicitly.

Rebuilt and reran after the head update. scripts/run_gpu_tests.py --require-pass passed with each of --filter ps_imgatomic and --filter cs_imgstore. The bindless pixel test reported 0/256 wrong storage-image texels and 0/4,096 wrong render-target pixels, including the 3D atomic case. Built vk_pipeline_check and ran python -I tests/test_vk_pipeline_check_index.py: all 8 passed.

AI-assisted verification with synthetic inputs.

@lunarminus

Copy link
Copy Markdown

Tested ccb572e3 merged onto main d0835dd9 on an AMD Radeon 760M (RDNA3 iGPU, gfx1103, subgroup 32..64), RADV Mesa 26.3.1, CachyOS Linux: pass

  • d0835dd9 is already an ancestor of the head, so the merge was a fast-forward. The tested tree is ccb572e3, which also contains main up to 7b7d73f8.
  • I built runtime/ from this head (RelWithDebInfo). ctest: 100% passed out of 49, with shader_library_corpus and vk_sync_validation reported Skipped.
  • tests/semantic/test_sampled_dynamic_index.py, tests/test_ab_control_flow.py, tests/test_image_load_typed.py: 82 passed, 108 subtests passed. tests/test_vk_pipeline_check_index.py against the PR's vk_pipeline_check: 8 OK.
  • Full tests/semantic (LLVM 23.1.5): 6251 tests, 3 failures and 2 errors, all in test_loop_ballot_barrier. That module fails the same way (15 tests, 3 failures, 2 errors) on 7b7d73f8 and d0835dd9 without this PR, so the failures were there before it.
  • run_gpu_tests.py, whole suite: 221 shaders translated, 221 pass spirv-val.
    • Native: 202/217 passed, 15 skipped, 0 failed.
    • LEONIDA_W64_EMULATE=1: 202/217 passed, 15 skipped, 0 failed.
  • Per-test comparison with d0835dd9 without the PR (196/210 passed, 14 skipped in both modes):
    • Every test from that run has the same result in both modes.
    • The 7 extra tests all came in with main up to 7b7d73f8, not with this PR. cs_smem_sconst_off, ps_far_branch, ps_sample_c, ps_sample_c_b, ps_texture_b_cl and ps_texture_cl pass; ps_m2_literal is skipped (run by d3d12_m2_textured_test).
  • The image fixtures pass in both modes, and no harness reported the device as unsupported:
    • cs_imgstore, cs_imgload, cs_imgload_d16, cs_store, ps_ssharp pass.
    • cs_imgatomic and cs_imgatomic3d: all 64 words of each image (uint, sint, volume) exact.
    • ps_imgatomic: 0/256 texels and 0/4096 render-target pixels wrong.
    • ps_tex: 24 draws, 0 bad pixels.
  • In the generated index.json, 9 modules list shaderStorageImageArrayDynamicIndexing: the six cs_img*/ps_imgatomic fixtures plus cs_m4_fill, cs_resinfo and cs_sample_lz_int_d16. 35 list the sampled feature.

Synthetic test shaders only, no game files. AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested ccb572e33 merged with main 3faac557b on native Windows 11 (MSVC 14.51, RelWithDebInfo, Python 3.13.1) and Linux (WSL2, Python 3.12.16): pass.

  • Windows ctest, RTX 4080 SUPER (device: NVIDIA GeForce RTX 4080 SUPER): 177/177 (main: 177/177). Intel UHD 770 (both env vars set, device: Intel(R) UHD Graphics 770): 175/177; the failures are d3d12_sparse_queue_family (also fails on main) and d3d12_present (white screen-pixel read on Intel; fails on main too). I did not run scripts/run_gpu_tests.py on this head (on Declare dynamic sampled descriptor indexing in translated SPIR-V #3045, which this PR contains, it gave 170/217 on the RTX 4080 SUPER, same as main).
  • Linux: test_sampled_dynamic_index.py 6 tests OK, plus test_ab_control_flow.py, test_image_load_typed.py (2 skips without the binary), test_vk_pipeline_check_index.py and the docs row tests. Whole tests/semantic suite (397 files, one process each): 395 OK; test_loop_ballot_barrier.py and test_vcmp16_opsel.py fail identically on a clean main worktree here.
  • Negative control: with main's tools/rdna2spirv.py the new semantic tests fail 27 assertions (6 tests).

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.