Skip to content

GPU tests for untested MIMG ops: image_atomic_*, image_get_lod, image_get_resinfo, image_bvh_intersect_ray (TEST-184) - #1402

Closed
henriquevinagre wants to merge 1 commit into
ItsNotRexed:mainfrom
henriquevinagre:test-184-mimg-gpu-tests
Closed

henriquevinagre wants to merge 1 commit into
ItsNotRexed:mainfrom
henriquevinagre:test-184-mimg-gpu-tests

Conversation

@henriquevinagre

Copy link
Copy Markdown
Contributor

Summary

Adds GPU test coverage for the 13 MIMG opcodes previously handled by tools/rdna2spirv.py without GPU tests (TEST-184, from @Vonsek's inventory in #1218):

  • runtime/test/shaders/cs_imgatomic.asm + vk_store_test ... atomic: exercises all 10 image_atomic_* opcodes (add, sub, and, or, xor, smin, smax, umin, umax, cmpswap) on both 2D (%simages, binding 4, 8x8 R32_UINT) and 3D (%simages3d, binding 7, 4x4x4 R32_UINT) storage images. Checks:
    • Signed vs. unsigned min/max boundary cases (-5 vs 5, 0x80000000 vs 0x7FFFFFFF), sub operand direction and wraparound, and cmpswap hit (vdata[0]=src, vdata[1]=cmp) and miss.
    • glc pre-op return value into vdata[0] (and preservation of vdata[1] on cmpswap) as well as non-glc preservation of vdata[0].
    • 64-lane concurrent contention on shared 2D and 3D texels.
    • Inactive-lane (EXEC masked) protection of memory canaries (including INT_MAX, INT_MIN, UINT_MAX, and matching-cmp cmpswap) and glc vdata registers.
    • Checks VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT and maxPushConstantsSize >= 144 (exiting 77 if unsupported); requires neither storage-image without-format feature.
  • runtime/test/shaders/ps_get_lod.asm: tests image_get_lod on vk_texture_test --two-mip (S# minLod=0, maxLod=1) for both SQ_RSRC_IMG_2D (clamped 1.0, unclamped 3.0 via dmask:0x3; negative unclamped -1.0 via dmask:0x2 and clamped 0.0 via dmask:0x1) and SQ_RSRC_IMG_2D_ARRAY (clamped 0.0, unclamped 2.0).
  • runtime/test/shaders/ps_get_resinfo.asm + vk_texture_test --rect-mip: binds a non-square 16x8 2D texture with 3 mip levels (16x8, 8x4, 4x2) so width, height, depth (1) and mip count (3) are all distinct, and tests image_get_resinfo across mips 0, 1 and 2 with full (0xf) and sparse (0x9, 0x6) dmask compaction.
  • runtime/test/shaders/cs_bvh32.asm: tests 32-bit image_bvh_intersect_ray (11-VGPR address layout with non-zero tmax in v2 where node_hi would sit in 64-bit, plus both zero and non-zero descriptor base s4 = 1) against vk_compute_test ... 1 bvh.
  • Wired all four fixtures into runtime/test/shaders/check.py and scripts/run_gpu_tests.py (including DRAWN_WITH for --filter runs and exit-77 SKIP handling).
  • Added tests/test_mimg_ops.py (stdlib-only SPIR-V translation, optional spirv-val, and checker/routing tests) and updated tests/test_shader_checks.py.

All fixtures are hand-written RDNA2 assembly using synthetic data only (no game files).

Testing

GPU / Driver / OS: AMD Radeon RX 6800 (RADV NAVI21, Mesa 26.2.6-arch3.1, Vulkan 1.4.354) on Arch Linux.

  • python3 -I scripts/run_gpu_tests.py --build runtime/build/linux: 137/137 passed (including cs_bvh32, cs_imgatomic, ps_get_lod, ps_get_resinfo).
  • LEONIDA_W64_EMULATE=1 python3 -I scripts/run_gpu_tests.py --build runtime/build/linux: 137/137 passed.
  • python3 -I runtime/test/shaders/build.py <tmp> + python3 -I runtime/test/shaders/check.py <tmp> runtime/build/linux: 125 of 128 pass, 3 skipped (mesh fixtures).
  • Verified all four new fixtures (cs_bvh32, cs_imgatomic, ps_get_lod, ps_get_resinfo) individually under VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (libVkLayer_khronos_validation.so confirmed loaded via VK_LOADER_DEBUG=layer): 0 validation errors or warnings.
  • Verified RADV ACO disassembly (RADV_DEBUG=shaders) for ps_get_lod and cs_imgatomic.
  • ctest --test-dir runtime/build/linux --output-on-failure: 21/21 passed.
  • g++ -std=c++20 -fsyntax-only -Wall -Wextra -Wno-missing-field-initializers -Wpedantic on vk_store_test.cpp and vk_texture_test.cpp: 0 warnings.
  • python3 -I tests/test_mimg_ops.py, tests/test_shader_checks.py, tests/test_run_gpu_tests.py, tests/test_gpu_build_dir.py, tests/test_resource_hygiene.py, tests/test_ctest_registration.py, tests/test_run_gpu_pixel_checks.py, tests/test_run_gpu_tests_paths.py, full stdlib test loop, tests/semantic (1,171 tests), and node --test tests/test_viewer_streaming.cjs (30 tests): all passed.

AI Disclosure

This PR was developed with AI assistance; all fixtures, harness code, SPIR-V output, and test results were verified locally on the RX 6800 GPU listed above.

Copilot AI balanced review requested due to automatic review settings November 22, 2026 11:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@Vonsek

Vonsek commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Independent ps_get_lod readbacks on 27e595c, Windows RTX 5080 (616.92) and Radeon gfx1036 (32.0.21045.16010). The registered runner returned (1,3,-1,2) at every one of 4096 pixels on both. I varied the sampler and shader independently: setting maxLOD=0 changed only R, to (0,3,-1,2); reducing the horizontal footprint from eight texels/pixel to half a texel while keeping vertical at eight retained (1,3,-1,2); reducing both axes to half a texel gave (0,-1,-1,2). Changing just the single-component query destined for B from mask 0x2 to 0x1 gave (1,3,0,2). All 4096 RGBA values per variant matched their expected tuples on both devices.
For image_get_resinfo, I also changed the local synthetic resource to 19×11 with three mips, then rebased its VkImageView at underlying mip 1 with only two levels visible. Each shader query addressed a valid view-relative level. On both GPUs, all pixels reported the expected packed words: (2835,769,777,258) for the whole view and (1289,513,516,258) for the 9×5 view. Deliberately querying relative mip 0 instead of 1 in the width query changed just B from 516 to 521 at every pixel. The mip count here tracks the visible view; the upstream test and local variants used source-built data.

@mokkymiah

Copy link
Copy Markdown
Contributor

Tested 27e595c on NVIDIA GeForce RTX 3070 (Ampere), driver 621.01, Vulkan 1.4.357, Windows 11 x64, compute subgroup 32..32: no failures.

  • runtime/test/shaders/build.py: 134 shaders, 134 translated, 134 pass spirv-val.
  • runtime/test/shaders/check.py: 97 of 128 pass, 31 skipped; cs_bvh32, cs_imgatomic, ps_get_lod and ps_get_resinfo all ok.
  • Targeted run_gpu_tests.py --filter runs: all four pass natively and with LEONIDA_W64_EMULATE=1. cs_imgatomic reports 0 bad in both the 2D 8x8 and 3D 4x4x4 atomics; ps_get_lod/ps_get_resinfo are 4096/4096 pixels exact; cs_bvh32 is 0 mismatches.
  • Full run_gpu_tests.py: 109/137 passed, 28 skipped, 0 failed. On unmodified f85582e2 the same machine reports 105/133 passed and 28 skipped, so the four new fixtures are the difference.
  • Validation layer: ran vk_store_test atomic, vk_compute_test ... 1 bvh, and vk_texture_test with the check.py arguments directly under VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. The loader confirmed VkLayer_khronos_validation.dll; no VUIDs or validation errors.
  • CPU: tests/test_mimg_ops.py 8 tests, tests/test_shader_checks.py 40, tests/test_run_gpu_tests.py 27, all OK.

This adds independent NVIDIA coverage for the ten image atomics (2D and 3D), image_get_resinfo and image_bvh_intersect_ray; @Vonsek already covered image_get_lod. Build: MSVC 19.44, Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0 / SPIRV-Tools v2026.4. Synthetic fixtures only; no game data.

@henriquevinagre

Copy link
Copy Markdown
Contributor Author

Thanks @Vonsek and @mokkymiah for the independent verification on RTX 5080, Radeon gfx1036, and RTX 3070! Rebased cleanly onto main (bb2e184), preserving the new load-d16 mode in vk_store_test/check.py/run_gpu_tests.py; re-verified 143/143 passing on RX 6800 (RADV, Linux) plus test_mimg_ops / test_shader_checks / test_run_gpu_tests.

…_get_resinfo, image_bvh_intersect_ray (TEST-184)
@henriquevinagre

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #1419 (05eb9ca), which landed TEST-184 MIMG GPU tests on main. Thanks @Vonsek and @mokkymiah for the independent verification!

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