From 2ab4fee455f32eb22aabe2b4305418d01cefd6ce Mon Sep 17 00:00:00 2001 From: Daekwang Ryu Date: Thu, 22 Jun 2017 15:29:39 +0900 Subject: [PATCH] evas_gl: FBO capa test for each version Supporting extensions by each version is different. So testing for each version is needed. In GLES 3.1, MSAA texture is core. But now renderer can't render MSAA texture. texture() in GLSL can't use with MSAA texture and binding point is different. MSAA texture binding point is GL_TEXTURE_2D_MULTISAMPLE. Change-Id: I8e7fe39c83272dcb44df10a6e847bd55b2879ccb --- src/modules/evas/engines/gl_common/evas_gl_api.c | 4 +- .../evas/engines/gl_common/evas_gl_common.h | 5 +- src/modules/evas/engines/gl_common/evas_gl_core.c | 547 ++++++++++++--------- .../evas/engines/gl_common/evas_gl_core_private.h | 6 +- .../evas/engines/gl_common/evas_gl_file_cache.c | 10 +- .../evas/engines/gl_common/evas_gl_shader.c | 4 +- .../gl_common/evas_gl_thread_evgl_generated.c | 52 ++ .../gl_common/evas_gl_thread_evgl_generated.h | 1 + .../gl_common/evas_gl_thread_evgl_link_generated.c | 2 + .../gl_common/evas_gl_thread_evgl_link_generated.h | 1 + src/utils/evas/gl_api_def.txt | 1 + 11 files changed, 379 insertions(+), 254 deletions(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_api.c b/src/modules/evas/engines/gl_common/evas_gl_api.c index d578d15..956d164 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_api.c +++ b/src/modules/evas/engines/gl_common/evas_gl_api.c @@ -632,12 +632,14 @@ static void _evgl_glEnable(GLenum cap) { EVGL_Context *ctx; + int caps_idx; ctx = evas_gl_common_current_context_get(); if (ctx && (cap == GL_SCISSOR_TEST)) { ctx->scissor_enabled = 1; + caps_idx = ctx->version - 1; if (_evgl_direct_enabled()) { @@ -689,7 +691,7 @@ _evgl_glEnable(GLenum cap) else if (ctx->direct_scissor) { // Back to the default scissors (here: max texture size) - glScissor(0, 0, evgl_engine->caps.max_w, evgl_engine->caps.max_h); + glScissor(0, 0, evgl_engine->caps[caps_idx].max_w, evgl_engine->caps[caps_idx].max_h); } ctx->direct_scissor = 0; } diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h index 45c45fd..68841c5 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_common.h @@ -41,6 +41,9 @@ # endif #endif +#define EVAS_GL_NO_GL_H_CHECK 1 +#include "Evas_GL.h" + #include "evas_gl_define.h" #define EVAS_GL_TILE_SIZE 16 @@ -650,7 +653,7 @@ Eina_Bool evas_gl_common_file_cache_file_exists(const char *file); Eina_Bool evas_gl_common_file_cache_mkpath_if_not_exists(const char *path); Eina_Bool evas_gl_common_file_cache_mkpath(const char *path); int evas_gl_common_file_cache_dir_check(char *cache_dir, int num); -int evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_name, char *cache_file, int dir_num); +int evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_name, char *cache_file, int dir_num, Evas_GL_Context_Version gles_version); void evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h); diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c index 3ee7e8d..c762ea7 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_core.c +++ b/src/modules/evas/engines/gl_common/evas_gl_core.c @@ -25,7 +25,7 @@ typedef void *(*glsym_func_void_ptr) (); glsym_func_void_ptr glsym_evas_gl_native_context_get = NULL; glsym_func_void_ptr glsym_evas_gl_engine_data_get = NULL; -static void _surface_cap_print(int error); +static void _surface_cap_print(int error, Evas_GL_Context_Version version); static void _surface_context_list_print(); static void _internal_resources_destroy(void *eng_data, EVGL_Resource *rsc); static void *_egl_image_create(EVGL_Context *context, int target, void *buffer); @@ -147,7 +147,7 @@ _internal_resource_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context { if (!sfc->indirect_sfc) { - evgl_engine->funcs->indirect_surface_create(evgl_engine, eng_data, sfc, sfc->cfg, sfc->w, sfc->h); + evgl_engine->funcs->indirect_surface_create(evgl_engine, eng_data, sfc, &sfc->cfg, sfc->w, sfc->h); if (sfc->egl_image) _egl_image_destroy(sfc->egl_image); sfc->egl_image = _egl_image_create(NULL, EVAS_GL_NATIVE_PIXMAP, sfc->indirect_sfc_native); } @@ -263,7 +263,7 @@ _texture_allocate_2d(GLuint tex, GLint ifmt, GLenum fmt, GLenum type, int w, int if (version == EVAS_GL_GLES_1_X) glTexImage2DEVAS_evgl_thread_cmd(1, GL_TEXTURE_2D, 0, ifmt, w, h, 0, fmt, type, NULL); else - glTexImage2D_evgl_thread_cmd(GL_TEXTURE_2D, 0, ifmt, w, h, 0, fmt, type, NULL); + glTexImage2D_evgl_thread_cmd(GL_TEXTURE_2D, 0, ifmt, w, h, 0, fmt, type, NULL); glBindTexture_evgl_thread_cmd(GL_TEXTURE_2D, (GLuint)curr_tex); } @@ -287,40 +287,98 @@ _texture_destroy(GLuint *tex) static void _texture_attach_2d(GLuint tex, GLenum attach, GLenum attach2, int samples, Evas_GL_Context_Version version) { - if (samples) + if (EVAS_GL_GLES_2_X == version) { + if (samples) + { #ifdef GL_GLES - //<<< TODO : CHECK EXTENSION SUPPORT>>> - EXT_FUNC(glFramebufferTexture2DMultisample)(GL_FRAMEBUFFER, - attach, - GL_TEXTURE_2D, tex, - 0, samples); - - if (attach2) - EXT_FUNC(glFramebufferTexture2DMultisample)(GL_FRAMEBUFFER, - attach2, - GL_TEXTURE_2D, tex, - 0, samples); -#else - ERR("MSAA not supported. Should not have come in here...!"); + if (EXT_FUNC(glFramebufferTexture2DMultisampleEXT)) + { + EXT_FUNC(glFramebufferTexture2DMultisampleEXT)(GL_FRAMEBUFFER, + attach, + GL_TEXTURE_2D, tex, + 0, samples); + + if (attach2) + EXT_FUNC(glFramebufferTexture2DMultisampleEXT)(GL_FRAMEBUFFER, + attach2, + GL_TEXTURE_2D, tex, + 0, samples); + } + else #endif + ERR("MSAA not supported. Should not have come in here...!"); + } + else + { + glFramebufferTexture2D_evgl_thread_cmd(GL_FRAMEBUFFER, attach, GL_TEXTURE_2D, tex, 0); + + if (attach2) + glFramebufferTexture2D_evgl_thread_cmd(GL_FRAMEBUFFER, attach2, GL_TEXTURE_2D, tex, 0); + } } - else if (version == EVAS_GL_GLES_1_X) + else if (EVAS_GL_GLES_3_X == version) { - if (EXT_FUNC_GLES1(glFramebufferTexture2DOES)) - EXT_FUNC_GLES1(glFramebufferTexture2DOES)(GL_FRAMEBUFFER, attach, GL_TEXTURE_2D, tex, 0); + if (samples) + { +#ifdef GL_GLES + if (EXT_FUNC_GLES3(glFramebufferTexture2DMultisampleEXT)) + { + EXT_FUNC_GLES3(glFramebufferTexture2DMultisampleEXT)(GL_FRAMEBUFFER, + attach, + GL_TEXTURE_2D, tex, + 0, samples); + + if (attach2) + EXT_FUNC_GLES3(glFramebufferTexture2DMultisampleEXT)(GL_FRAMEBUFFER, + attach2, + GL_TEXTURE_2D, tex, + 0, samples); + } + else +#endif + ERR("MSAA not supported. Should not have come in here...!"); + } + else + { + glFramebufferTexture2D_evgl_thread_cmd(GL_FRAMEBUFFER, attach, GL_TEXTURE_2D, tex, 0); - if (attach2) - if (EXT_FUNC_GLES1(glFramebufferTexture2DOES)) - EXT_FUNC_GLES1(glFramebufferTexture2DOES)(GL_FRAMEBUFFER, attach2, GL_TEXTURE_2D, tex, 0); + if (attach2) + glFramebufferTexture2D_evgl_thread_cmd(GL_FRAMEBUFFER, attach2, GL_TEXTURE_2D, tex, 0); + } } - else + else if (EVAS_GL_GLES_1_X == version) { - glFramebufferTexture2D_evgl_thread_cmd(GL_FRAMEBUFFER, attach, GL_TEXTURE_2D, tex, 0); + if (samples) + { +#ifdef GL_GLES + if (EXT_FUNC_GLES1(glFramebufferTexture2DMultisampleEXT)) + { + EXT_FUNC_GLES1(glFramebufferTexture2DMultisampleEXT)(GL_FRAMEBUFFER, + attach, + GL_TEXTURE_2D, tex, + 0, samples); + + if (attach2) + EXT_FUNC_GLES1(glFramebufferTexture2DMultisampleEXT)(GL_FRAMEBUFFER, + attach2, + GL_TEXTURE_2D, tex, + 0, samples); + } + else +#endif + ERR("MSAA not supported. Should not have come in here...!"); - if (attach2) - glFramebufferTexture2D_evgl_thread_cmd(GL_FRAMEBUFFER, attach2, GL_TEXTURE_2D, tex, 0); + } + else + { + if (EXT_FUNC_GLES1(glFramebufferTexture2DOES)) + EXT_FUNC_GLES1(glFramebufferTexture2DOES)(GL_FRAMEBUFFER, attach, GL_TEXTURE_2D, tex, 0); + if (attach2) + if (EXT_FUNC_GLES1(glFramebufferTexture2DOES)) + EXT_FUNC_GLES1(glFramebufferTexture2DOES)(GL_FRAMEBUFFER, attach2, GL_TEXTURE_2D, tex, 0); + } } } @@ -388,7 +446,7 @@ _framebuffer_create(GLuint *buf, Evas_GL_Context_Version version) if (version == EVAS_GL_GLES_1_X) { if (EXT_FUNC_GLES1(glGenFramebuffersOES)) - EXT_FUNC_GLES1(glGenFramebuffersOES)(1, buf); + EXT_FUNC_GLES1(glGenFramebuffersOES)(1, buf); } else { @@ -426,6 +484,20 @@ _framebuffer_read_bind(GLuint buf, Evas_GL_Context_Version version) glBindFramebuffer_evgl_thread_cmd(GL_READ_FRAMEBUFFER, buf); } +static void +_framebuffer_delete(GLuint *buf, Evas_GL_Context_Version version) +{ + if (version == EVAS_GL_GLES_1_X) + { + if (EXT_FUNC_GLES1(glDeleteFramebuffersOES)) + EXT_FUNC_GLES1(glDeleteFramebuffersOES)(1, buf); + } + else + { + glDeleteFramebuffers_evgl_thread_cmd(1, buf); + } +} + static GLenum _framebuffer_check(Evas_GL_Context_Version version) { @@ -469,7 +541,10 @@ _renderbuffer_allocate(GLuint buf, GLenum fmt, int w, int h, int samples, Evas_G if (samples) #ifdef GL_GLES - EXT_FUNC(glRenderbufferStorageMultisample)(GL_RENDERBUFFER, samples, fmt, w, h); + { + if (EXT_FUNC_GLES1(glRenderbufferStorageMultisampleEXT)) + EXT_FUNC_GLES1(glRenderbufferStorageMultisampleEXT)(GL_RENDERBUFFER, samples, fmt, w, h); + } #else ERR("MSAA not supported. Should not have come in here...!"); #endif @@ -481,14 +556,37 @@ _renderbuffer_allocate(GLuint buf, GLenum fmt, int w, int h, int samples, Evas_G if (EXT_FUNC_GLES1(glBindRenderbufferOES)) EXT_FUNC_GLES1(glBindRenderbufferOES)(GL_RENDERBUFFER, 0); - } + } + else if (version == EVAS_GL_GLES_3_X) + { + glBindRenderbuffer_evgl_thread_cmd(GL_RENDERBUFFER, buf); + + if (samples) +#ifdef GL_GLES + { + if (EXT_FUNC_GLES3(glRenderbufferStorageMultisampleEXT)) + EXT_FUNC_GLES3(glRenderbufferStorageMultisampleEXT)(GL_RENDERBUFFER, samples, fmt, w, h); + } +#else + ERR("MSAA not supported. Should not have come in here...!"); +#endif + else + { + glRenderbufferStorage_evgl_thread_cmd(GL_RENDERBUFFER, fmt, w, h); + } + + glBindRenderbuffer_evgl_thread_cmd(GL_RENDERBUFFER, 0); + } else { glBindRenderbuffer_evgl_thread_cmd(GL_RENDERBUFFER, buf); if (samples) #ifdef GL_GLES - EXT_FUNC(glRenderbufferStorageMultisample)(GL_RENDERBUFFER, samples, fmt, w, h); + { + if (EXT_FUNC(glRenderbufferStorageMultisampleEXT)) + EXT_FUNC(glRenderbufferStorageMultisampleEXT)(GL_RENDERBUFFER, samples, fmt, w, h); + } #else ERR("MSAA not supported. Should not have come in here...!"); #endif @@ -539,10 +637,9 @@ _renderbuffer_attach(GLuint buf, GLenum attach, Evas_GL_Context_Version version) } // Check whether the given FBO surface config is supported by the driver -// TODO - we also should test with GLES3's formats. static int _fbo_surface_cap_test(GLint color_ifmt, GLenum color_fmt, - GLenum depth_fmt, GLenum stencil_fmt, int mult_samples) + GLenum depth_fmt, GLenum stencil_fmt, int mult_samples, Evas_GL_Context_Version version) { GLuint fbo = 0; GLuint color_buf = 0; @@ -552,42 +649,34 @@ _fbo_surface_cap_test(GLint color_ifmt, GLenum color_fmt, int depth_stencil = 0; int fb_status = 0; int w = 2, h = 2; // Test it with a simple (2,2) surface. Should I test it with NPOT? + int ret = 1; // Gen FBO - glGenFramebuffers_evgl_thread_cmd(1, &fbo); - glBindFramebuffer_evgl_thread_cmd(GL_FRAMEBUFFER, fbo); + _framebuffer_create(&fbo, version); + _framebuffer_bind(fbo, version); // Color Buffer Texture if ((color_ifmt) && (color_fmt)) { _texture_create(&color_buf); - _texture_allocate_2d(color_buf, color_ifmt, color_fmt, GL_UNSIGNED_BYTE, w, h, EVAS_GL_GLES_2_X); - _texture_attach_2d(color_buf, GL_COLOR_ATTACHMENT0, 0, mult_samples, EVAS_GL_GLES_2_X); + _texture_allocate_2d(color_buf, color_ifmt, color_fmt, GL_UNSIGNED_BYTE, w, h, version); + _texture_attach_2d(color_buf, GL_COLOR_ATTACHMENT0, 0, mult_samples, version); } // Check Depth_Stencil Format First #ifdef GL_GLES - if ((depth_fmt == GL_DEPTH_STENCIL_OES) && (!mult_samples)) - { - _texture_create(&depth_stencil_buf); - _texture_allocate_2d(depth_stencil_buf, depth_fmt, - depth_fmt, GL_UNSIGNED_INT_24_8_OES, w, h, EVAS_GL_GLES_2_X); - _texture_attach_2d(depth_stencil_buf, GL_DEPTH_ATTACHMENT, - GL_STENCIL_ATTACHMENT, mult_samples, EVAS_GL_GLES_2_X); - depth_stencil = 1; - } - else if ((depth_fmt == GL_DEPTH24_STENCIL8_OES) && (mult_samples)) + if (depth_fmt == GL_DEPTH24_STENCIL8_OES) #else if (depth_fmt == GL_DEPTH24_STENCIL8) #endif { - _renderbuffer_create(&depth_stencil_buf,EVAS_GL_GLES_2_X); - _renderbuffer_allocate(depth_stencil_buf, depth_fmt, w, h, mult_samples,EVAS_GL_GLES_2_X); + _renderbuffer_create(&depth_stencil_buf, version); + _renderbuffer_allocate(depth_stencil_buf, depth_fmt, w, h, mult_samples, version); #ifdef GL_GLES - _renderbuffer_attach(depth_stencil_buf, GL_DEPTH_ATTACHMENT, EVAS_GL_GLES_2_X); - _renderbuffer_attach(depth_stencil_buf, GL_STENCIL_ATTACHMENT, EVAS_GL_GLES_2_X); + _renderbuffer_attach(depth_stencil_buf, GL_DEPTH_ATTACHMENT, version); + _renderbuffer_attach(depth_stencil_buf, GL_STENCIL_ATTACHMENT, version); #else - _renderbuffer_attach(depth_stencil_buf, GL_DEPTH_STENCIL_ATTACHMENT, EVAS_GL_GLES_2_X); + _renderbuffer_attach(depth_stencil_buf, GL_DEPTH_STENCIL_ATTACHMENT, version); #endif depth_stencil = 1; } @@ -595,55 +684,64 @@ _fbo_surface_cap_test(GLint color_ifmt, GLenum color_fmt, // Depth Attachment if ((!depth_stencil) && (depth_fmt)) { - _renderbuffer_create(&depth_buf, EVAS_GL_GLES_2_X); - _renderbuffer_allocate(depth_buf, depth_fmt, w, h, mult_samples, EVAS_GL_GLES_2_X); - _renderbuffer_attach(depth_buf, GL_DEPTH_ATTACHMENT, EVAS_GL_GLES_2_X); + _renderbuffer_create(&depth_buf, version); + _renderbuffer_allocate(depth_buf, depth_fmt, w, h, mult_samples, version); + _renderbuffer_attach(depth_buf, GL_DEPTH_ATTACHMENT, version); } // Stencil Attachment if ((!depth_stencil) && (stencil_fmt)) { - _renderbuffer_create(&stencil_buf, EVAS_GL_GLES_2_X); - _renderbuffer_allocate(stencil_buf, stencil_fmt, w, h, mult_samples, EVAS_GL_GLES_2_X); - _renderbuffer_attach(stencil_buf, GL_STENCIL_ATTACHMENT, EVAS_GL_GLES_2_X); + _renderbuffer_create(&stencil_buf, version); + _renderbuffer_allocate(stencil_buf, stencil_fmt, w, h, mult_samples, version); + _renderbuffer_attach(stencil_buf, GL_STENCIL_ATTACHMENT, version); } // Check FBO for completeness - fb_status = glCheckFramebufferStatus_evgl_thread_cmd(GL_FRAMEBUFFER); - - // Delete Created Resources - _texture_destroy(&color_buf); - _renderbuffer_destroy(&depth_buf, EVAS_GL_GLES_2_X); - _renderbuffer_destroy(&stencil_buf, EVAS_GL_GLES_2_X); - -#ifdef GL_GLES - if ((depth_fmt == GL_DEPTH_STENCIL_OES) && (!mult_samples)) - _texture_destroy(&depth_stencil_buf); - else if ((depth_fmt == GL_DEPTH24_STENCIL8_OES) && (mult_samples)) -#endif - _renderbuffer_destroy(&depth_stencil_buf, EVAS_GL_GLES_2_X); - - // Delete FBO - glBindFramebuffer_evgl_thread_cmd(GL_FRAMEBUFFER, 0); - if (fbo) glDeleteFramebuffers_evgl_thread_cmd(1, &fbo); + fb_status = _framebuffer_check(version); // Return the result if (fb_status != GL_FRAMEBUFFER_COMPLETE) { - int err = glGetError_evgl_thread_cmd(); + int err = glGetError(); if (err != GL_NO_ERROR) - DBG("glGetError_evgl_thread_cmd() returns %x ", err); + DBG("glGetError() returns %x ", err); - return 0; + ret = 0; } else - return 1; + { + // Check that all attachments is valid. + GLint color_atc, depth_atc, stencil_atc; + glGetFramebufferAttachmentParameteriv_evgl_thread_cmd(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &color_atc); + glGetFramebufferAttachmentParameteriv_evgl_thread_cmd(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &depth_atc); + glGetFramebufferAttachmentParameteriv_evgl_thread_cmd(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &stencil_atc); + + if (color_fmt && !color_atc) + ret = 0; + if ((depth_stencil || depth_fmt) && !depth_atc) + ret = 0; + if ((depth_stencil || stencil_fmt) && !stencil_atc) + ret = 0; + } + + // Delete Created Resources + _texture_destroy(&color_buf); + _renderbuffer_destroy(&depth_buf, version); + _renderbuffer_destroy(&stencil_buf, version); + _renderbuffer_destroy(&depth_stencil_buf, version); + + // Delete FBO + _framebuffer_bind(0, version); + if (fbo) _framebuffer_delete(&fbo, version); + + return ret; } static int _surface_cap_test(EVGL_Surface_Format *fmt, GL_Format *color, - GL_Format *depth, GL_Format *stencil, int samples) + GL_Format *depth, GL_Format *stencil, int samples, Evas_GL_Context_Version version) { int ret = 0; @@ -653,7 +751,7 @@ _surface_cap_test(EVGL_Surface_Format *fmt, GL_Format *color, ret = _fbo_surface_cap_test((GLint)color->fmt, color->fmt, depth->fmt, - stencil->fmt, samples); + stencil->fmt, samples, version); if (ret) { fmt->color_bit = color->bit; @@ -685,10 +783,11 @@ _surface_cap_test(EVGL_Surface_Format *fmt, GL_Format *color, static int -_surface_cap_check() +_surface_cap_check(Evas_GL_Context_Version version) { int num_fmts = 0; int i, j, k, m; + int caps_idx = version - 1; GL_Format color[] = { { COLOR_RGB_888, GL_RGB }, @@ -699,7 +798,6 @@ _surface_cap_check() #ifdef GL_GLES GL_Format depth[] = { { DEPTH_NONE, 0 }, - { DEPTH_STENCIL, GL_DEPTH_STENCIL_OES }, { DEPTH_STENCIL, GL_DEPTH24_STENCIL8_OES }, { DEPTH_BIT_8, GL_DEPTH_COMPONENT }, { DEPTH_BIT_16, GL_DEPTH_COMPONENT16 }, @@ -745,15 +843,15 @@ _surface_cap_check() } // Check Surface Cap for MSAA - if (evgl_engine->caps.msaa_supported) + if (evgl_engine->caps[caps_idx].msaa_supported) { - if ((evgl_engine->caps.msaa_samples[2] != evgl_engine->caps.msaa_samples[1]) && - (evgl_engine->caps.msaa_samples[2] != evgl_engine->caps.msaa_samples[0])) - msaa_samples[3] = evgl_engine->caps.msaa_samples[2]; // HIGH - if ((evgl_engine->caps.msaa_samples[1] != evgl_engine->caps.msaa_samples[0])) - msaa_samples[2] = evgl_engine->caps.msaa_samples[1]; // MED - if (evgl_engine->caps.msaa_samples[0]) - msaa_samples[1] = evgl_engine->caps.msaa_samples[0]; // LOW + if ((evgl_engine->caps[caps_idx].msaa_samples[2] != evgl_engine->caps[caps_idx].msaa_samples[1]) && + (evgl_engine->caps[caps_idx].msaa_samples[2] != evgl_engine->caps[caps_idx].msaa_samples[0])) + msaa_samples[3] = evgl_engine->caps[caps_idx].msaa_samples[2]; // HIGH + if ((evgl_engine->caps[caps_idx].msaa_samples[1] != evgl_engine->caps[caps_idx].msaa_samples[0])) + msaa_samples[2] = evgl_engine->caps[caps_idx].msaa_samples[1]; // MED + if (evgl_engine->caps[caps_idx].msaa_samples[0]) + msaa_samples[1] = evgl_engine->caps[caps_idx].msaa_samples[0]; // LOW } @@ -774,8 +872,8 @@ _surface_cap_check() // Stencil Formats while ( stencil[k].bit >= 0) { - fmt = &evgl_engine->caps.fbo_fmts[num_fmts]; - if (_surface_cap_test(fmt, &color[i], &depth[j], &stencil[k], msaa_samples[m])) + fmt = &evgl_engine->caps[caps_idx].fbo_fmts[num_fmts]; + if (_surface_cap_test(fmt, &color[i], &depth[j], &stencil[k], msaa_samples[m], version)) num_fmts++; k++; } @@ -789,20 +887,21 @@ _surface_cap_check() } static int -_surface_cap_load(Eet_File *ef) +_surface_cap_load(Eet_File *ef, Evas_GL_Context_Version version) { int res = 0, i = 0, length = 0; char tag[80]; char *data = NULL; + int caps_idx = version - 1; data = eet_read(ef, "num_fbo_fmts", &length); if ((!data) || (length <= 0)) goto finish; if (data[length - 1] != 0) goto finish; - evgl_engine->caps.num_fbo_fmts = atoi(data); + evgl_engine->caps[caps_idx].num_fbo_fmts = atoi(data); - if (evgl_engine->caps.num_fbo_fmts < 0 || evgl_engine->caps.num_fbo_fmts > 100) + if (evgl_engine->caps[caps_idx].num_fbo_fmts < 0 || evgl_engine->caps[caps_idx].num_fbo_fmts > 100) { - ERR("num_fbo_fmts is invalid. %d", evgl_engine->caps.num_fbo_fmts); + ERR("num_fbo_fmts is invalid. %d", evgl_engine->caps[caps_idx].num_fbo_fmts); goto finish; } @@ -811,9 +910,9 @@ _surface_cap_load(Eet_File *ef) // !!!FIXME // Should use eet functionality instead of just reading using sscanfs... - for (i = 0; i < evgl_engine->caps.num_fbo_fmts; ++i) + for (i = 0; i < evgl_engine->caps[caps_idx].num_fbo_fmts; ++i) { - EVGL_Surface_Format *fmt = &evgl_engine->caps.fbo_fmts[i]; + EVGL_Surface_Format *fmt = &evgl_engine->caps[caps_idx].fbo_fmts[i]; snprintf(tag, sizeof(tag), "fbo_%d", i); data = eet_read(ef, tag, &length); @@ -837,20 +936,21 @@ finish: } static int -_surface_cap_save(Eet_File *ef) +_surface_cap_save(Eet_File *ef, Evas_GL_Context_Version version) { int i = 0; char tag[80], data[80]; + int caps_idx = version - 1; - snprintf(data, sizeof(data), "%d", evgl_engine->caps.num_fbo_fmts); + snprintf(data, sizeof(data), "%d", evgl_engine->caps[caps_idx].num_fbo_fmts); if (eet_write(ef, "num_fbo_fmts", data, strlen(data) + 1, 1) < 0) return 0; // !!!FIXME // Should use eet functionality instead of just writing out using snprintfs... - for (i = 0; i < evgl_engine->caps.num_fbo_fmts; ++i) + for (i = 0; i < evgl_engine->caps[caps_idx].num_fbo_fmts; ++i) { - EVGL_Surface_Format *fmt = &evgl_engine->caps.fbo_fmts[i]; + EVGL_Surface_Format *fmt = &evgl_engine->caps[caps_idx].fbo_fmts[i]; snprintf(tag, sizeof(tag), "fbo_%d", i); snprintf(data, sizeof(data), "%d %d %d %d %d %d %d %d %d %d", @@ -867,7 +967,7 @@ _surface_cap_save(Eet_File *ef) } static int -_surface_cap_cache_load() +_surface_cap_cache_load(Evas_GL_Context_Version version) { /* check eet */ Eet_File *et = NULL; @@ -878,7 +978,7 @@ _surface_cap_cache_load() return 0; if (!evas_gl_common_file_cache_file_check(cap_dir_path, "surface_cap", - cap_file_path, sizeof(cap_dir_path))) + cap_file_path, sizeof(cap_dir_path), version)) return 0; /* use eet */ @@ -886,7 +986,7 @@ _surface_cap_cache_load() et = eet_open(cap_file_path, EET_FILE_MODE_READ); if (!et) goto error; - if (!_surface_cap_load(et)) + if (!_surface_cap_load(et, version)) goto error; if (et) eet_close(et); @@ -900,7 +1000,7 @@ error: } static int -_surface_cap_cache_save() +_surface_cap_cache_save(Evas_GL_Context_Version version) { /* check eet */ Eet_File *et = NULL; //check eet file @@ -920,7 +1020,7 @@ _surface_cap_cache_save() } evas_gl_common_file_cache_file_check(cap_dir_path, "surface_cap", cap_file_path, - sizeof(cap_dir_path)); + sizeof(cap_dir_path), version); /* use mkstemp for writing */ snprintf(tmp_file_name, sizeof(tmp_file_name), "%s.XXXXXX.cache", cap_file_path); @@ -930,7 +1030,7 @@ _surface_cap_cache_save() et = eet_open(tmp_file_path, EET_FILE_MODE_WRITE); if (!et) goto error; - if (!_surface_cap_save(et)) goto error; + if (!_surface_cap_save(et, version)) goto error; if (eet_close(et) != EET_ERROR_NONE) goto destroyed; if (rename(tmp_file_path, cap_file_path) < 0) goto destroyed; @@ -954,53 +1054,51 @@ error: } static int -_surface_cap_init(void *eng_data) +_surface_cap_init(void *eng_data EINA_UNUSED, Evas_GL_Context_Version version) { int ret = 0; int max_size = 0; - - // Do internal make current - if (!_internal_resource_make_current(eng_data, NULL, NULL)) - { - ERR("Error doing an internal resource make current"); - return ret; - } + int max_samples = 0; + int caps_idx = version - 1; // Query the max width and height of the surface glGetIntegerv_evgl_thread_cmd(GL_MAX_RENDERBUFFER_SIZE, &max_size); - evgl_engine->caps.max_w = max_size; - evgl_engine->caps.max_h = max_size; - DBG("Max Surface Width: %d Height: %d", evgl_engine->caps.max_w, evgl_engine->caps.max_h); - + evgl_engine->caps[caps_idx].max_w = max_size; + evgl_engine->caps[caps_idx].max_h = max_size; + DBG("Max Surface Width: %d Height: %d", evgl_engine->caps[caps_idx].max_w, evgl_engine->caps[caps_idx].max_h); // Check for MSAA support -#ifdef GL_GLES - int max_samples = 0; - if (EXTENSION_SUPPORT(IMG_multisampled_render_to_texture)) + if (version == 3) { - glGetIntegerv_evgl_thread_cmd(GL_MAX_SAMPLES_IMG, &max_samples); + glGetIntegerv_evgl_thread_cmd(GL_MAX_SAMPLES, &max_samples); } - else if (EXTENSION_SUPPORT(EXT_multisampled_render_to_texture)) +#ifdef GL_GLES + else { - glGetIntegerv_evgl_thread_cmd(GL_MAX_SAMPLES_EXT, &max_samples); + const char *exts = (const char *) glGetString_evgl_thread_cmd(GL_EXTENSIONS); + + if (exts && strstr(exts, "EXT_multisampled_render_to_texture")) + glGetIntegerv_evgl_thread_cmd(GL_MAX_SAMPLES_EXT, &max_samples); + else if (exts && strstr(exts, "IMG_multisampled_render_to_texture")) + glGetIntegerv_evgl_thread_cmd(GL_MAX_SAMPLES_IMG, &max_samples); } +#endif if (max_samples >= 2) { - evgl_engine->caps.msaa_samples[0] = 2; - evgl_engine->caps.msaa_samples[1] = (max_samples >> 1) < 2 ? 2 : (max_samples >> 1); - evgl_engine->caps.msaa_samples[2] = max_samples; - evgl_engine->caps.msaa_supported = 1; + evgl_engine->caps[caps_idx].msaa_samples[0] = 2; + evgl_engine->caps[caps_idx].msaa_samples[1] = (max_samples >> 1) < 2 ? 2 : (max_samples >> 1); + evgl_engine->caps[caps_idx].msaa_samples[2] = max_samples; + evgl_engine->caps[caps_idx].msaa_supported = 1; } -#endif // Load Surface Cap - if (!_surface_cap_cache_load()) + if (!_surface_cap_cache_load(version)) { // Check Surface Cap - evgl_engine->caps.num_fbo_fmts = _surface_cap_check(); - _surface_cap_cache_save(); + evgl_engine->caps[caps_idx].num_fbo_fmts = _surface_cap_check(version); + _surface_cap_cache_save(version); DBG("Ran Evas GL Surface Cap and Cached the existing values."); } else @@ -1008,10 +1106,10 @@ _surface_cap_init(void *eng_data) DBG("Loaded cached Evas GL Surface Cap values."); } - if (evgl_engine->caps.num_fbo_fmts) + if (evgl_engine->caps[caps_idx].num_fbo_fmts) { - _surface_cap_print(0); - DBG("Number of supported surface formats: %d", evgl_engine->caps.num_fbo_fmts); + _surface_cap_print(1, version); + DBG("Number of supported surface formats: %d", evgl_engine->caps[caps_idx].num_fbo_fmts); ret = 1; } else @@ -1019,9 +1117,6 @@ _surface_cap_init(void *eng_data) ERR("There are no available surface formats. Error!"); } - // Destroy internal resources - _evgl_tls_resource_destroy(eng_data); - return ret; } @@ -1140,9 +1235,10 @@ _glenum_string_get(GLenum e) } static void -_surface_cap_print(int error) +_surface_cap_print(int error, Evas_GL_Context_Version version) { int i = 0; + int caps_idx = version - 1; #define PRINT_LOG(...) \ if (error) \ ERR(__VA_ARGS__); \ @@ -1152,13 +1248,13 @@ _surface_cap_print(int error) PRINT_LOG("----------------------------------------------------------------------------------------------------------------"); PRINT_LOG(" Evas GL Supported Surface Format "); PRINT_LOG("----------------------------------------------------------------------------------------------------------------"); - PRINT_LOG(" Max Surface Width: %d Height: %d", evgl_engine->caps.max_w, evgl_engine->caps.max_h); - PRINT_LOG(" Multisample Support: %d", evgl_engine->caps.msaa_supported); + PRINT_LOG(" Max Surface Width: %d Height: %d", evgl_engine->caps[caps_idx].max_w, evgl_engine->caps[caps_idx].max_h); + PRINT_LOG(" Multisample Support: %d", evgl_engine->caps[caps_idx].msaa_supported); //if (evgl_engine->caps.msaa_supported) { - PRINT_LOG(" Low Samples: %d", evgl_engine->caps.msaa_samples[0]); - PRINT_LOG(" Med Samples: %d", evgl_engine->caps.msaa_samples[1]); - PRINT_LOG(" High Samples: %d", evgl_engine->caps.msaa_samples[2]); + PRINT_LOG(" Low Samples: %d", evgl_engine->caps[caps_idx].msaa_samples[0]); + PRINT_LOG(" Med Samples: %d", evgl_engine->caps[caps_idx].msaa_samples[1]); + PRINT_LOG(" High Samples: %d", evgl_engine->caps[caps_idx].msaa_samples[2]); } PRINT_LOG("[Index] [Color Format] [------Depth Bits------] [----Stencil Bits---] [---Depth_Stencil---] [Samples]"); @@ -1167,9 +1263,9 @@ _surface_cap_print(int error) PRINT_LOG(" %3d %10s %25s %25s %25s %5d", IDX, _glenum_string_get(COLOR), _glenum_string_get(DEPTH), _glenum_string_get(STENCIL), _glenum_string_get(DS), SAMPLE ); \ } - for (i = 0; i < evgl_engine->caps.num_fbo_fmts; ++i) + for (i = 0; i < evgl_engine->caps[caps_idx].num_fbo_fmts; ++i) { - EVGL_Surface_Format *fmt = &evgl_engine->caps.fbo_fmts[i]; + EVGL_Surface_Format *fmt = &evgl_engine->caps[caps_idx].fbo_fmts[i]; PRINT_SURFACE_CAP(i, fmt->color_fmt, fmt->depth_fmt, fmt->stencil_fmt, fmt->depth_stencil_fmt, fmt->samples); } @@ -1262,10 +1358,9 @@ _surface_buffers_fbo_set(EVGL_Surface *sfc, GLuint fbo, Evas_GL_Context_Version // Detach any previously attached buffers _texture_attach_2d(0, GL_COLOR_ATTACHMENT0, 0, 0, version); +#ifdef GL_GLES _renderbuffer_attach(0, GL_DEPTH_ATTACHMENT, version); _renderbuffer_attach(0, GL_STENCIL_ATTACHMENT, version); -#ifdef GL_GLES - _texture_attach_2d(0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, 0, version); #else _renderbuffer_attach(0, GL_DEPTH_STENCIL_ATTACHMENT, version); #endif @@ -1278,16 +1373,10 @@ _surface_buffers_fbo_set(EVGL_Surface *sfc, GLuint fbo, Evas_GL_Context_Version if (sfc->depth_stencil_buf) { #ifdef GL_GLES - if (sfc->depth_stencil_fmt == GL_DEPTH_STENCIL_OES) - _texture_attach_2d(sfc->depth_stencil_buf, GL_DEPTH_ATTACHMENT, - GL_STENCIL_ATTACHMENT, sfc->msaa_samples, version); - else - { - _renderbuffer_attach(sfc->depth_stencil_buf, GL_DEPTH_ATTACHMENT, version); - _renderbuffer_attach(sfc->depth_stencil_buf, GL_STENCIL_ATTACHMENT, version); - } + _renderbuffer_attach(sfc->depth_stencil_buf, GL_DEPTH_ATTACHMENT, version); + _renderbuffer_attach(sfc->depth_stencil_buf, GL_STENCIL_ATTACHMENT, version); #else - _renderbuffer_attach(sfc->depth_stencil_buf, GL_DEPTH_STENCIL_ATTACHMENT, version); + _renderbuffer_attach(sfc->depth_stencil_buf, GL_DEPTH_STENCIL_ATTACHMENT, version); #endif } @@ -1323,11 +1412,6 @@ _surface_buffers_create(EVGL_Surface *sfc, Evas_GL_Context_Version version) // Depth_stencil buffers or separate buffers if (sfc->depth_stencil_fmt) { -#ifdef GL_GLES - if (sfc->depth_stencil_fmt == GL_DEPTH_STENCIL_OES) - _texture_create(&sfc->depth_stencil_buf); - else -#endif _renderbuffer_create(&sfc->depth_stencil_buf, version); } else @@ -1368,24 +1452,6 @@ _surface_buffers_allocate(void *eng_data EINA_UNUSED, EVGL_Surface *sfc, int w, // Depth_stencil buffers or separate buffers if (sfc->depth_stencil_fmt) { -#ifdef GL_GLES - if (sfc->depth_stencil_fmt == GL_DEPTH_STENCIL_OES) - { - if (version == EVAS_GL_GLES_3_X) - { - _texture_allocate_2d(sfc->depth_stencil_buf, GL_DEPTH24_STENCIL8_OES, - sfc->depth_stencil_fmt, GL_UNSIGNED_INT_24_8_OES, - w, h, version); - } - else - { - _texture_allocate_2d(sfc->depth_stencil_buf, sfc->depth_stencil_fmt, - sfc->depth_stencil_fmt, GL_UNSIGNED_INT_24_8_OES, - w, h, version); - } - } - else -#endif { _renderbuffer_allocate(sfc->depth_stencil_buf, sfc->depth_stencil_fmt, w, h, @@ -1428,18 +1494,13 @@ _surface_buffers_destroy(EVGL_Surface *sfc, Evas_GL_Context_Version version) _renderbuffer_destroy(&sfc->stencil_buf, version); if (sfc->depth_stencil_buf) { -#ifdef GL_GLES - if (sfc->depth_stencil_fmt == GL_DEPTH_STENCIL_OES) - _texture_destroy(&sfc->depth_stencil_buf); - else -#endif _renderbuffer_destroy(&sfc->depth_stencil_buf, version); } return 1; } static int -_internal_config_set(void *eng_data, EVGL_Surface *sfc, Evas_GL_Config *cfg) +_internal_config_set(void *eng_data, EVGL_Surface *sfc, Evas_GL_Context_Version version) { int i = 0, cfg_index = -1; int color_bit = 0, depth_bit = 0, stencil_bit = 0, msaa_samples = 0; @@ -1447,6 +1508,8 @@ _internal_config_set(void *eng_data, EVGL_Surface *sfc, Evas_GL_Config *cfg) int native_win_depth = 0, native_win_stencil = 0, native_win_msaa = 0; Eina_Bool support_win_cfg = 1; int updated_by_wincfg = 0; + Evas_GL_Config *cfg = &sfc->cfg; + int caps_idx = version - 1; // Check if engine is valid if (!evgl_engine) @@ -1464,45 +1527,40 @@ _internal_config_set(void *eng_data, EVGL_Surface *sfc, Evas_GL_Config *cfg) } if (cfg->stencil_bits) stencil_bit = (1 << (cfg->stencil_bits-1)); if (cfg->multisample_bits) - msaa_samples = evgl_engine->caps.msaa_samples[cfg->multisample_bits-1]; + msaa_samples = evgl_engine->caps[caps_idx].msaa_samples[cfg->multisample_bits-1]; try_again: // Run through all the available formats and choose the first match - for (i = 0; i < evgl_engine->caps.num_fbo_fmts; ++i) + for (i = 0; i < evgl_engine->caps[caps_idx].num_fbo_fmts; ++i) { // Check if the MSAA is supported. Fallback if not. - if ((msaa_samples) && (evgl_engine->caps.msaa_supported)) + if ((msaa_samples) && (evgl_engine->caps[caps_idx].msaa_supported)) { - if (msaa_samples > evgl_engine->caps.fbo_fmts[i].samples) + if (msaa_samples > evgl_engine->caps[caps_idx].fbo_fmts[i].samples) continue; } - if (color_bit & evgl_engine->caps.fbo_fmts[i].color_bit) + if (color_bit & evgl_engine->caps[caps_idx].fbo_fmts[i].color_bit) { - if (cfg->gles_version == EVAS_GL_GLES_1_X && - (evgl_engine->caps.fbo_fmts[i].depth_stencil_fmt == GL_DEPTH_STENCIL_OES - || evgl_engine->caps.fbo_fmts[i].depth_stencil_fmt == GL_DEPTH24_STENCIL8_OES)) - continue; - if (depth_bit) { - if (!(depth_bit & evgl_engine->caps.fbo_fmts[i].depth_bit)) + if (!(depth_bit & evgl_engine->caps[caps_idx].fbo_fmts[i].depth_bit)) continue; } if (stencil_bit) { - if (!(stencil_bit & evgl_engine->caps.fbo_fmts[i].stencil_bit)) + if (!(stencil_bit & evgl_engine->caps[caps_idx].fbo_fmts[i].stencil_bit)) continue; } // Set the surface format - sfc->color_ifmt = evgl_engine->caps.fbo_fmts[i].color_ifmt; - sfc->color_fmt = evgl_engine->caps.fbo_fmts[i].color_fmt; - sfc->depth_fmt = evgl_engine->caps.fbo_fmts[i].depth_fmt; - sfc->stencil_fmt = evgl_engine->caps.fbo_fmts[i].stencil_fmt; - sfc->depth_stencil_fmt = evgl_engine->caps.fbo_fmts[i].depth_stencil_fmt; - sfc->msaa_samples = evgl_engine->caps.fbo_fmts[i].samples; + sfc->color_ifmt = evgl_engine->caps[caps_idx].fbo_fmts[i].color_ifmt; + sfc->color_fmt = evgl_engine->caps[caps_idx].fbo_fmts[i].color_fmt; + sfc->depth_fmt = evgl_engine->caps[caps_idx].fbo_fmts[i].depth_fmt; + sfc->stencil_fmt = evgl_engine->caps[caps_idx].fbo_fmts[i].stencil_fmt; + sfc->depth_stencil_fmt = evgl_engine->caps[caps_idx].fbo_fmts[i].depth_stencil_fmt; + sfc->msaa_samples = evgl_engine->caps[caps_idx].fbo_fmts[i].samples; // Direct Rendering Option if (evgl_engine->funcs->native_win_surface_config_get) @@ -1896,7 +1954,6 @@ _evgl_engine_data_get(Evas_GL *evasgl) // - Assign engine funcs form evas_engine // - Create internal resources: internal context, surface for resource creation // - Initialize extensions -// - Check surface capability // // This code should be called during eng_setup() in evas_engine EVGL_Engine * @@ -1952,13 +2009,6 @@ evgl_engine_init(void *eng_data, const EVGL_Interface *efunc) else ERR("Proc address get function not available. Extension not initialized."); - // Surface Caps - if (!_surface_cap_init(eng_data)) - { - ERR("Error initializing surface cap"); - goto error; - } - // NOTE: Should we finally remove these variables? // Check for Direct rendering override env var. if ((s = getenv("EVAS_GL_DIRECT_OVERRIDE"))) @@ -2080,15 +2130,6 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h) return NULL; } - // Check the size of the surface - if ((w > evgl_engine->caps.max_w) || (h > evgl_engine->caps.max_h)) - { - ERR("Requested surface size [%d, %d] is greater than max supported size [%d, %d]", - w, h, evgl_engine->caps.max_w, evgl_engine->caps.max_h); - evas_gl_common_error_set(eng_data, EVAS_GL_BAD_PARAMETER); - return NULL; - } - // Allocate surface structure sfc = calloc(1, sizeof(EVGL_Surface)); if (!sfc) @@ -2147,14 +2188,8 @@ evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h) } } - // Set the internal config value - if (!_internal_config_set(eng_data, sfc, cfg)) - { - ERR("Unsupported Format!"); - evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONFIG); - goto error; - } - sfc->cfg = cfg; + sfc->cfg = *cfg; + sfc->cfg_index = -1; // Keep track of all the created surfaces LKL(evgl_engine->resource_lock); @@ -2224,17 +2259,8 @@ evgl_pbuffer_surface_create(void *eng_data, Evas_GL_Config *cfg, if (sfc->pbuffer.color_fmt == EVAS_GL_NO_FBO) sfc->buffers_skip_allocate = 1; - if (!sfc->buffers_skip_allocate) - { - // Set the internal config value - if (!_internal_config_set(eng_data, sfc, cfg)) - { - ERR("Unsupported Format!"); - evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONFIG); - goto error; - } - } - sfc->cfg = cfg; + sfc->cfg = *cfg; + sfc->cfg_index = -1; pbuffer = evgl_engine->funcs->pbuffer_surface_create (eng_data, sfc, attrib_list); @@ -2405,6 +2431,7 @@ evgl_context_create(void *eng_data, EVGL_Context *share_ctx, void *(*engine_data_get)(void *)) { EVGL_Context *ctx = NULL; + int caps_idx = version - 1; // A little bit ugly. But it works even when dlsym(DEFAULT) doesn't work. glsym_evas_gl_native_context_get = native_context_get; @@ -2441,8 +2468,8 @@ evgl_context_create(void *eng_data, EVGL_Context *share_ctx, ctx->version = version; ctx->scissor_coord[0] = 0; ctx->scissor_coord[1] = 0; - ctx->scissor_coord[2] = evgl_engine->caps.max_w; - ctx->scissor_coord[3] = evgl_engine->caps.max_h; + ctx->scissor_coord[2] = evgl_engine->caps[caps_idx].max_w; + ctx->scissor_coord[3] = evgl_engine->caps[caps_idx].max_h; ctx->gl_error = GL_NO_ERROR; // Call engine create context @@ -2588,6 +2615,7 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx) Eina_Bool dbg = EINA_FALSE; EVGL_Resource *rsc; int curr_fbo = 0, curr_draw_fbo = 0, curr_read_fbo = 0; + int caps_idx; // Check the input validity. If either sfc is valid but ctx is NULL, it's also error. // sfc can be NULL as evas gl supports surfaceless make current @@ -2705,6 +2733,35 @@ evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx) } } + if (sfc && (sfc->cfg_index < 0 ) && (!sfc->buffers_skip_allocate)) + { + if (!_surface_cap_init(eng_data, ctx->version)) + { + ERR("Error initializing surface cap"); + evas_gl_common_error_set(eng_data, EVAS_GL_NOT_INITIALIZED); + return 0; + } + + caps_idx = ctx->version - 1; + + // Check the size of the surface + if ((sfc->w > evgl_engine->caps[caps_idx].max_w) || (sfc->h > evgl_engine->caps[caps_idx].max_h)) + { + ERR("Requested surface size [%d, %d] is greater than max supported size [%d, %d]", + sfc->w, sfc->h, evgl_engine->caps[caps_idx].max_w, evgl_engine->caps[caps_idx].max_h); + evas_gl_common_error_set(eng_data, EVAS_GL_BAD_PARAMETER); + return 0; + } + + // Set the internal config value + if (!_internal_config_set(eng_data, sfc, ctx->version)) + { + ERR("Unsupported Format!"); + evas_gl_common_error_set(eng_data, EVAS_GL_BAD_CONFIG); + return 0; + } + } + if (sfc) sfc->current_ctx = ctx; else { diff --git a/src/modules/evas/engines/gl_common/evas_gl_core_private.h b/src/modules/evas/engines/gl_common/evas_gl_core_private.h index b10cc9d..428aba9 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h +++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h @@ -139,8 +139,8 @@ struct _EVGL_Surface unsigned thread_rendering : 1; - void *cfg; - int cfg_index; + Evas_GL_Config cfg; + int cfg_index; // Rough estimate of buffer in memory per renderbuffer @@ -336,7 +336,7 @@ struct _EVGL_Engine const EVGL_Interface *funcs; - EVGL_Cap caps; + EVGL_Cap caps[3]; const char *gl_ext; const char *evgl_ext; diff --git a/src/modules/evas/engines/gl_common/evas_gl_file_cache.c b/src/modules/evas/engines/gl_common/evas_gl_file_cache.c index 91ebf9c..ccd4f8f 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_file_cache.c +++ b/src/modules/evas/engines/gl_common/evas_gl_file_cache.c @@ -1,4 +1,6 @@ #include "evas_gl_private.h" +#define EVAS_GL_NO_GL_H_CHECK 1 +#include "Evas_GL.h" static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; @@ -84,7 +86,7 @@ evas_gl_common_file_cache_dir_check(char *cache_dir, int num) } int -evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_name, char *cache_file, int dir_num) +evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_name, char *cache_file, int dir_num, Evas_GL_Context_Version gles_version) { char before_name[PATH_MAX]; char after_name[PATH_MAX]; @@ -103,7 +105,11 @@ evas_gl_common_file_cache_file_check(const char *cache_dir, const char *cache_na if (!driver) driver = "-UNKNOWN-"; if (!version) version = "-UNKNOWN-"; - new_path_len = snprintf(before_name, sizeof(before_name), "%s::%s::%s::%s.%d::%s.eet", + if (!strcmp(cache_name, "surface_cap")) + new_path_len = snprintf(before_name, sizeof(before_name), "%s::%s::%s::%s.%d::%s::%d.eet", + vendor, version, driver, MODULE_ARCH, evas_version->micro, cache_name, gles_version); + else + new_path_len = snprintf(before_name, sizeof(before_name), "%s::%s::%s::%s.%d::%s.eet", vendor, version, driver, MODULE_ARCH, evas_version->micro, cache_name); /* remove '/' from file name */ diff --git a/src/modules/evas/engines/gl_common/evas_gl_shader.c b/src/modules/evas/engines/gl_common/evas_gl_shader.c index bf2a42d..6ce8287 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_shader.c +++ b/src/modules/evas/engines/gl_common/evas_gl_shader.c @@ -271,7 +271,7 @@ _evas_gl_common_shader_binary_init(Evas_GL_Shared *shared) return 0; if (!evas_gl_common_file_cache_file_check(bin_dir_path, SHADER_EET_CACHENAME, - bin_file_path, sizeof(bin_dir_path))) + bin_file_path, sizeof(bin_dir_path), 0)) return 0; if (!eet_init()) return 0; @@ -311,7 +311,7 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared) } copy = evas_gl_common_file_cache_file_check(bin_dir_path, SHADER_EET_CACHENAME, - bin_file_path, sizeof(bin_dir_path)); + bin_file_path, sizeof(bin_dir_path), 0); /* use mkstemp for writing */ snprintf(tmp_file_name, sizeof(tmp_file_name), "%s.XXXXXX.cache", bin_file_path); diff --git a/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_generated.c b/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_generated.c index c4cdeb3..cd57d48 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_generated.c +++ b/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_generated.c @@ -5301,6 +5301,58 @@ finish: /* * void + * glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint *params); + */ + +typedef struct +{ + GLenum target; + GLenum attachment; + GLenum pname; + GLint *params; + +} EVGL_Thread_Command_glGetFramebufferAttachmentParameteriv; + +static void +_evgl_thread_glGetFramebufferAttachmentParameteriv(void *data) +{ + EVGL_Thread_Command_glGetFramebufferAttachmentParameteriv *thread_data = + (EVGL_Thread_Command_glGetFramebufferAttachmentParameteriv *)data; + + glGetFramebufferAttachmentParameteriv(thread_data->target, + thread_data->attachment, + thread_data->pname, + thread_data->params); + +} + +EAPI void +glGetFramebufferAttachmentParameteriv_evgl_thread_cmd(GLenum target, GLenum attachment, GLenum pname, GLint *params) +{ + if (!evas_evgl_thread_enabled()) + { + glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); + return; + } + + int thread_mode = EVAS_GL_THREAD_MODE_FINISH; + + EVGL_Thread_Command_glGetFramebufferAttachmentParameteriv thread_data_local; + EVGL_Thread_Command_glGetFramebufferAttachmentParameteriv *thread_data = &thread_data_local; + + thread_data->target = target; + thread_data->attachment = attachment; + thread_data->pname = pname; + thread_data->params = params; + + evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_EVGL, + _evgl_thread_glGetFramebufferAttachmentParameteriv, + thread_data, + thread_mode); +} + +/* + * void * glGenRenderbuffers(GLsizei n, GLuint *renderbuffers); */ diff --git a/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_generated.h b/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_generated.h index 33f95b8..f678d2e 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_generated.h +++ b/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_generated.h @@ -113,6 +113,7 @@ EAPI void glReadPixels_evgl_thread_cmd(GLint x, GLint y, GLsizei width, GLsizei EAPI void glGenFramebuffers_evgl_thread_cmd(GLsizei n, GLuint *framebuffers); EAPI void glBindFramebuffer_evgl_thread_cmd(GLenum target, GLuint framebuffer); EAPI void glDeleteFramebuffers_evgl_thread_cmd(GLsizei n, const GLuint *framebuffers); +EAPI void glGetFramebufferAttachmentParameteriv_evgl_thread_cmd(GLenum target, GLenum attachment, GLenum pname, GLint *params); EAPI void glGenRenderbuffers_evgl_thread_cmd(GLsizei n, GLuint *renderbuffers); EAPI void glBindRenderbuffer_evgl_thread_cmd(GLenum target, GLuint renderbuffer); EAPI void glDeleteRenderbuffers_evgl_thread_cmd(GLsizei n, const GLuint *renderbuffers); diff --git a/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_link_generated.c b/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_link_generated.c index 6cbcf56..ab71557 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_link_generated.c +++ b/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_link_generated.c @@ -81,6 +81,7 @@ void (*glReadPixels_evgl_thread_cmd)(GLint x, GLint y, GLsizei width, GLsizei he void (*glGenFramebuffers_evgl_thread_cmd)(GLsizei n, GLuint *framebuffers) = NULL; void (*glBindFramebuffer_evgl_thread_cmd)(GLenum target, GLuint framebuffer) = NULL; void (*glDeleteFramebuffers_evgl_thread_cmd)(GLsizei n, const GLuint *framebuffers) = NULL; +void (*glGetFramebufferAttachmentParameteriv_evgl_thread_cmd)(GLenum target, GLenum attachment, GLenum pname, GLint *params) = NULL; void (*glGenRenderbuffers_evgl_thread_cmd)(GLsizei n, GLuint *renderbuffers) = NULL; void (*glBindRenderbuffer_evgl_thread_cmd)(GLenum target, GLuint renderbuffer) = NULL; void (*glDeleteRenderbuffers_evgl_thread_cmd)(GLsizei n, const GLuint *renderbuffers) = NULL; @@ -198,6 +199,7 @@ _gl_thread_link_evgl_generated_init() LINK2GENERIC(glGenFramebuffers_evgl_thread_cmd); LINK2GENERIC(glBindFramebuffer_evgl_thread_cmd); LINK2GENERIC(glDeleteFramebuffers_evgl_thread_cmd); + LINK2GENERIC(glGetFramebufferAttachmentParameteriv_evgl_thread_cmd); LINK2GENERIC(glGenRenderbuffers_evgl_thread_cmd); LINK2GENERIC(glBindRenderbuffer_evgl_thread_cmd); LINK2GENERIC(glDeleteRenderbuffers_evgl_thread_cmd); diff --git a/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_link_generated.h b/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_link_generated.h index 0d4e9ae..41bdc7b 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_link_generated.h +++ b/src/modules/evas/engines/gl_common/evas_gl_thread_evgl_link_generated.h @@ -81,6 +81,7 @@ extern void (*glReadPixels_evgl_thread_cmd)(GLint x, GLint y, GLsizei width, GLs extern void (*glGenFramebuffers_evgl_thread_cmd)(GLsizei n, GLuint *framebuffers); extern void (*glBindFramebuffer_evgl_thread_cmd)(GLenum target, GLuint framebuffer); extern void (*glDeleteFramebuffers_evgl_thread_cmd)(GLsizei n, const GLuint *framebuffers); +extern void (*glGetFramebufferAttachmentParameteriv_evgl_thread_cmd)(GLenum target, GLenum attachment, GLenum pname, GLint *params); extern void (*glGenRenderbuffers_evgl_thread_cmd)(GLsizei n, GLuint *renderbuffers); extern void (*glBindRenderbuffer_evgl_thread_cmd)(GLenum target, GLuint renderbuffer); extern void (*glDeleteRenderbuffers_evgl_thread_cmd)(GLsizei n, const GLuint *renderbuffers); diff --git a/src/utils/evas/gl_api_def.txt b/src/utils/evas/gl_api_def.txt index d6f0548..0e67d88 100644 --- a/src/utils/evas/gl_api_def.txt +++ b/src/utils/evas/gl_api_def.txt @@ -360,6 +360,7 @@ | EVAS GL | void | glGenFramebuffers | GLsizei n,GLuint *framebuffers | finish | noext | | | | EVAS GL | void | glBindFramebuffer | GLenum target,GLuint framebuffer | flush | noext | | | | EVAS GL | void | glDeleteFramebuffers | GLsizei n,const GLuint *framebuffers | flush | noext | _mp_delete_object, n * sizeof(GLuint), framebuffers | | +| EVAS GL | void | glGetFramebufferAttachmentParameteriv | GLenum target, GLenum attachment, GLenum pname, GLint *params | finish | noext | | | # Renderbuffer Objects | EVAS GL | void | glGenRenderbuffers | GLsizei n,GLuint *renderbuffers | finish | noext | | | -- 2.7.4