pan/bi: Add texture operator descriptor
Used to encode all the different texture modes.
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.h b/src/panfrost/bifrost/bifrost.h
index 7638c5b..8da1efb 100644
--- a/src/panfrost/bifrost/bifrost.h
+++ b/src/panfrost/bifrost/bifrost.h
@@ -402,4 +402,140 @@
[BIFROST_IDLE] = { BIFROST_OP_IDLE, BIFROST_OP_IDLE, true },
};
+/* Texture operator descriptors in various states. Usually packed in the
+ * compiler and stored as a constant */
+
+enum bifrost_index {
+ /* Both texture/sampler index immediate */
+ BIFROST_INDEX_IMMEDIATE_SHARED = 0,
+
+ /* Sampler index immediate, texture index from staging */
+ BIFROST_INDEX_IMMEDIATE_SAMPLER = 1,
+
+ /* Texture index immediate, sampler index from staging */
+ BIFROST_INDEX_IMMEDIATE_TEXTURE = 2,
+
+ /* Both indices from (separate) staging registers */
+ BIFROST_INDEX_REGISTER = 3,
+};
+
+enum bifrost_tex_op {
+ /* Given explicit derivatives, compute a gradient descriptor */
+ BIFROST_TEX_OP_GRDESC_DER = 4,
+
+ /* Given implicit derivatives (texture coordinates in a fragment
+ * shader), compute a gradient descriptor */
+ BIFROST_TEX_OP_GRDESC = 5,
+
+ /* Fetch a texel. Takes a staging register with LOD level / face index
+ * packed 16:16 */
+ BIFROST_TEX_OP_FETCH = 6,
+
+ /* Filtered texture */
+ BIFROST_TEX_OP_TEX = 7,
+};
+
+enum bifrost_lod_mode {
+ /* Takes two staging registers forming a 64-bit gradient descriptor
+ * (computed by a previous GRDESC or GRDESC_DER operation) */
+ BIFROST_LOD_MODE_GRDESC = 3,
+
+ /* Take a staging register with 8:8 fixed-point in bottom 16-bits
+ * specifying an explicit LOD */
+ BIFROST_LOD_MODE_EXPLICIT = 4,
+
+ /* Takes a staging register with bottom 16-bits as 8:8 fixed-point LOD
+ * bias and top 16-bit as 8:8 fixed-point lower bound (generally left
+ * zero), added and clamped to a computed LOD */
+ BIFROST_LOD_MODE_BIAS = 5,
+
+ /* Set LOD to zero */
+ BIFROST_LOD_MODE_ZERO = 6,
+
+ /* Compute LOD */
+ BIFROST_LOD_MODE_COMPUTE = 7,
+};
+
+enum bifrost_texture_format {
+ /* 16-bit floating point, with optional clamping */
+ BIFROST_TEXTURE_FORMAT_F16 = 0,
+ BIFROST_TEXTURE_FORMAT_F16_POS = 1,
+ BIFROST_TEXTURE_FORMAT_F16_PM1 = 2,
+ BIFROST_TEXTURE_FORMAT_F16_1 = 3,
+
+ /* 32-bit floating point, with optional clamping */
+ BIFROST_TEXTURE_FORMAT_F32 = 4,
+ BIFROST_TEXTURE_FORMAT_F32_POS = 5,
+ BIFROST_TEXTURE_FORMAT_F32_PM1 = 6,
+ BIFROST_TEXTURE_FORMAT_F32_1 = 7,
+};
+
+enum bifrost_texture_format_full {
+ /* Transclude bifrost_texture_format from above */
+
+ /* Integers, unclamped */
+ BIFROST_TEXTURE_FORMAT_U16 = 12,
+ BIFROST_TEXTURE_FORMAT_S16 = 13,
+ BIFROST_TEXTURE_FORMAT_U32 = 14,
+ BIFROST_TEXTURE_FORMAT_S32 = 15,
+};
+
+enum bifrost_texture_fetch {
+ /* Default texelFetch */
+ BIFROST_TEXTURE_FETCH_TEXEL = 1,
+
+ /* Deprecated, fetches 4x U32 of a U8 x 4 texture. Do not use. */
+ BIFROST_TEXTURE_FETCH_GATHER4_RGBA = 3,
+
+ /* Gathers */
+ BIFROST_TEXTURE_FETCH_GATHER4_R = 4,
+ BIFROST_TEXTURE_FETCH_GATHER4_G = 5,
+ BIFROST_TEXTURE_FETCH_GATHER4_B = 6,
+ BIFROST_TEXTURE_FETCH_GATHER4_A = 7
+};
+
+struct bifrost_texture_operation {
+ /* If immediate_indices is set:
+ * - immediate sampler index
+ * - index used as texture index
+ * Otherwise:
+ * - bifrost_single_index in lower 2 bits
+ * - 0x3 in upper 2 bits (single-texturing)
+ */
+ unsigned sampler_index_or_mode : 4;
+ unsigned index : 7;
+ bool immediate_indices : 1;
+ enum bifrost_tex_op op : 3;
+
+ /* If set for TEX/FETCH, loads texel offsets and multisample index from
+ * a staging register containing offset_x:offset_y:offset_z:ms_index
+ * packed 8:8:8:8. Offsets must be in [-31, +31]. If set for
+ * GRDESC(_DER), disable LOD bias. */
+ bool offset_or_bias_disable : 1;
+
+ /* If set for TEX/FETCH, loads fp32 shadow comparison value from a
+ * staging register. Implies fetch_component = gather4_r. If set for
+ * GRDESC(_DER), disables LOD clamping. */
+ bool shadow_or_clamp_disable : 1;
+
+ /* If set, loads an uint32 array index from a staging register. */
+ bool array : 1;
+
+ /* Texture dimension, or 0 for a cubemap */
+ unsigned dimension : 2;
+
+ /* Method to compute LOD value */
+ enum bifrost_lod_mode lod_mode : 3;
+
+ /* Reserved */
+ unsigned zero : 1;
+
+ /* Register format for the result or for a FETCH, the
+ * bifrost_texture_fetch component specification */
+ enum bifrost_texture_format_full format_or_fetch : 4;
+
+ /* Write mask for the result */
+ unsigned mask : 4;
+} __attribute__((packed));
+
#endif