BIFROST_SRC_PASS_ADD = 7,
};
-#define BIFROST_FMA_EXT (0xe0000)
-#define BIFROST_FMA_OP_MOV BIFROST_FMA_EXT | (0x32d)
-#define BIFROST_FMA_OP_FREXPE_LOG BIFROST_FMA_EXT | 0x3c5
-#define BIFROST_FMA_OP_ADD_FREXPM ((BIFROST_FMA_EXT | 0x1e80) >> 3)
-#define BIFROST_FMA_SEL_16(swiz) (((BIFROST_FMA_EXT | 0x1e00) >> 3) | (swiz))
-
-#define BIFROST_FMA_ROUND_16(mode, swiz) (BIFROST_FMA_EXT | 0x1800 | (swiz) | ((mode) << 6))
-#define BIFROST_FMA_ROUND_32(mode) (BIFROST_FMA_EXT | 0x1805 | ((mode) << 6))
-
struct bifrost_fma_inst {
unsigned src0 : 3;
unsigned op : 20;
} __attribute__((packed));
-#define BIFROST_FMA_IADD_32 (0x4ff98 >> 3)
-#define BIFROST_FMA_ISUB_32 (0x4ffd8 >> 3)
-#define BIFROST_FMA_IMUL_32 ((BIFROST_FMA_EXT | 0x7818) >> 3)
-
-struct bifrost_fma_2src {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned op : 17;
-} __attribute__((packed));
-
-#define BIFROST_FMA_OP_SEL8 (0x71)
-
-struct bifrost_fma_sel8 {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src2 : 3;
- unsigned src3 : 3;
- unsigned swizzle : 4;
- unsigned op : 7;
-} __attribute__((packed));
-
-#define BIFROST_FMA_OP_MSCALE (0x50 >> 3)
-
-struct bifrost_fma_mscale {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src2 : 3;
- unsigned src3 : 3;
-
- /* If mscale_mode is set - an MSCALE specific mode. If it is not set, a
- * regular outmod */
- unsigned mode : 2;
- unsigned mscale_mode : 1;
-
- unsigned src0_abs : 1;
- unsigned src1_neg : 1;
- unsigned src2_neg : 1;
- unsigned op : 5;
-} __attribute__((packed));
-
-#define BIFROST_ADD_OP_BLEND (0x1952c)
-#define BIFROST_ADD_OP_FRCP_FAST_F32 (0x0cc00)
-#define BIFROST_ADD_OP_FRCP_FAST_F16_X (0x0ce10)
-#define BIFROST_ADD_OP_FRCP_FAST_F16_Y (0x0ce30)
-#define BIFROST_ADD_OP_FRSQ_FAST_F32 (0x0cc20)
-#define BIFROST_ADD_OP_FRSQ_FAST_F16_X (0x0ce50)
-#define BIFROST_ADD_OP_FRSQ_FAST_F16_Y (0x0ce70)
-#define BIFROST_ADD_OP_LOG2_HELP (0x0cc68)
-#define BIFROST_ADD_OP_IABS_32 (0x07bd4)
-
struct bifrost_add_inst {
unsigned src0 : 3;
unsigned op : 17;
} __attribute__((packed));
-#define BIFROST_ADD_OP_DISCARD (0x19100 >> 8)
-
-enum bifrost_discard_cond {
- BIFROST_DISCARD_FEQ = 0,
- BIFROST_DISCARD_FNE = 1,
- BIFROST_DISCARD_FLE = 2,
- BIFROST_DISCARD_FLT = 3,
-};
-
-struct bifrost_add_discard {
- unsigned src0 : 3;
- unsigned src1 : 3;
- enum bifrost_discard_cond cond : 2;
- /* Zero for fp32 */
- unsigned src0_select : 1;
- unsigned src1_select : 1;
- unsigned fp32 : 1;
- unsigned op : 9;
-} __attribute__((packed));
-
-#define BIFROST_ADD_OP_LD_UBO_1 (0x0c1a0 >> 3)
-#define BIFROST_ADD_OP_LD_UBO_2 (0x0c1e0 >> 3)
-#define BIFROST_ADD_OP_LD_UBO_3 (0x0caa0 >> 3)
-#define BIFROST_ADD_OP_LD_UBO_4 (0x0c220 >> 3)
-#define BIFROST_ADD_SEL_16(swiz) ((0xea60 >> 3) | (swiz))
-
-#define BIFROST_ADD_IADD_8 (0x17880 >> 3)
-#define BIFROST_ADD_IADD_16 (0x17900 >> 3)
-#define BIFROST_ADD_IADD_32 (0x178c0 >> 3)
-#define BIFROST_ADD_ISUB_8 (0x17a80 >> 3)
-#define BIFROST_ADD_ISUB_16 (0x17b00 >> 3)
-#define BIFROST_ADD_ISUB_32 (0x17ac0 >> 3)
-#define BIFROST_ADD_OP_FEXP2_FAST (0x0cd58 >> 3)
-
-struct bifrost_add_2src {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned op : 14;
-} __attribute__((packed));
-
-#define BIFROST_ADD_OP_FMAX32 (0x00)
-#define BIFROST_ADD_OP_FMIN32 (0x01)
-#define BIFROST_ADD_OP_FADD32 (0x02)
-
-#define BIFROST_ADD_OP_FADD16 (0x0A)
-
-struct bifrost_add_faddmin {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src1_abs : 1;
- unsigned src0_neg : 1;
- unsigned src1_neg : 1;
- unsigned select : 2; /* swizzle_0 for fp16 */
- unsigned outmod : 2; /* swizzle_1 for fp16 */
- unsigned mode : 2;
- unsigned src0_abs : 1;
- unsigned op : 4;
-} __attribute__((packed));
-
-#define BIFROST_ADD_OP_FMAX16 (0x10)
-#define BIFROST_ADD_OP_FMIN16 (0x12)
-
-struct bifrost_add_fmin16 {
- unsigned src0 : 3;
- unsigned src1 : 3;
- /* abs2 inferred as with FMA */
- unsigned abs1 : 1;
- unsigned src0_neg : 1;
- unsigned src1_neg : 1;
- unsigned src0_swizzle : 2;
- unsigned src1_swizzle : 2;
- unsigned mode : 2;
- unsigned op : 5;
-} __attribute__((packed));
-
-#define BIFROST_ADD_OP_ST_VAR (0x19300 >> 8)
-
-struct bifrost_st_vary {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src2 : 3;
- unsigned channels : 2;
- unsigned op : 9;
-} __attribute__((packed));
-
-#define BIFROST_ADD_OP_ATEST (0xc8f)
-
-struct bifrost_add_atest {
- /* gl_SampleMask (R60) */
- unsigned src0 : 3;
-
- /* Alpha value */
- unsigned src1 : 3;
-
- /* If half, X/Y select. If !half, always set */
- unsigned component : 1;
- unsigned half : 1;
-
- unsigned op : 12;
-} __attribute__((packed));
-
enum bifrost_outmod {
BIFROST_NONE = 0x0,
BIFROST_POS = 0x1,
BIFROST_SRC0_WINS = 0x3,
};
-#define BIFROST_FMA_OP_FADD32 (0x58 >> 2)
-#define BIFROST_FMA_OP_FMAX32 (0x40 >> 2)
-#define BIFROST_FMA_OP_FMIN32 (0x44 >> 2)
-
-struct bifrost_fma_add {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src1_abs : 1;
- unsigned src0_neg : 1;
- unsigned src1_neg : 1;
- unsigned unk : 3;
- unsigned src0_abs : 1;
- enum bifrost_roundmode roundmode : 2;
- enum bifrost_outmod outmod : 2;
- unsigned op : 6;
-} __attribute__((packed));
-
-#define BIFROST_FMA_OP_FMAX16 (0xC0 >> 2)
-#define BIFROST_FMA_OP_FMIN16 (0xCC >> 2)
-#define BIFROST_FMA_OP_FADD16 (0xD8 >> 2)
-
-struct bifrost_fma_add_minmax16 {
- unsigned src0 : 3;
- unsigned src1 : 3;
- /* abs2 inferred as (src1 < src0) */
- unsigned abs1 : 1;
- unsigned src0_neg : 1;
- unsigned src1_neg : 1;
- unsigned src0_swizzle : 2;
- unsigned src1_swizzle : 2;
- unsigned mode : 2;
- enum bifrost_outmod outmod : 2;
- /* roundmode for add, min/max mode for min/max */
- unsigned op : 6;
-} __attribute__((packed));
-
-#define BIFROST_FMA_OP_FMA (0x00)
-
-struct bifrost_fma_fma {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src2 : 3;
- unsigned src_expand : 3;
- unsigned src0_abs : 1;
- enum bifrost_roundmode roundmode : 2;
- enum bifrost_outmod outmod : 2;
- unsigned src0_neg : 1; /* 14 */
- unsigned src2_neg : 1;
- unsigned src1_abs : 1;
- unsigned src2_abs : 1; /* 17 */
- unsigned op : 2;
-} __attribute__((packed));
-
-#define BIFROST_FMA_OP_FMA16 (0x2)
-
-struct bifrost_fma_fma16 {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src2 : 3;
- unsigned swizzle_0 : 2;
- unsigned swizzle_1 : 2;
- enum bifrost_roundmode roundmode : 2;
- enum bifrost_outmod outmod : 2;
- unsigned src0_neg : 1;
- unsigned src2_neg : 1;
- unsigned swizzle_2 : 2;
- unsigned op : 2;
-} __attribute__((packed));
-
-enum bifrost_csel_cond {
- BIFROST_FEQ_F = 0x0,
- BIFROST_FGT_F = 0x1,
- BIFROST_FGE_F = 0x2,
- BIFROST_IEQ_F = 0x3,
- BIFROST_IGT_I = 0x4,
- BIFROST_IGE_I = 0x5,
- BIFROST_UGT_I = 0x6,
- BIFROST_UGE_I = 0x7
-};
-
-#define BIFROST_FMA_OP_CSEL4 (0x5c)
-#define BIFROST_FMA_OP_CSEL4_V16 (0xdc)
-
-struct bifrost_csel4 {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src2 : 3;
- unsigned src3 : 3;
- enum bifrost_csel_cond cond : 3;
- unsigned op : 8;
-} __attribute__((packed));
-
-#define BIFROST_FMA_OP_RSHIFT_NAND (0x60000 >> 12)
-#define BIFROST_FMA_OP_RSHIFT_AND (0x61000 >> 12)
-#define BIFROST_FMA_OP_LSHIFT_NAND (0x62000 >> 12)
-#define BIFROST_FMA_OP_LSHIFT_AND (0x63000 >> 12)
-#define BIFROST_FMA_OP_RSHIFT_XOR (0x64000 >> 12)
-#define BIFROST_FMA_OP_LSHIFT_ADD_32 (0x65200 >> 6)
-#define BIFROST_FMA_OP_LSHIFT_SUB_32 (0x65600 >> 6)
-#define BIFROST_FMA_OP_LSHIFT_RSUB_32 (0x65a00 >> 6)
-#define BIFROST_FMA_OP_RSHIFT_ADD_32 (0x65e00 >> 6)
-#define BIFROST_FMA_OP_RSHIFT_SUB_32 (0x66200 >> 6)
-#define BIFROST_FMA_OP_RSHIFT_RSUB_32 (0x66600 >> 6)
-
-struct bifrost_shift_fma {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src2 : 3;
- unsigned half : 3;
- unsigned unk : 1; /* always set? */
- unsigned invert_1 : 1; /* Inverts sources to combining op */
- /* For XOR, switches RSHIFT to LSHIFT since only one invert needed */
- unsigned invert_2 : 1;
- unsigned op : 8;
-} __attribute__((packed));
-
-struct bifrost_shift_add {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src2 : 3;
- unsigned zero : 2;
-
- unsigned invert_1 : 1;
- unsigned invert_2 : 1;
-
- unsigned op : 7;
-} __attribute__((packed));
-
-enum bifrost_fcmp_cond {
- BIFROST_OEQ = 0,
- BIFROST_OGT = 1,
- BIFROST_OGE = 2,
- BIFROST_UNE = 3,
- BIFROST_OLT = 4,
- BIFROST_OLE = 5,
-};
-
-/* "gl" version produces 0/1. "d3d" version produces 0/~0 */
-#define BIFROST_FMA_OP_FCMP_GL (0x48000 >> 13)
-#define BIFROST_FMA_OP_FCMP_D3D (0x4c000 >> 13)
-
-struct bifrost_fma_fcmp {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src1_abs : 1;
- unsigned unk1 : 1;
- unsigned src1_neg : 1;
- unsigned src_expand : 3;
- unsigned src0_abs : 1;
- enum bifrost_fcmp_cond cond : 3;
- unsigned op : 7;
-} __attribute__((packed));
-
-struct bifrost_add_fcmp {
- unsigned src0 : 3;
- unsigned src1 : 3;
- enum bifrost_fcmp_cond cond : 3;
- unsigned src_expand : 2;
- unsigned src0_abs : 1;
- unsigned src1_abs : 1;
- unsigned src1_neg : 1;
- unsigned op : 6;
-} __attribute__((packed));
-
-/* "gl" version produces 0/1. "d3d" version produces 0/~0 */
-#define BIFROST_FMA_OP_FCMP_GL_16 (0xc8000 >> 13)
-#define BIFROST_FMA_OP_FCMP_D3D_16 (0xcc000 >> 13)
-
-struct bifrost_fma_fcmp16 {
- unsigned src0 : 3;
- unsigned src1 : 3;
-
- /* abs2 inferred */
- unsigned abs1 : 1;
- unsigned unk : 2;
-
- unsigned src0_swizzle : 2;
- unsigned src1_swizzle : 2;
-
- enum bifrost_fcmp_cond cond : 3;
- unsigned op : 7;
-} __attribute__((packed));
-
-struct bifrost_add_fcmp16 {
- unsigned src0 : 3;
- unsigned src1 : 3;
- enum bifrost_fcmp_cond cond : 3;
-
- unsigned src0_swizzle : 2;
- unsigned src1_swizzle : 2;
-
- /* No abs mods */
- unsigned src0_neg : 1;
-
- unsigned op : 6;
-} __attribute__((packed));
-
-enum bifrost_icmp_cond {
- BIFROST_ICMP_IGT = 0,
- BIFROST_ICMP_IGE = 1, /* swapped for 16-bit */
- BIFROST_ICMP_UGT = 2, /* swapped for 16-bit */
- BIFROST_ICMP_UGE = 3,
- BIFROST_ICMP_EQ = 4,
- BIFROST_ICMP_NEQ = 5,
- BIFROST_ICMP_32_OR_8 = 6, /* nested */
- BIFROST_ICMP_64 = 7, /* nested */
-};
-
-struct bifrost_fma_icmp32 {
- unsigned src0 : 3;
- unsigned src1 : 3;
- enum bifrost_icmp_cond cond : 3;
- unsigned unk1 : 1; /* set */
- unsigned d3d : 1; /* if set, true is ~0. otherwise, true is 1 */
- unsigned op : 12;
-} __attribute__((packed));
-
-struct bifrost_fma_icmp16 {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned unk : 5; /* 11010 */
- enum bifrost_icmp_cond cond : 3;
- unsigned op : 9;
-} __attribute__((packed));
-
-#define BIFROST_ADD_OP_ICMP_32 (0x0f600 >> 8)
-#define BIFROST_ADD_OP_ICMP_16 (0x0f000 >> 11)
-
-struct bifrost_add_icmp {
- unsigned src0 : 3;
- unsigned src1 : 3;
- enum bifrost_icmp_cond cond : 3;
- unsigned sz : 1; /* 1 for 32, 0 for 8 */
- unsigned d3d : 1; /* if set, true is ~0. otherwise, true is 1 */
- unsigned op : 9;
-} __attribute__((packed));
-
-struct bifrost_add_icmp16 {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned src0_swizzle : 2;
- unsigned src1_swizzle : 2;
- unsigned d3d : 1; /* if set, true is ~0. otherwise, true is 1 */
- enum bifrost_icmp_cond cond : 3;
- unsigned op : 6;
-} __attribute__((packed));
-
-/* Two sources for vectorization */
-#define BIFROST_FMA_FLOAT32_TO_16 (0xdd000 >> 3)
-#define BIFROST_ADD_FLOAT32_TO_16 (0x0EC00 >> 3)
-
-enum bifrost_convert_mode {
- BIFROST_CONV_UNK0 = 0,
- BIFROST_CONV_F32_TO_I32 = 1,
- BIFROST_CONV_F16_TO_I16 = 2,
- BIFROST_CONV_I32_TO_F32 = 3,
- BIFROST_CONV_I16_TO_X32 = 4,
- BIFROST_CONV_F16_TO_F32 = 5,
- BIFROST_CONV_I16_TO_F16 = 6,
- BIFROST_CONV_UNK7 = 7
-};
-
-/* i16 to x32 */
-#define BIFROST_CONVERT_4(is_unsigned, component, to_float) \
- ((is_unsigned & 1) | ((component & 1) << 1) | ((to_float & 1) << 2) | \
- ((0x3) << 3) | ((4) << 5) | 0x100)
-
-/* f16 to f32 */
-#define BIFROST_CONVERT_5(component) \
- ((component & 1) | ((1) << 1) | ((5) << 5) | 0x100)
-
-/* Other conversions */
-#define BIFROST_CONVERT(is_unsigned, roundmode, swizzle, mode) \
- ((is_unsigned & 1) | ((roundmode & 3) << 1) | ((swizzle & 3) << 3) | ((mode & 7) << 5))
-
-#define BIFROST_FMA_CONVERT (0xe0000)
-#define BIFROST_ADD_CONVERT (0x07800)
-
-enum bifrost_ldst_type {
- BIFROST_LDST_F16 = 0,
- BIFROST_LDST_F32 = 1,
- BIFROST_LDST_I32 = 2,
- BIFROST_LDST_U32 = 3
-};
-
-#define BIFROST_ADD_OP_LD_VAR_ADDR (0x18000 >> 10)
-
-struct bifrost_ld_var_addr {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned location : 5;
- enum bifrost_ldst_type type : 2;
- unsigned op : 7;
-} __attribute__((packed));
-
-#define BIFROST_ADD_OP_LD_ATTR (0x08000 >> 12)
-
-struct bifrost_ld_attr {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned location : 5;
- unsigned channels : 2; /* MALI_POSITIVE */
- enum bifrost_ldst_type type : 2;
- unsigned op : 5;
-} __attribute__((packed));
-
enum bifrost_interp_mode {
BIFROST_INTERP_PER_FRAG = 0x0,
BIFROST_INTERP_CENTROID = 0x1,
BIFROST_INTERP_EXPLICIT = 0x3
};
-#define BIFROST_ADD_OP_LD_VAR_16 (0x1a << 1)
-#define BIFROST_ADD_OP_LD_VAR_32 (0x0a << 1)
-
/* Fixed location for gl_FragCoord.zw */
#define BIFROST_FRAGZ (23)
#define BIFROST_FRAGW (22)
-struct bifrost_ld_var {
- unsigned src0 : 3;
-
- /* If top two bits set, indirect with src in bottom three */
- unsigned addr : 5;
-
- unsigned channels : 2; /* MALI_POSITIVE */
- enum bifrost_interp_mode interp_mode : 2;
- unsigned reuse : 1;
- unsigned flat : 1;
- unsigned op : 6;
-} __attribute__((packed));
-
-struct bifrost_tex_ctrl {
- unsigned sampler_index : 4; // also used to signal indirects
- unsigned tex_index : 7;
- bool no_merge_index : 1; // whether to merge (direct) sampler & texture indices
- bool filter : 1; // use the usual filtering pipeline (0 for texelFetch & textureGather)
- unsigned unk0 : 2;
- bool texel_offset : 1; // *Offset()
- bool is_shadow : 1;
- bool is_array : 1;
- unsigned tex_type : 2; // 2D, 3D, Cube, Buffer
- bool compute_lod : 1; // 0 for *Lod()
- bool not_supply_lod : 1; // 0 for *Lod() or when a bias is applied
- bool calc_gradients : 1; // 0 for *Grad()
- unsigned unk1 : 1;
- unsigned result_type : 4; // integer, unsigned, float TODO: why is this 4 bits?
- unsigned unk2 : 4;
-} __attribute__((packed));
-
-struct bifrost_dual_tex_ctrl {
- unsigned sampler_index0 : 2;
- unsigned unk0 : 2;
- unsigned tex_index0 : 2;
- unsigned sampler_index1 : 2;
- unsigned tex_index1 : 2;
- unsigned unk1 : 22;
-} __attribute__((packed));
-
-#define BIFROST_ADD_OP_TEX_COMPACT_F32(vtx) ((0x0b000 | ((vtx) ? (0x400) : (0))) >> 10)
-#define BIFROST_ADD_OP_TEX_COMPACT_F16(vtx) ((0x1b000 | ((vtx) ? (0x400) : (0))) >> 10)
-
-struct bifrost_tex_compact {
- unsigned src0 : 3;
- unsigned src1 : 3;
- unsigned tex_index : 3;
- unsigned compute_lod : 1;
- unsigned sampler_index : 3;
- unsigned op : 7;
-} __attribute__((packed));
-
enum branch_bit_size {
BR_SIZE_32 = 0,
BR_SIZE_16XX = 1,
/* Clause packing */
-#define BIFROST_FMA_NOP (0x701960 | BIFROST_SRC_STAGE)
-#define BIFROST_ADD_NOP (0x3D960 | BIFROST_SRC_STAGE)
-
struct bifrost_fmt1 {
unsigned ins_0 : 3;
unsigned tag : 5;