Skip to content

Commit 7de3fde

Browse files
committed
expose VULKAN_EXTERNAL_MEMORY_WIN32 feature
1 parent 7c75ac7 commit 7de3fde

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

wgpu-hal/src/vulkan/adapter.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,11 @@ impl PhysicalDeviceFeatures {
776776
caps.supports_extension(google::display_timing::NAME),
777777
);
778778

779+
features.set(
780+
F::VULKAN_EXTERNAL_MEMORY_WIN32,
781+
caps.supports_extension(khr::external_memory_win32::NAME),
782+
);
783+
779784
(features, dl_flags)
780785
}
781786

@@ -1554,9 +1559,6 @@ impl super::Instance {
15541559
.is_some_and(|ext| ext.shader_zero_initialize_workgroup_memory == vk::TRUE),
15551560
image_format_list: phd_capabilities.device_api_version >= vk::API_VERSION_1_2
15561561
|| phd_capabilities.supports_extension(khr::image_format_list::NAME),
1557-
#[cfg(windows)]
1558-
external_memory_win32: phd_capabilities
1559-
.supports_extension(khr::external_memory_win32::NAME),
15601562
};
15611563
let capabilities = crate::Capabilities {
15621564
limits: phd_capabilities.to_wgpu_limits(),

wgpu-hal/src/vulkan/device.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ impl super::Device {
786786

787787
/// # Safety
788788
///
789-
/// - Vulkan 1.1+ (or VK_KHR_external_memory)
789+
/// - Vulkan (with VK_KHR_external_memory_win32)
790790
/// - The `d3d11_shared_handle` must be valid and respecting `desc`
791791
/// - `VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT` flag is used because we need to hold a reference to the handle
792792
#[cfg(windows)]
@@ -795,8 +795,12 @@ impl super::Device {
795795
d3d11_shared_handle: windows::Win32::Foundation::HANDLE,
796796
desc: &crate::TextureDescriptor,
797797
) -> Result<super::Texture, crate::DeviceError> {
798-
if !self.shared.private_caps.external_memory_win32 {
799-
log::error!("VK_KHR_external_memory extension is required");
798+
if !self
799+
.shared
800+
.features
801+
.contains(wgt::Features::VULKAN_EXTERNAL_MEMORY_WIN32)
802+
{
803+
log::error!("Vulkan driver does not support VK_KHR_external_memory_win32");
800804
return Err(crate::DeviceError::ResourceCreationFailed);
801805
}
802806

wgpu-hal/src/vulkan/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,6 @@ struct PrivateCapabilities {
532532
robust_image_access2: bool,
533533
zero_initialize_workgroup_memory: bool,
534534
image_format_list: bool,
535-
#[cfg(windows)]
536-
external_memory_win32: bool,
537535
}
538536

539537
bitflags::bitflags!(

wgpu-types/src/lib.rs

+10
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,16 @@ bitflags::bitflags! {
942942
/// [VK_GOOGLE_display_timing]: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_GOOGLE_display_timing.html
943943
/// [`Surface::as_hal()`]: https://docs.rs/wgpu/latest/wgpu/struct.Surface.html#method.as_hal
944944
const VULKAN_GOOGLE_DISPLAY_TIMING = 1 << 62;
945+
946+
/// Allows using the [VK_KHR_external_memory_win32] Vulkan extension.
947+
///
948+
/// Supported platforms:
949+
/// - Vulkan (with [VK_KHR_external_memory_win32])
950+
///
951+
/// This is a native only feature.
952+
///
953+
/// [VK_KHR_external_memory_win32]: https://registry.khronos.org/vulkan/specs/latest/man/html/VK_KHR_external_memory_win32.html
954+
const VULKAN_EXTERNAL_MEMORY_WIN32 = 1 << 63;
945955
}
946956
}
947957

0 commit comments

Comments
 (0)