mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 14:40:10 +01:00
radeon: rework mipmap tree reference counting
This commit is contained in:
parent
6e5d473cc1
commit
7628b06ba3
5 changed files with 30 additions and 37 deletions
|
|
@ -228,11 +228,8 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
|
|||
* we just have to rely on loading the right subset of mipmap levels
|
||||
* to simulate a clamped LOD.
|
||||
*/
|
||||
if (t->mt) {
|
||||
radeon_miptree_unreference(t->mt);
|
||||
t->mt = 0;
|
||||
t->validated = GL_FALSE;
|
||||
}
|
||||
radeon_miptree_unreference(&t->mt);
|
||||
t->validated = GL_FALSE;
|
||||
break;
|
||||
|
||||
case GL_DEPTH_TEXTURE_MODE:
|
||||
|
|
@ -286,10 +283,8 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
|
|||
t->bo = NULL;
|
||||
}
|
||||
|
||||
if (t->mt) {
|
||||
radeon_miptree_unreference(t->mt);
|
||||
t->mt = 0;
|
||||
}
|
||||
radeon_miptree_unreference(&t->mt);
|
||||
|
||||
_mesa_delete_texture_object(ctx, texObj);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -438,14 +438,10 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo
|
|||
radeon_bo_unref(rImage->bo);
|
||||
rImage->bo = NULL;
|
||||
}
|
||||
if (t->mt) {
|
||||
radeon_miptree_unreference(t->mt);
|
||||
t->mt = NULL;
|
||||
}
|
||||
if (rImage->mt) {
|
||||
radeon_miptree_unreference(rImage->mt);
|
||||
rImage->mt = NULL;
|
||||
}
|
||||
|
||||
radeon_miptree_unreference(&t->mt);
|
||||
radeon_miptree_unreference(&rImage->mt);
|
||||
|
||||
_mesa_init_teximage_fields(radeon->glCtx, target, texImage,
|
||||
rb->base.Width, rb->base.Height, 1, 0, rb->cpp);
|
||||
texImage->RowStride = rb->pitch / rb->cpp;
|
||||
|
|
|
|||
|
|
@ -223,23 +223,31 @@ radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa, radeonTexObj *
|
|||
return mt;
|
||||
}
|
||||
|
||||
void radeon_miptree_reference(radeon_mipmap_tree *mt)
|
||||
void radeon_miptree_reference(radeon_mipmap_tree *mt, radeon_mipmap_tree **ptr)
|
||||
{
|
||||
assert(!*ptr);
|
||||
|
||||
mt->refcount++;
|
||||
assert(mt->refcount > 0);
|
||||
|
||||
*ptr = mt;
|
||||
}
|
||||
|
||||
void radeon_miptree_unreference(radeon_mipmap_tree *mt)
|
||||
void radeon_miptree_unreference(radeon_mipmap_tree **ptr)
|
||||
{
|
||||
radeon_mipmap_tree *mt = *ptr;
|
||||
if (!mt)
|
||||
return;
|
||||
|
||||
assert(mt->refcount > 0);
|
||||
|
||||
mt->refcount--;
|
||||
if (!mt->refcount) {
|
||||
radeon_bo_unref(mt->bo);
|
||||
free(mt);
|
||||
}
|
||||
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -87,8 +87,9 @@ radeon_mipmap_tree* radeon_miptree_create(radeonContextPtr rmesa, radeonTexObj *
|
|||
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);
|
||||
void radeon_miptree_unreference(radeon_mipmap_tree *mt);
|
||||
|
||||
void radeon_miptree_reference(radeon_mipmap_tree *mt, radeon_mipmap_tree **ptr);
|
||||
void radeon_miptree_unreference(radeon_mipmap_tree **ptr);
|
||||
|
||||
GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
|
||||
struct gl_texture_image *texImage, GLuint face, GLuint level);
|
||||
|
|
|
|||
|
|
@ -81,8 +81,7 @@ void radeonFreeTexImageData(GLcontext *ctx, struct gl_texture_image *timage)
|
|||
radeon_texture_image* image = get_radeon_texture_image(timage);
|
||||
|
||||
if (image->mt) {
|
||||
radeon_miptree_unreference(image->mt);
|
||||
image->mt = 0;
|
||||
radeon_miptree_unreference(&image->mt);
|
||||
assert(!image->base.Data);
|
||||
} else {
|
||||
_mesa_free_texture_image_data(ctx, timage);
|
||||
|
|
@ -240,8 +239,7 @@ static void radeon_generate_mipmap(GLcontext *ctx, GLenum target,
|
|||
image->mtlevel = i;
|
||||
image->mtface = face;
|
||||
|
||||
radeon_miptree_unreference(image->mt);
|
||||
image->mt = NULL;
|
||||
radeon_miptree_unreference(&image->mt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -571,18 +569,16 @@ static void radeon_teximage(
|
|||
t->mt->lastLevel == level &&
|
||||
t->mt->target != GL_TEXTURE_CUBE_MAP_ARB &&
|
||||
!radeon_miptree_matches_image(t->mt, texImage, face, level)) {
|
||||
radeon_miptree_unreference(t->mt);
|
||||
t->mt = NULL;
|
||||
radeon_miptree_unreference(&t->mt);
|
||||
}
|
||||
|
||||
if (!t->mt)
|
||||
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;
|
||||
image->mtlevel = level - t->mt->firstLevel;
|
||||
image->mtface = face;
|
||||
radeon_miptree_reference(t->mt);
|
||||
radeon_miptree_reference(t->mt, &image->mt);
|
||||
lvl = &image->mt->levels[image->mtlevel];
|
||||
dstRowStride = lvl->rowstride;
|
||||
} else {
|
||||
|
|
@ -894,7 +890,7 @@ static void migrate_image_to_miptree(radeon_mipmap_tree *mt, radeon_texture_imag
|
|||
dstlvl->size);
|
||||
radeon_bo_unmap(image->mt->bo);
|
||||
|
||||
radeon_miptree_unreference(image->mt);
|
||||
radeon_miptree_unreference(&image->mt);
|
||||
} else {
|
||||
uint32_t srcrowstride;
|
||||
uint32_t height;
|
||||
|
|
@ -919,10 +915,9 @@ static void migrate_image_to_miptree(radeon_mipmap_tree *mt, radeon_texture_imag
|
|||
|
||||
radeon_bo_unmap(mt->bo);
|
||||
|
||||
image->mt = mt;
|
||||
image->mtface = face;
|
||||
image->mtlevel = level;
|
||||
radeon_miptree_reference(image->mt);
|
||||
radeon_miptree_reference(mt, &image->mt);
|
||||
}
|
||||
|
||||
int radeon_validate_texture_miptree(GLcontext * ctx, struct gl_texture_object *texObj)
|
||||
|
|
@ -954,12 +949,10 @@ int radeon_validate_texture_miptree(GLcontext * ctx, struct gl_texture_object *t
|
|||
if (baseimage->mt &&
|
||||
baseimage->mt != t->mt &&
|
||||
radeon_miptree_matches_texture(baseimage->mt, &t->base)) {
|
||||
radeon_miptree_unreference(t->mt);
|
||||
t->mt = baseimage->mt;
|
||||
radeon_miptree_reference(t->mt);
|
||||
radeon_miptree_unreference(&t->mt);
|
||||
radeon_miptree_reference(baseimage->mt, &t->mt);
|
||||
} else if (t->mt && !radeon_miptree_matches_texture(t->mt, &t->base)) {
|
||||
radeon_miptree_unreference(t->mt);
|
||||
t->mt = 0;
|
||||
radeon_miptree_unreference(&t->mt);
|
||||
}
|
||||
|
||||
if (!t->mt) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue