@@ -773,12 +773,7 @@ impl super::Device {
773773 vk_info = vk_info. push_next ( ext_info) ;
774774 }
775775
776- let raw = unsafe {
777- self . shared
778- . raw
779- . create_image ( & vk_info, None )
780- . map_err ( map_err) ?
781- } ;
776+ let raw = unsafe { self . shared . raw . create_image ( & vk_info, None ) } . map_err ( map_err) ?;
782777 fn map_err ( err : vk:: Result ) -> crate :: DeviceError {
783778 // We don't use VK_EXT_image_compression_control
784779 // VK_ERROR_COMPRESSION_EXHAUSTED_EXT
@@ -793,6 +788,7 @@ impl super::Device {
793788 ///
794789 /// - Vulkan 1.1+ (or VK_KHR_external_memory)
795790 /// - The `d3d11_shared_handle` must be valid and respecting `desc`
791+ /// - `VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT` flag is used because we need to hold a reference to the handle
796792 #[ cfg( windows) ]
797793 pub unsafe fn texture_from_d3d11_shared_handle (
798794 & self ,
@@ -804,38 +800,28 @@ impl super::Device {
804800 }
805801
806802 let mut external_memory_image_info = vk:: ExternalMemoryImageCreateInfo :: default ( )
807- . handle_types ( vk:: ExternalMemoryHandleTypeFlags :: D3D11_TEXTURE_KMT ) ;
803+ . handle_types ( vk:: ExternalMemoryHandleTypeFlags :: D3D11_TEXTURE ) ;
808804
809805 let ( raw, req, copy_size, wgt_view_formats, raw_flags) =
810806 self . create_image_without_memory ( desc, Some ( & mut external_memory_image_info) ) ?;
811807
812808 let mut import_memory_info = vk:: ImportMemoryWin32HandleInfoKHR :: default ( )
813- . handle_type ( vk:: ExternalMemoryHandleTypeFlags :: D3D11_TEXTURE_KMT )
809+ . handle_type ( vk:: ExternalMemoryHandleTypeFlags :: D3D11_TEXTURE )
814810 . handle ( d3d11_shared_handle as _ ) ;
815811
816- let Some ( mem_type_index) = self
812+ let mem_type_index = self
817813 . find_memory_type_index ( req. memory_type_bits , vk:: MemoryPropertyFlags :: DEVICE_LOCAL )
818- else {
819- return Err ( crate :: DeviceError :: ResourceCreationFailed ) ;
820- } ;
814+ . ok_or ( crate :: DeviceError :: ResourceCreationFailed ) ?;
821815
822816 let memory_allocate_info = vk:: MemoryAllocateInfo :: default ( )
823817 . allocation_size ( req. size )
824818 . memory_type_index ( mem_type_index as _ )
825819 . push_next ( & mut import_memory_info) ;
826- let memory = unsafe {
827- self . shared
828- . raw
829- . allocate_memory ( & memory_allocate_info, None )
830- . map_err ( super :: map_host_device_oom_err) ?
831- } ;
820+ let memory = unsafe { self . shared . raw . allocate_memory ( & memory_allocate_info, None ) }
821+ . map_err ( super :: map_host_device_oom_err) ?;
832822
833- unsafe {
834- self . shared
835- . raw
836- . bind_image_memory ( raw, memory, 0 )
837- . map_err ( super :: map_host_device_oom_err) ?
838- } ;
823+ unsafe { self . shared . raw . bind_image_memory ( raw, memory, 0 ) }
824+ . map_err ( super :: map_host_device_oom_err) ?;
839825
840826 if let Some ( label) = desc. label {
841827 unsafe { self . shared . set_object_name ( raw, label) } ;
0 commit comments