drisw: add multisample support to sw dri layer.
authorDave Airlie <airlied@redhat.com>
Wed, 25 Mar 2020 02:47:20 +0000 (12:47 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:38 +0000 (06:20 +0000)
This allocates the msaa resources like the dri2 layer
and adds the flushes

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>

src/gallium/state_trackers/dri/drisw.c

index 1c0f56e042d3a2680b8b2476a11052ad56b2938d..4afa69f891d1e64077af784e7eb1329eda79de5e 100644 (file)
@@ -254,6 +254,13 @@ drisw_swap_buffers(__DRIdrawable *dPriv)
 
       ctx->st->flush(ctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL);
 
+      if (drawable->stvis.samples > 1) {
+         /* Resolve the back buffer. */
+         dri_pipe_blit(ctx->st->pipe,
+                       drawable->textures[ST_ATTACHMENT_BACK_LEFT],
+                       drawable->msaa_textures[ST_ATTACHMENT_BACK_LEFT]);
+      }
+
       drisw_copy_to_front(dPriv, ptex);
    }
 }
@@ -292,6 +299,12 @@ drisw_flush_frontbuffer(struct dri_context *ctx,
    if (!ctx)
       return;
 
+   if (drawable->stvis.samples > 1) {
+      /* Resolve the front buffer. */
+      dri_pipe_blit(ctx->st->pipe,
+                    drawable->textures[ST_ATTACHMENT_FRONT_LEFT],
+                    drawable->msaa_textures[ST_ATTACHMENT_FRONT_LEFT]);
+   }
    ptex = drawable->textures[statt];
 
    if (ptex) {
@@ -327,8 +340,10 @@ drisw_allocate_textures(struct dri_context *stctx,
 
    /* remove outdated textures */
    if (resized) {
-      for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
+      for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
          pipe_resource_reference(&drawable->textures[i], NULL);
+         pipe_resource_reference(&drawable->msaa_textures[i], NULL);
+      }
    }
 
    memset(&templ, 0, sizeof(templ));
@@ -358,6 +373,8 @@ drisw_allocate_textures(struct dri_context *stctx,
 
       templ.format = format;
       templ.bind = bind;
+      templ.nr_samples = 0;
+      templ.nr_storage_samples = 0;
 
       if (statts[i] == ST_ATTACHMENT_FRONT_LEFT &&
           screen->base.screen->resource_create_front &&
@@ -367,6 +384,19 @@ drisw_allocate_textures(struct dri_context *stctx,
       } else
          drawable->textures[statts[i]] =
             screen->base.screen->resource_create(screen->base.screen, &templ);
+
+      if (drawable->stvis.samples > 1) {
+         templ.bind = templ.bind &
+            ~(PIPE_BIND_SCANOUT | PIPE_BIND_SHARED | PIPE_BIND_DISPLAY_TARGET);
+         templ.nr_samples = drawable->stvis.samples;
+         templ.nr_storage_samples = drawable->stvis.samples;
+         drawable->msaa_textures[statts[i]] =
+            screen->base.screen->resource_create(screen->base.screen, &templ);
+
+         dri_pipe_blit(stctx->st->pipe,
+                       drawable->msaa_textures[statts[i]],
+                       drawable->textures[statts[i]]);
+      }
    }
 
    drawable->old_w = width;