Open Bug 2002395 Opened 11 months ago Updated 11 months ago

`create_texture_with_shared_texture_dmabuf` should use `wgpu_hal`'s `external_memory` argument

Categories

(Core :: Graphics: WebGPU, enhancement, P5)

enhancement

Tracking

()

People

(Reporter: jimb, Unassigned)

References

Details

wgpu_bindings::server should rely on wgpu_hal::vulkan's own resource management to free the vk::DeviceMemory backing a swapchain texture, and remove our hand-coded VkImageHolder type that does exactly the same thing.

As of wgpu#8512, wgpu_hal::vulkan::Device::texture_from_raw can accept ownership of a vk::DeviceMemory presumed to hold the contents of the accompanying vk::Image, such that wgpu_hal::vulkan will free the DeviceMemory when the Texture is dropped. Thus, there is no need for Firefox to implement the same behavior itself via wgpu_bindings::server::VkImageHolder.

Be careful of the distinction between:

  • VkImageHandle, which owns a raw Vulkan image shared with WebRender for presentation. These are not managed by wgpu. They're owned by SharedTextureDMABuf, which participates in the whole RemoteTexture thing.
  • The wgpu_core::Textures created by create_texture_with_shared_texture_dmabuf for canvas textures. These are managed by wgpu, but share content with the VkImageHandles by exporting the image via VK_KHR_external_memory_fd and then re-importing it.

The latter are what we can simplify. The former don't touch wgpu_hal at all.

Depends on: 2000474
You need to log in before you can comment on or make changes to this bug.