diff options
author | Eric Anholt <[email protected]> | 2008-03-18 16:20:44 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2008-03-18 20:17:56 -0700 |
commit | e5f50f2fa32c50807da3a8f13733f0fbc7868f94 (patch) | |
tree | 34567b06425c9ecdd0f214f20672bba31e587ea7 /src | |
parent | 363d8785192e299963df520d53c221f494c8026c (diff) |
[intel] Clarify miptree layout by using byte offsets to images.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 22 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_mipmap_tree.h | 19 |
2 files changed, 29 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index ccb0fd53d02..55503f45ae8 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -326,7 +326,7 @@ intel_miptree_set_image_offset(struct intel_mipmap_tree *mt, assert(img < mt->level[level].nr_images); - mt->level[level].image_offset[img] = (x + y * mt->pitch); + mt->level[level].image_offset[img] = (x + y * mt->pitch) * mt->cpp; DBG("%s level %d img %d pos %d,%d image_offset %x\n", __FUNCTION__, level, img, x, y, mt->level[level].image_offset[img]); @@ -357,7 +357,7 @@ intel_miptree_image_offset(struct intel_mipmap_tree *mt, { if (mt->target == GL_TEXTURE_CUBE_MAP_ARB) return (mt->level[level].level_offset + - mt->level[level].image_offset[face] * mt->cpp); + mt->level[level].image_offset[face]); else return mt->level[level].level_offset; } @@ -368,6 +368,8 @@ intel_miptree_image_offset(struct intel_mipmap_tree *mt, * Map a teximage in a mipmap tree. * \param row_stride returns row stride in bytes * \param image_stride returns image stride in bytes (for 3D textures). + * \param image_offsets pointer to array of pixel offsets from the returned + * pointer to each depth image * \return address of mapping */ GLubyte * @@ -382,12 +384,16 @@ intel_miptree_image_map(struct intel_context * intel, if (row_stride) *row_stride = mt->pitch * mt->cpp; - if (image_offsets) { - if (mt->target == GL_TEXTURE_CUBE_MAP_ARB) - memset(image_offsets, 0, mt->level[level].depth * sizeof(GLuint)); - else - memcpy(image_offsets, mt->level[level].image_offset, - mt->level[level].depth * sizeof(GLuint)); + if (mt->target == GL_TEXTURE_3D) { + int i; + + for (i = 0; i < mt->level[level].depth; i++) + image_offsets[i] = mt->level[level].image_offset[i] / mt->cpp; + } else { + assert(mt->level[level].depth == 1); + assert(mt->target == GL_TEXTURE_CUBE_MAP || + mt->level[level].image_offset[0] == 0); + image_offsets[0] = 0; } return (intel_region_map(intel, mt->region) + diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h index 3c1a6ffa2a8..c9537dbb9a4 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h @@ -62,18 +62,29 @@ */ struct intel_mipmap_level { + /** + * Byte offset to the base of this level. + * + * This is used for mipmap levels of 1D/2D/3D textures. However, CUBE + * layouts spread images around the whole tree, so the level offset is + * always zero in that case. + */ GLuint level_offset; GLuint width; GLuint height; + /** Depth of the mipmap at this level: 1 for 1D/2D/CUBE, n for 3D. */ GLuint depth; + /** Number of images at this level: 1 for 1D/2D, 6 for CUBE, depth for 3D */ GLuint nr_images; - /* Explicitly store the offset of each image for each cube face or - * depth value. Pretty much have to accept that hardware formats + /** + * Byte offset from level_offset to the image for each cube face or depth + * level. + * + * Pretty much have to accept that hardware formats * are going to be so diverse that there is no unified way to * compute the offsets of depth/cube images within a mipmap level, - * so have to store them as a lookup table: - * NOTE level_offset is a byte offset, but the image_offsets are _pixel_ offsets!!! + * so have to store them as a lookup table. */ GLuint *image_offset; }; |