Skip to content

vk_harness, vk_store_test, vk_texture_test, vk_sampler_test: run under validation with LEONIDA_VK_VALIDATION (TEST-877 follow-up) - #4025

Open
TreXito wants to merge 4 commits into
ItsNotRexed:mainfrom
TreXito:test/877b-shader-programs-validation
Open

TreXito wants to merge 4 commits into
ItsNotRexed:mainfrom
TreXito:test/877b-shader-programs-validation

Conversation

@TreXito

@TreXito TreXito commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to TEST-877 (claim).

Depends on: #4005. This branch is stacked on it. Only the last commit, 6b301611, is new here.

vk_harness, vk_store_test, vk_texture_test and vk_sampler_test built their instance without layers and ignored LEONIDA_VK_VALIDATION. A validation message also never changed their exit code. Between them they run every pixel, store, texture and sampler case in scripts/run_gpu_tests.py. So even with #4005, a validation run of the suite could still only fail on the compute cases.

What changes:

  • Each of the four takes the instance setup from runtime/test/vk_validation.h (OptInValidation, added in vk_compute_test: run under validation with LEONIDA_VK_VALIDATION, fail on a validation error (TEST-877) #4005):
    • prepare before vkCreateInstance: with the variable set, it adds the layer, VK_EXT_debug_utils and a messenger, or fails with exit 1 if the layer is missing.
    • attach after it.
  • main now wraps the old body and ends through OptInValidation::exit_status. A counted validation error exits 1 with N validation errors.
  • The diff per program is 11 lines: the include, a header comment, int main renamed to static int run, the two calls, and the new main.
  • Without the variable nothing changes. No output line changes, so the device: and subgroup regexes in check.py and run_gpu_tests.py are unaffected.
  • docs/testing.md now lists every shader test program as reading the variable. It drops the by-hand VK_INSTANCE_LAYERS recipe, which existed only because these programs ignored it.

Tested on RTX 3060 Ti, driver 580.173.02, Linux, Khronos validation layer 1.4.357. Base main aa2988c. Whole suite, python -I scripts/run_gpu_tests.py:

build no variable LEONIDA_VK_VALIDATION=1 + VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1
this branch (6b30161) 164/210, = main 147/210 141/210
this branch + #3347 + #4067 164/210 164/210 158/210

Also tested on AMD Radeon RX 7800 XT, driver 26.11.2, Windows 10 19045, validation layer 1.4.363. Base main aa2988c:

build no variable LEONIDA_VK_VALIDATION=1 + GPU-AV
this branch (6b30161) 196/210, = main 179/210 171/210
this branch + #3347 + #4067 196/210 196/210, 0 VUID-08740 188/210
  • The 8 under GPU-AV are NVIDIA's 6 plus cs_w64x_lds_raw and cs_w64x_lds_war (native wave64, lane 0 against lane 32). All are race reports with 0 mismatches.
  • With the variable set and the layer hidden, every test program fails with the "not installed" diagnostic, as intended.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

TreXito and others added 3 commits November 22, 2026 22:51
…l on a validation error (TEST-877)

vk_compute_test created its instance without layers and ignored LEONIDA_VK_VALIDATION, and a
validation message never changed its exit code, so scripts/run_gpu_tests.py could not catch what
GPU-assisted validation finds in the compute fixtures (SHADER-708 only showed up with
VK_INSTANCE_LAYERS set by hand).

With LEONIDA_VK_VALIDATION=1 it now enables VK_LAYER_KHRONOS_validation and a debug messenger the
way vk_bindless_test does, prints each message to stderr and counts validation-type errors. main
wraps the old body, so every path (including errors GPU-AV reports when the queue finishes) ends
with "N validation errors" and exit 1. Without the variable nothing changes. docs/testing.md says
so, and no longer lists vk_bindless_test as a program that ignores the variable (it reads it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…/vk_validation.h

OptInValidation reads LEONIDA_VK_VALIDATION, adds VK_LAYER_KHRONOS_validation, VK_EXT_debug_utils and
a messenger to the instance (keeping what the program already enables), counts validation-type
errors and turns them into the exit status. vk_compute_test uses it instead of its own copy, so the
other shader test programs can opt in with a few lines. docs/testing.md also no longer lists
vk_image_fuzz as a program that ignores the variable (it reads it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alidation with LEONIDA_VK_VALIDATION

The four programs that run every pixel, store, texture and sampler case of scripts/run_gpu_tests.py
built their instance without layers and ignored LEONIDA_VK_VALIDATION, and a validation message
never changed their exit code, so a validation run of the suite could not fail on them. Each now
takes the instance setup from runtime/test/vk_validation.h, like vk_compute_test (TEST-877): the
layer, VK_EXT_debug_utils and a messenger when the variable is set, and main ends through
OptInValidation::exit_status, so a counted validation error exits 1 with "N validation errors".
Without the variable nothing changes. docs/testing.md now lists every shader test program as
reading the variable, and drops the by-hand VK_INSTANCE_LAYERS recipe that only covered them.

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

Copy link
Copy Markdown
Contributor

Tested 6b301611300266f1cdd1e6947f787668ec6a75cf on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

At 6b301611 on Linux, RTX 5090, driver 595.99.02, all four rebuilt programs (vk_harness, vk_store_test, vk_texture_test, and vk_sampler_test) exited 1 and named the missing Khronos validation layer when I requested validation with an empty explicit layer directory.

With that same directory, I drew a translated constant-white pixel shader in vk_harness twice: once with LEONIDA_VK_VALIDATION unset and once with it set to 0. Both runs exited 0, and all 4,096 RGBA32F pixels were exactly (1,1,1,1) on each run. This covers missing-layer handling in all four entry points and the disabled path on hardware. Counting messages from an installed validation layer was outside this check.

AI-assisted verification.

@SebSilent

Copy link
Copy Markdown

Tested 6b30161 on RTX 2070 (Turing, subgroup 32..32), NVIDIA 620.73.04, Vulkan 1.4.357, CachyOS Linux (kernel 7.3.5), gcc 16.2.1, llvm-mc 23.1.5. Native Linux build of the test tools, no game files.

  • No variable: python -I scripts/run_gpu_tests.py --build <build> --require-pass gives 214/214 translated + spirv-val, 164/210 passed, 46 skipped, 0 failed (exit 0). Same as main aa2988c, so nothing changes without the variable. The 46 skips are 32 needing a 64-wide subgroup and 14 Windows-only d3d12 tests.
  • LEONIDA_VK_VALIDATION=1 with the layer absent: all four (vk_harness, vk_store_test, vk_texture_test, vk_sampler_test) print "LEONIDA_VK_VALIDATION is set but VK_LAYER_KHRONOS_validation is not installed" and exit 1, the new prepare() guard, instead of running unchecked.
  • LEONIDA_VK_VALIDATION=0: validation off, normal run, the device: line unchanged.

Caveat: this box has no Khronos validation layer installed, so I could not exercise the validation-error-counting path (the 17 VUID-08740 cases you found). The missing-layer guard and the no-variable regression are confirmed on Turing. AI-assisted (Tacit).

@tedin7

tedin7 commented Nov 22, 2026

Copy link
Copy Markdown

Tested 6b30161 (stacked on #4005, merge base main aa2988c) on NVIDIA GeForce RTX 5080, driver 580.65.06, Ubuntu 22.04 (Linux): pass, all three counts match the PR description

Build: cmake -S runtime -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DVulkan_INCLUDE_DIR=<SDK 1.4.363.1>/include, then ninja -C build -j12 (all targets, including the five changed test programs; they compile cleanly). Khronos validation layer from Vulkan SDK 1.4.363.1 via VK_LAYER_PATH. VK_LOADER_LAYERS_DISABLE=~implicit~.

Whole suite, python -I scripts/run_gpu_tests.py --build build:

variables passed skipped failed
none 164/210 46 0 (same as main)
LEONIDA_VK_VALIDATION=1 147/210 46 17
LEONIDA_VK_VALIDATION=1 VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1 141/210 46 23

Not tested: the stacked runs with #3347 + #4067 (164/210 under validation), the vk_harness control with OpCapability Int16, the 6 GPU-AV compute LDS failures were not looked at one by one, LEONIDA_W64_EMULATE=1 (the PR does not touch the translator), and other GPUs/OSes (NVIDIA 3060 Ti, Windows).

No game data was used.

AI-assisted run.

@YaBulochka

Copy link
Copy Markdown
Contributor

Ran the branch (6b301611) with LEONIDA_VK_VALIDATION=1 on AMD RADV, which is the case this PR needs a second driver for. The suite does not pass clean here, but the failures are in two test programs, not in the shaders:

GPU:    AMD Radeon RX 7600 (gfx1102, RDNA3)
Driver: RADV, Mesa 27.0.0-devel (git-f7dd61f78f), Vulkan 1.4.363
Layer:  Khronos Validation 1.4.363
Result: 179/210 passed, 14 skipped, 17 failed

All 17 failures are the same VUID, VUID-VkShaderModuleCreateInfo-pCode-08740:

validation: vkCreateShaderModule(): SPIR-V Capability DrawParameters was declared, but one of the following
requirements must be met (VkPhysicalDeviceVulkan11Features::shaderDrawParameters OR VK_KHR_shader_draw_parameters).

1. runtime/test/vk_texture_test.cpp:219 breaks its own feature chain.

m8.maintenance8 = VK_TRUE; f12.pNext = &m8;

f12.pNext was &f11 (the VkPhysicalDeviceVulkan11Features holding shaderDrawParameters), so this replaces it and silently drops the feature. RADV supports VK_KHR_maintenance8 (the run prints enabled VK_KHR_maintenance8), so on this driver every draw with vs_ids fails validation. On a device without maintenance8 the assignment never runs, which is likely why it passes elsewhere. The idiom used by vk_harness.cpp:400 keeps the chain: m8.pNext = chain; chain = &m8;, so here m8.pNext = f12.pNext; f12.pNext = &m8; is enough.

This accounts for 16 of the 17: ps_array_resinfo, ps_cube_sample, ps_gather_border, ps_gather_wrap, ps_get_lod, ps_get_lod_array, ps_sample_c_lz, ps_sample_c_lz_a16, ps_texture_bias_a16, ps_texture_grad_a16, ps_texture_grad_cl_a16, ps_texture_mip0, ps_texture_sample, ps_texture_sample_d16, ps_gather_sampler_lod, ps_sample_implicit_sint. Manually re-running vk_texture_test with LEONIDA_VK_VALIDATION=1 reproduces the message for any of them.

2. runtime/test/vk_sampler_test.cpp never enables shaderDrawParameters.

Its device chain is VkPhysicalDeviceVulkan12Features only (enable12 at ~line 149), and its cases draw with vs_ids too, so the same VUID fires for the sampler test (ps_ssharp here). Adding the VkPhysicalDeviceVulkan11Features with shaderDrawParameters = VK_TRUE in front of enable12, as vk_texture_test/vk_harness do, closes it.

Nothing here is a translated-shader or RADV issue: without validation the same 210 tests pass, and all compute tests in this run were clean. I can re-run the full suite on the RX 7600 and on the Ryzen iGPU (gfx1036, RDNA2) once the two chains are fixed, if that helps.

@TreXito

TreXito commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

@YaBulochka thanks, that matches the NVIDIA run exactly (same 17, same VUID). Both chains already have open PRs:

  1. vk_texture_test: tests: preserve DrawParameters when enabling Vulkan maintenance8 #3347 (whattheflop). It keeps f11 in the chain when maintenance8 is enabled.
  2. vk_sampler_test: vk_sampler_test: enable shaderDrawParameters for the translated vs_ids (VUID-08740 on ps_ssharp) #4067 (mine). It queries VkPhysicalDeviceVulkan11Features and enables shaderDrawParameters when the device has it, as vk_harness does.

On the RTX 3060 Ti, this branch with both cherry-picked (git cherry-pick bf059364 4eb8d084 on 6b301611) gives 164/210 under LEONIDA_VK_VALIDATION=1, the same as without the variable. Yes please, that combination on the RX 7600 and the gfx1036 iGPU would be the AMD half of the proof. Expected result: 196/210 (your 179 plus those 17), with no pCode-08740.

AI-assisted (Claude Code).

@YaBulochka

Copy link
Copy Markdown
Contributor

AMD half of the proof, as asked: 6b301611 plus the two cherry-picks bf059364 (#3347) and 4eb8d084 (#4067) applies cleanly.

RX 7600 (gfx1102, RADV Mesa 27.0.0-devel git-f7dd61f78f, Khronos Validation 1.4.363):

  • LEONIDA_VK_VALIDATION=1: 196/210 passed, 14 skipped, 0 failed
  • control, no variable: 196/210 passed, 14 skipped, 0 failed
  • the 14 skips are the d3d12_* fixtures, as usual; there is no pCode-08740 anywhere in the run.

Ryzen 5 9600X iGPU (gfx1036, RDNA2, same driver and layer), MESA_VK_DEVICE_SELECT=1002:13c0!:

  • LEONIDA_VK_VALIDATION=1: 196/210 passed, 14 skipped, 0 failed, also no pCode-08740.

So both chains are needed and sufficient here: with #3347 (vk_texture_test keeps f11 when maintenance8 goes in) and #4067 (vk_sampler_test enables shaderDrawParameters), the validation run matches the plain run exactly on both AMD devices, at the expected 179 + 17 = 196.

Build used: cmake --build runtime/build -j4 on the cherry-picked branch, no other local changes.

vk_compute_test.cpp: keep both includes (vk_validation.h from this branch,
cs_wave_probe_spv.h from main).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

5 participants