Repository navigation
GPU tests for the MIMG ops that had none: image atomics, image_get_resinfo, image_get_lod, 32-bit BVH (TEST-184) - #1419
Conversation
The "bvh" mode writes its nodes at heap offsets 0x100 to 0x264, but with one group the heap buffer is 64 words, 256 bytes. The host wrote past the mapped range and the shader read the nodes through the buffer device address outside the buffer. It worked because the memory allocation is larger than the buffer. GPU-assisted validation reports it for cs_bvh on current main: VUID-RuntimeSpirv-PhysicalStorageBuffer64-11819, "trying to read 4 bytes at [..220, ..223) but this range does not belong to any buffer", the buffer being 256 bytes. The heap is now at least 0x280 bytes in this mode. The eight result words are unchanged, and both BVH fixtures are clean under core and GPU-assisted validation on RADV (RDNA2 integrated GPU) and llvmpipe. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The translator handles the image atomics, image_get_resinfo, image_get_lod and the 32-bit image_bvh_intersect_ray, but no test ran them. Six hand-written fixtures now do, with the expected words derived in each header from the RDNA2 ISA definition of the instruction: - cs_imgatomic: add, sub, and, or, xor, smin, smax, umin, umax and cmpswap on a 2D r32 uint image. 0xfffffff0 tells the signed min/max from the unsigned ones, each with a case that goes the other way; cmpswap hits and misses; one op runs without glc; 63 lanes are off; 64 threads add to one texel. - cs_imgatomic3d: six cases on a 4x4x4 volume, the 3D path of the translator. - cs_resinfo: a 16x4 image with five levels: levels 0, 1 and 3 in full, then dmask 0x3, 0xa and 0x8. - ps_get_lod, ps_get_lod_array: calculated LOD 1 and 3 on the two-mip texture, the clamped LOD held by the last level and by the sampler's MAX_LOD; 2 and -3 on the one-level 2D array. - cs_bvh32: the scene of cs_bvh through the 11-dword address form. vk_store_test gets a "words" mode for the compute ones: it also binds the uint image and a small volume as r32ui storage images (bindings 4 and 7) and a 16x4 five-level image behind its real T#, fills the images and prints them; check.py holds the expected words. The other two run on vk_texture_test and vk_compute_test as they are. All pass on an RX 7900 XTX and a Ryzen 9 7950X3D integrated GPU (RADV, Mesa 26.3.1) and on llvmpipe, natively and with LEONIDA_W64_EMULATE=1, and are clean under the validation layer. No translator change was needed. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
main is at c2967a5, 120 commits past the branch's base. Two conflicts, both sides kept: - docs/design.md: main added a third "Typed image loads" row at the place where this branch adds its "Image atomics, size and LOD queries" row. Main's row first, then this branch's. - tests/test_shader_checks.py: main counts one more check (cs_fmt_xy_xyz, TEST-185: 2 -> 3) on the line next to this branch's comment change. Main's count with this branch's comment; the STORE_WORDS and GET_LOD_TESTS terms stay. Nothing from main overlaps the new fixtures: TEST-185 and cs_w64x_andn2_exec run through vk_compute_test's dump mode, and vk_store_test, vk_texture_test and vk_compute_test are unchanged on main. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Tested I built the Vulkan harnesses from this head and ran the five image-operation fixtures on Linux 7.0.0-43-generic with llvm-mc 21.1.8 and SPIRV-Tools 2026.1.
GPU coverage here is limited to those image fixtures and controls. AI-assisted verification. |
|
Tested
No game files. AI-assisted (Claude Code). |
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): pass. |
|
Independently tested Built the Vulkan test programs from this commit with MSVC 19.44.35222. Ran I also repeated both draws directly with
Scope was the 2D fixture only. AI-assisted verification. |
|
Tested 174cad2 on NVIDIA GeForce RTX 3060 (Ampere), driver 620.70.06, Linux 7.3 (CachyOS), Vulkan 1.4.357, LLVM 23.1.5
|
main is at bb2e184. Three conflicts, both sides kept: - runtime/test/vk_store_test.cpp: main added the "load-d16" mode (a row of 16-bit boundary values in the fill, for the saturating d16 loads) and VK_KHR_shader_fma support; this branch added the "words" mode. Both modes and both includes stay; main's boundary row applies to "load-d16" only, so "words" keeps the plain fill its expected words are derived from. - runtime/test/shaders/check.py: main lengthened CS_STORE on the line next to this branch's cs_bvh32 entry. Both lines. - tests/test_shader_checks.py: main counts cs_fma_fused (8 -> 9) on the line after this branch's STORE_WORDS and GET_LOD_TESTS terms. Both. The automatic merges were read as well: vk_compute_test.cpp keeps the larger bvh heap next to main's shader_fma code, and check.py and run_gpu_tests.py run cs_imgload_d16 in "load-d16" next to the "words" fixtures. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Tested 5e91fb9 (0 behind main) on two GPUs: Windows 11 Home 10.0.26300, MSVC 14.44 (the PR's own
All six new tests pass on both GPUs: A note for other testers: run it with the PR's own build. With main's AI-assisted (Claude Code). No game files. |
main is at 99f9989. One conflict, both sides kept: - tests/test_shader_checks.py: main shortened the comment above TOTAL and counts a fourth vk_store_test shader (cs_sample_lz_int_d16: 3 -> 4) on the lines this branch's comment change touches. Main's comment with a clause for the "words" fixtures and the image_get_lod draws, main's count, and this branch's STORE_WORDS and GET_LOD_TESTS terms. The automatic merges were read as well: check.py and run_gpu_tests.py run cs_sample_lz_int_d16 through vk_store_test's "load-d16" mode next to the "words" fixtures, and gfx10_descriptors.h still encodes the T# of the 16x4 image the same way. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Merged Conflicts, both sides kept Merge of
Merge of
Merged automatically, read as well
Counts on
How often the game uses these ops (my own count over the whole corpus: 26,503 shaders, mnemonics in the disassembly)
Not re-run
AI-assisted (Claude Code, Claude Fable 5.2). |
main is at 41f4482. Two conflicts, both sides kept: - docs/design.md: both sides edited the one-line "Ray tracing" row. Main's row (the triangle node types and their vertex slots), with this branch's sentence about cs_bvh32 where it stood. - tests/test_shader_checks.py: main counts ps_ssharp (9 -> 10) and patches sampler_test on the lines next to this branch's STORE_WORDS / GET_LOD_TESTS terms and its get_lod_test patch. All four lines. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claimed in the coordination issue as: TEST-184 (claim)
What and why
The translator handles the image atomics,
image_get_resinfo,image_get_lodand the 32-bitimage_bvh_intersect_ray, but no test ran them (@Vonsek's inventory). This adds six hand-written fixtures. No translator change was needed: every word came out as derived.cs_imgatomicvk_store_test wordscs_imgatomic3dvk_store_test wordscs_resinfovk_store_test wordsps_get_lodvk_texture_test --two-mip, two drawsps_get_lod_arrayvk_texture_testcs_bvh32vk_compute_test bvhcs_bvh.asmheader from the RDNA2 ISA definition of the instruction, not from translator output.0xfffffff0separates the signed min/max from the unsigned ones, and each of the four has a case that goes the other way.cmpswaphits and misses. One op runs withoutglc, so the data register must keep its operand. 63 lanes are off in the single-thread cases, and 64 threads add 1 to one texel.image_get_resinfo: levels 0, 1 and 3 in full (the height stays 1 at level 3), thendmask0x3, 0xa and 0x8 for the packing.image_get_lod: calculated LOD 1 and 3 on the two-mip texture. The clamped LOD stops at the last level, and at 0 under a samplerMAX_LODof 0.25. On the one-level array: 2 and -3.Harness changes:
vk_store_testgets awordsmode: it fills the two r32 images and a small r32 uint volume and prints all three after the dispatch;check.pyholds the expected words. It now also binds the uint image and the volume as r32ui storage images (bindings 4 and 7, where atomics address their image) and a 16x4 five-level image behind the T# thatgfx10_descriptors.hwrites for it.cs_imgstore,cs_imgloadandcs_imgload_d16run as before.vk_compute_test, in its own commit: thebvhmode wrote its BVH past the end of its 256-byte heap buffer, socs_bvhread outside the buffer onmain(VUID-RuntimeSpirv-PhysicalStorageBuffer64-11819under GPU-assisted validation). The heap is now large enough; the result words are unchanged.docs/design.md: one contract row for these ops, with how they are confirmed and what is still unverified. The ray tracing row namescs_bvh32.Not covered:
image_get_lod: the tool's textures are square, where it makes no difference.image_get_resinfo's depth word on hardware: 1 follows from the T#'s DEPTH field.--wave64-emulate: the fixtures are wave32, likecs_bvhandcs_imgstore, soLEONIDA_W64_EMULATE=1translates them the same way.Overlap with #1402
#1402 was opened for the same item while this branch was being tested; the coordinator's ruling on the claim is here. The two cannot both merge as they are: both add
cs_imgatomic.asm,ps_get_lod.asmandcs_bvh32.asm, and both editvk_store_test.cppand the same registries.vk_compute_test, thedocs/design.mdrow, and runs on RDNA3 and llvmpipe.vk_texture_test(--rect-mip), which would close the u/v gap listed above; a BVH case with a non-zero descriptor base; a pixel-shaderimage_get_resinfo;tests/test_mimg_ops.py.Tested
Head
174cad2f: the branch's two commits (b9864d27,05eb9ca9) withmainc2967a5emerged in. Linux, Mesa 26.3.1, llvm-mc 23.1.5,LEONIDA_VK_VALIDATION=1.LEONIDA_W64_EMULATE=1main(c2967a5e) before--filter cs_, as CI)spirv-val(139, 139, 139 before).main.cs_bvhunder the Khronos layer with GPU-assisted validation, on the integrated GPU and on llvmpipe: 0 errors.cmpswapoperands swapped, the old value returned withoutglc, a wrong operand for inactive lanes, 3D coordinates swapped, resinfo width and height swapped, its level ignored, its depth, itsdmaskpacking, LOD components swapped, the fallback sampler, BVH sorting off,t maxfrom the wrong register. 21 fail the fixture. The u/v swap inimage_get_loddoes not (see above). These ran beforemainwas merged in; the fixtures' SPIR-V is byte-identical after the merge.compileall; all 151 standard-library test files;pytest tests --ignore=tests/semantic: 3517 passed, 37 skipped;unittest discover -s tests/semantic: 1194 tests OK.A host quirk the LOD test steps around: llvmpipe 26.3.1 does not apply a sampler's LOD range to
OpImageQueryLodwhen its minimum and maximum are equal (0..0 gave level 1, RADV gives 0). The second draw uses 0..0.25, where both agree.Checklist
docs/design.md, with how it was confirmed. (No new rule: the row added documents the existing ones and how these tests confirm them.)AI-assisted (Claude Code, Claude Fable 5.2).
🤖 Generated with Claude Code