Skip to content

Commit aa15f97

Browse files
committed
external_memory_win32 apability
1 parent 59b7d72 commit aa15f97

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
@@ -902,6 +902,11 @@ impl PhysicalDeviceProperties {
902902
if requested_features.contains(wgt::Features::TEXTURE_FORMAT_NV12) {
903903
extensions.push(khr::sampler_ycbcr_conversion::NAME);
904904
}
905+
906+
// Optional `VK_KHR_external_memory_win32`
907+
if self.supports_extension(khr::external_memory_win32::NAME) {
908+
extensions.push(khr::external_memory_win32::NAME);
909+
}
905910
}
906911

907912
if self.device_api_version < vk::API_VERSION_1_2 {
@@ -1504,6 +1509,8 @@ impl super::Instance {
15041509
}),
15051510
image_format_list: phd_capabilities.device_api_version >= vk::API_VERSION_1_2
15061511
|| phd_capabilities.supports_extension(khr::image_format_list::NAME),
1512+
external_memory_win32: phd_capabilities.device_api_version >= vk::API_VERSION_1_1
1513+
|| phd_capabilities.supports_extension(khr::external_memory_win32::NAME),
15071514
};
15081515
let capabilities = crate::Capabilities {
15091516
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
@@ -793,13 +793,19 @@ impl super::Device {
793793
}
794794

795795
/// # Safety
796-
/// The `d3d11_shared_handle` must be valid and respecting `desc`.
796+
///
797+
/// - Vulkan 1.1+ (or VK_KHR_external_memory)
798+
/// - The `d3d11_shared_handle` must be valid and respecting `desc`
797799
#[cfg(windows)]
798800
pub unsafe fn texture_from_d3d11_shared_handle(
799801
&self,
800802
d3d11_shared_handle: *mut std::ffi::c_void,
801803
desc: &crate::TextureDescriptor,
802804
) -> Result<super::Texture, crate::DeviceError> {
805+
if !self.shared.private_caps.external_memory_win32 {
806+
return Err(crate::DeviceError::ResourceCreationFailed);
807+
}
808+
803809
let mut external_memory_image_info = vk::ExternalMemoryImageCreateInfo::default()
804810
.handle_types(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE_KMT);
805811

wgpu-hal/src/vulkan/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ struct PrivateCapabilities {
499499
robust_image_access2: bool,
500500
zero_initialize_workgroup_memory: bool,
501501
image_format_list: bool,
502+
external_memory_win32: bool,
502503
}
503504

504505
bitflags::bitflags!(

0 commit comments

Comments
 (0)