[Mesa-dev] [PATCH 1/2] gallium/drisw: add multisample buffer support

Dave Airlie airlied at gmail.com
Mon Nov 25 02:41:50 PST 2013


This adds support for multisample to drisw, even if we fake
multisample in the drivers we should at least do best effort,
and not fail to render.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/gallium/state_trackers/dri/sw/drisw.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c
index 9f00a53..24e9e2f 100644
--- a/src/gallium/state_trackers/dri/sw/drisw.c
+++ b/src/gallium/state_trackers/dri/sw/drisw.c
@@ -167,6 +167,13 @@ 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) {
@@ -201,8 +208,12 @@ 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);
+
+         if (drawable->stvis.samples > 1)
+            pipe_resource_reference(&drawable->msaa_textures[i], NULL);
+      }
    }
 
    memset(&templ, 0, sizeof(templ));
@@ -235,6 +246,17 @@ drisw_allocate_textures(struct dri_context *stctx,
 
       drawable->textures[statts[i]] =
          screen->base.screen->resource_create(screen->base.screen, &templ);
+
+      if (drawable->stvis.samples > 1) {
+         enum st_attachment_type att = statts[i];
+         templ.nr_samples = drawable->stvis.samples;
+         drawable->msaa_textures[att] = screen->base.screen->resource_create(screen->base.screen, &templ);
+         dri_pipe_blit(stctx->st->pipe,
+                       drawable->msaa_textures[att],
+                       drawable->textures[att]);
+      } else {
+         pipe_resource_reference(&drawable->msaa_textures[statts[i]], NULL);
+      }
    }
 
    drawable->old_w = width;
-- 
1.8.3.1



More information about the mesa-dev mailing list