glapi / teximage: implement EGLImageTargetTexStorageEXT
authorGurchetan Singh <gurchetansingh@chromium.org>
Wed, 14 Aug 2019 22:16:04 +0000 (15:16 -0700)
committerGurchetan Singh <gurchetansingh@chromium.org>
Mon, 13 Jan 2020 22:57:18 +0000 (14:57 -0800)
Check various parts of the EXT_EGL_image_storage spec, and add a
new vfunc for drivers implementing it.

Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/mapi/glapi/gen/EXT_EGL_image_storage.xml [new file with mode: 0644]
src/mapi/glapi/gen/gl_API.xml
src/mapi/glapi/gen/static_data.py
src/mesa/main/dd.h
src/mesa/main/extensions_table.h
src/mesa/main/mtypes.h
src/mesa/main/tests/dispatch_sanity.cpp
src/mesa/main/teximage.c
src/mesa/main/teximage.h

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 (file)
index 0000000..ca38e13
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<category name="GL_EXT_EGL_image_storage" number="301">
+
+    <function name="EGLImageTargetTexStorageEXT" es2="3.0" desktop="true">
+        <param name="target" type="GLenum"/>
+        <param name="image" type="GLvoid *"/>
+        <param name="attrib_list" type="const GLint *"/>
+    </function>
+
+    <function name="EGLImageTargetTextureStorageEXT" desktop="true">
+        <param name="texture" type="GLuint"/>
+        <param name="image" type="GLvoid *"/>
+        <param name="attrib_list" type="const GLint *"/>
+    </function>
+
+</category>
+
+</OpenGLAPI>
index dff4e9560bcaabf508364060e028e5a1014f282c..1cee28f3105b91111ce9fe1d612398df0cfc49f0 100644 (file)
 </category>
 
 <xi:include href="OES_EGL_image.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+<xi:include href="EXT_EGL_image_storage.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
 <xi:include href="EXT_texture_integer.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
 
index 22bdf003544c654bc4ee857f719282d9bce127c8..d2a9c66b4cd6bcf4a3be49b480cb15f001fe5450 100644 (file)
@@ -1638,6 +1638,8 @@ offsets = {
     "IsNamedStringARB": 1602,
     "GetNamedStringARB": 1603,
     "GetNamedStringivARB": 1604,
+    "EGLImageTargetTexStorageEXT" : 1605,
+    "EGLImageTargetTextureStorageEXT" : 1606,
 }
 
 functions = [
index 8251af3f667d55f8be61299742a9509eb08e9a25..72af158dd07cd43aff23a2000768b8cffed39c26 100644 (file)
@@ -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
     */
index 2402f34f5616e70394437234de039aa17d0a20e7..7905232b429676bf95738f18fcd8c41eb1521c56 100644 (file)
@@ -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)
index 02766d3acede52d8b851e32d15e423b6f917cb36..c3cee09549f9009f2887ccc929509cd899880823 100644 (file)
@@ -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;
index c1c293b843a3f33b299aebe6c020f8526f08cb4f..7298aa663082ac2fb772ffed446ebbe9e3e8524c 100644 (file)
@@ -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 }
 };
 
index 263c473195bf29746aba19ccd79beb59d0b455a4..65952bca5fafa0f019390fd75ce47d82d9a51aac 100644 (file)
@@ -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:
+    *
+    * "<attrib_list> 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);
 }
 
 /**
index bd835883774caf2cadd62632cf4c4b5cdd84f5f6..ee4b1ac859550c1c3b52e7a2f49c1bea3e269a00 100644 (file)
@@ -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,