From 6d387d77b9446fdbca24e9d107684bd236b9f4ee Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Mon, 29 Jun 2026 16:31:24 -0400 Subject: [PATCH] Cherry Pick #9741 to v29 (#9767) Co-authored-by: Francis De Brabandere --- CHANGELOG.md | 6 ++++++ wgpu-hal/src/vulkan/adapter.rs | 28 +++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 593296873..331943248 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,12 @@ Bottom level categories: ## Unreleased +### Bug Fixes + +#### Vulkan + +- Fixed `VUID-RuntimeSpirv-vulkanMemoryModel-06265` validation errors by enabling `vulkanMemoryModelDeviceScope` whenever the Vulkan memory model is enabled, since the SPIR-V backend emits storage atomics with `Device` scope. By @francisdb in [#9741](https://github.com/gfx-rs/wgpu/pull/9741). + ## v29.0.3 (2026-05-01) ### Bug Fixes diff --git a/wgpu-hal/src/vulkan/adapter.rs b/wgpu-hal/src/vulkan/adapter.rs index 7f9daa1cd..7e8182c2c 100644 --- a/wgpu-hal/src/vulkan/adapter.rs +++ b/wgpu-hal/src/vulkan/adapter.rs @@ -612,7 +612,13 @@ impl PhysicalDeviceFeatures { requested_features.contains(wgt::Features::EXPERIMENTAL_COOPERATIVE_MATRIX); Some( vk::PhysicalDeviceVulkanMemoryModelFeaturesKHR::default() - .vulkan_memory_model(needed), + .vulkan_memory_model(needed) + // The SPIR-V backend emits storage atomics with `Device` + // memory scope, so whenever the Vulkan memory model is + // enabled we must also enable device scope, otherwise the + // validation layers report + // `VUID-RuntimeSpirv-vulkanMemoryModel-06265`. + .vulkan_memory_model_device_scope(needed), ) } else { None @@ -1041,10 +1047,17 @@ impl PhysicalDeviceFeatures { .map(|p| p.multisample_array_image == vk::TRUE) .unwrap_or(true), ); - // Enable cooperative matrix if any configuration is supported + // Enable cooperative matrix if any configuration is supported. The SPIR-V + // we emit for it uses `Device`-scope atomics under the Vulkan memory model, + // so the device must also support `vulkanMemoryModelDeviceScope`, otherwise + // those shaders trip `VUID-RuntimeSpirv-vulkanMemoryModel-06265`. features.set( F::EXPERIMENTAL_COOPERATIVE_MATRIX, - !caps.cooperative_matrix_properties.is_empty(), + !caps.cooperative_matrix_properties.is_empty() + && self.vulkan_memory_model.is_some_and(|m| { + m.vulkan_memory_model == vk::TRUE + && m.vulkan_memory_model_device_scope == vk::TRUE + }), ); features.set( @@ -2055,6 +2068,15 @@ impl super::InstanceShared { features2 = features2.push_next(next); } + if capabilities.device_api_version >= vk::API_VERSION_1_2 + || capabilities.supports_extension(khr::vulkan_memory_model::NAME) + { + let next = features + .vulkan_memory_model + .insert(vk::PhysicalDeviceVulkanMemoryModelFeaturesKHR::default()); + features2 = features2.push_next(next); + } + if capabilities.device_api_version >= vk::API_VERSION_1_1 { let next = features .shader_draw_parameters