From 1fe23d0e22afee2cccafaec4d06399bdcca0f7d6 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Tue, 13 Aug 2019 18:16:41 -0700 Subject: [PATCH] teximage: split out helper from EGLImageTargetTexture2DOES MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The major differences between EXT_EGL_image_storage and EGLImageTargetTexture2DOES are: (1) The texture target is made immutable (2) EXT_EGL_image_storage supports non-2D targets. We can reuse EGLImageTargetTexture2D and FreeTextureImageBuffer for (1) pretty easily. For (2), let's just not support the complicated targets. Let's reuse aspects of the EGLImageTargetTexture2DOES implementation. Reviewed-by: Tapani Pälli --- src/mesa/main/teximage.c | 47 +++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 251cc08ecc5..263c473195b 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3382,23 +3382,25 @@ _mesa_TexImage3D_no_error(GLenum target, GLint level, GLint internalFormat, width, height, depth, border, format, type, 0, pixels); } - -void GLAPIENTRY -_mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) +/* + * Helper used by __mesa_EGLImageTargetTexture2DOES. + */ +static void +egl_image_target_texture(struct gl_context *ctx, + struct gl_texture_object *texObj, GLenum target, + GLeglImageOES image, const char *caller) { - struct gl_texture_object *texObj; struct gl_texture_image *texImage; bool valid_target; - GET_CURRENT_CONTEXT(ctx); FLUSH_VERTICES(ctx, 0); switch (target) { case GL_TEXTURE_2D: - valid_target = ctx->Extensions.OES_EGL_image; + valid_target = _mesa_has_OES_EGL_image(ctx); break; case GL_TEXTURE_EXTERNAL_OES: valid_target = - _mesa_is_gles(ctx) ? ctx->Extensions.OES_EGL_image_external : false; + _mesa_is_gles(ctx) ? _mesa_has_OES_EGL_image_external(ctx) : false; break; default: valid_target = false; @@ -3406,36 +3408,29 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) } if (!valid_target) { - _mesa_error(ctx, GL_INVALID_ENUM, - "glEGLImageTargetTexture2D(target=%d)", target); + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target=%d)", caller, target); return; } if (!image) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEGLImageTargetTexture2D(image=%p)", image); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(image=%p)", caller, image); return; } if (ctx->NewState & _NEW_PIXEL) _mesa_update_state(ctx); - texObj = _mesa_get_current_tex_object(ctx, target); - if (!texObj) - return; - _mesa_lock_texture(ctx, texObj); if (texObj->Immutable) { - _mesa_error(ctx, GL_INVALID_OPERATION, - "glEGLImageTargetTexture2D(texture is immutable)"); + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(texture is immutable)", caller); _mesa_unlock_texture(ctx, texObj); return; } texImage = _mesa_get_tex_image(ctx, texObj, target, 0); if (!texImage) { - _mesa_error(ctx, GL_OUT_OF_MEMORY, "glEGLImageTargetTexture2D"); + _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller); } else { ctx->Driver.FreeTextureImageBuffer(ctx, texImage); @@ -3447,6 +3442,22 @@ _mesa_EGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image) _mesa_unlock_texture(ctx, texObj); } +void GLAPIENTRY +_mesa_EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) +{ + struct gl_texture_object *texObj; + const char *func = "glEGLImageTargetTexture2D"; + GET_CURRENT_CONTEXT(ctx); + + texObj = _mesa_get_current_tex_object(ctx, target); + if (!texObj) { + _mesa_error(ctx, GL_INVALID_ENUM, "%s(target=%d)", func, target); + return; + } + + egl_image_target_texture(ctx, texObj, target, image, func); +} + /** * Helper that implements the glTexSubImage1/2/3D() * and glTextureSubImage1/2/3D() functions. -- 2.30.2