Mesa (master): panfrost: Add a function to determine if a resource is 2D

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 20 23:55:03 UTC 2021


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

Author: Icecream95 <ixn at disroot.org>
Date:   Mon Nov  9 23:13:43 2020 +1300

panfrost: Add a function to determine if a resource is 2D

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

---

 src/gallium/drivers/panfrost/pan_resource.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index 24b7c85e9a0..2a1b602328c 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -491,6 +491,13 @@ panfrost_setup_layout(struct panfrost_device *dev,
                 *bo_size = ALIGN_POT(pres->layout.array_stride * res->array_size, 4096);
 }
 
+static inline bool
+panfrost_is_2d(const struct panfrost_resource *pres)
+{
+        return (pres->base.target == PIPE_TEXTURE_2D)
+                || (pres->base.target == PIPE_TEXTURE_RECT);
+}
+
 /* Based on the usage, determine if it makes sense to use u-inteleaved tiling.
  * We only have routines to tile 2D textures of sane bpps. On the hardware
  * level, not all usages are valid for tiling. Finally, if the app is hinting
@@ -585,10 +592,9 @@ panfrost_should_tile(struct panfrost_device *dev, const struct panfrost_resource
                 bpp == 8 || bpp == 16 || bpp == 24 || bpp == 32 ||
                 bpp == 64 || bpp == 128;
 
-        bool is_2d = (pres->base.target == PIPE_TEXTURE_2D)
-                || (pres->base.target == PIPE_TEXTURE_RECT);
-
-        bool can_tile = is_2d && is_sane_bpp && ((pres->base.bind & ~valid_binding) == 0);
+        bool can_tile = panfrost_is_2d(pres)
+                && is_sane_bpp
+                && ((pres->base.bind & ~valid_binding) == 0);
 
         return can_tile && (pres->base.usage != PIPE_USAGE_STREAM);
 }



More information about the mesa-commit mailing list