panfrost: Set zs_samples as necessary
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 15 Jul 2020 16:02:32 +0000 (12:02 -0400)
committerMarge Bot <eric+marge@anholt.net>
Wed, 15 Jul 2020 22:19:37 +0000 (22:19 +0000)
Fixes MSAA Z/S.

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

src/gallium/drivers/panfrost/pan_mfbd.c

index e1c389c39049299aa5a929b7eae5ce5602cf6f78..247dfd1ae180a1a11a9134f1bf5afdbb24e4d25e 100644 (file)
@@ -285,6 +285,15 @@ 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;
+
+        nr_samples = MAX2(nr_samples, 1);
+
+        fbx->zs_samples = MALI_POSITIVE(nr_samples);
+
         unsigned level = surf->u.tex.level;
         unsigned first_layer = surf->u.tex.first_layer;
         assert(surf->u.tex.last_layer == first_layer);
@@ -315,11 +324,6 @@ panfrost_mfbd_set_zsbuf(
 
                 int stride = rsrc->slices[level].stride;
 
-                unsigned nr_samples = surf->nr_samples;
-
-                if (!nr_samples)
-                        nr_samples = surf->texture->nr_samples;
-
                 unsigned layer_stride = (nr_samples > 1) ? rsrc->slices[level].size0 : 0;
 
                 fb->mfbd_flags |= MALI_MFBD_EXTRA | MALI_MFBD_DEPTH_WRITE;