pan/bi: Add bi_emit_lod_cube helper
There's a different LOD format used for TXF that will be able to
accomodate cube maps as well.
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7081>
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 8586736..79ff7e7 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -1101,6 +1101,28 @@
return mkvec.dest;
}
+/* FETCH takes a 32-bit staging register containing the LOD as an integer in
+ * the bottom 16-bits and (if present) the cube face index in the top 16-bits.
+ * TODO: Cube face.
+ */
+
+static unsigned
+bi_emit_lod_cube(bi_context *ctx, unsigned lod)
+{
+ /* MKVEC.v2i16 out, lod.h0, #0 */
+ bi_instruction mkvec = {
+ .type = BI_SELECT,
+ .dest = bi_make_temp(ctx),
+ .dest_type = nir_type_int16,
+ .src = { lod, BIR_INDEX_ZERO },
+ .src_types = { nir_type_int16, nir_type_int16 },
+ };
+
+ bi_emit(ctx, mkvec);
+
+ return mkvec.dest;
+}
+
/* Map to the main texture op used. Some of these (txd in particular) will
* lower to multiple texture ops with different opcodes (GRDESC_DER + TEX in
* sequence). We assume that lowering is handled elsewhere.