We need to figure out if the compression format changes.
without this texcmp segfaults if you change format
enough times.
* Create a new mipmap tree, calculate its layout and allocate memory.
*/
radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa, radeonTexObj *t,
- GLenum target, GLuint firstLevel, GLuint lastLevel,
+ GLenum target, GLenum internal_format, GLuint firstLevel, GLuint lastLevel,
GLuint width0, GLuint height0, GLuint depth0,
GLuint bpp, GLuint tilebits, GLuint compressed)
{
radeon_mipmap_tree *mt = CALLOC_STRUCT(_radeon_mipmap_tree);
mt->radeon = rmesa;
+ mt->internal_format = internal_format;
mt->refcount = 1;
mt->t = t;
mt->target = target;
if (face >= mt->faces || level < mt->firstLevel || level > mt->lastLevel)
return GL_FALSE;
- if ((!texImage->IsCompressed && mt->compressed) ||
- (texImage->IsCompressed && !mt->compressed))
+ if (texImage->InternalFormat != mt->internal_format ||
+ texImage->IsCompressed != mt->compressed)
return GL_FALSE;
if (!texImage->IsCompressed &&
* given image in the given position.
*/
void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
- struct gl_texture_image *texImage, GLuint face, GLuint level)
+ radeon_texture_image *image, GLuint face, GLuint level)
{
- GLuint compressed = texImage->IsCompressed ? texImage->TexFormat->MesaFormat : 0;
+ GLuint compressed = image->base.IsCompressed ? image->base.TexFormat->MesaFormat : 0;
GLuint numfaces = 1;
GLuint firstLevel, lastLevel;
return;
t->mt = radeon_miptree_create(rmesa, t, t->base.Target,
+ image->base.InternalFormat,
firstLevel, lastLevel,
- texImage->Width, texImage->Height, texImage->Depth,
- texImage->TexFormat->TexelBytes, t->tile_bits, compressed);
+ image->base.Width, image->base.Height, image->base.Depth,
+ image->base.TexFormat->TexelBytes, t->tile_bits, compressed);
}
/* Although we use the image_offset[] array to store relative offsets
GLuint totalsize; /** total size of the miptree, in bytes */
GLenum target; /** GL_TEXTURE_xxx */
+ GLenum internal_format;
GLuint faces; /** # of faces: 6 for cubemaps, 1 otherwise */
GLuint firstLevel; /** First mip level stored in this mipmap tree */
GLuint lastLevel; /** Last mip level stored in this mipmap tree */
};
radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa, radeonTexObj *t,
- GLenum target, GLuint firstLevel, GLuint lastLevel,
+ GLenum target, GLenum internal_format, GLuint firstLevel, GLuint lastLevel,
GLuint width0, GLuint height0, GLuint depth0,
GLuint bpp, GLuint tilebits, GLuint compressed);
void radeon_miptree_reference(radeon_mipmap_tree *mt);
struct gl_texture_image *texImage, GLuint face, GLuint level);
GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_texture_object *texObj);
void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
- struct gl_texture_image *texImage, GLuint face, GLuint level);
+ radeon_texture_image *texImage, GLuint face, GLuint level);
GLuint radeon_miptree_image_offset(radeon_mipmap_tree *mt,
GLuint face, GLuint level);
void radeon_miptree_depth_offsets(radeon_mipmap_tree *mt, GLuint level, GLuint *offsets);
}
if (!t->mt)
- radeon_try_alloc_miptree(rmesa, t, texImage, face, level);
+ radeon_try_alloc_miptree(rmesa, t, image, face, level);
if (t->mt && radeon_miptree_matches_image(t->mt, texImage, face, level)) {
radeon_mipmap_level *lvl;
image->mt = t->mt;
if (!t->mt) {
if (RADEON_DEBUG & RADEON_TEXTURE)
fprintf(stderr, " Allocate new miptree\n");
- radeon_try_alloc_miptree(rmesa, t, &baseimage->base, 0, texObj->BaseLevel);
+ radeon_try_alloc_miptree(rmesa, t, baseimage, 0, texObj->BaseLevel);
if (!t->mt) {
_mesa_problem(ctx, "radeon_validate_texture failed to alloc miptree");
return GL_FALSE;