[Mesa-dev] [PATCH 10/10] i915: Finish switching i915 to using miptrees instead of regions.

Eric Anholt eric at anholt.net
Mon Jan 28 21:00:38 PST 2013


---
 src/mesa/drivers/dri/i915/i830_vtbl.c      |   52 ++++++++++++-------------
 src/mesa/drivers/dri/i915/i915_vtbl.c      |   58 ++++++++++++++--------------
 src/mesa/drivers/dri/intel/intel_context.h |    5 ++-
 3 files changed, 58 insertions(+), 57 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i830_vtbl.c b/src/mesa/drivers/dri/i915/i830_vtbl.c
index 67b4c96..037effc 100644
--- a/src/mesa/drivers/dri/i915/i830_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i830_vtbl.c
@@ -607,9 +607,9 @@ i830_render_target_supported(struct intel_context *intel,
 }
 
 static void
-i830_set_draw_region(struct intel_context *intel,
-                     struct intel_region *color_region,
-                     struct intel_region *depth_region)
+i830_set_draw_miptree(struct intel_context *intel,
+                      struct intel_mipmap_tree *color_mt,
+                      struct intel_mipmap_tree *depth_mt)
 {
    struct i830_context *i830 = i830_context(&intel->ctx);
    struct gl_context *ctx = &intel->ctx;
@@ -623,25 +623,25 @@ i830_set_draw_region(struct intel_context *intel,
 
    drm_intel_bo_unreference(state->color_bo);
    state->color_bo = NULL;
-   if (color_region) {
-      state->color_bo = color_region->bo;
-      drm_intel_bo_unreference(color_region->bo);
+   if (color_mt) {
+      state->color_bo = color_mt->region->bo;
+      drm_intel_bo_unreference(color_mt->region->bo);
    }
    drm_intel_bo_unreference(state->depth_bo);
    state->depth_bo = NULL;
-   if (depth_region) {
-      state->depth_bo = depth_region->bo;
-      drm_intel_bo_unreference(depth_region->bo);
+   if (depth_mt) {
+      state->depth_bo = depth_mt->region->bo;
+      drm_intel_bo_unreference(depth_mt->region->bo);
    }
 
    /*
     * Set stride/cpp values
     */
-   i915_set_buf_info_for_region(&state->Buffer[I830_DESTREG_CBUFADDR0],
-				color_region, BUF_3D_ID_COLOR_BACK);
+   i915_set_buf_info_for_miptree(&state->Buffer[I830_DESTREG_CBUFADDR0],
+                                 color_mt, BUF_3D_ID_COLOR_BACK);
 
-   i915_set_buf_info_for_region(&state->Buffer[I830_DESTREG_DBUFADDR0],
-				depth_region, BUF_3D_ID_DEPTH);
+   i915_set_buf_info_for_miptree(&state->Buffer[I830_DESTREG_DBUFADDR0],
+                                 depth_mt, BUF_3D_ID_DEPTH);
 
    /*
     * Compute/set I830_DESTREG_DV1 value
@@ -653,7 +653,7 @@ i830_set_draw_region(struct intel_context *intel,
       value |= i830_render_target_format_for_mesa_format[intel_rb_format(irb)];
    }
 
-   if (depth_region && depth_region->cpp == 4) {
+   if (depth_mt && depth_mt->cpp == 4) {
       value |= DEPTH_FRMT_24_FIXED_8_OTHER;
    }
    else {
@@ -720,7 +720,7 @@ i830_update_draw_buffer(struct intel_context *intel)
 {
    struct gl_context *ctx = &intel->ctx;
    struct gl_framebuffer *fb = ctx->DrawBuffer;
-   struct intel_region *colorRegion, *depthRegion = NULL;
+   struct intel_mipmap_tree *color_mt, *depth_mt = NULL;
    struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
 
    if (!fb) {
@@ -759,7 +759,7 @@ i830_update_draw_buffer(struct intel_context *intel)
        || (fb->Height > ctx->Const.MaxRenderbufferSize)
        || (fb->_NumColorDrawBuffers == 0)) {
       /* writing to 0  */
-      colorRegion = NULL;
+      color_mt = NULL;
    }
    else {
       /* Get the intel_renderbuffer for the single colorbuffer we're drawing
@@ -768,19 +768,19 @@ i830_update_draw_buffer(struct intel_context *intel)
       if (_mesa_is_winsys_fbo(fb)) {
 	 /* drawing to window system buffer */
 	 if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)
-	    colorRegion = intel_get_rb_region(fb, BUFFER_FRONT_LEFT);
+	    color_mt = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT)->mt;
 	 else
-	    colorRegion = intel_get_rb_region(fb, BUFFER_BACK_LEFT);
+	    color_mt = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT)->mt;
       }
       else {
 	 /* drawing to user-created FBO */
 	 struct intel_renderbuffer *irb;
 	 irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
-	 colorRegion = (irb && irb->mt->region) ? irb->mt->region : NULL;
+	 color_mt = irb ? irb->mt : NULL;
       }
    }
 
