Skip to content

Commit 6533789

Browse files
authored
Fix texture_from_d3d11_shared_handle compatibility on AMD/Nvidia GPUs (gfx-rs#7782)
* wrapper dedicated allocate info * comment on why p_next is set manually
1 parent f96ac55 commit 6533789

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

wgpu-hal/src/vulkan/device.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,19 @@ impl super::Device {
761761
let image =
762762
self.create_image_without_memory(desc, Some(&mut external_memory_image_info))?;
763763

764+
// Some external memory types require dedicated allocation
765+
// https://docs.vulkan.org/guide/latest/extensions/external.html#_importing_memory
766+
let mut dedicated_allocate_info =
767+
vk::MemoryDedicatedAllocateInfo::default().image(image.raw);
768+
764769
let mut import_memory_info = vk::ImportMemoryWin32HandleInfoKHR::default()
765770
.handle_type(vk::ExternalMemoryHandleTypeFlags::D3D11_TEXTURE)
766771
.handle(d3d11_shared_handle.0 as _);
772+
// TODO: We should use `push_next` instead, but currently ash does not provide this method for the `ImportMemoryWin32HandleInfoKHR` type.
773+
#[allow(clippy::unnecessary_mut_passed)]
774+
{
775+
import_memory_info.p_next = <*const _>::cast(&mut dedicated_allocate_info);
776+
}
767777

768778
let mem_type_index = self
769779
.find_memory_type_index(

0 commit comments

Comments
 (0)