Fix texture_from_d3d11_shared_handle compatibility on AMD/Nvidia GPUs (#7782)

* wrapper dedicated allocate info

* comment on why p_next is set manually
This commit is contained in:
Xiaopeng Li 2025-06-14 02:48:56 +08:00 committed by GitHub
parent f96ac55aa4
commit 65337894f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -761,9 +761,19 @@ impl super::Device {
let image =
self.create_image_without_memory(desc, Some(&mut external_memory_image_info))?;
// Some external memory types require dedicated allocation
// https://docs.vulkan.org/guide/latest/extensions/external.html#_importing_memory
let mut dedicated_allocate_info =
vk::MemoryDedicatedAllocateInfo::default().image(image.raw);
let mut import_memory_info = vk::ImportMemoryWin32HandleInfoKHR::default()
.handle_type(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE)
.handle(d3d11_shared_handle.0 as _);
// TODO: We should use `push_next` instead, but currently ash does not provide this method for the `ImportMemoryWin32HandleInfoKHR` type.
#[allow(clippy::unnecessary_mut_passed)]
{
import_memory_info.p_next = <*const _>::cast(&mut dedicated_allocate_info);
}
let mem_type_index = self
.find_memory_type_index(