Skip to content

Commit b378e9b

Browse files
committed
fix handle_type
1 parent 79632e8 commit b378e9b

File tree

1 file changed

+10
-24
lines changed

1 file changed

+10
-24
lines changed

wgpu-hal/src/vulkan/device.rs

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,7 @@ impl super::Device {
776776
vk_info = vk_info.push_next(ext_info);
777777
}
778778

779-
let raw = unsafe {
780-
self.shared
781-
.raw
782-
.create_image(&vk_info, None)
783-
.map_err(map_err)?
784-
};
779+
let raw = unsafe { self.shared.raw.create_image(&vk_info, None) }.map_err(map_err)?;
785780
fn map_err(err: vk::Result) -> crate::DeviceError {
786781
// We don't use VK_EXT_image_compression_control
787782
// VK_ERROR_COMPRESSION_EXHAUSTED_EXT
@@ -796,6 +791,7 @@ impl super::Device {
796791
///
797792
/// - Vulkan 1.1+ (or VK_KHR_external_memory)
798793
/// - The `d3d11_shared_handle` must be valid and respecting `desc`
794+
/// - `VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT` flag is used because we need to hold a reference to the handle
799795
#[cfg(windows)]
800796
pub unsafe fn texture_from_d3d11_shared_handle(
801797
&self,
@@ -807,38 +803,28 @@ impl super::Device {
807803
}
808804

809805
let mut external_memory_image_info = vk::ExternalMemoryImageCreateInfo::default()
810-
.handle_types(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE_KMT);
806+
.handle_types(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE);
811807

812808
let (raw, req, copy_size, wgt_view_formats, raw_flags) =
813809
self.create_image_without_memory(desc, Some(&mut external_memory_image_info))?;
814810

815811
let mut import_memory_info = vk::ImportMemoryWin32HandleInfoKHR::default()
816-
.handle_type(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE_KMT)
812+
.handle_type(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE)
817813
.handle(d3d11_shared_handle as _);
818814

819-
let Some(mem_type_index) = self
815+
let mem_type_index = self
820816
.find_memory_type_index(req.memory_type_bits, vk::MemoryPropertyFlags::DEVICE_LOCAL)
821-
else {
822-
return Err(crate::DeviceError::ResourceCreationFailed);
823-
};
817+
.ok_or(crate::DeviceError::ResourceCreationFailed)?;
824818

825819
let memory_allocate_info = vk::MemoryAllocateInfo::default()
826820
.allocation_size(req.size)
827821
.memory_type_index(mem_type_index as _)
828822
.push_next(&mut import_memory_info);
829-
let memory = unsafe {
830-
self.shared
831-
.raw
832-
.allocate_memory(&memory_allocate_info, None)
833-
.map_err(super::map_host_device_oom_err)?
834-
};
823+
let memory = unsafe { self.shared.raw.allocate_memory(&memory_allocate_info, None) }
824+
.map_err(super::map_host_device_oom_err)?;
835825

836-
unsafe {
837-
self.shared
838-
.raw
839-
.bind_image_memory(raw, memory, 0)
840-
.map_err(super::map_host_device_oom_err)?
841-
};
826+
unsafe { self.shared.raw.bind_image_memory(raw, memory, 0) }
827+
.map_err(super::map_host_device_oom_err)?;
842828

843829
if let Some(label) = desc.label {
844830
unsafe { self.shared.set_object_name(raw, label) };

0 commit comments

Comments
 (0)