GLES translator: don't delete EGLImage textures

When remapping a GLES texture to a different GL texture in
glEGLImageTargetTexture2DOES(), the GLES texture's previous GL texture was
deleted unconditionally. This is bad when it came from an EGLImage and is
therefore owned by (and will continue to be used by) some other object.

The code now skips deleting the old GL texture if it came from an EGLImage.
This mirrors the logic in glDeleteTextures().

Change-Id: I5b650334a7019d824517c2915b1f23961fbbd809
This commit is contained in:
Jesse Hall
2011-11-18 14:05:26 -08:00
parent faaf1553cf
commit f37a7ed6c5

View File

@@ -1664,9 +1664,12 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
if (ctx->shareGroup().Ptr()) {
ObjectLocalName tex = TextureLocalName(target,ctx->getBindedTexture(target));
unsigned int oldGlobal = ctx->shareGroup()->getGlobalName(TEXTURE, tex);
// Delete old texture object
// Delete old texture object but only if it is not a target of a EGLImage
if (oldGlobal) {
ctx->dispatcher().glDeleteTextures(1, &oldGlobal);
TextureData* oldTexData = getTextureData(tex);
if (!oldTexData || oldTexData->sourceEGLImage == 0) {
ctx->dispatcher().glDeleteTextures(1, &oldGlobal);
}
}
// replace mapping and bind the new global object
ctx->shareGroup()->replaceGlobalName(TEXTURE, tex,img->globalTexName);