#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. */
/* 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.
/* 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
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.");
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.");
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.");
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.");