[Mesa-dev] [PATCH 6/9] intel: Push face/level -> slice handling to the caller of get_image_offset().

Eric Anholt eric at anholt.net
Mon Nov 5 16:48:12 PST 2012


We were always passing 0 for one of the two fields, and the code just used
whichever one wasn't 0.
---
 src/mesa/drivers/dri/i915/i830_texstate.c       |    2 +-
 src/mesa/drivers/dri/i965/brw_blorp.cpp         |    2 +-
 src/mesa/drivers/dri/intel/intel_blit.c         |    1 -
 src/mesa/drivers/dri/intel/intel_fbo.c          |    1 -
 src/mesa/drivers/dri/intel/intel_mipmap_tree.c  |   47 +++++++----------------
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h  |    2 +-
 src/mesa/drivers/dri/intel/intel_tex_copy.c     |    1 -
 src/mesa/drivers/dri/intel/intel_tex_image.c    |    2 +-
 src/mesa/drivers/dri/intel/intel_tex_subimage.c |    2 +-
 src/mesa/drivers/dri/intel/intel_tex_validate.c |    4 +-
 10 files changed, 20 insertions(+), 44 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c
index b7d2d33..73ab55e6 100644
--- a/src/mesa/drivers/dri/i915/i830_texstate.c
+++ b/src/mesa/drivers/dri/i915/i830_texstate.c
@@ -145,7 +145,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
     */
    firstImage = tObj->Image[0][tObj->BaseLevel];
 
-   intel_miptree_get_image_offset(intelObj->mt, tObj->BaseLevel, 0, 0,
+   intel_miptree_get_image_offset(intelObj->mt, tObj->BaseLevel, 0,
 				  &dst_x, &dst_y);
 
    drm_intel_bo_reference(intelObj->mt->region->bo);
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp b/src/mesa/drivers/dri/i965/brw_blorp.cpp
index 77b9f8f..5f72b5d 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp
@@ -53,7 +53,7 @@ brw_blorp_mip_info::set(struct intel_mipmap_tree *mt,
    this->width = mt->level[level].width;
    this->height = mt->level[level].height;
 
-   intel_miptree_get_image_offset(mt, level, 0, layer, &x_offset, &y_offset);
+   intel_miptree_get_image_offset(mt, level, layer, &x_offset, &y_offset);
 }
 
 void
diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c
index 5658bd7..521e6eb 100644
--- a/src/mesa/drivers/dri/intel/intel_blit.c
+++ b/src/mesa/drivers/dri/intel/intel_blit.c
@@ -553,7 +553,6 @@ intel_set_teximage_alpha_to_one(struct gl_context *ctx,
    intel_miptree_get_image_offset(intel_image->mt,
 				  intel_image->base.Base.Level,
 				  intel_image->base.Base.Face,
-				  0,
 				  &image_x, &image_y);
 
    x1 = image_x;
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index bb6dfbe..96f6c32 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -539,7 +539,6 @@ intel_renderbuffer_set_draw_offset(struct intel_renderbuffer *irb)
    /* compute offset of the particular 2D image within the texture region */
    intel_miptree_get_image_offset(irb->mt,
 				  irb->mt_level,
-				  0, /* face, which we ignore */
 				  irb->mt_layer,
 				  &dst_x, &dst_y);
 
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index db0bac5..03ba0a4 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -640,31 +640,12 @@ intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
        mt->level[level].slice[img].y_offset);
 }
 
-
-/**
- * For cube map textures, either the \c face parameter can be used, of course,
- * or the cube face can be interpreted as a depth layer and the \c layer
- * parameter used.
- */
 void
 intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
