From be9e66430763aa2785cbd12d483c7eb9e7055436 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 31 Oct 2012 17:00:21 -0700 Subject: [PATCH] intel: Push face/level -> slice handling to the caller of get_image_offset(). 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 --- 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 - .../drivers/dri/intel/intel_mipmap_tree.c | 53 +++++++------------ .../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 +- .../drivers/dri/intel/intel_tex_subimage.c | 2 +- .../drivers/dri/intel/intel_tex_validate.c | 4 +- 10 files changed, 26 insertions(+), 44 deletions(-) diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c index b7d2d33c131..73ab55e6d40 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 77b9f8fb3c9..5f72b5dce19 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 5658bd7131d..521e6eb62f9 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 bb6dfbe8aff..96f6c32d2ef 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 c70c1de0ccc..04be7576653 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; @@ -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++) { diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h index 0d0e7579460..1a415fbce34 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 c744633c578..1af7b1c5671 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 55b721fb046..cc4d49fcf0b 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 76ea0de01df..f07a312ffdf 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 578b4173512..ad173c9d451 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); -- 2.30.2