Skip to content

vk_compute_test: run under validation with LEONIDA_VK_VALIDATION, fail on a validation error (TEST-877) - #4005

Open
TreXito wants to merge 3 commits into
ItsNotRexed:mainfrom
TreXito:test/877-compute-validation
Open

TreXito wants to merge 3 commits into
ItsNotRexed:mainfrom
TreXito:test/877-compute-validation

Conversation

@TreXito

@TreXito TreXito commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

TEST-877 (found by @zzEmmazz, finding).

vk_compute_test built its instance without layers and ignored LEONIDA_VK_VALIDATION. A validation message also 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.

What changes:

  • New runtime/test/vk_validation.h (OptInValidation, header only):
    • With LEONIDA_VK_VALIDATION set and not 0, it adds VK_LAYER_KHRONOS_validation, VK_EXT_debug_utils and a messenger to the instance info, keeping whatever the program already enables. The messenger also covers instance creation.
    • Every message goes to stderr. Only validation-type errors are counted, as in vk_bindless_test, so a broken third-party layer can't fail a test.
    • exit_status(rc) turns counted errors into exit 1 (also over 0 and 77) and prints N validation errors.
    • A missing layer is an error, not a silent run without validation.
  • vk_compute_test uses it. main now wraps the old body, so every path ends through exit_status. That includes the errors GPU-AV reports when the queue finishes, after the words were judged.
  • The layer's own variables still apply, so LEONIDA_VK_VALIDATION=1 VK_KHRONOS_VALIDATION_GPUAV_ENABLE=1 python scripts/run_gpu_tests.py now fails every compute test the layer objects to.
  • Without the variable nothing changes. The device: line gains (validation on) only when it is set. The subgroup MIN..MAX regexes in check.py and run_gpu_tests.py still match.
  • docs/testing.md says this. It also stops listing vk_bindless_test and vk_image_fuzz as programs that ignore the variable, because both read it.

The other four programs (vk_harness, vk_store_test, vk_texture_test, vk_sampler_test) get the same helper in a follow-up PR, claimed as a new item.

Tested on RTX 3060 Ti, driver 580.173.02, Linux, Khronos validation layer 1.4.357. Base main aa2988c against this branch with #4025 on top (head 6b30161). Controls are vk_compute_test <spv> 1 dump:

control main, LEONIDA_VK_VALIDATION=1 + GPU-AV this branch, variable set this branch, + GPU-AV
translated cs_lds (clean) exit 0 exit 0 exit 0
same + OpCapability Int16 (feature never enabled) exit 0 exit 1, VUID-VkShaderModuleCreateInfo-pCode-08740 exit 1
store 256 bytes past the heap (PhysicalStorageBuffer) exit 0 exit 0 (core validation can't see it) exit 1, VUID-RuntimeSpirv-PhysicalStorageBuffer64-11819
  • out[0..7] is identical in every run of a row, so validation only changes the exit status.
  • With the variable set and the layer hidden: exit 1, LEONIDA_VK_VALIDATION is set but VK_LAYER_KHRONOS_validation is not installed.
  • Whole suite (python -I scripts/run_gpu_tests.py) without the variable: 164/210 passed, 46 skipped, the same as main.
  • With the variable: every compute test still passes. The 17 new failures are all pixel-shader tests drawn by vk_texture_test / vk_sampler_test (so they come from vk_harness, vk_store_test, vk_texture_test, vk_sampler_test: run under validation with LEONIDA_VK_VALIDATION (TEST-877 follow-up) #4025), with one VUID: a translated VS declares DrawParameters and the device never enabled shaderDrawParameters. tests: preserve DrawParameters when enabling Vulkan maintenance8 #3347 (whattheflop) fixes vk_texture_test, and vk_sampler_test: enable shaderDrawParameters for the translated vs_ids (VUID-08740 on ps_ssharp) #4067 fixes vk_sampler_test.
  • With GPU-AV: 6 compute LDS tests also fail, all on GPU-AV's shared-memory data-race check. cs_w32_lds_wide, cs_w32_lds_subdword and cs_w32_lds_u8_d16 write one LDS dword from every lane by design (their header says so), which is a race under the Vulkan memory model and harmless on hardware. cs_lds_b64_cmpst, cs_w32_misc_ext and cs_w32_new_ops cut EXEC to lane 0 first. The translated LDS ops sit in %active branches, so only invocation 0 runs the atomic and the later load, in program order. The layer reports these as "Likely against unknown invocation", so they look like layer false positives, not translator bugs.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

…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>
@FIocker

FIocker commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Independent Windows/RTX 5080 check at 9b28252a, AI-assisted. NVIDIA 621.01, Vulkan loader and Khronos validation 1.4.357, MSVC 19.44/Ninja. With the layer absent, the harness gave exit 1 and the missing-layer diagnostic. With the layer installed for the test, a valid synthetic LDS shader had identical readbacks and exit 0 with validation off, core checks, and GPU-assisted validation (whose startup message confirmed activation). A statically valid empty compute shader with an unused Int16 capability gave exit 0 with validation off and exit 1 with validation on; the layer reported VUID-VkShaderModuleCreateInfo-pCode-08740, the dispatch still printed zero result mismatches, and the wrapper counted one validation error. Temporary explicit-layer registration was removed and prior entries verified.

@Mia-ld

Mia-ld commented Nov 22, 2026

Copy link
Copy Markdown

Tested 9b28252a on NVIDIA GeForce RTX 5080 Laptop GPU (subgroup 32..32, driver 621.24), Windows 11, MSVC 2022 (RelWithDebInfo): pass

  • LEONIDA_VK_VALIDATION=1 python scripts/run_gpu_tests.py (LLVM 21.1.8): 214/214 shaders translated and passed spirv-val; 164/210 passed, 46 skipped (0 failures, 0 validation errors; (validation on) confirmed active on device).
  • ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure: 100% tests passed, 0 tests failed out of 145 (9 skipped, 1 disabled).

@TreXito
TreXito marked this pull request as ready for review November 22, 2026 23:18
@YaBulochka

Copy link
Copy Markdown
Contributor

Compute side is clean on AMD RADV. Built the branch and ran the full GPU suite with LEONIDA_VK_VALIDATION=1 on an RX 7600 (gfx1102, RADV Mesa 27.0.0-devel git-f7dd61f78f, Vulkan 1.4.363, Khronos Validation 1.4.363): all 99 compute tests that run here passed, no validation messages from vk_compute_test (14 skips are the d3d12_* fixtures, as usual).

The 17 failures in that run are all VUID-VkShaderModuleCreateInfo-pCode-08740 (DrawParameters) and belong to #4025's programs: vk_texture_test drops its Vulkan-11 feature struct when it inserts maintenance8 (RADV has that extension), and vk_sampler_test never enables shaderDrawParameters. Details are in #4025; nothing in this PR's scope fails.

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.

4 participants