intel/perf: export performance counters sorted by [group|set] and name
[mesa.git] / src / intel / isl / isl_aux_info.c
index 4fe6e516fc3fe82ebfb9fe4e29cb023e3133a1a0..d771b15b604144244a25b08be689a689e350e1dc 100644 (file)
 
 #include "isl/isl.h"
 
+#ifdef IN_UNIT_TEST
+/* STATIC_ASSERT is a do { ... } while(0) statement */
+UNUSED static void static_assert_func(void) {
+   STATIC_ASSERT(ISL_AUX_OP_ASSERT == ((enum isl_aux_op) 0));
+   STATIC_ASSERT(ISL_AUX_STATE_ASSERT == ((enum isl_aux_state) 0));
+}
+
+#undef unreachable
+#define unreachable(str) return 0
+
+#undef assert
+#define assert(cond) do { \
+   if (!(cond)) { \
+      return 0; \
+   } \
+} while (0)
+#endif
+
 /* How writes with an isl_aux_usage behave. */
 enum write_behavior {
    /* Writes only touch the main surface. */
@@ -31,6 +49,11 @@ enum write_behavior {
    /* Writes using the 3D engine are compressed. */
    WRITES_COMPRESS,
 
+   /* Writes using the 3D engine are either compressed or substituted with
+    * fast-cleared blocks.
+    */
+   WRITES_COMPRESS_CLEAR,
+
    /* Writes implicitly fully resolve the compression block and write the data
     * uncompressed into the main surface. The resolved aux blocks are
     * ambiguated and left in the pass-through state.
@@ -65,11 +88,14 @@ static const struct aux_usage_info info[] = {
 /*         write_behavior c fc pr fra */
    AUX(         COMPRESS, Y, Y, x, x, HIZ)
    AUX(         COMPRESS, Y, Y, x, x, HIZ_CCS)
+   AUX(         COMPRESS, Y, Y, x, x, HIZ_CCS_WT)
    AUX(         COMPRESS, Y, Y, Y, x, MCS)
    AUX(         COMPRESS, Y, Y, Y, x, MCS_CCS)
    AUX(         COMPRESS, Y, Y, Y, Y, CCS_E)
+   AUX(   COMPRESS_CLEAR, Y, Y, Y, Y, GEN12_CCS_E)
    AUX(RESOLVE_AMBIGUATE, x, Y, x, Y, CCS_D)
    AUX(RESOLVE_AMBIGUATE, Y, x, x, Y, MC)
+   AUX(         COMPRESS, Y, x, x, Y, STC_CCS)
 };
 #undef x
 #undef Y
@@ -91,6 +117,10 @@ aux_state_possible(enum isl_aux_state state,
    case ISL_AUX_STATE_PASS_THROUGH:
    case ISL_AUX_STATE_AUX_INVALID:
       return true;
+#ifdef IN_UNIT_TEST
+   case ISL_AUX_STATE_ASSERT:
+      break;
+#endif
    }
 
    unreachable("Invalid aux state.");
@@ -128,6 +158,10 @@ isl_aux_prepare_access(enum isl_aux_state initial_state,
    case ISL_AUX_STATE_AUX_INVALID:
       return info[usage].write_behavior == WRITES_ONLY_TOUCH_MAIN ?
              ISL_AUX_OP_NONE : ISL_AUX_OP_AMBIGUATE;
+#ifdef IN_UNIT_TEST
+   case ISL_AUX_STATE_ASSERT:
+      break;
+#endif
    }
 
    unreachable("Invalid aux state.");
@@ -161,6 +195,10 @@ isl_aux_state_transition_aux_op(enum isl_aux_state initial_state,
              ISL_AUX_STATE_PASS_THROUGH : ISL_AUX_STATE_RESOLVED;
    case ISL_AUX_OP_AMBIGUATE:
       return ISL_AUX_STATE_PASS_THROUGH;
+#if IN_UNIT_TEST
+   case ISL_AUX_OP_ASSERT:
+      break;
+#endif
    }
 
    unreachable("Invalid aux op.");
@@ -181,26 +219,35 @@ isl_aux_state_transition_write(enum isl_aux_state initial_state,
    assert(isl_aux_state_has_valid_aux(initial_state));
    assert(aux_state_possible(initial_state, usage));
    assert(info[usage].write_behavior == WRITES_COMPRESS ||
+          info[usage].write_behavior == WRITES_COMPRESS_CLEAR ||
           info[usage].write_behavior == WRITES_RESOLVE_AMBIGUATE);
 
    if (full_surface) {
       return info[usage].write_behavior == WRITES_COMPRESS ?
-             ISL_AUX_STATE_COMPRESSED_NO_CLEAR : ISL_AUX_STATE_PASS_THROUGH;
+                ISL_AUX_STATE_COMPRESSED_NO_CLEAR :
+             info[usage].write_behavior == WRITES_COMPRESS_CLEAR ?
+                ISL_AUX_STATE_COMPRESSED_CLEAR : ISL_AUX_STATE_PASS_THROUGH;
    }
 
    switch (initial_state) {
    case ISL_AUX_STATE_CLEAR:
    case ISL_AUX_STATE_PARTIAL_CLEAR:
-      return info[usage].write_behavior == WRITES_COMPRESS ?
-             ISL_AUX_STATE_COMPRESSED_CLEAR : ISL_AUX_STATE_PARTIAL_CLEAR;
+      return info[usage].write_behavior == WRITES_RESOLVE_AMBIGUATE ?
+             ISL_AUX_STATE_PARTIAL_CLEAR : ISL_AUX_STATE_COMPRESSED_CLEAR;
    case ISL_AUX_STATE_RESOLVED:
    case ISL_AUX_STATE_PASS_THROUGH:
+   case ISL_AUX_STATE_COMPRESSED_NO_CLEAR:
       return info[usage].write_behavior == WRITES_COMPRESS ?
-             ISL_AUX_STATE_COMPRESSED_NO_CLEAR : initial_state;
+                ISL_AUX_STATE_COMPRESSED_NO_CLEAR :
+             info[usage].write_behavior == WRITES_COMPRESS_CLEAR ?
+                ISL_AUX_STATE_COMPRESSED_CLEAR : initial_state;
    case ISL_AUX_STATE_COMPRESSED_CLEAR:
-   case ISL_AUX_STATE_COMPRESSED_NO_CLEAR:
    case ISL_AUX_STATE_AUX_INVALID:
       return initial_state;
+#ifdef IN_UNIT_TEST
+   case ISL_AUX_STATE_ASSERT:
+      break;
+#endif
    }
 
    unreachable("Invalid aux state.");