Mesa (main): zink: replace context-based null framebuffer surfaces with internal ones
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jun 2 17:14:01 UTC 2021
Module: Mesa
Branch: main
Commit: b8970120545b3cb250821013cb459bf4d2acfda4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8970120545b3cb250821013cb459bf4d2acfda4
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Mar 25 15:44:18 2021 -0400
zink: replace context-based null framebuffer surfaces with internal ones
this is a bit cleaner and avoids accessing the context
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11122>
---
src/gallium/drivers/zink/zink_context.c | 3 ---
src/gallium/drivers/zink/zink_context.h | 1 -
src/gallium/drivers/zink/zink_framebuffer.c | 32 +++--------------------------
3 files changed, 3 insertions(+), 33 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index e2297e668e4..3888cb3a9a6 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -98,9 +98,6 @@ zink_context_destroy(struct pipe_context *pctx)
if (ctx->tc)
util_queue_destroy(&ctx->batch.flush_queue);
- for (unsigned i = 0; i < ARRAY_SIZE(ctx->null_buffers); i++)
- pipe_resource_reference(&ctx->null_buffers[i], NULL);
-
simple_mtx_destroy(&ctx->batch_mtx);
zink_clear_batch_state(ctx, ctx->batch.state);
zink_batch_state_reference(screen, &ctx->batch.state, NULL);
diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h
index f097c66b5f1..e1d1e449591 100644
--- a/src/gallium/drivers/zink/zink_context.h
+++ b/src/gallium/drivers/zink/zink_context.h
@@ -231,7 +231,6 @@ struct zink_context {
struct pipe_resource *dummy_vertex_buffer;
struct pipe_resource *dummy_xfb_buffer;
- struct pipe_resource *null_buffers[5]; /* used to create zink_framebuffer->null_surface, one buffer per samplecount */
struct {
/* descriptor info */
diff --git a/src/gallium/drivers/zink/zink_framebuffer.c b/src/gallium/drivers/zink/zink_framebuffer.c
index 3ddd2f0bcbf..6464944c15a 100644
--- a/src/gallium/drivers/zink/zink_framebuffer.c
+++ b/src/gallium/drivers/zink/zink_framebuffer.c
@@ -31,34 +31,6 @@
#include "util/u_memory.h"
#include "util/u_string.h"
-static struct pipe_surface *
-framebuffer_null_surface_init(struct zink_context *ctx, struct zink_framebuffer_state *state)
-{
- struct pipe_surface surf_templ = {};
- unsigned idx = util_logbase2_ceil(MAX2(state->samples, 1));
-
- if (!ctx->null_buffers[idx]) {
- struct pipe_resource *pres;
- struct pipe_resource templ = {};
- templ.width0 = state->width;
- templ.height0 = state->height;
- templ.depth0 = 1;
- templ.format = PIPE_FORMAT_R8_UINT;
- templ.target = PIPE_TEXTURE_2D;
- templ.bind = PIPE_BIND_RENDER_TARGET;
- templ.nr_samples = state->samples;
-
- pres = ctx->base.screen->resource_create(ctx->base.screen, &templ);
- if (!pres)
- return NULL;
-
- ctx->null_buffers[idx] = pres;
- }
- surf_templ.format = PIPE_FORMAT_R8_UINT;
- surf_templ.nr_samples = state->samples;
- return ctx->base.create_surface(&ctx->base, ctx->null_buffers[idx], &surf_templ);
-}
-
void
zink_destroy_framebuffer(struct zink_screen *screen,
struct zink_framebuffer *fb)
@@ -72,6 +44,8 @@ zink_destroy_framebuffer(struct zink_screen *screen,
#endif
}
+ if (fb->null_surface)
+ pipe_resource_reference(&fb->null_surface->texture, NULL);
zink_surface_reference(screen, (struct zink_surface**)&fb->null_surface, NULL);
ralloc_free(fb);
@@ -145,7 +119,7 @@ zink_create_framebuffer(struct zink_context *ctx,
num_attachments++;
} else {
if (!fb->null_surface)
- fb->null_surface = framebuffer_null_surface_init(ctx, state);
+ fb->null_surface = zink_surface_create_null(ctx, PIPE_TEXTURE_2D, state->width, state->height, state->samples);
surf = zink_surface(fb->null_surface);
state->attachments[i] = zink_surface(fb->null_surface)->image_view;
}
More information about the mesa-commit
mailing list