From b68ff2b8731427b3b68c9c81902f7ba93606caaf Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Wed, 14 Aug 2019 15:16:04 -0700 Subject: [PATCH] glapi / teximage: implement EGLImageTargetTexStorageEXT MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Check various parts of the EXT_EGL_image_storage spec, and add a new vfunc for drivers implementing it. Reviewed-by: Tapani Pälli --- src/mapi/glapi/gen/EXT_EGL_image_storage.xml | 22 ++++ src/mapi/glapi/gen/gl_API.xml | 1 + src/mapi/glapi/gen/static_data.py | 2 + src/mesa/main/dd.h | 7 ++ src/mesa/main/extensions_table.h | 1 + src/mesa/main/mtypes.h | 1 + src/mesa/main/tests/dispatch_sanity.cpp | 7 ++ src/mesa/main/teximage.c | 102 +++++++++++++++++-- src/mesa/main/teximage.h | 6 ++ 9 files changed, 142 insertions(+), 7 deletions(-) create mode 100644 src/mapi/glapi/gen/EXT_EGL_image_storage.xml diff --git a/src/mapi/glapi/gen/EXT_EGL_image_storage.xml b/src/mapi/glapi/gen/EXT_EGL_image_storage.xml new file mode 100644 index 00000000000..ca38e13450e --- /dev/null +++ b/src/mapi/glapi/gen/EXT_EGL_image_storage.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml index dff4e9560bc..1cee28f3105 100644 --- a/src/mapi/glapi/gen/gl_API.xml +++ b/src/mapi/glapi/gen/gl_API.xml @@ -13260,6 +13260,7 @@ + diff --git a/src/mapi/glapi/gen/static_data.py b/src/mapi/glapi/gen/static_data.py index 22bdf003544..d2a9c66b4cd 100644 --- a/src/mapi/glapi/gen/static_data.py +++ b/src/mapi/glapi/gen/static_data.py @@ -1638,6 +1638,8 @@ offsets = { "IsNamedStringARB": 1602, "GetNamedStringARB": 1603, "GetNamedStringivARB": 1604, + "EGLImageTargetTexStorageEXT" : 1605, + "EGLImageTargetTextureStorageEXT" : 1606, } functions = [ diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index 8251af3f667..72af158dd07 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -974,6 +974,13 @@ struct dd_function_table { struct gl_renderbuffer *rb, void *image_handle); + /** + * \name GL_EXT_EGL_image_storage interface + */ + void (*EGLImageTargetTexStorage)(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLeglImageOES image_handle); /** * \name GL_EXT_transform_feedback interface */ diff --git a/src/mesa/main/extensions_table.h b/src/mesa/main/extensions_table.h index 2402f34f561..7905232b429 100644 --- a/src/mesa/main/extensions_table.h +++ b/src/mesa/main/extensions_table.h @@ -205,6 +205,7 @@ EXT(ATI_texture_env_combine3 , ATI_texture_env_combine3 EXT(ATI_texture_float , ARB_texture_float , GLL, GLC, x , x , 2002) EXT(ATI_texture_mirror_once , ATI_texture_mirror_once , GLL, GLC, x , x , 2006) +EXT(EXT_EGL_image_storage , EXT_EGL_image_storage , GLL, GLC , x , 30, 2018) EXT(EXT_EGL_sync , dummy_true , GLL, GLC, x , x , 2019) EXT(EXT_abgr , dummy_true , GLL, GLC, x , x , 1995) EXT(EXT_base_instance , ARB_base_instance , x , x , x , 30, 2014) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 02766d3aced..c3cee09549f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4295,6 +4295,7 @@ struct gl_extensions GLboolean EXT_depth_bounds_test; GLboolean EXT_disjoint_timer_query; GLboolean EXT_draw_buffers2; + GLboolean EXT_EGL_image_storage; GLboolean EXT_float_blend; GLboolean EXT_framebuffer_multisample; GLboolean EXT_framebuffer_multisample_blit_scaled; diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp index c1c293b843a..7298aa66308 100644 --- a/src/mesa/main/tests/dispatch_sanity.cpp +++ b/src/mesa/main/tests/dispatch_sanity.cpp @@ -559,6 +559,10 @@ const struct function common_desktop_functions_possible[] = { { "glEGLImageTargetRenderbufferStorageOES", 31, -1 }, { "glEGLImageTargetTexture2DOES", 31, -1 }, + /* EXT_EGL_image_storage */ + { "glEGLImageTargetTexStorageEXT", 31, -1 }, + { "glEGLImageTargetTextureStorageEXT", 31, -1 }, + /* GL 3.2 */ { "glGetInteger64i_v", 32, -1 }, { "glGetBufferParameteri64v", 32, -1 }, @@ -2637,6 +2641,9 @@ const struct function gles3_functions_possible[] = { { "glFramebufferParameteriMESA", 30, -1 }, { "glGetFramebufferParameterivMESA", 30, -1 }, + /* EXT_EGL_image_storage */ + { "glEGLImageTargetTexStorageEXT", 30, -1 }, + { NULL, 0, -1 } }; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 263c473195b..65952bca5fa 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -3383,12 +3383,14 @@ _mesa_TexImage3D_no_error(GLenum target, GLint level, GLint internalFormat, } /* - * Helper used by __mesa_EGLImageTargetTexture2DOES. + * Helper used by __mesa_EGLImageTargetTexture2DOES and + * _mesa_EGLImageTargetTexStorageEXT. */ static void egl_image_target_texture(struct gl_context *ctx, struct gl_texture_object *texObj, GLenum target, - GLeglImageOES image, const char *caller) + GLeglImageOES image, bool tex_storage, + const char *caller) { struct gl_texture_image *texImage; bool valid_target; @@ -3396,7 +3398,8 @@ egl_image_target_texture(struct gl_context *ctx, switch (target) { case GL_TEXTURE_2D: - valid_target = _mesa_has_OES_EGL_image(ctx); + valid_target = _mesa_has_OES_EGL_image(ctx) || + (tex_storage && _mesa_has_EXT_EGL_image_storage(ctx)); break; case GL_TEXTURE_EXTERNAL_OES: valid_target = @@ -3413,7 +3416,7 @@ egl_image_target_texture(struct gl_context *ctx, } if (!image) { - _mesa_error(ctx, GL_INVALID_OPERATION, "%s(image=%p)", caller, image); + _mesa_error(ctx, GL_INVALID_VALUE, "%s(image=%p)", caller, image); return; } @@ -3434,11 +3437,20 @@ egl_image_target_texture(struct gl_context *ctx, } else { ctx->Driver.FreeTextureImageBuffer(ctx, texImage); - ctx->Driver.EGLImageTargetTexture2D(ctx, target, - texObj, texImage, image); + if (tex_storage) { + ctx->Driver.EGLImageTargetTexStorage(ctx, target, texObj, texImage, + image); + } else { + ctx->Driver.EGLImageTargetTexture2D(ctx, target, texObj, texImage, + image); + } _mesa_dirty_texobj(ctx, texObj); } + + if (tex_storage) + _mesa_set_texture_view_state(ctx, texObj, target, 1); + _mesa_unlock_texture(ctx, texObj); } @@ -3455,7 +3467,83 @@ _mesa_EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image) return; } - egl_image_target_texture(ctx, texObj, target, image, func); + egl_image_target_texture(ctx, texObj, target, image, false, func); +} + +static void +egl_image_target_texture_storage(struct gl_context *ctx, + struct gl_texture_object *texObj, GLenum target, + GLeglImageOES image, const GLint *attrib_list, + const char *caller) +{ + /* + * EXT_EGL_image_storage: + * + * " must be NULL or a pointer to the value GL_NONE." + */ + if (attrib_list && attrib_list[0] != GL_NONE) { + _mesa_error(ctx, GL_INVALID_VALUE, "%s(image=%p)", caller, image); + return; + } + + switch (target) { + case GL_TEXTURE_2D: + case GL_TEXTURE_EXTERNAL_OES: + break; + default: + /* + * The EXT_EGL_image_storage spec allows for many other targets besides + * GL_TEXTURE_2D and GL_TEXTURE_EXTERNAL_OES, however these are complicated + * to implement. + */ + _mesa_error(ctx, GL_INVALID_OPERATION, "%s(unsupported target=%d)", + caller, target); + return; + } + + egl_image_target_texture(ctx, texObj, target, image, true, caller); +} + + +void GLAPIENTRY +_mesa_EGLImageTargetTexStorageEXT(GLenum target, GLeglImageOES image, + const GLint *attrib_list) +{ + struct gl_texture_object *texObj; + const char *func = "glEGLImageTargetTexStorageEXT"; + 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_storage(ctx, texObj, target, image, attrib_list, + func); +} + +void GLAPIENTRY +_mesa_EGLImageTargetTextureStorageEXT(GLuint texture, GLeglImageOES image, + const GLint *attrib_list) +{ + struct gl_texture_object *texObj; + const char *func = "glEGLImageTargetTextureStorageEXT"; + GET_CURRENT_CONTEXT(ctx); + + if (!(_mesa_is_desktop_gl(ctx) && ctx->Version >= 45) && + !_mesa_has_ARB_direct_state_access(ctx) && + !_mesa_has_EXT_direct_state_access(ctx)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "direct access not supported"); + return; + } + + texObj = _mesa_lookup_texture_err(ctx, texture, func); + if (!texObj) + return; + + egl_image_target_texture_storage(ctx, texObj, texObj->Target, image, + attrib_list, func); } /** diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h index bd835883774..ee4b1ac8595 100644 --- a/src/mesa/main/teximage.h +++ b/src/mesa/main/teximage.h @@ -330,6 +330,12 @@ _mesa_TexImage3D_no_error(GLenum target, GLint level, GLint internalformat, extern void GLAPIENTRY _mesa_EGLImageTargetTexture2DOES( GLenum target, GLeglImageOES image ); +extern void GLAPIENTRY +_mesa_EGLImageTargetTexStorageEXT(GLenum target, GLeglImageOES image, + const GLint *attrib_list); +extern void GLAPIENTRY +_mesa_EGLImageTargetTextureStorageEXT(GLuint texture, GLeglImageOES image, + const GLint *attrib_list); void GLAPIENTRY _mesa_TexSubImage1D_no_error(GLenum target, GLint level, GLint xoffset, GLsizei width, -- 2.30.2