OSDN Git Service

es: Add support for GL_OES_EGL_image.
authorChia-I Wu <olvaffe@gmail.com>
Mon, 14 Sep 2009 05:51:54 +0000 (13:51 +0800)
committerChia-I Wu <olvaffe@gmail.com>
Mon, 14 Sep 2009 08:05:46 +0000 (16:05 +0800)
src/mesa/es/main/APIspec.txt
src/mesa/es/main/eglimage.c [new file with mode: 0644]
src/mesa/es/main/eglimage.h [new file with mode: 0644]
src/mesa/es/main/mfeatures.h
src/mesa/es/main/specials_es1.c
src/mesa/es/sources.mak
src/mesa/main/dd.h
src/mesa/main/extensions.c
src/mesa/main/mtypes.h

index f102e70..08ce699 100644 (file)
@@ -2939,6 +2939,22 @@ convertalias    DrawTexfv
 convertparams   GLfloat         coords
 category        GLES1.1:OES_draw_texture
 
+name            EGLImageTargetTexture2D
+alias           EGLImageTargetTexture2DOES
+return          void
+param           target          GLenum
+param           image           GLeglImageOES
+checkparam      target          GL_TEXTURE_2D
+category        GLES1.1:OES_EGL_image GLES2.0:OES_EGL_image
+
+name            EGLImageTargetRenderbufferStorage
+alias           EGLImageTargetRenderbufferStorageOES
+return          void
+param           target          GLenum
+param           image           GLeglImageOES
+checkparam      target          GLES1.1:GL_RENDERBUFFER_OES GLES2.0:GL_RENDERBUFFER
+category        GLES1.1:OES_EGL_image GLES2.0:OES_EGL_image
+
 # We don't support OES_get_program_binary yet either
 #name GetProgramBinary
 #return void
diff --git a/src/mesa/es/main/eglimage.c b/src/mesa/es/main/eglimage.c
new file mode 100644 (file)
index 0000000..5dd7a0c
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "main/mtypes.h"
+#include "main/context.h"
+#include "main/teximage.h"
+#include "main/texstate.h"
+#include "main/imports.h"
+#include "glapi/dispatch.h"
+
+#include "eglimage.h"
+
+
+#if FEATURE_OES_EGL_image
+
+
+void GLAPIENTRY
+_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_renderbuffer *rb;
+
+   if (!ctx->Extensions.OES_EGL_image) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glEGLImageTargetRenderbufferStorageOES(unsupported)");
+      return;
+   }
+
+   if (target != GL_RENDERBUFFER) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "glEGLImageTargetRenderbufferStorage(target=0x%x)", target);
+      return;
+   }
+
+   rb = ctx->CurrentRenderbuffer;
+   if (!rb) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glEGLImageTargetRenderbufferStorageOES(no bound rb)");
+      return;
+   }
+
+   FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+   ASSERT(ctx->Driver.EGLImageTargetRenderbufferStorage);
+   ctx->Driver.EGLImageTargetRenderbufferStorage(ctx, rb, image);
+   /* invalidate fbo? */
+}
+
+void GLAPIENTRY _mesa_EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   struct gl_texture_unit *texUnit;
+   struct gl_texture_object *texObj;
+
+   if (!ctx->Extensions.OES_EGL_image) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glEGLImageTargetTexture2DOES(unsupported)");
+      return;
+   }
+
+   if (target != GL_TEXTURE_2D) {
+      _mesa_error(ctx, GL_INVALID_ENUM,
+                  "glEGLImageTargetTexture2D(target=0x%x)", target);
+      return;
+   }
+
+   ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+   texUnit = _mesa_get_current_tex_unit(ctx);
+   texObj = _mesa_select_tex_object(ctx, texUnit, target);
+
+   _mesa_lock_texture(ctx, texObj);
+
+   ASSERT(ctx->Driver.EGLImageTargetTexture2D);
+   ctx->Driver.EGLImageTargetTexture2D(ctx, texObj ,image);
+
+   /* invalidate state and fbo?*/
+   /* fbo? */
+   texObj->_Complete = GL_FALSE;
+   ctx->NewState |= _NEW_TEXTURE;
+
+   _mesa_unlock_texture(ctx, texObj);
+}
+
+
+void
+_mesa_init_eglimage_dispatch(struct _glapi_table *disp)
+{
+   SET_EGLImageTargetRenderbufferStorageOES(disp,
+         _mesa_EGLImageTargetRenderbufferStorageOES);
+   SET_EGLImageTargetTexture2DOES(disp, _mesa_EGLImageTargetTexture2DOES);
+}
+
+
+#endif /* FEATURE_OES_EGL_image */
diff --git a/src/mesa/es/main/eglimage.h b/src/mesa/es/main/eglimage.h
new file mode 100644 (file)
index 0000000..7acb991
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 Chia-I Wu <olvaffe@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef EGLIMAGE_H
+#define EGLIMAGE_H
+
+
+#include "main/mtypes.h"
+
+
+#if FEATURE_OES_EGL_image
+
+#define _MESA_INIT_EGLIMAGE_FUNCTIONS(driver, impl)                        \
+   do {                                                                    \
+      (driver)->EGLImageTargetRenderbufferStorage =                        \
+                        impl ## EGLImageTargetRenderbufferStorage;         \
+      (driver)->EGLImageTargetTexture2D = impl ## EGLImageTargetTexture2D; \
+   } while (0)
+
+extern void GLAPIENTRY
+_mesa_EGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
+
+extern void GLAPIENTRY
+_mesa_EGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
+
+extern void
+_mesa_init_eglimage_dispatch(struct _glapi_table *disp);
+
+#else /* FEATURE_OES_EGL_image */
+
+#define _MESA_INIT_EGLIMAGE_FUNCTIONS(driver, impl) do { } while (0)
+
+static INLINE void
+_mesa_init_eglimage_dispatch(struct _glapi_table *disp)
+{
+}
+
+#endif /* FEATURE_OES_EGL_image */
+
+
+#endif /* EGLIMAGE_H */
index 0f69682..28f376d 100644 (file)
@@ -98,6 +98,7 @@
 #define FEATURE_NV_fragment_program 0
 #define FEATURE_NV_vertex_program 0
 
