Skip to content

fix(vulkan): enable Synchronization Validation and filter validation-only debug messages - #741

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
totonicpu:pr/vk-sync-validation
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
totonicpu:pr/vk-sync-validation

Conversation

@totonicpu

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: N/A (standalone validation hardening)

What and why

  • Chains VkValidationFeaturesEXT with VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT when LEONIDA_VK_VALIDATION=1 in runtime/test/vk_test_device.h and runtime/shims/d3d12_vulkan_device.cpp (create_vulkan_device_standalone), so GPU tests catch pipeline barrier and memory synchronization hazards in addition to core validation.
  • Filters VkDebugUtilsMessengerCreateInfoEXT::messageType and on_validation() in runtime/test/vk_test_device.h to VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT (matching runtime/test/vk_bindless_test.cpp). Previously, VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT caused unrelated broken Windows implicit loader layers (e.g. missing third-party overlay JSONs) to be counted as Vulkan validation errors and fail GPU tests.

Tested

NVIDIA GeForce RTX 4070 Ti, driver 616.56, Vulkan 1.4.351 (VK_LAYER_KHRONOS_validation with Synchronization Validation enabled):

  • MSVC RelWithDebInfo & Debug (/W4 /permissive- /utf-8): 0 errors, 0 warnings.
  • ctest -C RelWithDebInfo: 23/23 PASS.
  • GPU tests (RelWithDebInfo & Debug, LEONIDA_VK_VALIDATION=1): vk_command_replay_test, d3d12_com_test, d3d12_vulkan_device_test, d3d12_descriptor_test (with cs_sample.comp), and d3d12_uint_clear_test — all PASS with 0 Core + Synchronization Validation errors.
  • dotnet build tools/rpf9dump/rpf9dump.csproj -c Release: 0 errors, 0 warnings.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (N/A — runtime/test validation only)

@Derpbeat

Copy link
Copy Markdown
Contributor

Tested d00864d on an NVIDIA GeForce RTX 4090 (driver 617.14, Vulkan 1.4.351), Windows 10 Home 22H2 (19045), MSVC 19.39, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0 (Khronos validation layer from that SDK), Ninja RelWithDebInfo, LEONIDA_VK_VALIDATION=1. The change does what it says, and on current main sync validation finds real hazards in d3d12_vulkan_device_test. (TEST-98 territory: counting only validation-type messages.)

On the PR's own base (ee97b84, 417 commits behind main): builds clean. Every GPU test I ran reports 0 validation messages with sync validation on (vk_texture/compute/store/bindless_test, vk_command_replay_test, d3d12_com_test, d3d12_descriptor_test). On this Windows 10 machine d3d12_vulkan_device_test stops early at its footprint comparison (TEST-97, fixed by #717), and root_signature_oracle fails on the 1.2 serializer. Both are known Windows 10 issues that main has since addressed, not from this PR.

Merged onto current main (67204bf; the merge is clean):

  • ctest: 28/29. d3d12_vulkan_device fails, only because of 10 sync-validation errors. Every pixel and footprint check in it matched (I made the two Windows 10 host comparisons non-fatal locally, as tests: keep d3d12_vulkan_device_test running on Windows 10 (TEST-97) #717 does).
  • Main without this PR: 0 validation errors in the same run, so these are newly visible, not new bugs from the PR.
  • The messages are all WRITE_AFTER_WRITE between consecutive copies into the same image subresource, with nothing between them:
    • 6 × vkCmdCopyImage(): WRITE_AFTER_WRITE hazard detected ... previously written by another vkCmdCopyImage command (for example mip 2, layer 1, a 4×5 region);
    • 3 × the same for vkCmdCopyBufferToImage;
    • then This VUID has now been reported 10 times, which is the duplicate_message_limit value, so there are probably more.
  • Every other GPU test (d3d12_com_test, d3d12_descriptor_test, d3d12_method_variants_test, vk_command_replay_test, vk_*) is still at 0 with sync validation on.

So the replay emits back-to-back transfer writes to overlapping subresources without a transfer→transfer barrier. That looks like a real gap in the copy replay: D3D12 apps don't put a barrier between two copies into a resource that stays in COPY_DEST, so the layer would have to add one. It could also be overlapping copies in the newer test cases. Either way, it's worth an item of its own rather than blocking this PR. But it means this PR, once rebased, will turn d3d12_vulkan_device red under LEONIDA_VK_VALIDATION=1 until that's fixed or the hazards are allowed for. A rebase onto main before merging would show it in CI too.

Two smaller notes:

  • VkValidationFeaturesEXT is chained without enabling VK_EXT_validation_features. This layer didn't complain, so it seems fine in practice, but enabling the extension when the layer offers it would be the strictly valid form.
  • With the messenger now VALIDATION_BIT only, the type check added in on_validation is redundant, though harmless as a belt and braces.

AI-assisted (Claude Code); repository tests only, no game files.

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.

3 participants