summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasiliy Ulyanov <v.ulyanov@samsung.com>2016-02-01 18:32:47 +0300
committerVasiliy Ulyanov <v.ulyanov@samsung.com>2016-05-24 14:34:36 +0300
commitd98c8ec78b523aec19bab5a1125fbe0ca7939e32 (patch)
tree35998751ed4d9e317b0024c67ed80fafed0b88f6
parent917838c32271ac715870c17c4bced682c432e965 (diff)
downloademulator-yagl-d98c8ec78b523aec19bab5a1125fbe0ca7939e32.tar.gz
emulator-yagl-d98c8ec78b523aec19bab5a1125fbe0ca7939e32.tar.bz2
emulator-yagl-d98c8ec78b523aec19bab5a1125fbe0ca7939e32.zip
YaGL: Implement GL_OES_EGL_image_external extension
Currently external textures are handled as 2d textures since host will unlikely recognize GL_TEXTURE_EXTERNAL_OES as a valid target. The same applies to GLSL (i.e. sampler2D is used instead of samplerExternalOES). Color conversion is performed in software and it is done when glEGLImageTargetTexture2DOES function is called. It is an initial implementation and at the moment it is not fully conformant. Change-Id: I6a781d1062a2f5373e8ff507a5279c58ed29b042 Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
-rw-r--r--EGL/yagl_onscreen_image_tizen_sfc.c192
-rw-r--r--EGL/yagl_onscreen_image_tizen_sfc.h5
-rw-r--r--GLES_common/yagl_gles_calls.c21
-rw-r--r--GLES_common/yagl_gles_context.c15
-rw-r--r--GLES_common/yagl_gles_texture.c14
-rw-r--r--GLES_common/yagl_gles_texture.h2
-rw-r--r--GLES_common/yagl_gles_texture_unit.c5
-rw-r--r--GLES_common/yagl_gles_types.h3
-rw-r--r--GLESv1_CM/yagl_gles1_context.c11
-rw-r--r--GLESv2/yagl_gles2_context.c2
-rw-r--r--GLESv2/yagl_glsl_lexer.l6
-rw-r--r--GLESv2/yagl_glsl_parser.y6
-rw-r--r--include/yagl_sharegroup.h2
13 files changed, 265 insertions, 19 deletions
diff --git a/EGL/yagl_onscreen_image_tizen_sfc.c b/EGL/yagl_onscreen_image_tizen_sfc.c
index 2ff5242..aa750b3 100644
--- a/EGL/yagl_onscreen_image_tizen_sfc.c
+++ b/EGL/yagl_onscreen_image_tizen_sfc.c
@@ -33,6 +33,7 @@
#include "yagl_onscreen_image_tizen_sfc.h"
#include "yagl_display.h"
+#include "yagl_native_display.h"
#include "yagl_log.h"
#include "yagl_malloc.h"
#include "yagl_host_egl_calls.h"
@@ -45,9 +46,97 @@
#include <tbm_bufmgr_backend.h>
#include <tbm_surface.h>
#include <tbm_surface_internal.h>
+#include <string.h>
+
+static inline uint32_t yuv2argb(float y, float u, float v)
+{
+ int32_t r, g, b;
+
+ r = y + 1.402 * (v - 128);
+ g = y - 0.344 * (u - 128) - 0.714 * (v - 128);
+ b = y + 1.772 * (u - 128);
+
+ r = r < 0 ? 0 : (r > 255 ? 255 : r);
+ g = g < 0 ? 0 : (g > 255 ? 255 : g);
+ b = b < 0 ? 0 : (b > 255 ? 255 : b);
+
+ return (0xff000000 | (r << 16) | (g << 8) | b);
+}
+
+/* TODO need to think about HW convertion */
+static bool yagl_onscreen_image_tizen_sfc_convert(struct yagl_onscreen_image_tizen_sfc *image)
+{
+ uint32_t *dst;
+ float y, u, v;
+ int i, j;
+ tbm_surface_info_s info;
+ int ret;
+
+ YAGL_LOG_FUNC_SET(yagl_onscreen_image_tizen_sfc_convert);
+
+ if (!image->planar) {
+ return true;
+ }
+
+ ret = tbm_surface_map(image->sfc, TBM_SURF_OPTION_READ, &info);
+
+ if (ret != TBM_SURFACE_ERROR_NONE) {
+ YAGL_LOG_ERROR("tbm_surface_map failed: %d", ret);
+ return false;
+ }
+
+ ret = vigs_drm_surface_start_access(image->drm_sfc, VIGS_DRM_SAF_WRITE);
+
+ if (ret) {
+ YAGL_LOG_ERROR("vigs_drm_surface_start_access failed: %s", strerror(-ret));
+ tbm_surface_unmap(image->sfc);
+ return false;
+ }
+
+ dst = image->drm_sfc->gem.vaddr;
+
+ switch (info.format) {
+ case TBM_FORMAT_NV21:
+ for (i = 0; i < info.height; i++) {
+ for (j = 0; j < info.width; j++) {
+ y = info.planes[0].ptr[i * info.width + j];
+ v = info.planes[1].ptr[i * info.width / 2 + (j & ~1) + 0];
+ u = info.planes[1].ptr[i * info.width / 2 + (j & ~1) + 1];
+
+ *dst++ = yuv2argb(y, u, v);
+ }
+ }
+ break;
+ case TBM_FORMAT_YUV420:
+ for (i = 0; i < info.height; i++) {
+ for (j = 0; j < info.width; j++) {
+ y = info.planes[0].ptr[i * info.width + j];
+ u = info.planes[1].ptr[(i / 2) * (info.width / 2) + (j / 2)];
+ v = info.planes[2].ptr[(i / 2) * (info.width / 2) + (j / 2)];
+
+ *dst++ = yuv2argb(y, u, v);
+ }
+ }
+ break;
+ }
+
+ ret = vigs_drm_surface_end_access(image->drm_sfc, 1);
+
+ if (ret) {
+ YAGL_LOG_ERROR("vigs_drm_surface_end_access failed: %s", strerror(-ret));
+ }
+
+ tbm_surface_unmap(image->sfc);
+
+ return true;
+}
static void yagl_onscreen_image_tizen_sfc_update(struct yagl_image *image)
{
+ struct yagl_onscreen_image_tizen_sfc *tizen_sfc_image =
+ (struct yagl_onscreen_image_tizen_sfc *)image;
+
+ yagl_onscreen_image_tizen_sfc_convert(tizen_sfc_image);
}
static void yagl_onscreen_image_tizen_sfc_destroy(struct yagl_ref *ref)
@@ -56,12 +145,13 @@ static void yagl_onscreen_image_tizen_sfc_destroy(struct yagl_ref *ref)
vigs_drm_gem_unref(&image->drm_sfc->gem);
+ tbm_surface_internal_unref(image->sfc);
+
yagl_image_cleanup(&image->base);
yagl_free(image);
}
-
struct yagl_onscreen_image_tizen_sfc
*yagl_onscreen_image_tizen_sfc_create(struct yagl_display *dpy,
EGLClientBuffer buffer,
@@ -70,34 +160,106 @@ struct yagl_onscreen_image_tizen_sfc
EGLint error = 0;
yagl_object_name tex_global_name = yagl_get_global_name();
struct yagl_client_image *client_image;
- struct yagl_onscreen_image_tizen_sfc *image;
- struct vigs_drm_surface *drm_sfc;
+ struct yagl_onscreen_image_tizen_sfc *image = NULL;
+ struct vigs_drm_surface *drm_sfc = NULL;
tbm_surface_h sfc;
tbm_bo bo;
+ tbm_surface_info_s info;
+ bool planar;
+ int ret;
- image = yagl_malloc0(sizeof(*image));
+ YAGL_LOG_FUNC_SET(yagl_onscreen_image_tizen_sfc_create);
sfc = (tbm_surface_h)buffer;
- bo = tbm_surface_internal_get_bo(sfc, 0);
- drm_sfc = bo ? tbm_backend_get_bo_priv(bo) : NULL;
- if (!drm_sfc || (tbm_surface_internal_get_num_bos(sfc) != 1)) {
+ tbm_surface_internal_ref(sfc);
+
+ ret = tbm_surface_get_info(sfc, &info);
+
+ if (ret != TBM_SURFACE_ERROR_NONE) {
+ YAGL_LOG_ERROR("tbm_surface_get_info failed: %d", ret);
yagl_set_error(EGL_BAD_PARAMETER);
goto fail;
}
- vigs_drm_gem_ref(&drm_sfc->gem);
+ switch (info.format) {
+ case TBM_FORMAT_RGB888:
+ case TBM_FORMAT_ARGB8888:
+ case TBM_FORMAT_XRGB8888:
+ planar = false;
+ break;
+ case TBM_FORMAT_NV21:
+ case TBM_FORMAT_YUV420:
+ planar = true;
+ break;
+ default:
+ YAGL_LOG_ERROR("bad format: 0x%X", info.format);
+ yagl_set_error(EGL_BAD_PARAMETER);
+ goto fail;
+ }
+
+ if (planar) {
+ ret = vigs_drm_surface_create(dpy->native_dpy->drm_dev,
+ info.width,
+ info.height,
+ info.width * 4,
+ vigs_drm_surface_bgra8888,
+ 0,
+ &drm_sfc);
+
+ if (ret) {
+ YAGL_LOG_ERROR("vigs_drm_surface_create failed: %s", strerror(-ret));
+ yagl_set_error(EGL_BAD_ALLOC);
+ goto fail;
+ }
+
+ ret = vigs_drm_gem_get_name(&drm_sfc->gem);
+
+ if (ret) {
+ YAGL_LOG_ERROR("vigs_drm_gem_get_name failed: %s", strerror(-ret));
+ yagl_set_error(EGL_BAD_ALLOC);
+ goto fail;
+ }
+
+ ret = vigs_drm_gem_map(&drm_sfc->gem, 1);
+
+ if (ret) {
+ YAGL_LOG_ERROR("vigs_drm_gem_map failed: %s", strerror(-ret));
+ yagl_set_error(EGL_BAD_ALLOC);
+ goto fail;
+ }
+ } else {
+ if (tbm_surface_internal_get_num_bos(sfc) < 1) {
+ YAGL_LOG_ERROR("tbm_surface_internal_get_num_bos < 1");
+ yagl_set_error(EGL_BAD_PARAMETER);
+ goto fail;
+ }
+
+ bo = tbm_surface_internal_get_bo(sfc, 0);
+ drm_sfc = bo ? tbm_backend_get_bo_priv(bo) : NULL;
+
+ if (!drm_sfc) {
+ YAGL_LOG_ERROR("drm_sfc is NULL");
+ yagl_set_error(EGL_BAD_PARAMETER);
+ goto fail;
+ }
+
+ vigs_drm_gem_ref(&drm_sfc->gem);
+ }
if (!yagl_host_eglCreateImageYAGL(tex_global_name,
dpy->host_dpy,
drm_sfc->id,
&error)) {
+ YAGL_LOG_ERROR("yagl_host_eglCreateImageYAGL failed: %d", error);
yagl_set_error(error);
goto fail;
}
client_image = iface->create_image(iface, tex_global_name);
+ image = yagl_malloc0(sizeof(*image));
+
yagl_image_init(&image->base,
&yagl_onscreen_image_tizen_sfc_destroy,
dpy,
@@ -107,8 +269,20 @@ struct yagl_onscreen_image_tizen_sfc
yagl_client_image_release(client_image);
image->base.update = &yagl_onscreen_image_tizen_sfc_update;
+ image->sfc = sfc;
+ image->planar = planar;
image->drm_sfc = drm_sfc;
+ YAGL_LOG_DEBUG("%ux%u/%u, sfc_id = %u, planar = %d (0x%X), num_planes = %u, size = %u",
+ info.width,
+ info.height,
+ info.bpp,
+ drm_sfc->id,
+ planar,
+ info.format,
+ info.num_planes,
+ info.size);
+
return image;
fail:
@@ -118,5 +292,7 @@ fail:
yagl_free(image);
+ tbm_surface_internal_unref(sfc);
+
return NULL;
}
diff --git a/EGL/yagl_onscreen_image_tizen_sfc.h b/EGL/yagl_onscreen_image_tizen_sfc.h
index d07eb69..ccd3a39 100644
--- a/EGL/yagl_onscreen_image_tizen_sfc.h
+++ b/EGL/yagl_onscreen_image_tizen_sfc.h
@@ -36,6 +36,7 @@
#include "yagl_image.h"
#include "EGL/egl.h"
+#include <tbm_surface.h>
struct yagl_client_interface;
struct vigs_drm_surface;
@@ -44,6 +45,10 @@ struct yagl_onscreen_image_tizen_sfc
{
struct yagl_image base;
+ tbm_surface_h sfc;
+
+ bool planar;
+
struct vigs_drm_surface *drm_sfc;
};
diff --git a/GLES_common/yagl_gles_calls.c b/GLES_common/yagl_gles_calls.c
index c79c2c1..90ece0b 100644
--- a/GLES_common/yagl_gles_calls.c
+++ b/GLES_common/yagl_gles_calls.c
@@ -59,6 +59,8 @@
#include <string.h>
#include <assert.h>
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+
#define YAGL_SET_ERR(err) \
yagl_gles_context_set_error(ctx, err); \
YAGL_LOG_ERROR("error = 0x%X", err)
@@ -1449,7 +1451,11 @@ void glGenerateMipmap(GLenum target)
YAGL_GET_CTX();
- yagl_host_glGenerateMipmap(target);
+ if (target == GL_TEXTURE_EXTERNAL_OES) {
+ YAGL_SET_ERR(GL_INVALID_ENUM);
+ } else {
+ yagl_host_glGenerateMipmap(target);
+ }
YAGL_LOG_FUNC_EXIT(NULL);
}
@@ -2420,12 +2426,20 @@ YAGL_API void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
struct yagl_gles_image *image_obj = NULL;
struct yagl_gles_texture_target_state *tex_target_state;
+ yagl_gles_texture_target texture_target;
YAGL_LOG_FUNC_ENTER_SPLIT2(glEGLImageTargetTexture2DOES, GLenum, GLeglImageOES, target, image);
YAGL_GET_CTX();
- if (target != GL_TEXTURE_2D) {
+ switch (target) {
+ case GL_TEXTURE_2D:
+ texture_target = yagl_gles_texture_target_2d;
+ break;
+ case GL_TEXTURE_EXTERNAL_OES:
+ texture_target = yagl_gles_texture_target_external_oes;
+ break;
+ default:
YAGL_SET_ERR(GL_INVALID_ENUM);
goto out;
}
@@ -2438,8 +2452,7 @@ YAGL_API void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
}
tex_target_state =
- yagl_gles_context_get_active_texture_target_state(ctx,
- yagl_gles_texture_target_2d);
+ yagl_gles_context_get_active_texture_target_state(ctx, texture_target);
if (tex_target_state->texture == tex_target_state->texture_zero) {
YAGL_SET_ERR(GL_INVALID_OPERATION);
diff --git a/GLES_common/yagl_gles_context.c b/GLES_common/yagl_gles_context.c
index 9e43e3b..3b6f14d 100644
--- a/GLES_common/yagl_gles_context.c
+++ b/GLES_common/yagl_gles_context.c
@@ -61,6 +61,9 @@
*/
#define GL_HALF_FLOAT_OES 0x8D61
#define GL_RGB565_OES 0x8D62
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67
+#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68
#define YAGL_SET_ERR(err) \
yagl_gles_context_set_error(ctx, err); \
@@ -510,6 +513,9 @@ int yagl_gles_context_validate_texture_target(struct yagl_gles_context *ctx,
case GL_TEXTURE_2D:
*texture_target = yagl_gles_texture_target_2d;
break;
+ case GL_TEXTURE_EXTERNAL_OES:
+ *texture_target = yagl_gles_texture_target_external_oes;
+ break;
default:
return ctx->validate_texture_target(ctx, target, texture_target);
}
@@ -1503,6 +1509,12 @@ int yagl_gles_context_get_integerv(struct yagl_gles_context *ctx,
*params = tts->texture->base.local_name;
*num_params = 1;
break;
+ case GL_TEXTURE_BINDING_EXTERNAL_OES:
+ tts = yagl_gles_context_get_active_texture_target_state(ctx,
+ yagl_gles_texture_target_external_oes);
+ *params = tts->texture->base.local_name;
+ *num_params = 1;
+ break;
case GL_ARRAY_BUFFER_BINDING:
*params = ctx->vbo ? ctx->vbo->base.local_name : 0;
*num_params = 1;
@@ -2401,6 +2413,9 @@ int yagl_gles_context_get_tex_parameteriv(struct yagl_gles_context *ctx,
case GL_TEXTURE_IMMUTABLE_FORMAT:
params[0] = texture_obj->immutable;
return 1;
+ case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES:
+ params[0] = texture_obj->num_image_units;
+ return 1;
default:
break;
}
diff --git a/GLES_common/yagl_gles_texture.c b/GLES_common/yagl_gles_texture.c
index df8a0fe..ff5f608 100644
--- a/GLES_common/yagl_gles_texture.c
+++ b/GLES_common/yagl_gles_texture.c
@@ -44,6 +44,7 @@
* We can't include GLES2/gl2ext.h here
*/
#define GL_HALF_FLOAT_OES 0x8D61
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
static void yagl_gles_texture_swizzle(struct yagl_gles_texture *texture,
GLenum internalformat)
@@ -129,6 +130,7 @@ struct yagl_gles_texture *yagl_gles_texture_create(void)
texture->global_name = yagl_get_global_name();
texture->min_filter = GL_NEAREST_MIPMAP_LINEAR;
texture->mag_filter = GL_LINEAR;
+ texture->num_image_units = 1;
yagl_host_glGenTextures(&texture->global_name, 1);
@@ -156,7 +158,8 @@ int yagl_gles_texture_bind(struct yagl_gles_texture *texture,
return 0;
}
- yagl_host_glBindTexture(target, texture->global_name);
+ yagl_host_glBindTexture(target == GL_TEXTURE_EXTERNAL_OES ? GL_TEXTURE_2D : target,
+ texture->global_name);
texture->target = target;
@@ -260,7 +263,8 @@ void yagl_gles_texture_set_image(struct yagl_gles_texture *texture,
texture->global_name = image->tex_global_name;
texture->image = image;
- yagl_host_glBindTexture(texture->target, texture->global_name);
+ yagl_host_glBindTexture(texture->target == GL_TEXTURE_EXTERNAL_OES ? GL_TEXTURE_2D : texture->target,
+ texture->global_name);
}
void yagl_gles_texture_unset_image(struct yagl_gles_texture *texture)
@@ -277,7 +281,8 @@ void yagl_gles_texture_unset_image(struct yagl_gles_texture *texture)
texture->global_name = yagl_get_global_name();
yagl_host_glGenTextures(&texture->global_name, 1);
- yagl_host_glBindTexture(texture->target, texture->global_name);
+ yagl_host_glBindTexture(texture->target == GL_TEXTURE_EXTERNAL_OES ? GL_TEXTURE_2D : texture->target,
+ texture->global_name);
}
}
@@ -305,7 +310,8 @@ void yagl_gles_texture_bind_tex_image(struct yagl_gles_texture *texture,
texture->image = image;
texture->binding = binding;
- yagl_host_glBindTexture(texture->target, texture->global_name);
+ yagl_host_glBindTexture(texture->target == GL_TEXTURE_EXTERNAL_OES ? GL_TEXTURE_2D : texture->target,
+ texture->global_name);
}
/*
diff --git a/GLES_common/yagl_gles_texture.h b/GLES_common/yagl_gles_texture.h
index a693063..bf5e1eb 100644
--- a/GLES_common/yagl_gles_texture.h
+++ b/GLES_common/yagl_gles_texture.h
@@ -59,6 +59,8 @@ struct yagl_gles_texture
GLenum min_filter;
GLenum mag_filter;
+ GLint num_image_units;
+
/*
* Non-NULL if it's an EGLImage/eglBindTexImage target.
*/
diff --git a/GLES_common/yagl_gles_texture_unit.c b/GLES_common/yagl_gles_texture_unit.c
index 537442a..cd9f638 100644
--- a/GLES_common/yagl_gles_texture_unit.c
+++ b/GLES_common/yagl_gles_texture_unit.c
@@ -38,12 +38,15 @@
#include "yagl_gles_sampler.h"
#include <string.h>
+#define GL_TEXTURE_EXTERNAL_OES 0x8D65
+
static const GLenum target_map[] =
{
GL_TEXTURE_2D,
GL_TEXTURE_2D_ARRAY,
GL_TEXTURE_3D,
- GL_TEXTURE_CUBE_MAP
+ GL_TEXTURE_CUBE_MAP,
+ GL_TEXTURE_EXTERNAL_OES
};
void yagl_gles_texture_unit_init(struct yagl_gles_texture_unit *texture_unit,
diff --git a/GLES_common/yagl_gles_types.h b/GLES_common/yagl_gles_types.h
index c3a282f..87ce56b 100644
--- a/GLES_common/yagl_gles_types.h
+++ b/GLES_common/yagl_gles_types.h
@@ -43,7 +43,8 @@ typedef enum
yagl_gles_texture_target_2d = 0,
yagl_gles_texture_target_2d_array = 1,
yagl_gles_texture_target_3d = 2,
- yagl_gles_texture_target_cubemap = 3
+ yagl_gles_texture_target_cubemap = 3,
+ yagl_gles_texture_target_external_oes = 4
} yagl_gles_texture_target;
typedef enum
diff --git a/GLESv1_CM/yagl_gles1_context.c b/GLESv1_CM/yagl_gles1_context.c
index 46964d5..d2af36a 100644
--- a/GLESv1_CM/yagl_gles1_context.c
+++ b/GLESv1_CM/yagl_gles1_context.c
@@ -83,6 +83,7 @@ static const GLchar *stencil1_ext = "GL_OES_stencil1";
static const GLchar *stencil4_ext = "GL_OES_stencil4";
static const GLchar *stencil8_ext = "GL_OES_stencil8";
static const GLchar *egl_image_ext = "GL_OES_EGL_image";
+static const GLchar *egl_image_external_ext = "GL_OES_EGL_image_external";
static const GLchar *framebuffer_blit_ext = "GL_ANGLE_framebuffer_blit";
static const GLchar *draw_buffers_ext = "GL_EXT_draw_buffers";
static const GLchar *mapbuffer_ext = "GL_OES_mapbuffer";
@@ -128,6 +129,7 @@ static const GLchar **yagl_gles1_context_get_extensions(struct yagl_gles1_contex
extensions[i++] = stencil4_ext;
extensions[i++] = stencil8_ext;
extensions[i++] = egl_image_ext;
+ extensions[i++] = egl_image_external_ext;
extensions[i++] = framebuffer_blit_ext;
extensions[i++] = draw_buffers_ext;
extensions[i++] = mapbuffer_ext;
@@ -856,6 +858,10 @@ static int yagl_gles1_context_enable(struct yagl_gles_context *ctx,
yagl_gles_context_active_texture_set_enabled(ctx,
yagl_gles_texture_target_2d, enable);
break;
+ case GL_TEXTURE_EXTERNAL_OES:
+ yagl_gles_context_active_texture_set_enabled(ctx,
+ yagl_gles_texture_target_external_oes, enable);
+ break;
case GL_ALPHA_TEST:
case GL_COLOR_LOGIC_OP:
case GL_COLOR_MATERIAL:
@@ -901,6 +907,11 @@ static int yagl_gles1_context_is_enabled(struct yagl_gles_context *ctx,
yagl_gles_texture_target_2d);
*enabled = tts->enabled;
return 1;
+ case GL_TEXTURE_EXTERNAL_OES:
+ tts = yagl_gles_context_get_active_texture_target_state(ctx,
+ yagl_gles_texture_target_external_oes);
+ *enabled = tts->enabled;
+ return 1;
case GL_VERTEX_ARRAY:
case GL_NORMAL_ARRAY:
case GL_COLOR_ARRAY:
diff --git a/GLESv2/yagl_gles2_context.c b/GLESv2/yagl_gles2_context.c
index f9591e2..0949ccf 100644
--- a/GLESv2/yagl_gles2_context.c
+++ b/GLESv2/yagl_gles2_context.c
@@ -67,6 +67,7 @@
#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
static const GLchar *egl_image_ext = "GL_OES_EGL_image";
+static const GLchar *egl_image_external_ext = "GL_OES_EGL_image_external";
static const GLchar *depth24_ext = "GL_OES_depth24";
static const GLchar *depth32_ext = "GL_OES_depth32";
static const GLchar *texture_float_ext = "GL_OES_texture_float";
@@ -343,6 +344,7 @@ const GLchar **yagl_gles2_context_get_extensions(struct yagl_gles2_context *ctx,
extensions = yagl_malloc(100 * sizeof(*extensions));
extensions[i++] = egl_image_ext;
+ extensions[i++] = egl_image_external_ext;
extensions[i++] = depth24_ext;
extensions[i++] = depth32_ext;
extensions[i++] = texture_float_ext;
diff --git a/GLESv2/yagl_glsl_lexer.l b/GLESv2/yagl_glsl_lexer.l
index b3508d6..fdca03e 100644
--- a/GLESv2/yagl_glsl_lexer.l
+++ b/GLESv2/yagl_glsl_lexer.l
@@ -193,6 +193,12 @@ STRING [^ \r\t\v\f\n()\[\]{},;?:/%*&|^!+\-=<>\.]+
return TOK_GLFRAGCOLOR;
}
+"samplerExternalOES" {
+ struct yagl_glsl_state *state = yagl_glsl_lexer_get_extra(yyscanner);
+ yagl_glsl_state_new_str_token(state, yylval, yytext);
+ return TOK_SAMPLEREXTERNALOES;
+}
+
{PRECISION} {
struct yagl_glsl_state *state = yagl_glsl_lexer_get_extra(yyscanner);
yagl_glsl_state_new_str_token(state, yylval, yytext);
diff --git a/GLESv2/yagl_glsl_parser.y b/GLESv2/yagl_glsl_parser.y
index 9f71e0f..93049a7 100644
--- a/GLESv2/yagl_glsl_parser.y
+++ b/GLESv2/yagl_glsl_parser.y
@@ -69,6 +69,7 @@ static int yagl_glsl_lex(union YYSTYPE *val, struct yagl_glsl_state *state)
%token <str> TOK_TEXTURECUBE
%token <str> TOK_TEXTURECUBELOD
%token <str> TOK_GLFRAGCOLOR
+%token <str> TOK_SAMPLEREXTERNALOES
%%
@@ -590,4 +591,9 @@ expression
yagl_glsl_state_append_output(state, $1.value);
}
}
+| TOK_SAMPLEREXTERNALOES
+{
+ yagl_glsl_state_flush_pending(state, $1.index);
+ yagl_glsl_state_append_output(state, "sampler2D");
+}
;
diff --git a/include/yagl_sharegroup.h b/include/yagl_sharegroup.h
index c98ddd9..868beb7 100644
--- a/include/yagl_sharegroup.h
+++ b/include/yagl_sharegroup.h
@@ -41,7 +41,7 @@
#define YAGL_NUM_NAMESPACES 6
-#define YAGL_NUM_TEXTURE_TARGETS 4
+#define YAGL_NUM_TEXTURE_TARGETS 5
struct yagl_sharegroup
{