i965/miptree: Refactor isl aux usage resolver
authorTopi Pohjolainen <topi.pohjolainen@intel.com>
Wed, 11 Jan 2017 13:35:29 +0000 (15:35 +0200)
committerTopi Pohjolainen <topi.pohjolainen@intel.com>
Mon, 19 Jun 2017 19:57:56 +0000 (22:57 +0300)
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_blorp.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h

index f13b61bbc402db3819adf561632929e46ad46b63..178dffa0387cc9d74ed4e216e4892cb25684250e 100644 (file)
@@ -163,8 +163,10 @@ blorp_surf_for_miptree(struct brw_context *brw,
       .write_domain = is_render_target ? I915_GEM_DOMAIN_RENDER : 0,
    };
 
+   surf->aux_usage = intel_miptree_get_aux_isl_usage(brw, mt);
+
    struct isl_surf *aux_surf = &tmp_surfs[1];
-   intel_miptree_get_aux_isl_surf(brw, mt, aux_surf, &surf->aux_usage);
+   intel_miptree_get_aux_isl_surf(brw, mt, surf->aux_usage, aux_surf);
 
    if (wants_resolve) {
       bool supports_aux = surf->aux_usage != ISL_AUX_USAGE_NONE &&
index 93efbb16f6f5b687a4d2decc0233d8579b1241f9..164a5cd9ddbb54c68b2b1efc19c523455875d92a 100644 (file)
@@ -142,7 +142,8 @@ brw_emit_surface_state(struct brw_context *brw,
    enum isl_aux_usage aux_usage = ISL_AUX_USAGE_NONE;
    if ((mt->mcs_buf || intel_miptree_sample_with_hiz(brw, mt)) &&
        !(flags & INTEL_AUX_BUFFER_DISABLED)) {
-      intel_miptree_get_aux_isl_surf(brw, mt, &aux_surf_s, &aux_usage);
+      aux_usage = intel_miptree_get_aux_isl_usage(brw, mt);
+      intel_miptree_get_aux_isl_surf(brw, mt, aux_usage, &aux_surf_s);
       aux_surf = &aux_surf_s;
 
       if (mt->mcs_buf) {
index 59db06a91bd32975e42850e4c4015df70a1bf9a3..76944530b47304a2b3fa23c3e3bc7d0cf94b3a87 100644 (file)
@@ -3966,6 +3966,32 @@ intel_miptree_get_isl_surf(struct brw_context *brw,
       surf->usage |= ISL_SURF_USAGE_CUBE_BIT;
 }
 
+enum isl_aux_usage
+intel_miptree_get_aux_isl_usage(const struct brw_context *brw,
+                                const struct intel_mipmap_tree *mt)
+{
+   if (mt->hiz_buf)
+      return ISL_AUX_USAGE_HIZ;
+
+   if (!mt->mcs_buf)
+      return ISL_AUX_USAGE_NONE;
+
+   if (mt->num_samples > 1) {
+      assert(mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS);
+      return ISL_AUX_USAGE_MCS;
+   }
+
+   if (intel_miptree_is_lossless_compressed(brw, mt)) {
+      assert(brw->gen >= 9);
+      return ISL_AUX_USAGE_CCS_E;
+   }
+
+   if ((mt->aux_disable & INTEL_AUX_DISABLE_CCS) == 0)
+      return ISL_AUX_USAGE_CCS_D;
+
+   unreachable("Invalid MCS miptree");
+}
+
 /* WARNING: THE SURFACE CREATED BY THIS FUNCTION IS NOT COMPLETE AND CANNOT BE
  * USED FOR ANY REAL CALCULATIONS.  THE ONLY VALID USE OF SUCH A SURFACE IS TO
  * PASS IT INTO isl_surf_fill_state.
@@ -3973,32 +3999,17 @@ intel_miptree_get_isl_surf(struct brw_context *brw,
 void
 intel_miptree_get_aux_isl_surf(struct brw_context *brw,
                                const struct intel_mipmap_tree *mt,
-                               struct isl_surf *surf,
-                               enum isl_aux_usage *usage)
+                               enum isl_aux_usage usage,
+                               struct isl_surf *surf)
 {
    uint32_t aux_pitch, aux_qpitch;
    if (mt->mcs_buf) {
       aux_pitch = mt->mcs_buf->pitch;
       aux_qpitch = mt->mcs_buf->qpitch;
-
-      if (mt->num_samples > 1) {
-         assert(mt->msaa_layout == INTEL_MSAA_LAYOUT_CMS);
-         *usage = ISL_AUX_USAGE_MCS;
-      } else if (intel_miptree_is_lossless_compressed(brw, mt)) {
-         assert(brw->gen >= 9);
-         *usage = ISL_AUX_USAGE_CCS_E;
-      } else if ((mt->aux_disable & INTEL_AUX_DISABLE_CCS) == 0) {
-         *usage = ISL_AUX_USAGE_CCS_D;
-      } else {
-         unreachable("Invalid MCS miptree");
-      }
    } else if (mt->hiz_buf) {
       aux_pitch = mt->hiz_buf->aux_base.pitch;
       aux_qpitch = mt->hiz_buf->aux_base.qpitch;
-
-      *usage = ISL_AUX_USAGE_HIZ;
    } else {
-      *usage = ISL_AUX_USAGE_NONE;
       return;
    }
 
@@ -4006,7 +4017,7 @@ intel_miptree_get_aux_isl_surf(struct brw_context *brw,
    intel_miptree_get_isl_surf(brw, mt, surf);
 
    /* Figure out the format and tiling of the auxiliary surface */
-   switch (*usage) {
+   switch (usage) {
    case ISL_AUX_USAGE_NONE:
       unreachable("Invalid auxiliary usage");
 
index 8cb06b86066e12f1b108ea9c1a6b733f202826ee..41179b37c378e7808267dbde4ecd933189823d04 100644 (file)
@@ -771,11 +771,16 @@ void
 intel_miptree_get_isl_surf(struct brw_context *brw,
                            const struct intel_mipmap_tree *mt,
                            struct isl_surf *surf);
+
+enum isl_aux_usage
+intel_miptree_get_aux_isl_usage(const struct brw_context *brw,
+                                const struct intel_mipmap_tree *mt);
+
 void
 intel_miptree_get_aux_isl_surf(struct brw_context *brw,
                                const struct intel_mipmap_tree *mt,
-                               struct isl_surf *surf,
-                               enum isl_aux_usage *usage);
+                               enum isl_aux_usage usage,
+                               struct isl_surf *surf);
 
 void
 intel_get_image_dims(struct gl_texture_image *image,