[Mesa-dev] [PATCH 5/5] intel: Remove intel_renderbuffer::hiz_region

Chad Versace chad at chad-versace.us
Mon Oct 17 07:40:28 PDT 2011


Replace it with intel_renderbuffer::region::hiz::region.

Signed-off-by: Chad Versace <chad at chad-versace.us>
---
 src/mesa/drivers/dri/i965/brw_misc_state.c     |   27 +++++++++--------
 src/mesa/drivers/dri/intel/intel_context.c     |   10 ++++--
 src/mesa/drivers/dri/intel/intel_fbo.c         |   36 +++++------------------
 src/mesa/drivers/dri/intel/intel_fbo.h         |    3 --
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c |    1 -
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h |   14 ---------
 6 files changed, 29 insertions(+), 62 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c b/src/mesa/drivers/dri/i965/brw_misc_state.c
index 2e6780b..6b521e0 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -206,8 +206,8 @@ static void prepare_depthbuffer(struct brw_context *brw)
 
    if (drb)
       brw_add_validated_bo(brw, drb->region->bo);
-   if (drb && drb->hiz_region)
-      brw_add_validated_bo(brw, drb->hiz_region->bo);
+   if (drb && drb->region->hiz.region)
+      brw_add_validated_bo(brw, drb->region->hiz.region->bo);
    if (srb)
       brw_add_validated_bo(brw, srb->region->bo);
 }
@@ -220,7 +220,7 @@ static void emit_depthbuffer(struct brw_context *brw)
    /* _NEW_BUFFERS */
    struct intel_renderbuffer *depth_irb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
    struct intel_renderbuffer *stencil_irb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
-   struct intel_region *hiz_region = depth_irb ? depth_irb->hiz_region : NULL;
+   bool has_hiz = intel_framebuffer_has_hiz(fb);
    unsigned int len;
 
    /* 3DSTATE_DEPTH_BUFFER, 3DSTATE_STENCIL_BUFFER are both
@@ -315,7 +315,7 @@ static void emit_depthbuffer(struct brw_context *brw)
       uint32_t tile_x, tile_y, offset;
 
       /* If using separate stencil, hiz must be enabled. */
-      assert(!stencil_irb || hiz_region);
+      assert(!stencil_irb || has_hiz);
 
       switch (region->cpp) {
       case 2:
@@ -324,7 +324,7 @@ static void emit_depthbuffer(struct brw_context *brw)
       case 4:
 	 if (intel->depth_buffer_is_float)
 	    format = BRW_DEPTHFORMAT_D32_FLOAT;
-	 else if (hiz_region)
+	 else if (has_hiz)
 	    format = BRW_DEPTHFORMAT_D24_UNORM_X8_UINT;
 	 else
 	    format = BRW_DEPTHFORMAT_D24_UNORM_S8_UINT;
@@ -337,14 +337,14 @@ static void emit_depthbuffer(struct brw_context *brw)
       offset = intel_renderbuffer_tile_offsets(depth_irb, &tile_x, &tile_y);
 
       assert(intel->gen < 6 || region->tiling == I915_TILING_Y);
-      assert(!hiz_region || region->tiling == I915_TILING_Y);
+      assert(!has_hiz || region->tiling == I915_TILING_Y);
 
       BEGIN_BATCH(len);
       OUT_BATCH(_3DSTATE_DEPTH_BUFFER << 16 | (len - 2));
       OUT_BATCH(((region->pitch * region->cpp) - 1) |
 		(format << 18) |
-		((hiz_region ? 1 : 0) << 21) | /* separate stencil enable */
-		((hiz_region ? 1 : 0) << 22) | /* hiz enable */
+		((has_hiz ? 1 : 0) << 21) | /* separate stencil enable */
+		((has_hiz ? 1 : 0) << 22) | /* hiz enable */
 		(BRW_TILEWALK_YMAJOR << 26) |
 		((region->tiling != I915_TILING_NONE) << 27) |
 		(BRW_SURFACE_2D << 29));
@@ -367,7 +367,7 @@ static void emit_depthbuffer(struct brw_context *brw)
       ADVANCE_BATCH();
    }
 
