intel: Push face/level -> slice handling to the caller of get_image_offset().
authorEric Anholt <eric@anholt.net>
Thu, 1 Nov 2012 00:00:21 +0000 (17:00 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 19 Nov 2012 23:07:22 +0000 (15:07 -0800)
We were always passing 0 for one of the two fields, and the code just used
whichever one wasn't 0.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
src/mesa/drivers/dri/i915/i830_texstate.c
src/mesa/drivers/dri/i965/brw_blorp.cpp
src/mesa/drivers/dri/intel/intel_blit.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_mipmap_tree.h
src/mesa/drivers/dri/intel/intel_tex_copy.c
src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/intel/intel_tex_subimage.c
src/mesa/drivers/dri/intel/intel_tex_validate.c

index b7d2d33c131c8cf07d0ee62cd882f669e2b18ab7..73ab55e6d405b1a8e7185c7c15d6208ec246a064 100644 (file)
@@ -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);
index 77b9f8fb3c92e6f21e58c2e5d08a64e53324607a..5f72b5dce194756dd2dcdcd59a25e84a18893b30 100644 (file)
@@ -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
index 5658bd7131d398448bf37b6449cde3de9a526400..521e6eb62f95525752b129d3eab082f99b3f8bbb 100644 (file)
@@ -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;
index bb6dfbe8aff1e43837879dcc617603a72d5d095e..96f6c32d2ef7b74148a63e719568f6ea2bfa0ca2 100644 (file)
@@ -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);
 
index c70c1de0ccc946f0082f73cd456080a6fe4342e6..04be7576653c32c037cd90a3ce89f82c97277c26 100644 (file)
@@ -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;
@@ -682,6 +663,12 @@ intel_miptree_copy_slice(struct intel_context *intel,
    gl_format format = src_mt->format;
    uint32_t width = src_mt->level[level].width;
    uint32_t height = src_mt->level[level].height;
+   int slice;
+
+   if (face > 0)
+      slice = face;
+   else
+      slice = depth;
 
    assert(depth < src_mt->level[level].depth);
 
@@ -691,10 +678,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),
@@ -1094,7 +1079,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;
 
@@ -1139,7 +1124,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;
 
@@ -1214,7 +1199,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++) {
@@ -1250,7 +1235,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++) {
@@ -1309,7 +1294,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
@@ -1362,9 +1347,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++) {
@@ -1422,9 +1407,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++) {
index 0d0e7579460af521bf0496e444f5e3447938ed86..1a415fbce3413e0c5174469c483b46905bbdaa68 100644 (file)
@@ -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
index c744633c57842144310fa99673611f06fda7db00..1af7b1c5671d6be651d556d73b2b2424dc17d8f2 100644 (file)
@@ -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. */
index 55b721fb0463dc1f0f30bec78ee23567bd60f442..cc4d49fcf0b5f9547655dc933cce2e5e792382f3 100644 (file)
@@ -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;
index 76ea0de01df7bff6de11d86f934c7d0764d03a3c..f07a312ffdfc5d5f581df9240f26e1875cdf775a 100644 (file)
@@ -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;
index 578b4173512b5b276003c9fceace1690c12354d3..ad173c9d45124ea9460142a7a0a7f916338f8aa1 100644 (file)
@@ -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);