Skip to content

Commit 4fe28d8

Browse files
committed
external_memory_win32 apability
1 parent a93cc07 commit 4fe28d8

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

wgpu-hal/src/vulkan/adapter.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,11 @@ impl PhysicalDeviceProperties {
897897
if requested_features.contains(wgt::Features::TEXTURE_FORMAT_NV12) {
898898
extensions.push(khr::sampler_ycbcr_conversion::NAME);
899899
}
900+
901+
// Optional `VK_KHR_external_memory_win32`
902+
if self.supports_extension(khr::external_memory_win32::NAME) {
903+
extensions.push(khr::external_memory_win32::NAME);
904+
}
900905
}
901906

902907
if self.device_api_version < vk::API_VERSION_1_2 {
@@ -1494,6 +1499,8 @@ impl super::Instance {
14941499
}),
14951500
image_format_list: phd_capabilities.device_api_version >= vk::API_VERSION_1_2
14961501
|| phd_capabilities.supports_extension(khr::image_format_list::NAME),
1502+
external_memory_win32: phd_capabilities.device_api_version >= vk::API_VERSION_1_1
1503+
|| phd_capabilities.supports_extension(khr::external_memory_win32::NAME),
14971504
};
14981505
let capabilities = crate::Capabilities {
14991506
limits: phd_capabilities.to_wgpu_limits(),

wgpu-hal/src/vulkan/device.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,13 +790,19 @@ impl super::Device {
790790
}
791791

792792
/// # Safety
793-
/// The `d3d11_shared_handle` must be valid and respecting `desc`.
793+
///
794+
/// - Vulkan 1.1+ (or VK_KHR_external_memory)
795+
/// - The `d3d11_shared_handle` must be valid and respecting `desc`
794796
#[cfg(windows)]
795797
pub unsafe fn texture_from_d3d11_shared_handle(
796798
&self,
797799
d3d11_shared_handle: *mut std::ffi::c_void,
798800
desc: &crate::TextureDescriptor,
799801
) -> Result<super::Texture, crate::DeviceError> {
802+
if !self.shared.private_caps.external_memory_win32 {
803+
return Err(crate::DeviceError::ResourceCreationFailed);
804+
}
805+
800806
let mut external_memory_image_info = vk::ExternalMemoryImageCreateInfo::default()
801807
.handle_types(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE_KMT);
802808

wgpu-hal/src/vulkan/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ struct PrivateCapabilities {
451451
robust_image_access2: bool,
452452
zero_initialize_workgroup_memory: bool,
453453
image_format_list: bool,
454+
external_memory_win32: bool,
454455
}
455456

456457
bitflags::bitflags!(

0 commit comments

Comments
 (0)