Commit Graph

5 Commits

Author SHA1 Message Date
Ollie Hensman-Crook
0e8e4f14c8 LibGfx: Fall back when dmabuf modifiers are unsupported
If create_shared_vulkan_image() cannot provide any of the requested DRM
format modifiers, return an
  error so BackingStoreManager falls back to
ShareableBitmap backing stores instead of continuing into a dmabuf
import that later aborts.
2026-04-14 23:56:26 +02:00
Aliaksandr Kalenik
9a4e731746 LibGfx+LibWeb: Add Linux dmabuf backing stores to SharedImage
On Linux builds with Vulkan, WebContent already paints into GPU-backed
Skia surfaces, but the backing store shared with the UI process was
still a CPU ShareableBitmap. That forced every flush to read the GPU
image back into a bitmap so the UI could sample it, defeating most of
the benefit of GPU painting.

Teach SharedImage to carry a LinuxDmaBufHandle alongside ShareableBitmap
as a Variant, with a tagged IPC encoding and an fd clone on encode so
both processes own an independent handle. When USE_VULKAN_DMABUF_IMAGES
is enabled, BackingStoreManager now allocates the front/back buffers as
linear-modifier Vulkan images and publishes their dmabuf fds to the UI;
the Skia painting surfaces wrap those Vulkan images directly, so no
readback is needed. The old shareable-bitmap path is preserved as a
fallback for the non-Vulkan case and when image creation fails.

On the receive side, SharedImageBuffer::import_from_shared_image mmaps
a linear dmabuf to reconstruct a CPU Bitmap, keeping existing consumers
that expect CPU access working unchanged.

VulkanImage memory type selection is factored into a small helper, and
linear images now request host-visible (cached if available) memory
rather than device-local, since a linear dmabuf has to be CPU-mappable
on the importer side.
2026-04-14 21:49:08 +02:00
Aliaksandr Kalenik
0fdafaaf48 LibGfx: Make create_shared_vulkan_image() accept modifiers as a span 2026-04-14 21:49:08 +02:00
Aliaksandr Kalenik
d093edbe6d LibGfx: Make VulkanImage::get_dma_buf_fd() const 2026-04-14 21:49:08 +02:00
Aliaksandr Kalenik
46fcf51bf7 LibGfx: Move VulkanImage into a separate file 2026-04-12 21:18:33 +02:00