+#define FEATURE_OES_EGL_image 1
 #define FEATURE_OES_framebuffer_object 1
 #define FEATURE_OES_draw_texture 1
 #define FEATURE_OES_mapbuffer 1
index 0792dcf..02c3247 100644 (file)
@@ -100,6 +100,9 @@ make_extension_string(const GLcontext *ctx, char *str)
    /* 1.1 deprecated extensions */
    len += append_extension(&str, "GL_OES_query_matrix");
 
+   if (ctx->Extensions.OES_EGL_image)
+      len += append_extension(&str, "GL_OES_EGL_image");
+
    if (ctx->Extensions.OES_draw_texture)
       len += append_extension(&str, "GL_OES_draw_texture");
 
index b52978b..6d20740 100644 (file)
@@ -3,6 +3,7 @@
 ES1_LOCAL_SOURCES :=                   \
        main/api_exec_es1.c             \
        main/drawtex.c                  \
+       main/eglimage.c                 \
        main/get_es1.c                  \
        main/specials_es1.c             \
        main/es_cpaltex.c               \
@@ -23,6 +24,7 @@ ES1_LOCAL_INCLUDES :=                 \
 
 ES2_LOCAL_SOURCES :=                   \
        main/api_exec_es2.c             \
+       main/eglimage.c                 \
        main/get_es2.c                  \
        main/specials_es2.c             \
        main/es_cpaltex.c               \
index afcab5b..307ecd3 100644 (file)
@@ -1070,6 +1070,19 @@ struct dd_function_table {
                    GLfloat width, GLfloat height);
    /*@}*/
 #endif
+#if FEATURE_OES_EGL_image
+   /**
+    * \name GL_OES_EGL_image interface
+    */
+   /*@{*/
+   void (*EGLImageTargetRenderbufferStorage)(GLcontext *ctx,
+                                             struct gl_renderbuffer *rb,
+                                             GLvoid *image);
+   void (*EGLImageTargetTexture2D)(GLcontext *ctx,
+                                   struct gl_texture_object *texObj,
+                                   GLvoid *image);
+   /*@}*/
+#endif
 };
 
 
index 7e28974..5b54c1c 100644 (file)
@@ -186,6 +186,9 @@ static const struct {
 #if FEATURE_OES_draw_texture
    { OFF, "GL_OES_draw_texture",               F(OES_draw_texture) },
 #endif /* FEATURE_OES_draw_texture */
+#if FEATURE_OES_EGL_image
+   { OFF, "GL_OES_EGL_image",                  F(OES_EGL_image) },
+#endif
 };
 
 
index bebb3e5..6ce9ae1 100644 (file)
@@ -2602,6 +2602,9 @@ struct gl_extensions
 #if FEATURE_OES_draw_texture
    GLboolean OES_draw_texture;
 #endif /* FEATURE_OES_draw_texture */
+#if FEATURE_OES_EGL_image
+   GLboolean OES_EGL_image;
+#endif
    /** The extension string */
    const GLubyte *String;
 };