freedreno/a4xx: better workaround for astc+srgb
[mesa.git] / src / gallium / drivers / freedreno / ir3 / ir3.h
index 23e43b1e13dc5b98074817e0d33c8ad3c90be09b..a40d3aa3b405d40af3350fe6776bcfc95624f01a 100644 (file)
@@ -308,8 +308,14 @@ struct ir3_instruction {
 static inline struct ir3_instruction *
 ir3_neighbor_first(struct ir3_instruction *instr)
 {
-       while (instr->cp.left)
+       int cnt = 0;
+       while (instr->cp.left) {
                instr = instr->cp.left;
+               if (++cnt > 0xffff) {
+                       debug_assert(0);
+                       break;
+               }
+       }
        return instr;
 }
 
@@ -322,6 +328,10 @@ static inline int ir3_neighbor_count(struct ir3_instruction *instr)
        while (instr->cp.right) {
                num++;
                instr = instr->cp.right;
+               if (num > 0xffff) {
+                       debug_assert(0);
+                       break;
+               }
        }
 
        return num;
@@ -367,6 +377,12 @@ struct ir3 {
        unsigned keeps_count, keeps_sz;
        struct ir3_instruction **keeps;
 
+       /* Track texture sample instructions which need texture state
+        * patched in (for astc-srgb workaround):
+        */
+       unsigned astc_srgb_count, astc_srgb_sz;
+       struct ir3_instruction **astc_srgb;
+
        /* List of blocks: */
        struct list_head block_list;
 
@@ -628,6 +644,18 @@ static inline bool is_input(struct ir3_instruction *instr)
        }
 }
 
+static inline bool is_bool(struct ir3_instruction *instr)
+{
+       switch (instr->opc) {
+       case OPC_CMPS_F:
+       case OPC_CMPS_S:
+       case OPC_CMPS_U:
+               return true;
+       default:
+               return false;
+       }
+}
+
 static inline bool is_meta(struct ir3_instruction *instr)
 {
        /* TODO how should we count PHI (and maybe fan-in/out) which