st/mesa: fix switching from surface-based to non-surface-based textures
This can happen with surface-based texture objects derived from EGL images, since those aren't immutable. Fixes tests in dEQP-EGL.functional.sharing.gles2.multithread.random.images.teximage2d.* and others Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
a2c8812f91
commit
d245724399
|
@ -471,16 +471,19 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
|
|||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
@ -490,7 +493,7 @@ _mesa_clear_texture_object(struct gl_context *ctx,
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,8 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
|
|||
|
||||
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,
|
||||
|
|
|
@ -198,7 +198,7 @@ st_bind_egl_image(struct gl_context *ctx,
|
|||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -693,7 +693,8 @@ prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage,
|
|||
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 */
|
||||
|
|
|
@ -694,7 +694,7 @@ st_context_teximage(struct st_context_iface *stctxi,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
|
|||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue