@@ -783,12 +783,7 @@ impl super::Device {
783783 vk_info = vk_info. push_next ( ext_info) ;
784784 }
785785
786- let raw = unsafe {
787- self . shared
788- . raw
789- . create_image ( & vk_info, None )
790- . map_err ( map_err) ?
791- } ;
786+ let raw = unsafe { self . shared . raw . create_image ( & vk_info, None ) } . map_err ( map_err) ?;
792787 fn map_err ( err : vk:: Result ) -> crate :: DeviceError {
793788 // We don't use VK_EXT_image_compression_control
794789 // VK_ERROR_COMPRESSION_EXHAUSTED_EXT
@@ -803,6 +798,7 @@ impl super::Device {
803798 ///
804799 /// - Vulkan 1.1+ (or VK_KHR_external_memory)
805800 /// - The `d3d11_shared_handle` must be valid and respecting `desc`
801+ /// - `VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT` flag is used because we need to hold a reference to the handle
806802 #[ cfg( windows) ]
807803 pub unsafe fn texture_from_d3d11_shared_handle (
808804 & self ,
@@ -814,38 +810,28 @@ impl super::Device {
814810 }
815811
816812 let mut external_memory_image_info = vk:: ExternalMemoryImageCreateInfo :: default ( )
817- . handle_types ( vk:: ExternalMemoryHandleTypeFlags :: D3D11_TEXTURE_KMT ) ;
813+ . handle_types ( vk:: ExternalMemoryHandleTypeFlags :: D3D11_TEXTURE ) ;
818814
819815 let ( raw, req, copy_size, wgt_view_formats, raw_flags) =
820816 self . create_image_without_memory ( desc, Some ( & mut external_memory_image_info) ) ?;
821817
822818 let mut import_memory_info = vk:: ImportMemoryWin32HandleInfoKHR :: default ( )
823- . handle_type ( vk:: ExternalMemoryHandleTypeFlags :: D3D11_TEXTURE_KMT )
819+ . handle_type ( vk:: ExternalMemoryHandleTypeFlags :: D3D11_TEXTURE )
824820 . handle ( d3d11_shared_handle as _ ) ;
825821
826- let Some ( mem_type_index) = self
822+ let mem_type_index = self
827823 . find_memory_type_index ( req. memory_type_bits , vk:: MemoryPropertyFlags :: DEVICE_LOCAL )
828- else {
829- return Err ( crate :: DeviceError :: ResourceCreationFailed ) ;
830- } ;
824+ . ok_or ( crate :: DeviceError :: ResourceCreationFailed ) ?;
831825
832826 let memory_allocate_info = vk:: MemoryAllocateInfo :: default ( )
833827 . allocation_size ( req. size )
834828 . memory_type_index ( mem_type_index as _ )
835829 . push_next ( & mut import_memory_info) ;
836- let memory = unsafe {
837- self . shared
838- . raw
839- . allocate_memory ( & memory_allocate_info, None )
840- . map_err ( super :: map_host_device_oom_err) ?
841- } ;
830+ let memory = unsafe { self . shared . raw . allocate_memory ( & memory_allocate_info, None ) }
831+ . map_err ( super :: map_host_device_oom_err) ?;
842832
843- unsafe {
844- self . shared
845- . raw
846- . bind_image_memory ( raw, memory, 0 )
847- . map_err ( super :: map_host_device_oom_err) ?
848- } ;
833+ unsafe { self . shared . raw . bind_image_memory ( raw, memory, 0 ) }
834+ . map_err ( super :: map_host_device_oom_err) ?;
849835
850836 if let Some ( label) = desc. label {
851837 unsafe { self . shared . set_object_name ( raw, label) } ;
0 commit comments