-   if (hiz_region || stencil_irb) {
+   if (has_hiz || stencil_irb) {
       /*
        * In the 3DSTATE_DEPTH_BUFFER batch emitted above, the 'separate
        * stencil enable' and 'hiz enable' bits were set. Therefore we must
@@ -377,11 +377,12 @@ static void emit_depthbuffer(struct brw_context *brw)
        */
 
       /* Emit hiz buffer. */
-      if (hiz_region) {
+      if (has_hiz) {
+	 struct intel_hiz_control *hiz = &depth_irb->region->hiz;
 	 BEGIN_BATCH(3);
 	 OUT_BATCH((_3DSTATE_HIER_DEPTH_BUFFER << 16) | (3 - 2));
-	 OUT_BATCH(hiz_region->pitch * hiz_region->cpp - 1);
-	 OUT_RELOC(hiz_region->bo,
+	 OUT_BATCH(hiz->region->pitch * hiz->region->cpp - 1);
+	 OUT_RELOC(hiz->region->bo,
 		   I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
 		   0);
 	 ADVANCE_BATCH();
@@ -419,7 +420,7 @@ static void emit_depthbuffer(struct brw_context *brw)
     *     3DSTATE_CLEAR_PARAMS packet must follow the DEPTH_BUFFER_STATE packet
     *     when HiZ is enabled and the DEPTH_BUFFER_STATE changes.
     */
-   if (intel->gen >= 6 || hiz_region) {
+   if (intel->gen >= 6 || has_hiz) {
       if (intel->gen == 6)
 	 intel_emit_post_sync_nonzero_flush(intel);
 
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 7f8347e..8b4744a 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -1315,8 +1315,8 @@ intel_process_dri2_buffer_with_separate_stencil(struct intel_context *intel,
 	rb->region &&
 	rb->region->name == buffer->name) ||
        (buffer->attachment == __DRI_BUFFER_HIZ &&
-	rb->hiz_region &&
-	rb->hiz_region->name == buffer->name)) {
+	rb->region->hiz.region &&
+	rb->region->hiz.region->name == buffer->name)) {
       return;
    }
 
@@ -1354,7 +1354,11 @@ intel_process_dri2_buffer_with_separate_stencil(struct intel_context *intel,
 				    buffer_name);
 
    if (buffer->attachment == __DRI_BUFFER_HIZ) {
-      intel_region_reference(&rb->hiz_region, region);
+      /* We assume that the depth buffer has already been processed. */
+      struct intel_hiz_control *hiz = &rb->region->hiz;
+      intel_region_reference(&hiz->region, region);
+      hiz->need_resolve = INTEL_HIZ_NEED_NO_RESOLVE;
+      hiz->depth_format = rb->Base.Format;
    } else {
       intel_region_reference(&rb->region, region);
    }
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 17397e1..0527c97 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -75,7 +75,6 @@ intel_delete_renderbuffer(struct gl_renderbuffer *rb)
    ASSERT(irb);
 
    intel_region_release(&irb->region);
-   intel_region_release(&irb->hiz_region);
 
    _mesa_reference_renderbuffer(&irb->wrapped_depth, NULL);
    _mesa_reference_renderbuffer(&irb->wrapped_stencil, NULL);
@@ -104,8 +103,8 @@ intel_framebuffer_get_hiz_region(struct gl_framebuffer *fb)
    if (fb)
       rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
 
-   if (rb)
-      return rb->hiz_region;
+   if (rb && rb->region)
+      return rb->region->hiz.region;
    else
       return NULL;
 }
@@ -183,9 +182,6 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
    if (irb->region) {
       intel_region_release(&irb->region);
    }
-   if (irb->hiz_region) {
-      intel_region_release(&irb->hiz_region);
-   }
 
    /* allocate new memory region/renderbuffer */
 
@@ -268,13 +264,8 @@ intel_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffer
 	 return false;
 
       if (intel->vtbl.is_hiz_depth_format(intel, rb->Format)) {
-	 irb->hiz_region = intel_region_alloc(intel->intelScreen,
-					      I915_TILING_Y,
-					      irb->region->cpp,
-					      irb->region->width,
-					      irb->region->height,
-					      GL_TRUE);
-	 if (!irb->hiz_region) {
+	 bool ok = intel_renderbuffer_alloc_hiz(intel, irb);
+	 if (!ok) {
 	    intel_region_release(&irb->region);
 	    return false;
 	 }
@@ -583,21 +574,10 @@ intel_update_tex_wrapper_regions(struct intel_context *intel,
 
    /* Allocate the texture's hiz region if necessary. */
    if (intel->vtbl.is_hiz_depth_format(intel, rb->Format)
-       && !intel_image->mt->hiz_region) {
-      intel_image->mt->hiz_region =
-         intel_region_alloc(intel->intelScreen,
-                            I915_TILING_Y,
-                            _mesa_get_format_bytes(rb->Format),
-                            rb->Width,
-                            rb->Height,
-                            GL_TRUE);
-      if (!intel_image->mt->hiz_region)
-         return GL_FALSE;
-   }
-
-   /* Point the renderbuffer's hiz region to the texture's hiz region. */
-   if (irb->hiz_region != intel_image->mt->hiz_region) {
-      intel_region_reference(&irb->hiz_region, intel_image->mt->hiz_region);
+       && irb->region->hiz.region == NULL) {
+      bool ok = intel_renderbuffer_alloc_hiz(intel, irb);
+      if (!ok)
+	 return false;
    }
 
    return GL_TRUE;
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h
index 377cb1b..6573d40 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.h
+++ b/src/mesa/drivers/dri/intel/intel_fbo.h
@@ -45,9 +45,6 @@ struct intel_renderbuffer
    struct gl_renderbuffer Base;
    struct intel_region *region;
 
-   /** Only used by depth renderbuffers for which HiZ is enabled. */
-   struct intel_region *hiz_region;
-
    /**
     * \name Packed depth/stencil unwrappers
     *
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index dbdc5ef..8a5b4e7 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -202,7 +202,6 @@ intel_miptree_release(struct intel_mipmap_tree **mt)
       DBG("%s deleting %p\n", __FUNCTION__, *mt);
 
       intel_region_release(&((*mt)->region));
-      intel_region_release(&((*mt)->hiz_region));
 
       for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
 	 free((*mt)->level[i].x_offset);
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index 22295aa..20a20db 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -114,20 +114,6 @@ struct intel_mipmap_tree
     */
    struct intel_region *region;
 
-   /**
-    * This points to an auxillary hiz region if all of the following hold:
-    *     1. The texture has been attached to an FBO as a depthbuffer.
-    *     2. The texture format is hiz compatible.
-    *     3. The intel context supports hiz.
-    *
-    * When a texture is attached to multiple FBO's, a separate renderbuffer
-    * wrapper is created for each attachment. This necessitates storing the
-    * hiz region in the texture itself instead of the renderbuffer wrapper.
-    *
-    * \see intel_fbo.c:intel_wrap_texture()
-    */
-   struct intel_region *hiz_region;
-
    /* These are also refcounted:
     */
    GLuint refcount;
-- 
1.7.6.4



More information about the mesa-dev mailing list