panfrost: Set depth to sample_count for MSAA 2D
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 30 Jun 2020 19:41:24 +0000 (15:41 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 7 Jul 2020 01:13:39 +0000 (01:13 +0000)
Treated like a 3D texture.

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

src/gallium/drivers/panfrost/pan_context.c

index 69f05e5beab7e1ee99f152566f06a8704bd0582f..98e67adf4f7a619a9c0fe8be91495e8b868f760c 100644 (file)
@@ -932,6 +932,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
          * whereas in Gallium, it also covers cubemaps */
 
         unsigned array_size = texture->array_size;
+        unsigned depth = texture->depth0;
 
         if (so->base.target == PIPE_TEXTURE_CUBE) {
                 /* TODO: Cubemap arrays */
@@ -939,6 +940,17 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
                 array_size /= 6;
         }
 
+        /* MSAA only supported for 2D textures (and 2D texture arrays via an
+         * extension currently unimplemented */
+
+        if (so->base.target == PIPE_TEXTURE_2D) {
+                assert(depth == 1);
+                depth = texture->nr_samples;
+        } else {
+                /* MSAA only supported for 2D textures */
+                assert(texture->nr_samples <= 1);
+        }
+
         enum mali_texture_type type =
                 panfrost_translate_texture_type(so->base.target);
 
@@ -961,7 +973,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
                 panfrost_new_texture_bifrost(
                                 so->bifrost_descriptor,
                                 texture->width0, texture->height0,
-                                texture->depth0, array_size,
+                                depth, array_size,
                                 so->base.format,
                                 type, prsrc->layout,
                                 so->base.u.tex.first_level,
@@ -987,7 +999,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
                 panfrost_new_texture(
                                 so->bo->cpu,
                                 texture->width0, texture->height0,
-                                texture->depth0, array_size,
+                                depth, array_size,
                                 so->base.format,
                                 type, prsrc->layout,
                                 so->base.u.tex.first_level,