zink: fix up color_write_enable workaround
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 24 Mar 2022 19:44:02 +0000 (15:44 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 25 Mar 2022 03:09:26 +0000 (03:09 +0000)
this needs to only swizzle to dummy surfaces if it's the workaround,
not just if color_write_enable is active

Fixes: 3892c133811 ("zink: add an alternate path for EXT_color_write_enable usage")

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15568>

src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_context.h
src/gallium/drivers/zink/zink_framebuffer.c

index 08ea0fb..b183a86 100644 (file)
@@ -1950,7 +1950,7 @@ get_render_pass(struct zink_context *ctx)
 
    for (int i = 0; i < fb->nr_cbufs; i++) {
       struct pipe_surface *surf = fb->cbufs[i];
-      if (surf) {
+      if (surf && !zink_use_dummy_attachments(ctx)) {
          struct zink_surface *transient = zink_transient_surface(surf);
          state.rts[i].format = zink_get_format(screen, surf->format);
          state.rts[i].samples = MAX3(transient ? transient->base.nr_samples : 0, surf->texture->nr_samples, 1);
@@ -2092,7 +2092,7 @@ setup_framebuffer(struct zink_context *ctx)
 static VkImageView
 prep_fb_attachment(struct zink_context *ctx, struct zink_surface *surf, unsigned i)
 {
-   if (!surf)
+   if (!surf || (i < ctx->fb_state.nr_cbufs && zink_use_dummy_attachments(ctx)))
       return zink_csurface(ctx->dummy_surface[util_logbase2_ceil(ctx->fb_state.samples)])->image_view;
 
    zink_batch_resource_usage_set(&ctx->batch, zink_resource(surf->base.texture), true);
@@ -2581,6 +2581,7 @@ zink_set_color_write_enables(struct zink_context *ctx)
    if (zink_screen(ctx->base.screen)->driver_workarounds.color_write_missing) {
       /* use dummy color buffers instead of the more sane option */
       zink_end_render_pass(ctx);
+      ctx->rp_changed = true;
       update_framebuffer_state(ctx, ctx->fb_state.width, ctx->fb_state.height);
    } else {
       VKCTX(CmdSetColorWriteEnableEXT)(ctx->batch.state->cmdbuf, max_att, disable_color_writes ? disables : enables);
index ea74123..7b442c4 100644 (file)
@@ -527,6 +527,8 @@ zink_resource_rebind(struct zink_context *ctx, struct zink_resource *res);
 
 void
 zink_rebind_framebuffer(struct zink_context *ctx, struct zink_resource *res);
+bool
+zink_use_dummy_attachments(const struct zink_context *ctx);
 void
 zink_set_color_write_enables(struct zink_context *ctx);
 void
index fdbed2b..cf3ea72 100644 (file)
@@ -137,6 +137,12 @@ fail:
    return NULL;
 }
 
+bool
+zink_use_dummy_attachments(const struct zink_context *ctx)
+{
+   return ctx->disable_color_writes && zink_screen(ctx->base.screen)->driver_workarounds.color_write_missing;
+}
+
 struct zink_framebuffer *
 zink_get_framebuffer_imageless(struct zink_context *ctx)
 {
@@ -149,7 +155,7 @@ zink_get_framebuffer_imageless(struct zink_context *ctx)
    unsigned num_resolves = 0;
    for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
       struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
-      if (!psurf || ctx->disable_color_writes)
+      if (!psurf || zink_use_dummy_attachments(ctx))
          psurf = ctx->dummy_surface[util_logbase2_ceil(ctx->gfx_pipeline_state.rast_samples+1)];
       struct zink_surface *surface = zink_csurface(psurf);
       struct zink_surface *transient = zink_transient_surface(psurf);
@@ -300,7 +306,7 @@ zink_get_framebuffer(struct zink_context *ctx)
    unsigned num_resolves = 0;
 
    struct zink_framebuffer_state state = {0};
-   if (!ctx->disable_color_writes) {
+   if (!zink_use_dummy_attachments(ctx)) {
       for (int i = 0; i < ctx->fb_state.nr_cbufs; i++) {
          struct pipe_surface *psurf = ctx->fb_state.cbufs[i];
          if (psurf) {