In brw_try_draw_prims(), perform a HiZ resolve on the attached depthbuffer
and perform a depth resolve on each enabled depth texture, if needed.

Signed-off-by: Chad Versace <c...@chad-versace.us>
---
 src/mesa/drivers/dri/i965/brw_draw.c |   43 ++++++++++++++++++++++++++++++++++
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index af02332..91f45d2 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -43,6 +43,10 @@
 #include "brw_state.h"
 
 #include "intel_batchbuffer.h"
+#include "intel_mipmap_tree.h"
+#include "intel_regions.h"
+
+#include "intel_fbo.h"
 
 #define FILE_DEBUG_FLAG DEBUG_PRIMS
 
@@ -275,6 +279,42 @@ static void brw_merge_inputs( struct brw_context *brw,
       brw->state.dirty.brw |= BRW_NEW_INPUT_DIMENSIONS;
 }
 
+/**
+ * \brief Perform needed HiZ ops before preparing for draw
+ *
+ * If needed, perform a HiZ resolve on the attached depthbuffer and
+ * perform a depth resolve on each enabled depth texture.
+ */
+static void
+brw_predraw_hiz_ops(struct brw_context *brw)
+{
+   struct gl_context *ctx = &brw->intel.ctx;
+   struct intel_context *intel = &brw->intel;
+
+   /* Maybe perform HiZ resolve on attached depthbuffer. */
+   struct intel_renderbuffer *depth_irb =
+        intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
+   if (depth_irb) {
+      struct intel_region *region = depth_irb->region;
+      if (region->hiz.need_resolve == INTEL_HIZ_NEED_HIZ_RESOLVE) {
+        intel->vtbl.resolve_hizbuffer(intel, region);
+      }
+   }
+
+   /* Perform depth resolves on enabled depth textures. */
+   for (int i = 0; i < BRW_MAX_TEX_UNIT; i++) {
+      const struct gl_texture_unit *tex_unit = &ctx->Texture.Unit[i];
+      if (!tex_unit->_ReallyEnabled)
+        continue;
+      struct intel_texture_object *tex_obj =
+           intel_texture_object(tex_unit->_Current);
+      struct intel_region *region = tex_obj->mt->region;
+      if (region->hiz.need_resolve == INTEL_HIZ_NEED_DEPTH_RESOLVE) {
+        intel->vtbl.resolve_depthbuffer(intel, region);
+      }
+   }
+}
+
 /* May fail if out of video memory for texture or vbo upload, or on
  * fallback conditions.
  */
@@ -292,6 +332,9 @@ static GLboolean brw_try_draw_prims( struct gl_context *ctx,
    GLboolean warn = GL_FALSE;
    GLuint i;
 
+   /* HiZ meta-ops must occur before we update the draw state. */
+   brw_predraw_hiz_ops(brw);
+
    if (ctx->NewState)
       _mesa_update_state( ctx );
 
-- 
1.7.6.2

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to