i965: Move depth to the new resolve functions
authorJason Ekstrand <jason.ekstrand@intel.com>
Thu, 25 May 2017 21:15:44 +0000 (14:15 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Thu, 8 Jun 2017 05:18:53 +0000 (22:18 -0700)
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Reviewed-by: Chad Versace <chadversary@chromium.org>
src/mesa/drivers/dri/i965/brw_clear.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.c
src/mesa/drivers/dri/i965/intel_mipmap_tree.h

index 8a635e3ce4bca25b421ef9a225be7d3918fd5f15..fb557afe35618be93b15e978177f4b072db675dc 100644 (file)
@@ -179,13 +179,13 @@ brw_fast_clear_depth(struct gl_context *ctx)
     * buffer.
     */
    if (depth_att->Layered) {
-      for (unsigned layer = 0; layer < depth_irb->layer_count; layer++) {
-         intel_miptree_slice_set_needs_depth_resolve(mt, depth_irb->mt_level,
-                                                     depth_irb->mt_layer + layer);
-      }
+      intel_miptree_set_aux_state(brw, mt, depth_irb->mt_level,
+                                  depth_irb->mt_layer, depth_irb->layer_count,
+                                  ISL_AUX_STATE_CLEAR);
    } else {
-      intel_miptree_slice_set_needs_depth_resolve(mt, depth_irb->mt_level,
-                                                  depth_irb->mt_layer);
+      intel_miptree_set_aux_state(brw, mt, depth_irb->mt_level,
+                                  depth_irb->mt_layer, 1,
+                                  ISL_AUX_STATE_CLEAR);
    }
 
    return true;
index 0cc72bfc83b5f2d12391c83b5bca61baa7e9e4be..92490f728faa09b07ee8bd418667d7aabeb46d68 100644 (file)
@@ -204,9 +204,10 @@ intel_update_state(struct gl_context * ctx, GLuint new_state)
    /* Resolve the depth buffer's HiZ buffer. */
    depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
    if (depth_irb && depth_irb->mt) {
-      intel_miptree_slice_resolve_hiz(brw, depth_irb->mt,
-                                      depth_irb->mt_level,
-                                      depth_irb->mt_layer);
+      intel_miptree_prepare_depth(brw, depth_irb->mt,
+                                  depth_irb->mt_level,
+                                  depth_irb->mt_layer,
+                                  depth_irb->layer_count);
    }
 
    memset(brw->draw_aux_buffer_disabled, 0,
index 07f1d48ff65b89a6cada096aec39afde17544c05..9e0e2423dae1ffaa9ddbc258af48fbf510397163 100644 (file)
@@ -372,19 +372,22 @@ brw_postdraw_set_buffers_need_resolve(struct brw_context *brw)
       front_irb->need_downsample = true;
    if (back_irb)
       back_irb->need_downsample = true;
-   if (depth_irb && brw_depth_writes_enabled(brw)) {
+   if (depth_irb) {
+      bool depth_written = brw_depth_writes_enabled(brw);
       if (depth_att->Layered) {
-         for (unsigned layer = 0; layer < depth_irb->layer_count; layer++) {
-            intel_miptree_slice_set_needs_depth_resolve(depth_irb->mt,
-                                                        depth_irb->mt_level,
-                                                        depth_irb->mt_layer + layer);
-         }
+         intel_miptree_finish_depth(brw, depth_irb->mt,
+                                    depth_irb->mt_level,
+                                    depth_irb->mt_layer,
+                                    depth_irb->layer_count,
+                                    depth_written);
       } else {
-         intel_miptree_slice_set_needs_depth_resolve(depth_irb->mt,
-                                                     depth_irb->mt_level,
-                                                     depth_irb->mt_layer);
+         intel_miptree_finish_depth(brw, depth_irb->mt,
+                                    depth_irb->mt_level,
+                                    depth_irb->mt_layer, 1,
+                                    depth_written);
       }
-      brw_render_cache_set_add_bo(brw, depth_irb->mt->bo);
+      if (depth_written)
+         brw_render_cache_set_add_bo(brw, depth_irb->mt->bo);
    }
 
    if (ctx->Extensions.ARB_stencil_texturing &&
index 4e913882fffa7172132d091d41c35f765f13d5cc..3d207328356149d9b237380b120f305bec912b36 100644 (file)
@@ -2531,7 +2531,28 @@ intel_miptree_finish_render(struct brw_context *brw,
 {
    assert(_mesa_is_format_color_format(mt->format));
    intel_miptree_finish_write(brw, mt, level, start_layer, layer_count,
-                              mt->mcs_buf);
+                              mt->mcs_buf != NULL);
+}
+
+void
+intel_miptree_prepare_depth(struct brw_context *brw,
+                            struct intel_mipmap_tree *mt, uint32_t level,
+                            uint32_t start_layer, uint32_t layer_count)
+{
+   intel_miptree_prepare_access(brw, mt, level, 1, start_layer, layer_count,
+                                mt->hiz_buf != NULL, mt->hiz_buf != NULL);
+}
+
+void
+intel_miptree_finish_depth(struct brw_context *brw,
+                           struct intel_mipmap_tree *mt, uint32_t level,
+                           uint32_t start_layer, uint32_t layer_count,
+                           bool depth_written)
+{
+   if (depth_written) {
+      intel_miptree_finish_write(brw, mt, level, start_layer, layer_count,
+                                 mt->hiz_buf != NULL);
+   }
 }
 
 /**
index 799695d0a01f4d40f4edeb4dcc2f64e2e48d1a9d..41963365b51f5120b4928ea6cd07bd5d239ffd05 100644 (file)
@@ -1066,6 +1066,15 @@ void
 intel_miptree_finish_render(struct brw_context *brw,
                             struct intel_mipmap_tree *mt, uint32_t level,
                             uint32_t start_layer, uint32_t layer_count);
+void
+intel_miptree_prepare_depth(struct brw_context *brw,
+                            struct intel_mipmap_tree *mt, uint32_t level,
+                            uint32_t start_layer, uint32_t layer_count);
+void
+intel_miptree_finish_depth(struct brw_context *brw,
+                           struct intel_mipmap_tree *mt, uint32_t level,
+                           uint32_t start_layer, uint32_t layer_count,
+                           bool depth_written);
 
 void
 intel_miptree_make_shareable(struct brw_context *brw,