-   if (!colorRegion) {
+   if (!color_mt) {
       FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, true);
    }
    else {
@@ -790,14 +790,14 @@ i830_update_draw_buffer(struct intel_context *intel)
    /* Check for depth fallback. */
    if (irbDepth && irbDepth->mt) {
       FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, false);
-      depthRegion = irbDepth->mt->region;
+      depth_mt = irbDepth->mt;
    } else if (irbDepth && !irbDepth->mt) {
       FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, true);
-      depthRegion = NULL;
+      depth_mt = NULL;
    } else { /* !irbDepth */
       /* No fallback is needed because there is no depth buffer. */
       FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, false);
-      depthRegion = NULL;
+      depth_mt = NULL;
    }
 
    /* Check for stencil fallback. */
@@ -814,9 +814,9 @@ i830_update_draw_buffer(struct intel_context *intel)
    /* If we have a (packed) stencil buffer attached but no depth buffer,
     * we still need to set up the shared depth/stencil state so we can use it.
     */
-   if (depthRegion == NULL && irbStencil && irbStencil->mt
+   if (depth_mt == NULL && irbStencil && irbStencil->mt
        && intel_rb_format(irbStencil) == MESA_FORMAT_S8_Z24) {
-      depthRegion = irbStencil->mt->region;
+      depth_mt = irbStencil->mt;
    }
 
    /*
@@ -826,7 +826,7 @@ i830_update_draw_buffer(struct intel_context *intel)
    ctx->Driver.Enable(ctx, GL_STENCIL_TEST,
 		      (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0));
 
-   i830_set_draw_region(intel, colorRegion, depthRegion);
+   i830_set_draw_miptree(intel, color_mt, depth_mt);
    intel->NewGLState |= _NEW_BUFFERS;
 
    /* update viewport since it depends on window size */
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 7b78699..d52c0dd 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -522,18 +522,18 @@ i915_destroy_context(struct intel_context *intel)
 }
 
 void
