diff options
author | Dave Airlie <airlied@redhat.com> | 2009-09-03 12:01:52 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-09-03 12:02:54 +1000 |
commit | 5f7c532b1e5414f65e126948b35cf9e1ef10c3a1 (patch) | |
tree | a4e2b975812be6111ff4f286f0ea087c9790b052 /src/mesa | |
parent | e5b93e116180d7ae360af1fd3e7b05f14ebce656 (diff) |
radeon: pass internal format into the miptree.
We need to figure out if the compression format changes.
without this texcmp segfaults if you change format
enough times.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 16 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texture.c | 4 |
3 files changed, 14 insertions, 11 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index d9f17cfc58..38db305e2a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c @@ -190,13 +190,14 @@ static void calculate_miptree_layout_r300(radeonContextPtr rmesa, radeon_mipmap_ * 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; @@ -318,8 +319,8 @@ GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt, 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 && @@ -369,9 +370,9 @@ GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_textu * 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; @@ -385,9 +386,10 @@ void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t, 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 diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h index 7ece688493..db28252da3 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.h @@ -67,6 +67,7 @@ struct _radeon_mipmap_tree { 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 */ @@ -83,7 +84,7 @@ struct _radeon_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); @@ -93,7 +94,7 @@ GLboolean radeon_miptree_matches_image(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); diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 181b23c396..fad3d1ceda 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -579,7 +579,7 @@ static void radeon_teximage( } 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; @@ -966,7 +966,7 @@ int radeon_validate_texture_miptree(GLcontext * ctx, struct gl_texture_object *t 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; |