summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2009-09-14 13:51:54 +0800
committerChia-I Wu <olvaffe@gmail.com>2009-09-14 16:05:46 +0800
commitc4a8ce7ffdf603c515b5202e2322e1b965f69f3a (patch)
tree9002ed93d3b9855e89be60ceb63426fc513eb875 /src/mesa
parent9199889374164c0541f3f7202c4dedb40a6b7458 (diff)
es: Add support for GL_OES_EGL_image.
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/es/main/APIspec.txt16
-rw-r--r--src/mesa/es/main/eglimage.c115
-rw-r--r--src/mesa/es/main/eglimage.h61
-rw-r--r--src/mesa/es/main/mfeatures.h1
-rw-r--r--src/mesa/es/main/specials_es1.c3
-rw-r--r--src/mesa/es/sources.mak2
-rw-r--r--src/mesa/main/dd.h13
-rw-r--r--src/mesa/main/extensions.c3
-rw-r--r--src/mesa/main/mtypes.h3
9 files changed, 217 insertions, 0 deletions
diff --git a/src/mesa/es/main/APIspec.txt b/src/mesa/es/main/APIspec.txt
index f102e7083c..08ce699696 100644
--- a/src/mesa/es/main/APIspec.txt
+++ b/src/mesa/es/main/APIspec.txt
@@ -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
index 0000000000..5dd7a0cfaa
--- /dev/null
+++ b/src/mesa/es/main/eglimage.c
@@ -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
index 0000000000..7acb991200
--- /dev/null
+++ b/src/mesa/es/main/eglimage.h
@@ -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 */
diff --git a/src/mesa/es/main/mfeatures.h b/src/mesa/es/main/mfeatures.h
index 0f696824d0..28f376d2d1 100644
--- a/src/mesa/es/main/mfeatures.h
+++ b/src/mesa/es/main/mfeatures.h
@@ -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
diff --git a/src/mesa/es/main/specials_es1.c b/src/mesa/es/main/specials_es1.c
index 0792dcfa97..02c3247e94 100644
--- a/src/mesa/es/main/specials_es1.c
+++ b/src/mesa/es/main/specials_es1.c
@@ -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");
diff --git a/src/mesa/es/sources.mak b/src/mesa/es/sources.mak
index b52978be96..6d20740095 100644
--- a/src/mesa/es/sources.mak
+++ b/src/mesa/es/sources.mak
@@ -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 \
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index afcab5bf2b..307ecd3d8b 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -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
};
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 7e289743ce..5b54c1cf8c 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -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
};
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index bebb3e56a6..6ce9ae1d6a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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;
};