-i915_set_buf_info_for_region(uint32_t *state, struct intel_region *region,
-			     uint32_t buffer_id)
+i915_set_buf_info_for_miptree(uint32_t *state, struct intel_mipmap_tree *mt,
+                              uint32_t buffer_id)
 {
    state[0] = _3DSTATE_BUF_INFO_CMD;
    state[1] = buffer_id;
 
-   if (region != NULL) {
-      state[1] |= BUF_3D_PITCH(region->pitch);
+   if (mt != NULL) {
+      state[1] |= BUF_3D_PITCH(mt->region->pitch);
 
-      if (region->tiling != I915_TILING_NONE) {
+      if (mt->region->tiling != I915_TILING_NONE) {
 	 state[1] |= BUF_3D_TILED_SURFACE;
-	 if (region->tiling == I915_TILING_Y)
+	 if (mt->region->tiling == I915_TILING_Y)
 	    state[1] |= BUF_3D_TILE_WALK_Y;
       }
    } else {
@@ -571,8 +571,8 @@ i915_render_target_supported(struct intel_context *intel,
 
 static void
 i915_set_draw_region(struct intel_context *intel,
-                     struct intel_region *color_region,
-                     struct intel_region *depth_region)
+                     struct intel_mipmap_tree *color_mt,
+                     struct intel_mipmap_tree *depth_mt)
 {
    struct i915_context *i915 = i915_context(&intel->ctx);
    struct gl_context *ctx = &intel->ctx;
@@ -586,25 +586,25 @@ i915_set_draw_region(struct intel_context *intel,
 
    drm_intel_bo_unreference(state->color_bo);
    state->color_bo = NULL;
-   if (color_region) {
-      state->color_bo = color_region->bo;
-      drm_intel_bo_unreference(color_region->bo);
+   if (color_mt->region) {
+      state->color_bo = color_mt->region->bo;
+      drm_intel_bo_unreference(color_mt->region->bo);
    }
    drm_intel_bo_unreference(state->depth_bo);
    state->depth_bo = NULL;
-   if (depth_region) {
-      state->depth_bo = depth_region->bo;
-      drm_intel_bo_unreference(depth_region->bo);
+   if (depth_mt) {
+      state->depth_bo = depth_mt->region->bo;
+      drm_intel_bo_unreference(depth_mt->region->bo);
    }
 
    /*
     * Set stride/cpp values
     */
-   i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_CBUFADDR0],
-				color_region, BUF_3D_ID_COLOR_BACK);
+   i915_set_buf_info_for_miptree(&state->Buffer[I915_DESTREG_CBUFADDR0],
+                                 color_mt, BUF_3D_ID_COLOR_BACK);
 
-   i915_set_buf_info_for_region(&state->Buffer[I915_DESTREG_DBUFADDR0],
-				depth_region, BUF_3D_ID_DEPTH);
+   i915_set_buf_info_for_miptree(&state->Buffer[I915_DESTREG_DBUFADDR0],
+                                 depth_mt, BUF_3D_ID_DEPTH);
 
    /*
     * Compute/set I915_DESTREG_DV1 value
@@ -623,10 +623,10 @@ i915_set_draw_region(struct intel_context *intel,
     * can only be set when a depth buffer is already defined.
     */
    if (intel->is_945 && intel->use_early_z &&
-       depth_region->tiling != I915_TILING_NONE)
+       depth_mt->region->tiling != I915_TILING_NONE)
       value |= CLASSIC_EARLY_DEPTH;
 
-   if (depth_region && depth_region->cpp == 4) {
+   if (depth_mt->region && depth_mt->cpp == 4) {
       value |= DEPTH_FRMT_24_FIXED_8_OTHER;
    }
    else {
@@ -719,7 +719,7 @@ i915_update_draw_buffer(struct intel_context *intel)
    struct i915_context *i915 = (struct i915_context *)intel;
    struct gl_context *ctx = &intel->ctx;
    struct gl_framebuffer *fb = ctx->DrawBuffer;
-   struct intel_region *colorRegion = NULL, *depthRegion = NULL;
+   struct intel_mipmap_tree *color_mt = NULL, *depth_mt = NULL;
    struct intel_renderbuffer *irbDepth = NULL, *irbStencil = NULL;
 
    if (!fb) {
@@ -761,21 +761,21 @@ i915_update_draw_buffer(struct intel_context *intel)
    } else {
       struct intel_renderbuffer *irb;
       irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
-      colorRegion = (irb && irb->mt) ? irb->mt->region : NULL;
+      color_mt = (irb && irb->mt) ? irb->mt : NULL;
       FALLBACK(intel, INTEL_FALLBACK_DRAW_BUFFER, false);
    }
 
    /* Check for depth fallback. */
    if (irbDepth && irbDepth->mt) {
       FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, false);
-      depthRegion = irbDepth->mt->region;
+      depth_mt = irbDepth->mt;
    } else if (irbDepth && !irbDepth->mt) {
       FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, true);
-      depthRegion = NULL;
+      depth_mt = NULL;
    } else { /* !irbDepth */
       /* No fallback is needed because there is no depth buffer. */
       FALLBACK(intel, INTEL_FALLBACK_DEPTH_BUFFER, false);
-      depthRegion = NULL;
+      depth_mt = NULL;
    }
 
    /* Check for stencil fallback. */
@@ -792,9 +792,9 @@ i915_update_draw_buffer(struct intel_context *intel)
    /* If we have a (packed) stencil buffer attached but no depth buffer,
     * we still need to set up the shared depth/stencil state so we can use it.
     */
-   if (depthRegion == NULL && irbStencil && irbStencil->mt
+   if (depth_mt == NULL && irbStencil && irbStencil->mt
        && intel_rb_format(irbStencil) == MESA_FORMAT_S8_Z24) {
-      depthRegion = irbStencil->mt->region;
+      depth_mt = irbStencil->mt;
    }
 
    /*
@@ -803,9 +803,9 @@ i915_update_draw_buffer(struct intel_context *intel)
    ctx->Driver.Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
    ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
 
-   i915_update_color_write_enable(i915, colorRegion != NULL);
+   i915_update_color_write_enable(i915, color_mt != NULL);
 
-   i915_set_draw_region(intel, colorRegion, depthRegion);
+   i915_set_draw_region(intel, color_mt, depth_mt);
    intel->NewGLState |= _NEW_BUFFERS;
 
    /* update viewport since it depends on window size */
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index b051f7c..9c94e1e 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -586,8 +586,9 @@ void
 intel_downsample_for_dri2_flush(struct intel_context *intel,
                                 __DRIdrawable *drawable);
 
-void i915_set_buf_info_for_region(uint32_t *state, struct intel_region *region,
-				  uint32_t buffer_id);
+void i915_set_buf_info_for_miptree(uint32_t *state,
+                                   struct intel_mipmap_tree *mt,
+                                   uint32_t buffer_id);
 void intel_init_texture_formats(struct gl_context *ctx);
 
 /*======================================================================
-- 
1.7.10.4



More information about the mesa-dev mailing list