Mesa (main): zink: remove the worst part of basic framebuffer support
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Apr 18 23:55:48 UTC 2022
Module: Mesa
Branch: main
Commit: beb71504f42b79cff1031e8b08952df325e897d0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=beb71504f42b79cff1031e8b08952df325e897d0
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Tue Apr 12 15:03:39 2022 -0400
zink: remove the worst part of basic framebuffer support
this was one of the most complex interactions in zink, and now it's
finally gone
thanks to @jekstrand for licensing his patented Delete The Code methodology
for this project
Acked-by: Adam Jackson <ajax at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15904>
---
src/gallium/drivers/zink/zink_framebuffer.h | 10 ++--------
src/gallium/drivers/zink/zink_surface.c | 30 -----------------------------
src/gallium/drivers/zink/zink_surface.h | 1 -
3 files changed, 2 insertions(+), 39 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_framebuffer.h b/src/gallium/drivers/zink/zink_framebuffer.h
index 6ec92544ee5..7c55c6101fe 100644
--- a/src/gallium/drivers/zink/zink_framebuffer.h
+++ b/src/gallium/drivers/zink/zink_framebuffer.h
@@ -40,10 +40,7 @@ struct zink_framebuffer_state {
uint32_t layers:6;
uint32_t samples:6;
uint32_t num_attachments:4;
- union {
- VkImageView attachments[PIPE_MAX_COLOR_BUFS + 1];
- struct zink_surface_info infos[PIPE_MAX_COLOR_BUFS + 1];
- };
+ struct zink_surface_info infos[PIPE_MAX_COLOR_BUFS + 1];
};
struct zink_framebuffer {
@@ -54,10 +51,7 @@ struct zink_framebuffer {
struct zink_render_pass *rp;
struct zink_framebuffer_state state;
- union {
- struct pipe_surface *surfaces[PIPE_MAX_COLOR_BUFS + 1];
- VkFramebufferAttachmentImageInfo infos[PIPE_MAX_COLOR_BUFS + 1];
- };
+ VkFramebufferAttachmentImageInfo infos[PIPE_MAX_COLOR_BUFS + 1];
struct hash_table objects;
};
diff --git a/src/gallium/drivers/zink/zink_surface.c b/src/gallium/drivers/zink/zink_surface.c
index bdacaf60e32..373650415a8 100644
--- a/src/gallium/drivers/zink/zink_surface.c
+++ b/src/gallium/drivers/zink/zink_surface.c
@@ -165,7 +165,6 @@ create_surface(struct pipe_context *pctx,
surface->base.u.tex.first_layer = templ->u.tex.first_layer;
surface->base.u.tex.last_layer = templ->u.tex.last_layer;
surface->obj = zink_resource(pres)->obj;
- util_dynarray_init(&surface->framebuffer_refs, NULL);
util_dynarray_init(&surface->desc_set_refs.refs, NULL);
init_surface_info(surface, res, ivci);
@@ -291,33 +290,6 @@ zink_create_surface(struct pipe_context *pctx,
return &csurf->base;
}
-/* framebuffers are owned by their surfaces, so each time a surface that's part of a cached fb
- * is destroyed, it has to unref all the framebuffers it's attached to in order to avoid leaking
- * all the framebuffers
- *
- * surfaces are always batch-tracked, so it is impossible for a framebuffer to be destroyed
- * while it is in use
- */
-static void
-surface_clear_fb_refs(struct zink_screen *screen, struct pipe_surface *psurface)
-{
- struct zink_surface *surface = zink_surface(psurface);
- util_dynarray_foreach(&surface->framebuffer_refs, struct zink_framebuffer*, fb_ref) {
- struct zink_framebuffer *fb = *fb_ref;
- for (unsigned i = 0; i < fb->state.num_attachments; i++) {
- if (fb->surfaces[i] == psurface) {
- simple_mtx_lock(&screen->framebuffer_mtx);
- fb->surfaces[i] = NULL;
- _mesa_hash_table_remove_key(&screen->framebuffer_cache, &fb->state);
- zink_framebuffer_reference(screen, &fb, NULL);
- simple_mtx_unlock(&screen->framebuffer_mtx);
- break;
- }
- }
- }
- util_dynarray_fini(&surface->framebuffer_refs);
-}
-
void
zink_destroy_surface(struct zink_screen *screen, struct pipe_surface *psurface)
{
@@ -337,7 +309,6 @@ zink_destroy_surface(struct zink_screen *screen, struct pipe_surface *psurface)
simple_mtx_unlock(&res->surface_mtx);
}
zink_descriptor_set_refs_clear(&surface->desc_set_refs, surface);
- util_dynarray_fini(&surface->framebuffer_refs);
if (surface->simage_view)
VKSCR(DestroyImageView)(screen->dev, surface->simage_view, NULL);
if (surface->is_swapchain) {
@@ -379,7 +350,6 @@ zink_rebind_surface(struct zink_context *ctx, struct pipe_surface **psurface)
struct hash_entry *new_entry = _mesa_hash_table_search_pre_hashed(&res->surface_cache, hash, &ivci);
if (zink_batch_usage_exists(surface->batch_uses))
zink_batch_reference_surface(&ctx->batch, surface);
- surface_clear_fb_refs(screen, *psurface);
zink_descriptor_set_refs_clear(&surface->desc_set_refs, surface);
if (new_entry) {
/* reuse existing surface; old one will be cleaned up naturally */
diff --git a/src/gallium/drivers/zink/zink_surface.h b/src/gallium/drivers/zink/zink_surface.h
index b7146a1816a..4614069d71f 100644
--- a/src/gallium/drivers/zink/zink_surface.h
+++ b/src/gallium/drivers/zink/zink_surface.h
@@ -55,7 +55,6 @@ struct zink_surface {
void *obj; //backing resource object
uint32_t hash;
struct zink_batch_usage *batch_uses;
- struct util_dynarray framebuffer_refs;
struct zink_descriptor_refs desc_set_refs;
};
More information about the mesa-commit
mailing list