pan/bi: Emit load_vary ops
[mesa.git] / src / panfrost / bifrost / bifrost.h
index 959c951e582dc00d00913af85f3b86ccfbdb2b61..c7e6bcf8630bdc00eeca60fdfa23dd4a6008bb69 100644 (file)
@@ -70,17 +70,28 @@ struct bifrost_header {
         unsigned unk3 : 1; // part of clauseType?
         unsigned next_clause_type: 4;
         unsigned unk4 : 1; // part of nextClauseType?
+} __attribute__((packed));
+
+enum bifrost_packed_src {
+        BIFROST_SRC_PORT0    = 0,
+        BIFROST_SRC_PORT1    = 1,
+        BIFROST_SRC_PORT3    = 2,
+        BIFROST_SRC_STAGE    = 3,
+        BIFROST_SRC_CONST_LO = 4,
+        BIFROST_SRC_CONST_HI = 5,
+        BIFROST_SRC_PASS_FMA = 6,
+        BIFROST_SRC_PASS_ADD = 7,
 };
 
 struct bifrost_fma_inst {
         unsigned src0 : 3;
         unsigned op   : 20;
-};
+} __attribute__((packed));
 
 struct bifrost_add_inst {
         unsigned src0 : 3;
         unsigned op   : 17;
-};
+} __attribute__((packed));
 
 enum bifrost_outmod {
         BIFROST_NONE = 0x0,
@@ -123,6 +134,8 @@ enum bifrost_minmax_mode {
         BIFROST_SRC0_WINS   = 0x3,
 };
 
+#define BIFROST_FMA_OP_FADD32 (0x58 >> 2)
+
 struct bifrost_fma_add {
         unsigned src0 : 3;
         unsigned src1 : 3;
@@ -134,7 +147,23 @@ struct bifrost_fma_add {
         enum bifrost_outmod outmod : 2;
         enum bifrost_roundmode roundmode : 2;
         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;
+        unsigned unk : 4;
+        unsigned src0_neg : 1;
+        unsigned src2_neg : 1;
+        unsigned src1_abs : 1;
+        unsigned src2_abs : 1;
+        unsigned op : 5;
+} __attribute__((packed));
 
 enum bifrost_csel_cond {
         BIFROST_FEQ_F = 0x0,
@@ -154,7 +183,7 @@ struct bifrost_csel4 {
         unsigned src3 : 3;
         enum bifrost_csel_cond cond : 3;
         unsigned op   : 8;
-};
+} __attribute__((packed));
 
 struct bifrost_shift_fma {
         unsigned src0 : 3;
@@ -166,7 +195,7 @@ struct bifrost_shift_fma {
         /* 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;
@@ -178,7 +207,7 @@ struct bifrost_shift_add {
         unsigned invert_2 : 1;
 
         unsigned op : 7;
-};
+} __attribute__((packed));
 
 enum bifrost_ldst_type {
         BIFROST_LDST_F16 = 0,
@@ -193,7 +222,7 @@ struct bifrost_ld_var_addr {
         unsigned location : 5;
         enum bifrost_ldst_type type : 2;
         unsigned op : 7;
-};
+} __attribute__((packed));
 
 struct bifrost_ld_attr {
         unsigned src0 : 3;
@@ -202,7 +231,7 @@ struct bifrost_ld_attr {
         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,
@@ -211,6 +240,9 @@ enum bifrost_interp_mode {
         BIFROST_INTERP_EXPLICIT = 0x3
 };
 
+#define BIFROST_ADD_OP_LD_VAR_16 (0x1a << 1)
+#define BIFROST_ADD_OP_LD_VAR_32 (0x0a << 1)
+
 struct bifrost_ld_var {
         unsigned src0 : 3;
 
@@ -222,7 +254,7 @@ struct bifrost_ld_var {
         unsigned reuse : 1;
         unsigned flat : 1;
         unsigned op : 6;
-};
+} __attribute__((packed));
 
 struct bifrost_tex_ctrl {
         unsigned sampler_index : 4; // also used to signal indirects
@@ -240,7 +272,7 @@ struct bifrost_tex_ctrl {
         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;
@@ -249,7 +281,7 @@ struct bifrost_dual_tex_ctrl {
         unsigned sampler_index1 : 2;
         unsigned tex_index1 : 2;
         unsigned unk1 : 22;
-};
+} __attribute__((packed));
 
 enum branch_bit_size {
         BR_SIZE_32 = 0,
@@ -284,7 +316,7 @@ struct bifrost_regs {
         unsigned reg0 : 5;
         unsigned reg1 : 6;
         unsigned ctrl : 4;
-};
+} __attribute__((packed));
 
 enum bifrost_branch_cond {
         BR_COND_LT = 0,
@@ -323,6 +355,9 @@ struct bifrost_branch {
 
 /* Clause packing */
 
+#define BIFROST_FMA_NOP (0x701960)
+#define BIFROST_ADD_NOP (0x3D960)
+
 struct bifrost_fmt1 {
         unsigned ins_0 : 3;
         unsigned tag : 5;
@@ -335,4 +370,22 @@ struct bifrost_fmt1 {
 #define BIFROST_FMT1_FINAL           0b01001
 #define BIFROST_FMT1_CONSTANTS       0b00001
 
+enum bifrost_reg_control {
+        BIFROST_WRITE_FMA_P2         = 1,
+        BIFROST_WRITE_FMA_P2_READ_P3 = 2,
+        BIFROST_WRITE_FMA_P2_READ_P3_ALT = 3,
+        BIFROST_READ_P3              = 4,
+        BIFROST_WRITE_ADD_P2         = 5,
+        BIFROST_WRITE_ADD_P2_READ_P3 = 6,
+        BIFROST_WRITE_ADD_P2_FMA_P3  = 7,
+
+        BIFROST_FIRST_NONE           = 8,
+        BIFROST_FIRST_WRITE_FMA_P2   = 9,
+        BIFROST_REG_NONE             = 11,
+        BIFROST_FIRST_READ_P3        = 12,
+        BIFROST_FIRST_WRITE_ADD_P2   = 13,
+        BIFROST_FIRST_WRITE_ADD_P2_READ_P3 = 14,
+        BIFROST_FIRST_WRITE_ADD_P2_FMA_P3  = 15
+};
+
 #endif