Mesa (main): zink: unify fb surface unbinding
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jul 1 23:57:57 UTC 2021
Module: Mesa
Branch: main
Commit: 22530ad9f10cda9622f7e9c4094374629c61f6d5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=22530ad9f10cda9622f7e9c4094374629c61f6d5
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Tue May 11 09:37:10 2021 -0400
zink: unify fb surface unbinding
Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11666>
---
src/gallium/drivers/zink/zink_context.c | 38 ++++++++++++++++++---------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c
index 3b444b2c219..e679d884cb8 100644
--- a/src/gallium/drivers/zink/zink_context.c
+++ b/src/gallium/drivers/zink/zink_context.c
@@ -1903,6 +1903,18 @@ rebind_fb_state(struct zink_context *ctx, struct zink_resource *match_res, bool
return rebind;
}
+static void
+unbind_fb_surface(struct zink_context *ctx, struct pipe_surface *surf, bool changed)
+{
+ if (!surf)
+ return;
+ if (changed) {
+ zink_fb_clears_apply(ctx, surf->texture);
+ ctx->rp_changed = true;
+ }
+ zink_resource(surf->texture)->fb_binds--;
+}
+
static void
zink_set_framebuffer_state(struct pipe_context *pctx,
const struct pipe_framebuffer_state *state)
@@ -1911,26 +1923,18 @@ zink_set_framebuffer_state(struct pipe_context *pctx,
for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
struct pipe_surface *surf = ctx->fb_state.cbufs[i];
- if (surf && (i >= state->nr_cbufs || surf != state->cbufs[i])) {
- zink_fb_clears_apply(ctx, surf->texture);
- ctx->rp_changed = true;
- }
- if (surf)
- zink_resource(surf->texture)->fb_binds--;
+ unbind_fb_surface(ctx, surf, i >= state->nr_cbufs || surf != state->cbufs[i]);
}
if (ctx->fb_state.zsbuf) {
struct pipe_surface *surf = ctx->fb_state.zsbuf;
- if (surf != state->zsbuf) {
- struct zink_resource *res = zink_resource(surf->texture);
- zink_fb_clears_apply(ctx, ctx->fb_state.zsbuf->texture);
- if (unlikely(res->obj->needs_zs_evaluate))
- /* have to flush zs eval while the sample location data still exists,
- * so just throw some random barrier */
- zink_resource_image_barrier(ctx, NULL, res, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
- VK_ACCESS_SHADER_READ_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
- ctx->rp_changed = true;
- }
- zink_resource(surf->texture)->fb_binds--;
+ struct zink_resource *res = zink_resource(surf->texture);
+ bool changed = surf != state->zsbuf;
+ unbind_fb_surface(ctx, surf, changed);
+ if (changed && unlikely(res->obj->needs_zs_evaluate))
+ /* have to flush zs eval while the sample location data still exists,
+ * so just throw some random barrier */
+ zink_resource_image_barrier(ctx, NULL, res, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
+ VK_ACCESS_SHADER_READ_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
}
/* renderpass changes if the number or types of attachments change */
ctx->rp_changed |= ctx->fb_state.nr_cbufs != state->nr_cbufs;
More information about the mesa-commit
mailing list