summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-10-10 13:58:44 +0200
committerNicolai Hähnle <[email protected]>2017-10-10 13:58:44 +0200
commitd245724399b7ac9e2ddf99d381f7fe092204006a (patch)
treedfe3d07df0a1f8611496d66ef6607c93bd30a243 /src
parenta2c8812f919c59933605c5942d6613e14ec8b3d1 (diff)
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/texobj.c11
-rw-r--r--src/mesa/main/texobj.h3
-rw-r--r--src/mesa/state_tracker/st_cb_eglimage.c2
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c3
-rw-r--r--src/mesa/state_tracker/st_manager.c2
-rw-r--r--src/mesa/state_tracker/st_vdpau.c2
6 files changed, 14 insertions, 9 deletions
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index b703da01bef..1978898b8b9 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -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);
}
}
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 71cc8ffba2e..e67ce3ff9df 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -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,
diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c
index cca2c026097..e15b32ff199 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -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;
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index b5006b05a7b..b0a95ecbc79 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -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 */
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 50bc3c33c62..aef87ea8b75 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -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;
}
diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c
index 02738153085..bb4070eec34 100644
--- a/src/mesa/state_tracker/st_vdpau.c
+++ b/src/mesa/state_tracker/st_vdpau.c
@@ -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;
}