aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/render/vulkan.h4
-rw-r--r--render/vulkan/renderer.c39
2 files changed, 24 insertions, 19 deletions
diff --git a/include/render/vulkan.h b/include/render/vulkan.h
index dbfe750f..1cbe00c1 100644
--- a/include/render/vulkan.h
+++ b/include/render/vulkan.h
@@ -9,6 +9,7 @@
#include <wlr/render/wlr_texture.h>
#include <wlr/render/drm_format_set.h>
#include <wlr/render/interface.h>
+#include <wlr/util/addon.h>
struct wlr_vk_descriptor_pool;
@@ -132,6 +133,7 @@ struct wlr_vk_render_format_setup {
// Renderer-internal represenation of an wlr_buffer imported for rendering.
struct wlr_vk_render_buffer {
struct wlr_buffer *wlr_buffer;
+ struct wlr_addon addon;
struct wlr_vk_renderer *renderer;
struct wlr_vk_render_format_setup *render_setup;
struct wl_list link; // wlr_vk_renderer.buffers
@@ -142,8 +144,6 @@ struct wlr_vk_render_buffer {
uint32_t mem_count;
VkDeviceMemory memories[WLR_DMABUF_MAX_PLANES];
bool transitioned;
-
- struct wl_listener buffer_destroy;
};
// Vulkan wlr_renderer implementation on top of a wlr_vk_device.
diff --git a/render/vulkan/renderer.c b/render/vulkan/renderer.c
index 8649ff14..4d134877 100644
--- a/render/vulkan/renderer.c
+++ b/render/vulkan/renderer.c
@@ -386,7 +386,7 @@ struct wlr_vk_format_props *vulkan_format_props_from_drm(
// buffer import
static void destroy_render_buffer(struct wlr_vk_render_buffer *buffer) {
wl_list_remove(&buffer->link);
- wl_list_remove(&buffer->buffer_destroy.link);
+ wlr_addon_finish(&buffer->addon);
assert(buffer->renderer->current_render_buffer != buffer);
@@ -403,23 +403,16 @@ static void destroy_render_buffer(struct wlr_vk_render_buffer *buffer) {
free(buffer);
}
-static struct wlr_vk_render_buffer *get_render_buffer(
- struct wlr_vk_renderer *renderer, struct wlr_buffer *wlr_buffer) {
- struct wlr_vk_render_buffer *buffer;
- wl_list_for_each(buffer, &renderer->render_buffers, link) {
- if (buffer->wlr_buffer == wlr_buffer) {
- return buffer;
- }
- }
- return NULL;
-}
-
-static void handle_render_buffer_destroy(struct wl_listener *listener, void *data) {
- struct wlr_vk_render_buffer *buffer =
- wl_container_of(listener, buffer, buffer_destroy);
+static void handle_render_buffer_destroy(struct wlr_addon *addon) {
+ struct wlr_vk_render_buffer *buffer = wl_container_of(addon, buffer, addon);
destroy_render_buffer(buffer);
}
+static struct wlr_addon_interface render_buffer_addon_impl = {
+ .name = "wlr_vk_render_buffer",
+ .destroy = handle_render_buffer_destroy,
+};
+
static struct wlr_vk_render_buffer *create_render_buffer(
struct wlr_vk_renderer *renderer, struct wlr_buffer *wlr_buffer) {
VkResult res;
@@ -496,8 +489,8 @@ static struct wlr_vk_render_buffer *create_render_buffer(
goto error_view;
}
- buffer->buffer_destroy.notify = handle_render_buffer_destroy;
- wl_signal_add(&wlr_buffer->events.destroy, &buffer->buffer_destroy);
+ wlr_addon_init(&buffer->addon, &wlr_buffer->addons, renderer,
+ &render_buffer_addon_impl);
wl_list_insert(&renderer->render_buffers, &buffer->link);
return buffer;
@@ -515,6 +508,18 @@ error_buffer:
return NULL;
}
+static struct wlr_vk_render_buffer *get_render_buffer(
+ struct wlr_vk_renderer *renderer, struct wlr_buffer *wlr_buffer) {
+ struct wlr_addon *addon =
+ wlr_addon_find(&wlr_buffer->addons, renderer, &render_buffer_addon_impl);
+ if (addon == NULL) {
+ return NULL;
+ }
+
+ struct wlr_vk_render_buffer *buffer = wl_container_of(addon, buffer, addon);
+ return buffer;
+}
+
// interface implementation
static bool vulkan_bind_buffer(struct wlr_renderer *wlr_renderer,
struct wlr_buffer *wlr_buffer) {