summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-10-12 17:37:06 -0600
committerBrian Paul <[email protected]>2009-10-12 18:12:00 -0600
commite6594a22f298833eeb6881795b24d03d2fd8e898 (patch)
tree02012d0fc7c5334244309441a1d117f3a0810836 /src/mesa/drivers
parent15d2ef602461ca75e7160af46a2b5040742a91c9 (diff)
intel: pass zslice to intel_miptree_image_offset()
This lets us get rid of intel_miptree_depth_offsets() and simplify all of the calling code.
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i915/i830_texstate.c5
-rw-r--r--src/mesa/drivers/dri/i915/i915_texstate.c5
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c11
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.c61
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.h14
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_copy.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c7
7 files changed, 40 insertions, 65 deletions
diff --git a/src/mesa/drivers/dri/i915/i830_texstate.c b/src/mesa/drivers/dri/i915/i830_texstate.c
index 6f998fa6f77..f270a137812 100644
--- a/src/mesa/drivers/dri/i915/i830_texstate.c
+++ b/src/mesa/drivers/dri/i915/i830_texstate.c
@@ -162,9 +162,8 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
} else {
dri_bo_reference(intelObj->mt->region->buffer);
i830->state.tex_buffer[unit] = intelObj->mt->region->buffer;
- i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
- 0, intelObj->
- firstLevel);
+ i830->state.tex_offset[unit] =
+ intel_miptree_image_offset(intelObj->mt, 0, intelObj->firstLevel, 0);
format = translate_texture_format(firstImage->TexFormat->MesaFormat,
firstImage->InternalFormat);
diff --git a/src/mesa/drivers/dri/i915/i915_texstate.c b/src/mesa/drivers/dri/i915/i915_texstate.c
index 32d4b30cf9a..b2f82f56551 100644
--- a/src/mesa/drivers/dri/i915/i915_texstate.c
+++ b/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -173,9 +173,8 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
} else {
dri_bo_reference(intelObj->mt->region->buffer);
i915->state.tex_buffer[unit] = intelObj->mt->region->buffer;
- i915->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
- 0, intelObj->
- firstLevel);
+ i915->state.tex_offset[unit] =
+ intel_miptree_image_offset(intelObj->mt, 0, intelObj->firstLevel, 0);
format = translate_texture_format(firstImage->TexFormat->MesaFormat,
firstImage->InternalFormat,
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 8dfb24290d5..2e613718051 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -618,15 +618,8 @@ intel_render_texture(GLcontext * ctx,
}
/* compute offset of the particular 2D image within the texture region */
- imageOffset = intel_miptree_image_offset(intel_image->mt,
- att->CubeMapFace,
- att->TextureLevel);
-
- if (att->Texture->Target == GL_TEXTURE_3D) {
- const GLuint *offsets = intel_miptree_depth_offsets(intel_image->mt,
- att->TextureLevel);
- imageOffset += offsets[att->Zoffset];
- }
+ imageOffset = intel_miptree_image_offset(intel_image->mt, att->CubeMapFace,
+ att->TextureLevel, att->Zoffset);
/* store that offset in the region */
intel_image->mt->region->draw_offset = imageOffset;
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 4f5101a3128..d9d2edfe190 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -395,33 +395,26 @@ intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
}
-/* Although we use the image_offset[] array to store relative offsets
- * to cube faces, Mesa doesn't know anything about this and expects
- * each cube face to be treated as a separate image.
- *
- * These functions present that view to mesa:
+/**
+ * Return offset to the start of a 2D slice of a texture (a mipmap level,
+ * cube face, 3D Z slice).
+ * \param mt the texture object/miptree
+ * \param face cube map face in [0,5] or zero for non-cube textures
+ * \param level mipmap level
+ * \param zslice Z slice of a 3D texture, or zero for non-3D textures
*/
-const GLuint *
-intel_miptree_depth_offsets(struct intel_mipmap_tree *mt, GLuint level)
-{
- static const GLuint zero = 0;
-
- if (mt->target != GL_TEXTURE_3D || mt->level[level].nr_images == 1)
- return &zero;
- else
- return mt->level[level].image_offset;
-}
-
-
GLuint
-intel_miptree_image_offset(struct intel_mipmap_tree *mt,
- GLuint face, GLuint level)
+intel_miptree_image_offset(const struct intel_mipmap_tree *mt,
+ GLuint face, GLuint level, GLuint zslice)
{
+ GLuint offset = mt->level[level].level_offset;
+
if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
- return (mt->level[level].level_offset +
- mt->level[level].image_offset[face]);
- else
- return mt->level[level].level_offset;
+ offset += mt->level[level].image_offset[face];
+ else if (mt->target == GL_TEXTURE_3D)
+ offset += mt->level[level].image_offset[zslice];
+
+ return offset;
}
@@ -459,7 +452,7 @@ intel_miptree_image_map(struct intel_context * intel,
}
return (intel_region_map(intel, mt->region) +
- intel_miptree_image_offset(mt, face, level));
+ intel_miptree_image_offset(mt, face, level, 0));
}
void
@@ -484,19 +477,18 @@ intel_miptree_image_data(struct intel_context *intel,
GLuint src_image_pitch)
{
GLuint depth = dst->level[level].depth;
- GLuint dst_offset = intel_miptree_image_offset(dst, face, level);
- const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
GLuint i;
GLuint height = 0;
DBG("%s: %d/%d\n", __FUNCTION__, face, level);
for (i = 0; i < depth; i++) {
+ GLuint dst_offset = intel_miptree_image_offset(dst, face, level, i);
height = dst->level[level].height;
if(dst->compressed)
height = (height + 3) / 4;
intel_region_data(intel,
dst->region,
- dst_offset + dst_depth_offset[i], /* dst_offset */
+ dst_offset,
0, 0, /* dstx, dsty */
src,
src_row_pitch,
@@ -519,10 +511,6 @@ intel_miptree_image_copy(struct intel_context *intel,
GLuint width = src->level[level].width;
GLuint height = src->level[level].height;
GLuint depth = src->level[level].depth;
- GLuint dst_offset = intel_miptree_image_offset(dst, face, level);
- GLuint src_offset = intel_miptree_image_offset(src, face, level);
- const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
- const GLuint *src_depth_offset = intel_miptree_depth_offsets(src, level);
GLuint i;
GLboolean success;
@@ -535,10 +523,13 @@ intel_miptree_image_copy(struct intel_context *intel,
}
for (i = 0; i < depth; i++) {
+ GLuint dst_offset = intel_miptree_image_offset(dst, face, level, i);
+ GLuint src_offset = intel_miptree_image_offset(src, face, level, i);
+
success = intel_region_copy(intel,
- dst->region, dst_offset + dst_depth_offset[i],
+ dst->region, dst_offset,
0, 0,
- src->region, src_offset + src_depth_offset[i],
+ src->region, src_offset,
0, 0, width, height, GL_COPY);
if (!success) {
GLubyte *src_ptr, *dst_ptr;
@@ -546,11 +537,11 @@ intel_miptree_image_copy(struct intel_context *intel,
src_ptr = intel_region_map(intel, src->region);
dst_ptr = intel_region_map(intel, dst->region);
- _mesa_copy_rect(dst_ptr + dst_offset + dst_depth_offset[i],
+ _mesa_copy_rect(dst_ptr + dst_offset,
dst->cpp,
dst->pitch,
0, 0, width, height,
- src_ptr + src_offset + src_depth_offset[i],
+ src_ptr + src_offset,
src->pitch,
0, 0);
intel_region_unmap(intel, src->region);
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index c890b2a0d04..c08f9cd8b66 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -177,17 +177,9 @@ void intel_miptree_image_unmap(struct intel_context *intel,
struct intel_mipmap_tree *mt);
-/* Return the linear offset of an image relative to the start of the
- * tree:
- */
-GLuint intel_miptree_image_offset(struct intel_mipmap_tree *mt,
- GLuint face, GLuint level);
-
-/* Return pointers to each 2d slice within an image. Indexed by depth
- * value.
- */
-const GLuint *intel_miptree_depth_offsets(struct intel_mipmap_tree *mt,
- GLuint level);
+GLuint
+intel_miptree_image_offset(const struct intel_mipmap_tree *mt,
+ GLuint face, GLuint level, GLuint zslice);
void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c
index f3e312420dd..99cd818417d 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c
@@ -117,7 +117,7 @@ do_copy_texsubimage(struct intel_context *intel,
INTEL_WRITE_PART);
GLuint image_offset = intel_miptree_image_offset(intelImage->mt,
intelImage->face,
- intelImage->level);
+ intelImage->level, 0);
const GLint orig_x = x;
const GLint orig_y = y;
GLshort src_pitch;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 5c915178e75..dcc613449f0 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -222,7 +222,8 @@ try_pbo_upload(struct intel_context *intel,
dst_offset = intel_miptree_image_offset(intelImage->mt,
intelImage->face,
- intelImage->level);
+ intelImage->level,
+ 0 /* zslice */);
dst_stride = intelImage->mt->pitch;
@@ -281,8 +282,8 @@ try_pbo_zcopy(struct intel_context *intel,
dst_offset = intel_miptree_image_offset(intelImage->mt,
intelImage->face,
- intelImage->level);
-
+ intelImage->level,
+ 0 /* zslice */);
dst_stride = intelImage->mt->pitch;
if (src_stride != dst_stride || dst_offset != 0 || src_offset != 0) {