intel/isl: Add a separate ISL_AUX_USAGE_STC_CCS
authorJason Ekstrand <jason@jlekstrand.net>
Thu, 5 Mar 2020 17:17:28 +0000 (11:17 -0600)
committerMarge Bot <eric+marge@anholt.net>
Thu, 12 Mar 2020 17:51:28 +0000 (17:51 +0000)
Stencil CCS is slightly different from color CCS.  Using a color CCS
resolve with stencil CCS doesn't do the right thing and you can't sample
from a stencil CCS image without the DepthStencilResource bit set or you
will get the wrong data.  Stencil CCS also has it's own rules such as it
doesn't support fast-clear and has no partial resolve.  This seems to
indicate that it should probably be its own isl_aux_usage.  Now that
adding new isl_aux_usage values is pretty cheap, let's split stencil CCS
out on its own.

Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4056>

src/intel/blorp/blorp_genX_exec.h
src/intel/isl/isl.h
src/intel/isl/isl_aux_info.c
src/intel/isl/isl_emit_depth_stencil.c
src/intel/isl/isl_surface_state.c
src/intel/isl/tests/isl_aux_info_test.cpp

index a77cff3716c86de62065ecfba1355ecc7854e0c7..cc032e6dba887678c0d1e521696d45f567f3e6f9 100644 (file)
@@ -1805,7 +1805,8 @@ blorp_emit_gen8_hiz_op(struct blorp_batch *batch,
          hzp.DepthBufferResolveEnable = params->depth.enabled;
 #if GEN_GEN >= 12
          if (params->stencil.enabled) {
-            assert(params->stencil.aux_usage == ISL_AUX_USAGE_CCS_E);
+            assert(params->stencil.aux_usage == ISL_AUX_USAGE_CCS_E ||
+                   params->stencil.aux_usage == ISL_AUX_USAGE_STC_CCS);
             hzp.StencilBufferResolveEnable = true;
          }
 #endif
index 596ec75c4af7e1d2651d6af6665fb06441ea70d8..aabf980b86a6e48adbcbf4b17d8b1b047d4a35ff 100644 (file)
@@ -648,6 +648,12 @@ enum isl_aux_usage {
     * @invariant isl_surf::samples > 1
     */
    ISL_AUX_USAGE_MCS_CCS,
+
+   /** CCS auxiliary data is used to compress a stencil buffer
+    *
+    * @invariant isl_surf::samples == 1
+    */
+   ISL_AUX_USAGE_STC_CCS,
 };
 
 /**
@@ -1779,7 +1785,8 @@ isl_aux_usage_has_ccs(enum isl_aux_usage usage)
           usage == ISL_AUX_USAGE_MC ||
           usage == ISL_AUX_USAGE_HIZ_CCS_WT ||
           usage == ISL_AUX_USAGE_HIZ_CCS ||
-          usage == ISL_AUX_USAGE_MCS_CCS;
+          usage == ISL_AUX_USAGE_MCS_CCS ||
+          usage == ISL_AUX_USAGE_STC_CCS;
 }
 
 static inline bool
index 556827b97bf407f60181625b24a40c819124dffe..1155fee03258e909abf9de5555e05a8b0c013a8e 100644 (file)
@@ -71,6 +71,7 @@ static const struct aux_usage_info info[] = {
    AUX(         COMPRESS, Y, Y, Y, Y, 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
index 9615a34f718c64732aeed04a8fda6c60799d6384..3921543e1adaa9f36b9da0158d3af20a1aeedc1d 100644 (file)
@@ -165,7 +165,8 @@ isl_genX(emit_depth_stencil_hiz_s)(const struct isl_device *dev, void *batch,
       sb.SurfLOD = info->view->base_level;
       sb.MinimumArrayElement = info->view->base_array_layer;
       sb.StencilCompressionEnable =
-         info->stencil_aux_usage == ISL_AUX_USAGE_CCS_E;
+         info->stencil_aux_usage == ISL_AUX_USAGE_CCS_E ||
+         info->stencil_aux_usage == ISL_AUX_USAGE_STC_CCS;
       sb.ControlSurfaceEnable = sb.StencilCompressionEnable;
 #elif GEN_GEN >= 8 || GEN_IS_HASWELL
       sb.StencilBufferEnable = true;
index 63ee7b10d2f996b64b0987e43f957b3e750ec6e1..0145be160c7ba73ed8f3c8255b4461bf268c9a6c 100644 (file)
@@ -93,6 +93,7 @@ static const uint32_t isl_to_gen_aux_mode[] = {
    [ISL_AUX_USAGE_CCS_E] = AUX_CCS_E,
    [ISL_AUX_USAGE_HIZ_CCS_WT] = AUX_CCS_E,
    [ISL_AUX_USAGE_MCS_CCS] = AUX_MCS_LCE,
+   [ISL_AUX_USAGE_STC_CCS] = AUX_CCS_E,
 };
 #elif GEN_GEN >= 9
 static const uint32_t isl_to_gen_aux_mode[] = {
@@ -561,7 +562,8 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
          assert(info->aux_usage == ISL_AUX_USAGE_MCS ||
                 info->aux_usage == ISL_AUX_USAGE_CCS_E ||
                 info->aux_usage == ISL_AUX_USAGE_HIZ_CCS_WT ||
-                info->aux_usage == ISL_AUX_USAGE_MCS_CCS);
+                info->aux_usage == ISL_AUX_USAGE_MCS_CCS ||
+                info->aux_usage == ISL_AUX_USAGE_STC_CCS);
       } else if (GEN_GEN >= 9) {
          assert(info->aux_usage == ISL_AUX_USAGE_HIZ ||
                 info->aux_usage == ISL_AUX_USAGE_MCS ||
index c1c4e203e70bb62a618cca40852b36fda8b7ac41..47e41d8b8c61a8df2480d96825cd7e0d43c91ee8 100644 (file)
@@ -389,6 +389,21 @@ TEST(StateTransitionWrite, WritesCompress) {
    E(PASS_THROUGH, MCS, true, COMPRESSED_NO_CLEAR);
    E(AUX_INVALID, MCS, false, ASSERT);
    E(AUX_INVALID, MCS, true, ASSERT);
+
+   E(CLEAR, STC_CCS, false, ASSERT);
+   E(CLEAR, STC_CCS, true, ASSERT);
+   E(PARTIAL_CLEAR, STC_CCS, false, ASSERT);
+   E(PARTIAL_CLEAR, STC_CCS, true, ASSERT);
+   E(COMPRESSED_CLEAR, STC_CCS, false, ASSERT);
+   E(COMPRESSED_CLEAR, STC_CCS, true, ASSERT);
+   E(COMPRESSED_NO_CLEAR, STC_CCS, false, COMPRESSED_NO_CLEAR);
+   E(COMPRESSED_NO_CLEAR, STC_CCS, true, COMPRESSED_NO_CLEAR);
+   E(RESOLVED, STC_CCS, false, COMPRESSED_NO_CLEAR);
+   E(RESOLVED, STC_CCS, true, COMPRESSED_NO_CLEAR);
+   E(PASS_THROUGH, STC_CCS, false, COMPRESSED_NO_CLEAR);
+   E(PASS_THROUGH, STC_CCS, true, COMPRESSED_NO_CLEAR);
+   E(AUX_INVALID, STC_CCS, false, ASSERT);
+   E(AUX_INVALID, STC_CCS, true, ASSERT);
 }
 
 TEST(StateTransitionWrite, WritesResolveAmbiguate) {