From 8f7e7201d0e9e7ea9c90bbd5d9c073bc0f336cb1 Mon Sep 17 00:00:00 2001 From: Erich Gubler Date: Fri, 9 Feb 2024 23:03:00 -0500 Subject: [PATCH] amend! feat(vulkan): enable GPU-based validation for Vulkan backend MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat(vulkan): enable GPU-based validation for Vulkan backend If [`VK_LAYER_KHRONOS_validation`] is present, and it supports [`VK_EXT_validation_features`], we can configure it with another instance creation info. element of type [`VkValidationFeaturesEXT`] to enable GPU-based validation. Wire `InstanceFlags::GPU_BASED_VALIDATION` to do this in the Vulkan backend. It's even already finding issues in our `examples` and other tests! But…we'd like to handle those later, since this is so important for users. So, I've broken that out to separate issues. The instances we're aware of: * `water` is running into sync. validation issues: see * `wgpu_test::shader::struct_layout::uniform_input` is failing to instrument shaders now; see It is apparent from this and the [DX12 implementation of GPU-based validation] that we will need to communicate clearly to users that `InstanceFlags::GPU_BASED_VALIDATION` implies `InstanceFlags::VALIDATION`. Not all backends enforce this yet; I have [split out this work][follow-up for flag implication]. Note that `VK_EXT_validation_features` has been deprecated in favor of the more general layer configuration mechanism offered by [`VK_EXT_layer_settings`]. [DX12 implementation of GPU-based validation]: https://github.com/gfx-rs/wgpu/pull/5146 [`VK_EXT_layer_settings`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_layer_settings.html [`VK_EXT_validation_features`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_EXT_validation_features.html [`VK_LAYER_KHRONOS_validation`]:https://vulkan.lunarg.com/doc/sdk/1.3.275.0/linux/khronos_validation_layer.html [`VkValidationFeaturesEXT`]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkValidationFeaturesEXT.html [follow-up for flag implication]: https://github.com/gfx-rs/wgpu/pull/5232 --- tests/tests/shader/struct_layout.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/tests/shader/struct_layout.rs b/tests/tests/shader/struct_layout.rs index f5acde971c9..3aa731f9466 100644 --- a/tests/tests/shader/struct_layout.rs +++ b/tests/tests/shader/struct_layout.rs @@ -229,6 +229,11 @@ static UNIFORM_INPUT: GpuTestConfiguration = GpuTestConfiguration::new() FailureCase::backend(wgpu::Backends::VULKAN) .validation_error("a matrix with stride 8 not satisfying alignment to 16"), ) + .expect_fail( + FailureCase::backend(wgpu::Backends::VULKAN).validation_error( + "Failure to instrument shader. Proceeding with non-instrumented shader.", + ), + ) .limits(Limits::downlevel_defaults()), ) .run_async(|ctx| {