Mesa (master): gallivm/rgtc: enable fast path for snorm types.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Apr 4 02:55:45 UTC 2020


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Apr  3 14:25:51 2020 +1000

gallivm/rgtc: enable fast path for snorm types.

As per Roland's suggestions it should be easy to enable the
fast path fetch for rgtc snorm as well here.

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4425>

---

 src/gallium/auxiliary/gallivm/lp_bld_format_soa.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
index 69e3185f4fa..ab130deb151 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c
@@ -741,13 +741,14 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
    /*
     * Try calling lp_build_fetch_rgba_aos for all pixels.
     * Should only really hit subsampled, compressed
-    * (for s3tc srgb too, for rgtc the unorm ones only) by now.
+    * (for s3tc srgb and rgtc too).
     * (This is invalid for plain 8unorm formats because we're lazy with
     * the swizzle since some results would arrive swizzled, some not.)
     */
 
    if ((format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) &&
        (util_format_fits_8unorm(format_desc) ||
+        format_desc->layout == UTIL_FORMAT_LAYOUT_RGTC ||
         format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) &&
        type.floating && type.width == 32 &&
        (type.length == 1 || (type.length % 4 == 0))) {
@@ -757,6 +758,10 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
       const struct util_format_description *flinear_desc;
       const struct util_format_description *frgba8_desc;
       unsigned chan;
+      bool is_signed = (format_desc->format == PIPE_FORMAT_RGTC1_SNORM ||
+                        format_desc->format == PIPE_FORMAT_RGTC2_SNORM ||
+                        format_desc->format == PIPE_FORMAT_LATC1_SNORM ||
+                        format_desc->format == PIPE_FORMAT_LATC2_SNORM);
 
       lp_build_context_init(&bld, gallivm, type);
 
@@ -769,6 +774,7 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
       tmp_type.width = 8;
       tmp_type.length = type.length * 4;
       tmp_type.norm = TRUE;
+      tmp_type.sign = is_signed;
 
       packed = lp_build_fetch_rgba_aos(gallivm, flinear_desc, tmp_type,
                                        aligned, base_ptr, offset, i, j, cache);
@@ -778,7 +784,7 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
        * The values are now packed so they match ordinary (srgb) RGBA8 format,
        * hence need to use matching format for unpack.
        */
-      frgba8_desc = util_format_description(PIPE_FORMAT_R8G8B8A8_UNORM);
+      frgba8_desc = util_format_description(is_signed ? PIPE_FORMAT_R8G8B8A8_SNORM : PIPE_FORMAT_R8G8B8A8_UNORM);
       if (format_desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
          assert(format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC);
          frgba8_desc = util_format_description(PIPE_FORMAT_R8G8B8A8_SRGB);
@@ -815,7 +821,7 @@ lp_build_fetch_rgba_soa(struct gallivm_state *gallivm,
     * in particular if the formats have less than 4 channels.
     *
     * Right now, this should only be hit for:
-    * - RGTC snorm formats
+    * - ETC formats
     *   (those miss fast fetch functions hence they are terrible anyway)
     */
 



More information about the mesa-commit mailing list