fix(vulkan): enable vulkanMemoryModelDeviceScope with the memory model (#9741)

This commit is contained in:
Francis De Brabandere authored and GitHub committed 2026-06-28 22:26:49 -04:00
1 parent 3fb225a9c6
commit 56535d7d90
2 files changed
+26 -3

No files matched your search

+1
View File
@@ -280,6 +280,7 @@ By @stuartparmenter in [#9658](https://github.com/gfx-rs/wgpu/pull/9658).
- Fixed vkAcquireNextImage fence being awaited on non-Windows platforms causing frametime spikes on nvidia drivers. By @cohaereo in [#9486](https://github.com/gfx-rs/wgpu/pull/9486).
- Fixed alignment and `MatrixStride` for mat2x2 in SPIR-V uniform blocks. By @39ali [#9369](https://github.com/gfx-rs/wgpu/pull/9369).
- Fixed loading of `libvulkan.so` on OpenHarmony (`target_env = "ohos"`). By @jschwe in [#9649](https://github.com/gfx-rs/wgpu/pull/9649).
- 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).
#### DX12
+25 -3
View File
@@ -628,7 +628,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
@@ -1079,10 +1085,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(
@@ -2174,6 +2187,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