render/vulkan: Delay shm texture updates till render

In order to optimize rendering of shm-backed buffers, we copy the buffer
into a properly allocated texture. However, some clients might send
rapid updates for large surfaces, or may not even be visible, making the
copy wasteful.

Move the copy to the point where the texture is added to the render
pass, ensuring that we only perform the copy if texture is being used
and only once per render. This means that the shm optimization is
effectively disabled for clients that are not visible.
This commit is contained in:
Kenny Levinsen 2024-07-04 00:57:17 +02:00
parent 67b88e46b0
commit 6ca84bf64d
3 changed files with 51 additions and 15 deletions

View file

@ -11,6 +11,7 @@
#include <wlr/render/interface.h>
#include <wlr/util/addon.h>
#include "util/rect_union.h"
#include <pixman.h>
struct wlr_vk_descriptor_pool;
struct wlr_vk_texture;
@ -454,6 +455,9 @@ struct wlr_vk_texture {
VkSemaphore foreign_semaphores[WLR_DMABUF_MAX_PLANES];
struct wl_list views; // struct wlr_vk_texture_ds.link
// For SHM buffers
pixman_region32_t invalidated;
};
struct wlr_vk_texture *vulkan_get_texture(struct wlr_texture *wlr_texture);
@ -464,6 +468,7 @@ VkImage vulkan_import_dmabuf(struct wlr_vk_renderer *renderer,
struct wlr_texture *vulkan_texture_from_buffer(
struct wlr_renderer *wlr_renderer, struct wlr_buffer *buffer);
void vulkan_texture_destroy(struct wlr_vk_texture *texture);
void vulkan_texture_update(struct wlr_vk_texture *texture);
struct wlr_vk_descriptor_pool {
VkDescriptorPool pool;