/**
- * Free all texture images of the given texture object.
+ * Free all texture images of the given texture objectm, except for
+ * \p retainTexImage.
*
* \param ctx GL context.
- * \param t texture object.
+ * \param texObj texture object.
+ * \param retainTexImage a texture image that will \em not be freed.
*
* \sa _mesa_clear_texture_image().
*/
void
_mesa_clear_texture_object(struct gl_context *ctx,
- struct gl_texture_object *texObj)
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *retainTexImage)
{
GLuint i, j;
for (i = 0; i < MAX_FACES; i++) {
for (j = 0; j < MAX_TEXTURE_LEVELS; j++) {
struct gl_texture_image *texImage = texObj->Image[i][j];
- if (texImage)
+ if (texImage && texImage != retainTexImage)
_mesa_clear_texture_image(ctx, texImage);
}
}
extern void
_mesa_clear_texture_object(struct gl_context *ctx,
- struct gl_texture_object *obj);
+ struct gl_texture_object *obj,
+ struct gl_texture_image *retainTexImage);
extern void
_mesa_reference_texobj_(struct gl_texture_object **ptr,
/* switch to surface based */
if (!stObj->surface_based) {
- _mesa_clear_texture_object(ctx, texObj);
+ _mesa_clear_texture_object(ctx, texObj, NULL);
stObj->surface_based = GL_TRUE;
}
const GLuint level = texImage->Level;
mesa_format texFormat;
- _mesa_clear_texture_object(ctx, texObj);
+ assert(!st_texture_image(texImage)->pt);
+ _mesa_clear_texture_object(ctx, texObj, texImage);
pipe_resource_reference(&stObj->pt, NULL);
/* oops, need to init this image again */
stObj = st_texture_object(texObj);
/* switch to surface based */
if (!stObj->surface_based) {
- _mesa_clear_texture_object(ctx, texObj);
+ _mesa_clear_texture_object(ctx, texObj, NULL);
stObj->surface_based = GL_TRUE;
}
/* switch to surface based */
if (!stObj->surface_based) {
- _mesa_clear_texture_object(ctx, texObj);
+ _mesa_clear_texture_object(ctx, texObj, NULL);
stObj->surface_based = GL_TRUE;
}