render/vulkan: Use VK_EXT_host_image_copy for shm

When uploading shm buffers to our internal backing texture, we first
allocate suitable chunk from our staging buffer accessible from both CPU
and GPU, and then we queue a GPU-side copy from the staging buffer to
the texture. This is a lot of copying, especially on iGPUs where
everything is system memory anyway.

Instead, use VK_EXT_host_image_copy when available for formats that are
reported as having optimal device access. This allows us to copy
directly to the target texture from CPU, eliminating the queued GPU-side
copy. To keep things simple we keep this texture in GENERAL for the
entire duration for now.
This commit is contained in:
Kenny Levinsen 2026-04-17 01:08:25 +02:00
parent e8c03e9ce9
commit 9a457a3f1d
4 changed files with 199 additions and 17 deletions

View file

@ -44,6 +44,7 @@ struct wlr_vk_device {
bool sync_file_import_export;
bool implicit_sync_interop;
bool sampler_ycbcr_conversion;
bool host_image_copy;
// we only ever need one queue for rendering and transfer commands
uint32_t queue_family;
@ -60,6 +61,8 @@ struct wlr_vk_device {
PFN_vkCreateSamplerYcbcrConversionKHR vkCreateSamplerYcbcrConversionKHR;
PFN_vkDestroySamplerYcbcrConversionKHR vkDestroySamplerYcbcrConversionKHR;
PFN_vkGetImageMemoryRequirements2KHR vkGetImageMemoryRequirements2KHR;
PFN_vkCopyMemoryToImageEXT vkCopyMemoryToImageEXT;
PFN_vkTransitionImageLayoutEXT vkTransitionImageLayoutEXT;
} api;
uint32_t format_prop_count;
@ -115,6 +118,7 @@ struct wlr_vk_format_props {
VkExtent2D max_extent;
VkFormatFeatureFlags features;
bool has_mutable_srgb;
bool host_image_copy;
} shm;
struct {
@ -518,6 +522,7 @@ struct wlr_vk_texture {
bool transitioned; // if dma_imported: whether we transitioned it away from preinit
bool has_alpha; // whether the image is has alpha channel
bool using_mutable_srgb; // can be accessed through _SRGB format view
bool host_image_copy; // whether uploads skip the staging buffer
struct wl_list foreign_link; // wlr_vk_renderer.foreign_textures
struct wl_list destroy_link; // wlr_vk_command_buffer.destroy_textures
struct wl_list link; // wlr_vk_renderer.textures