Mesa (master): panfrost: Fix estimate_texture_payload_size() on Bifrost

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 12 22:58:59 UTC 2021


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

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Tue Jan 12 17:43:16 2021 +0100

panfrost: Fix estimate_texture_payload_size() on Bifrost

Bifrost mandates manual stride usage.

Fixes: a3d2936a8e9e ("panfrost: The texture descriptor has a pointer to a trampoline")
Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8449>

---

 src/gallium/drivers/panfrost/pan_context.c |  3 ++-
 src/panfrost/lib/pan_texture.c             | 17 +++++++++++------
 src/panfrost/lib/pan_texture.h             | 13 ++++++++-----
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index ec5395e86ae..2df59a8230d 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -1064,7 +1064,8 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
 
         unsigned size =
                 (is_bifrost ? 0 : MALI_MIDGARD_TEXTURE_LENGTH) +
-                panfrost_estimate_texture_payload_size(first_level, last_level,
+                panfrost_estimate_texture_payload_size(device,
+                                                       first_level, last_level,
                                                        first_layer, last_layer,
                                                        texture->nr_samples,
                                                        type,
diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c
index 73c9698e881..35fb450c890 100644
--- a/src/panfrost/lib/pan_texture.c
+++ b/src/panfrost/lib/pan_texture.c
@@ -220,14 +220,19 @@ panfrost_texture_num_elements(
  * as an allocation amount */
 
 unsigned
-panfrost_estimate_texture_payload_size(
-                unsigned first_level, unsigned last_level,
-                unsigned first_layer, unsigned last_layer,
-                unsigned nr_samples,
-                enum mali_texture_dimension dim, uint64_t modifier)
+panfrost_estimate_texture_payload_size(const struct panfrost_device *dev,
+                                       unsigned first_level,
+                                       unsigned last_level,
+                                       unsigned first_layer,
+                                       unsigned last_layer,
+                                       unsigned nr_samples,
+                                       enum mali_texture_dimension dim,
+                                       uint64_t modifier)
 {
+        bool is_bifrost = dev->quirks & IS_BIFROST;
         /* Assume worst case */
-        unsigned manual_stride = (modifier == DRM_FORMAT_MOD_LINEAR);
+        unsigned manual_stride = is_bifrost ||
+                                 (modifier == DRM_FORMAT_MOD_LINEAR);
 
         unsigned elements = panfrost_texture_num_elements(
                         first_level, last_level,
diff --git a/src/panfrost/lib/pan_texture.h b/src/panfrost/lib/pan_texture.h
index 975ffd2ebf2..1b2f40646ed 100644
--- a/src/panfrost/lib/pan_texture.h
+++ b/src/panfrost/lib/pan_texture.h
@@ -124,11 +124,14 @@ unsigned
 panfrost_block_dim(uint64_t modifier, bool width, unsigned plane);
 
 unsigned
-panfrost_estimate_texture_payload_size(
-                unsigned first_level, unsigned last_level,
-                unsigned first_layer, unsigned last_layer,
-                unsigned nr_samples,
-                enum mali_texture_dimension dim, uint64_t modifier);
+panfrost_estimate_texture_payload_size(const struct panfrost_device *dev,
+                                       unsigned first_level,
+                                       unsigned last_level,
+                                       unsigned first_layer,
+                                       unsigned last_layer,
+                                       unsigned nr_samples,
+                                       enum mali_texture_dimension dim,
+                                       uint64_t modifier);
 
 void
 panfrost_new_texture(const struct panfrost_device *dev,



More information about the mesa-commit mailing list