Mesa (master): panfrost: Add bi_emit_array_index helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 3 14:55:05 UTC 2020


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Tue Nov  3 08:22:42 2020 -0500

panfrost: Add bi_emit_array_index helper

Need to handle type conversion.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7408>

---

 src/panfrost/bifrost/bifrost_compile.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 6f9497d4eb7..442128f3772 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -1255,6 +1255,39 @@ bi_texture_format(nir_alu_type T, enum bifrost_outmod outmod)
         }
 }
 
+/* Array indices are specified as 32-bit uints, need to convert. In .z component from NIR */
+static unsigned
+bi_emit_array_index(bi_context *ctx, unsigned idx, nir_alu_type T, unsigned *c)
+{
+        /* For (u)int we can just passthrough */
+        nir_alu_type base = nir_alu_type_get_base_type(T);
+        if (base == nir_type_int || base == nir_type_uint) {
+                *c = 2;
+                return idx;
+        }
+
+        /* Otherwise we convert */
+        assert(T == nir_type_float16 || T == nir_type_float32);
+
+        /* OpenGL ES 3.2 specification section 8.14.2 ("Coordinate Wrapping and
+         * Texel Selection") defines the layer to be taken from clamp(RNE(r),
+         * 0, dt - 1). So we use roundmode RTE, clamping is handled at the data
+         * structure level */
+        bi_instruction f2i = {
+                .type = BI_CONVERT,
+                .dest = bi_make_temp(ctx),
+                .dest_type = nir_type_uint32,
+                .src = { idx },
+                .src_types = { T },
+                .swizzle = { { 2 } },
+                .roundmode = BIFROST_RTE
+        };
+
+        *c = 0;
+        bi_emit(ctx, f2i);
+        return f2i.dest;
+}
+
 /* TEXC's explicit and bias LOD modes requires the LOD to be transformed to a
  * 16-bit 8:8 fixed-point format. We lower as:
  *



More information about the mesa-commit mailing list