Mesa (master): panfrost: Implement EXT_multisampled_render_to_texture

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Aug 4 19:05:43 UTC 2020


Module: Mesa
Branch: master
Commit: b75427cc31f67efc53006b38ce85597612833238
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b75427cc31f67efc53006b38ce85597612833238

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Tue Jul 21 18:54:18 2020 -0400

panfrost: Implement EXT_multisampled_render_to_texture

Significantly helps WebGL performance with Chromium's OpenGL ES backend.
Also update docs/features.txt

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6161>

---

 docs/features.txt                           |  2 +-
 src/gallium/drivers/panfrost/pan_job.c      |  7 +------
 src/gallium/drivers/panfrost/pan_mfbd.c     | 24 +++++++-----------------
 src/gallium/drivers/panfrost/pan_resource.c |  1 +
 src/gallium/drivers/panfrost/pan_screen.c   |  1 +
 5 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index ed82a0944f1..4ce5b570245 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -321,7 +321,7 @@ Khronos, ARB, and OES extensions that are not part of any OpenGL or OpenGL ES ve
   GL_EXT_memory_object                                  DONE (radeonsi)
   GL_EXT_memory_object_fd                               DONE (radeonsi)
   GL_EXT_memory_object_win32                            not started
-  GL_EXT_multisampled_render_to_texture                 DONE (freedreno/a6xx)
+  GL_EXT_multisampled_render_to_texture                 DONE (freedreno/a6xx, panfrost)
   GL_EXT_render_snorm                                   DONE (i965, r600, radeonsi)
   GL_EXT_semaphore                                      DONE (radeonsi)
   GL_EXT_semaphore_fd                                   DONE (radeonsi)
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index 87c6c223503..3295d841602 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -839,11 +839,6 @@ panfrost_load_surface(struct panfrost_batch *batch, struct pipe_surface *surf, u
         enum mali_texture_type type =
                 panfrost_translate_texture_type(rsrc->base.target);
 
-        unsigned nr_samples = surf->nr_samples;
-
-        if (!nr_samples)
-                nr_samples = surf->texture->nr_samples;
-
         struct pan_image img = {
                 .width0 = rsrc->base.width0,
                 .height0 = rsrc->base.height0,
@@ -856,7 +851,7 @@ panfrost_load_surface(struct panfrost_batch *batch, struct pipe_surface *surf, u
                 .last_level = level,
                 .first_layer = surf->u.tex.first_layer,
                 .last_layer = surf->u.tex.last_layer,
-                .nr_samples = nr_samples,
+                .nr_samples = rsrc->base.nr_samples,
                 .cubemap_stride = rsrc->cubemap_stride,
                 .bo = rsrc->bo,
                 .slices = rsrc->slices
diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c
index 43a26a81e03..522dd8f6dfb 100644
--- a/src/gallium/drivers/panfrost/pan_mfbd.c
+++ b/src/gallium/drivers/panfrost/pan_mfbd.c
@@ -211,13 +211,9 @@ panfrost_mfbd_set_cbuf(
         assert(surf->u.tex.last_layer == first_layer);
         int stride = rsrc->slices[level].stride;
 
-        /* Only set layer_stride for MSAA rendering */
-
-        unsigned nr_samples = surf->nr_samples;
-
-        if (!nr_samples)
-                nr_samples = surf->texture->nr_samples;
+        /* Only set layer_stride for layered MSAA rendering  */
 
+        unsigned nr_samples = surf->texture->nr_samples;
         unsigned layer_stride = (nr_samples > 1) ? rsrc->slices[level].size0 : 0;
 
         mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer, 0);
@@ -289,11 +285,7 @@ panfrost_mfbd_set_zsbuf(
         bool is_bifrost = dev->quirks & IS_BIFROST;
         struct panfrost_resource *rsrc = pan_resource(surf->texture);
 
-        unsigned nr_samples = surf->nr_samples;
-
-        if (!nr_samples)
-                nr_samples = surf->texture->nr_samples;
-
+        unsigned nr_samples = surf->texture->nr_samples;
         nr_samples = MAX2(nr_samples, 1);
 
         fbx->zs_samples = MALI_POSITIVE(nr_samples);
@@ -566,12 +558,7 @@ panfrost_mfbd_fragment(struct panfrost_batch *batch, bool has_draws)
                 unsigned rt_offset = offset << tib_shift;
 
                 if (surf && ((batch->clear | batch->draws) & (PIPE_CLEAR_COLOR0 << cb))) {
-                        unsigned nr_samples = surf->nr_samples;
-
-                        if (!nr_samples)
-                                nr_samples = surf->texture->nr_samples;
-
-                        if (nr_samples > 1)
+                        if (MAX2(surf->nr_samples, surf->texture->nr_samples) > 1)
                                 batch->requirements |= PAN_REQ_MSAA;
 
                         panfrost_mfbd_set_cbuf(&rts[cb], surf);
@@ -600,6 +587,9 @@ panfrost_mfbd_fragment(struct panfrost_batch *batch, bool has_draws)
         fb.rt_count_2 = MAX2(DIV_ROUND_UP(offset, 1 << (10 - tib_shift)), 1);
 
         if (batch->key.zsbuf && ((batch->clear | batch->draws) & PIPE_CLEAR_DEPTHSTENCIL)) {
+                if (MAX2(batch->key.zsbuf->nr_samples, batch->key.zsbuf->nr_samples) > 1)
+                        batch->requirements |= PAN_REQ_MSAA;
+
                 panfrost_mfbd_set_zsbuf(&fb, &fbx, batch->key.zsbuf);
         }
 
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 08ec83cd195..5d651ee44d1 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -177,6 +177,7 @@ panfrost_create_surface(struct pipe_context *pipe,
                         assert(surf_tmpl->u.tex.level <= pt->last_level);
                         ps->width = u_minify(pt->width0, surf_tmpl->u.tex.level);
                         ps->height = u_minify(pt->height0, surf_tmpl->u.tex.level);
+                        ps->nr_samples = surf_tmpl->nr_samples;
                         ps->u.tex.level = surf_tmpl->u.tex.level;
                         ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
                         ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index d5ffdda9b05..2e5658036d3 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -134,6 +134,7 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
         case PIPE_CAP_OCCLUSION_QUERY:
         case PIPE_CAP_TGSI_INSTANCEID:
         case PIPE_CAP_TEXTURE_MULTISAMPLE:
+        case PIPE_CAP_SURFACE_SAMPLE_COUNT:
         case PIPE_CAP_PRIMITIVE_RESTART:
         case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX:
                 return !is_bifrost;



More information about the mesa-commit mailing list