mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
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.
This commit is contained in:
parent
15d2ef6024
commit
e6594a22f2
7 changed files with 40 additions and 65 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue