[Mesa-dev] [PATCH 12/19] i965: Add HiZ operation state to brw_context

Chad Versace chad at chad-versace.us
Fri Sep 23 17:37:42 PDT 2011


struct brw_context::hiz contains state needed to perform HiZ meta-ops and
indicates if a HiZ operation is currently in progress.

Signed-off-by: Chad Versace <chad at chad-versace.us>
---
 src/mesa/drivers/dri/i965/brw_context.h |   35 +++++++++++++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_hiz.c     |   20 +++++++++++++++++
 src/mesa/drivers/dri/i965/brw_hiz.h     |    8 +++++++
 src/mesa/drivers/dri/i965/brw_vtbl.c    |    1 +
 4 files changed, 64 insertions(+), 0 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index 6772029..177aa67 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -898,6 +898,41 @@ struct brw_context
       enum state_struct_type type;
    } *state_batch_list;
    int state_batch_count;
+
+   /**
+    * \brief State needed to execute HiZ meta-ops
+    *
+    * All fields except \c op are initialized by brw_hiz_init().
+    */
+   struct brw_hiz_state {
+      /**
+       * \brief Indicates which HiZ operation is in progress.
+       *
+       * See the following sections of the Sandy Bridge PRM, Volume 1, Part2:
+       *   - 7.5.3.1 Depth Buffer Clear
+       *   - 7.5.3.2 Depth Buffer Resolve
+       *   - 7.5.3.3 Hierarchical Depth Buffer Resolve
+       */
+      enum brw_hiz_op {
+	 BRW_HIZ_OP_NONE = 0,
+	 BRW_HIZ_OP_DEPTH_CLEAR,
+	 BRW_HIZ_OP_DEPTH_RESOLVE,
+	 BRW_HIZ_OP_HIZ_RESOLVE,
+      } op;
+
+      /** \brief Shader state */
+      struct {
+	 GLuint program;
+	 GLuint position_vbo;
+	 GLint position_location;
+      } shader;
+
+      /** \brief VAO for the rectangle primitive's vertices. */
+      GLuint vao;
+
+      GLuint fbo;
+      struct gl_renderbuffer *depth_rb;
+   } hiz;
 };
 
 
diff --git a/src/mesa/drivers/dri/i965/brw_hiz.c b/src/mesa/drivers/dri/i965/brw_hiz.c
index 297b654..4e8baa0 100644
--- a/src/mesa/drivers/dri/i965/brw_hiz.c
+++ b/src/mesa/drivers/dri/i965/brw_hiz.c
@@ -21,6 +21,11 @@
  * IN THE SOFTWARE.
  */
 
+#include "mesa/main/arrayobj.h"
+#include "mesa/main/bufferobj.h"
+#include "mesa/main/fbobject.h"
+#include "mesa/main/shaderapi.h"
+
 #include "brw_hiz.h"
 
 void
@@ -38,3 +43,18 @@ brw_hiz_resolve_hizbuffer(struct intel_context *intel,
    /* stub */
    abort();
 }
+
+void
+brw_hiz_destroy(struct brw_context *brw)
+{
+   if (brw->hiz.fbo == 0) {
+      /* brw->hiz was never initialized. */
+      return;
+   }
+
+   _mesa_DeleteFramebuffersEXT(1, &brw->hiz.fbo);
+   _mesa_DeleteRenderbuffersEXT(1, &brw->hiz.depth_rb->Name);
+   _mesa_DeleteProgram(brw->hiz.shader.program);
+   _mesa_DeleteVertexArraysAPPLE(1, &brw->hiz.vao);
+   _mesa_DeleteBuffersARB(1, &brw->hiz.shader.position_vbo);
+}
diff --git a/src/mesa/drivers/dri/i965/brw_hiz.h b/src/mesa/drivers/dri/i965/brw_hiz.h
index 1fec0f7..9962d50 100644
--- a/src/mesa/drivers/dri/i965/brw_hiz.h
+++ b/src/mesa/drivers/dri/i965/brw_hiz.h
@@ -33,3 +33,11 @@ brw_hiz_resolve_depthbuffer(struct intel_context *intel,
 void
 brw_hiz_resolve_hizbuffer(struct intel_context *intel,
                           struct intel_region *depth_region);
+
+/**
+ * \brief Destroy brw->hiz
+ *
+ * Called by brw_destroy() during context destruction.
+ */
+void
+brw_hiz_destroy(struct brw_context *brw);
diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c
index 135887b..4338d80 100644
--- a/src/mesa/drivers/dri/i965/brw_vtbl.c
+++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
@@ -70,6 +70,7 @@ static void brw_destroy_context( struct intel_context *intel )
    brw_destroy_state(brw);
    brw_draw_destroy( brw );
    brw_clear_validated_bos(brw);
+   brw_hiz_destroy(brw);
    ralloc_free(brw->wm.compile_data);
 
    dri_bo_release(&brw->curbe.curbe_bo);
-- 
1.7.6.2



More information about the mesa-dev mailing list