-			       GLuint level, GLuint face, GLuint layer,
+			       GLuint level, GLuint slice,
 			       GLuint *x, GLuint *y)
 {
-   int slice;
-
-   if (face > 0) {
-      assert(mt->target == GL_TEXTURE_CUBE_MAP);
-      assert(face < 6);
-      assert(layer == 0);
-      slice = face;
-   } else {
-      /* This branch may be taken even if the texture target is a cube map. In
-       * that case, the caller chose to interpret each cube face as a layer.
-       */
-      assert(face == 0);
-      slice = layer;
-   }
+   assert(slice < mt->level[level].depth);
 
    *x = mt->level[level].slice[slice].x_offset;
    *y = mt->level[level].slice[slice].y_offset;
@@ -772,10 +753,8 @@ intel_miptree_copy_slice(struct intel_context *intel,
    }
 
    uint32_t dst_x, dst_y, src_x, src_y;
-   intel_miptree_get_image_offset(dst_mt, level, face, depth,
-				  &dst_x, &dst_y);
-   intel_miptree_get_image_offset(src_mt, level, face, depth,
-				  &src_x, &src_y);
+   intel_miptree_get_image_offset(dst_mt, level, slice, &dst_x, &dst_y);
+   intel_miptree_get_image_offset(src_mt, level, slice, &src_x, &src_y);
 
    DBG("validate blit mt %s %p %d,%d/%d -> mt %s %p %d,%d/%d (%dx%d)\n",
        _mesa_get_format_name(src_mt->format),
@@ -1159,7 +1138,7 @@ intel_miptree_map_gtt(struct intel_context *intel,
       /* Note that in the case of cube maps, the caller must have passed the
        * slice number referencing the face.
       */
-      intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+      intel_miptree_get_image_offset(mt, level, slice, &image_x, &image_y);
       x += image_x;
       y += image_y;
 
@@ -1204,7 +1183,7 @@ intel_miptree_map_blit(struct intel_context *intel,
       goto fail;
    }
 
-   intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+   intel_miptree_get_image_offset(mt, level, slice, &image_x, &image_y);
    x += image_x;
    y += image_y;
 
@@ -1279,7 +1258,7 @@ intel_miptree_map_s8(struct intel_context *intel,
 					       GL_MAP_READ_BIT);
       unsigned int image_x, image_y;
 
-      intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+      intel_miptree_get_image_offset(mt, level, slice, &image_x, &image_y);
 
       for (uint32_t y = 0; y < map->h; y++) {
 	 for (uint32_t x = 0; x < map->w; x++) {
@@ -1315,7 +1294,7 @@ intel_miptree_unmap_s8(struct intel_context *intel,
       uint8_t *untiled_s8_map = map->ptr;
       uint8_t *tiled_s8_map = intel_region_map(intel, mt->region, map->mode);
 
-      intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+      intel_miptree_get_image_offset(mt, level, slice, &image_x, &image_y);
 
       for (uint32_t y = 0; y < map->h; y++) {
 	 for (uint32_t x = 0; x < map->w; x++) {
@@ -1374,7 +1353,7 @@ intel_miptree_unmap_etc1(struct intel_context *intel,
 {
    uint32_t image_x;
    uint32_t image_y;
-   intel_miptree_get_image_offset(mt, level, 0, slice, &image_x, &image_y);
+   intel_miptree_get_image_offset(mt, level, slice, &image_x, &image_y);
 
    uint8_t *xbgr = intel_region_map(intel, mt->region, map->mode)
                  + image_y * mt->region->pitch * mt->region->cpp
@@ -1427,9 +1406,9 @@ intel_miptree_map_depthstencil(struct intel_context *intel,
       unsigned int s_image_x, s_image_y;
       unsigned int z_image_x, z_image_y;
 
-      intel_miptree_get_image_offset(s_mt, level, 0, slice,
+      intel_miptree_get_image_offset(s_mt, level, slice,
 				     &s_image_x, &s_image_y);
-      intel_miptree_get_image_offset(z_mt, level, 0, slice,
+      intel_miptree_get_image_offset(z_mt, level, slice,
 				     &z_image_x, &z_image_y);
 
       for (uint32_t y = 0; y < map->h; y++) {
@@ -1487,9 +1466,9 @@ intel_miptree_unmap_depthstencil(struct intel_context *intel,
       unsigned int s_image_x, s_image_y;
       unsigned int z_image_x, z_image_y;
 
-      intel_miptree_get_image_offset(s_mt, level, 0, slice,
+      intel_miptree_get_image_offset(s_mt, level, slice,
 				     &s_image_x, &s_image_y);
-      intel_miptree_get_image_offset(z_mt, level, 0, slice,
+      intel_miptree_get_image_offset(z_mt, level, slice,
 				     &z_image_x, &z_image_y);
 
       for (uint32_t y = 0; y < map->h; y++) {
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index 0d0e757..1a415fb 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -436,7 +436,7 @@ bool intel_miptree_match_image(struct intel_mipmap_tree *mt,
 
 void
 intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
-			       GLuint level, GLuint face, GLuint depth,
+			       GLuint level, GLuint slice,
 			       GLuint *x, GLuint *y);
 
 void
diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c
index c744633..1af7b1c 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c
@@ -106,7 +106,6 @@ intel_copy_texsubimage(struct intel_context *intel,
       intel_miptree_get_image_offset(intelImage->mt,
 				     intelImage->base.Base.Level,
 				     intelImage->base.Base.Face,
-				     0,
 				     &image_x, &image_y);
 
       /* The blitter can't handle Y-tiled buffers. */
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index f3588f6..65e1b59 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -184,7 +184,7 @@ try_pbo_upload(struct gl_context *ctx,
       src_stride = image->Width;
 
    intel_miptree_get_image_offset(intelImage->mt, intelImage->base.Base.Level,
-				  intelImage->base.Base.Face, 0,
+				  intelImage->base.Base.Face,
 				  &dst_x, &dst_y);
 
    dst_stride = intelImage->mt->region->pitch;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
index 76ea0de..f07a312 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
@@ -114,7 +114,7 @@ intel_blit_texsubimage(struct gl_context * ctx,
    dstRowStride = pitch;
 
    intel_miptree_get_image_offset(intelImage->mt, texImage->Level,
-				  intelImage->base.Base.Face, 0,
+				  intelImage->base.Base.Face,
 				  &blit_x, &blit_y);
    blit_x += xoffset;
    blit_y += yoffset;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
index 578b417..ad173c9 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_validate.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c
@@ -146,7 +146,7 @@ intel_tex_map_image_for_swrast(struct intel_context *intel,
        * share code with the normal path.
        */
       for (i = 0; i < mt->level[level].depth; i++) {
-	 intel_miptree_get_image_offset(mt, level, face, i, &x, &y);
+	 intel_miptree_get_image_offset(mt, level, i, &x, &y);
 	 intel_image->base.ImageOffsets[i] = x + y * mt->region->pitch;
       }
 
@@ -155,7 +155,7 @@ intel_tex_map_image_for_swrast(struct intel_context *intel,
       intel_image->base.Map = intel_region_map(intel, mt->region, mode);
    } else {
       assert(intel_image->base.Base.Depth == 1);
-      intel_miptree_get_image_offset(mt, level, face, 0, &x, &y);
+      intel_miptree_get_image_offset(mt, level, face, &x, &y);
 
       DBG("%s: (%d,%d) -> (%d, %d)/%d\n",
 	  __FUNCTION__, face, level, x, y, mt->region->pitch * mt->cpp);
-- 
1.7.10.4



More information about the mesa-dev mailing list