summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h1
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c27
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.c13
-rw-r--r--src/modules/evas/engines/gl_x11/evas_engine.h1
-rw-r--r--src/modules/evas/engines/gl_x11/evas_x_main.c62
5 files changed, 92 insertions, 12 deletions
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 24e926f337..c0f3c97d99 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -515,6 +515,7 @@ struct _Evas_Engine_GL_Context
515#endif 515#endif
516 516
517 GLuint preserve_bit; 517 GLuint preserve_bit;
518 int gles_version;
518}; 519};
519 520
520struct _Evas_GL_Texture_Pool 521struct _Evas_GL_Texture_Pool
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c
index b925d365d5..3f47cb6807 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -337,13 +337,14 @@ matrix_ortho(GLfloat *m,
337} 337}
338 338
339static int 339static int
340_evas_gl_common_version_check() 340_evas_gl_common_version_check(int *gles_ver)
341{ 341{
342 char *version; 342 char *version;
343 char *tmp; 343 char *tmp;
344 char *tmp2; 344 char *tmp2;
345 int major = 0; 345 int major = 0;
346 int minor = 0; 346 int minor = 0;
347 *gles_ver = 0;
347 348
348 /* 349 /*
349 * glGetString returns a string describing the current GL connection. 350 * glGetString returns a string describing the current GL connection.
@@ -375,11 +376,21 @@ _evas_gl_common_version_check()
375 return 0; 376 return 0;
376 } 377 }
377 378
379 /* OpenGL ES 3.* */
380
381 if (strstr(version, "OpenGL ES 3"))
382 {
383 /* Supported */
384 *gles_ver = 3;
385 return 1;
386 }
387
378 /* OpenGL ES 2.* ? */ 388 /* OpenGL ES 2.* ? */
379 389
380 if (strstr(version, "OpenGL ES ")) 390 if (strstr(version, "OpenGL ES "))
381 { 391 {
382 /* Supported */ 392 /* Supported */
393 *gles_ver = 2;
383 return 1; 394 return 1;
384 } 395 }
385 396
@@ -422,7 +433,14 @@ _evas_gl_common_version_check()
422 free(version); 433 free(version);
423 434
424 if (((major == 1) && (minor >= 4)) || (major >= 2)) 435 if (((major == 1) && (minor >= 4)) || (major >= 2))
425 return 1; 436 {
437 /* Map GL to GLES version: Refer http://en.wikipedia.org/wiki/OpenGL_ES */
438 if ((major >=4 ) && (minor >= 3))
439 *gles_ver = 3;
440 else
441 *gles_ver = 2;
442 return 1;
443 }
426 444
427 return 0; 445 return 0;
428} 446}
@@ -579,7 +597,7 @@ evas_gl_common_context_new(void)
579{ 597{
580 Evas_Engine_GL_Context *gc; 598 Evas_Engine_GL_Context *gc;
581 const char *s; 599 const char *s;
582 int i; 600 int i, gles_version;
583 601
584#if 1 602#if 1
585 if (_evas_gl_common_context) 603 if (_evas_gl_common_context)
@@ -588,12 +606,13 @@ evas_gl_common_context_new(void)
588 return _evas_gl_common_context; 606 return _evas_gl_common_context;
589 } 607 }
590#endif 608#endif
591 if (!_evas_gl_common_version_check()) 609 if (!_evas_gl_common_version_check(&gles_version))
592 return NULL; 610 return NULL;
593 gc = calloc(1, sizeof(Evas_Engine_GL_Context)); 611 gc = calloc(1, sizeof(Evas_Engine_GL_Context));
594 if (!gc) return NULL; 612 if (!gc) return NULL;
595 613
596 tbm_symbols(); 614 tbm_symbols();
615 gc->gles_version = gles_version;
597 616
598 gc->references = 1; 617 gc->references = 1;
599 618
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.c b/src/modules/evas/engines/gl_x11/evas_engine.c
index 6bda8ea675..0f5ae5331d 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.c
+++ b/src/modules/evas/engines/gl_x11/evas_engine.c
@@ -479,6 +479,9 @@ evgl_eng_context_create(void *data, void *share_ctx, Evas_GL_Context_Version ver
479 EGLContext context = EGL_NO_CONTEXT; 479 EGLContext context = EGL_NO_CONTEXT;
480 int context_attrs[3]; 480 int context_attrs[3];
481 481
482 if (eng_get_ob(re)->gles3 && (version >= EVAS_GL_GLES_2_X))
483 version = 3;
484
482 context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION; 485 context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
483 context_attrs[1] = version; 486 context_attrs[1] = version;
484 context_attrs[2] = EGL_NONE; 487 context_attrs[2] = EGL_NONE;
@@ -698,7 +701,10 @@ evgl_eng_pbuffer_surface_create(void *data, EVGL_Surface *sfc,
698 } 701 }
699 702
700 config_attrs[i++] = EGL_RENDERABLE_TYPE; 703 config_attrs[i++] = EGL_RENDERABLE_TYPE;
701 config_attrs[i++] = EGL_OPENGL_ES2_BIT; 704 if (eng_get_ob(re)->gles3)
705 config_attrs[i++] = EGL_OPENGL_ES3_BIT_KHR;
706 else
707 config_attrs[i++] = EGL_OPENGL_ES2_BIT;
702 config_attrs[i++] = EGL_SURFACE_TYPE; 708 config_attrs[i++] = EGL_SURFACE_TYPE;
703 config_attrs[i++] = EGL_PBUFFER_BIT; 709 config_attrs[i++] = EGL_PBUFFER_BIT;
704 config_attrs[i++] = EGL_NONE; 710 config_attrs[i++] = EGL_NONE;
@@ -2239,7 +2245,10 @@ eng_image_native_set(void *data, void *image, void *native)
2239 config_attrs[i++] = EGL_STENCIL_SIZE; 2245 config_attrs[i++] = EGL_STENCIL_SIZE;
2240 config_attrs[i++] = 0; 2246 config_attrs[i++] = 0;
2241 config_attrs[i++] = EGL_RENDERABLE_TYPE; 2247 config_attrs[i++] = EGL_RENDERABLE_TYPE;
2242 config_attrs[i++] = EGL_OPENGL_ES2_BIT; 2248 if (eng_get_ob(re)->gles3)
2249 config_attrs[i++] = EGL_OPENGL_ES3_BIT_KHR;
2250 else
2251 config_attrs[i++] = EGL_OPENGL_ES2_BIT;
2243 config_attrs[i++] = EGL_SURFACE_TYPE; 2252 config_attrs[i++] = EGL_SURFACE_TYPE;
2244 config_attrs[i++] = EGL_PIXMAP_BIT; 2253 config_attrs[i++] = EGL_PIXMAP_BIT;
2245 config_attrs[i++] = EGL_NONE; 2254 config_attrs[i++] = EGL_NONE;
diff --git a/src/modules/evas/engines/gl_x11/evas_engine.h b/src/modules/evas/engines/gl_x11/evas_engine.h
index 347c41f30e..114ea6e45e 100644
--- a/src/modules/evas/engines/gl_x11/evas_engine.h
+++ b/src/modules/evas/engines/gl_x11/evas_engine.h
@@ -65,6 +65,7 @@ struct _Outbuf
65 EGLSurface egl_surface[2]; 65 EGLSurface egl_surface[2];
66 EGLConfig egl_config; 66 EGLConfig egl_config;
67 EGLDisplay egl_disp; 67 EGLDisplay egl_disp;
68 Eina_Bool gles3 : 1;
68#else 69#else
69 GLXContext context; 70 GLXContext context;
70 GLXWindow glxwin; 71 GLXWindow glxwin;
diff --git a/src/modules/evas/engines/gl_x11/evas_x_main.c b/src/modules/evas/engines/gl_x11/evas_x_main.c
index 7cad2e6d2a..767f580bc5 100644
--- a/src/modules/evas/engines/gl_x11/evas_x_main.c
+++ b/src/modules/evas/engines/gl_x11/evas_x_main.c
@@ -7,6 +7,7 @@ static Eina_TLS _context_key = 0;
7typedef EGLContext GLContext; 7typedef EGLContext GLContext;
8static EGLConfig fbconf = 0; 8static EGLConfig fbconf = 0;
9static EGLConfig rgba_fbconf = 0; 9static EGLConfig rgba_fbconf = 0;
10static Eina_Bool gles3_supported = EINA_FALSE;
10#else 11#else
11// FIXME: this will only work for 1 display connection (glx land can have > 1) 12// FIXME: this will only work for 1 display connection (glx land can have > 1)
12typedef GLXContext GLContext; 13typedef GLXContext GLContext;
@@ -158,10 +159,7 @@ eng_window_new(Evas_Engine_Info_GL_X11 *info,
158 159
159// EGL / GLES 160// EGL / GLES
160#ifdef GL_GLES 161#ifdef GL_GLES
161 context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION; 162 gw->gles3 = gles3_supported;
162 context_attrs[1] = 2;
163 context_attrs[2] = EGL_NONE;
164
165 gw->egl_disp = eglGetDisplay((EGLNativeDisplayType)(gw->disp)); 163 gw->egl_disp = eglGetDisplay((EGLNativeDisplayType)(gw->disp));
166 if (!gw->egl_disp) 164 if (!gw->egl_disp)
167 { 165 {
@@ -197,13 +195,25 @@ eng_window_new(Evas_Engine_Info_GL_X11 *info,
197 eng_window_free(gw); 195 eng_window_free(gw);
198 return NULL; 196 return NULL;
199 } 197 }
200 198
199try_gles2:
200 context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
201 context_attrs[1] = gw->gles3 ? 3 : 2;
202 context_attrs[2] = EGL_NONE;
203
201 context = _tls_context_get(); 204 context = _tls_context_get();
202 gw->egl_context[0] = eglCreateContext 205 gw->egl_context[0] = eglCreateContext
203 (gw->egl_disp, gw->egl_config, context, context_attrs); 206 (gw->egl_disp, gw->egl_config, context, context_attrs);
204 if (gw->egl_context[0] == EGL_NO_CONTEXT) 207 if (gw->egl_context[0] == EGL_NO_CONTEXT)
205 { 208 {
206 ERR("eglCreateContext() fail. code=%#x", eglGetError()); 209 ERR("eglCreateContext() fail. code=%#x", eglGetError());
210 if (gw->gles3)
211 {
212 /* Note: this shouldn't happen */
213 ERR("Trying again with an Open GL ES 2 context (fallback).");
214 gw->gles3 = EINA_FALSE;
215 goto try_gles2;
216 }
207 eng_window_free(gw); 217 eng_window_free(gw);
208 return NULL; 218 return NULL;
209 } 219 }
@@ -687,11 +697,46 @@ eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
687 EGLDisplay *egl_disp; 697 EGLDisplay *egl_disp;
688 EGLConfig configs[200]; 698 EGLConfig configs[200];
689 int major_version, minor_version; 699 int major_version, minor_version;
700 const char *eglexts, *s;
690 701
691 egl_disp = eglGetDisplay((EGLNativeDisplayType)(einfo->info.display)); 702 egl_disp = eglGetDisplay((EGLNativeDisplayType)(einfo->info.display));
692 if (!egl_disp) return NULL; 703 if (!egl_disp) return NULL;
693 if (!eglInitialize(egl_disp, &major_version, &minor_version)) return NULL; 704 if (!eglInitialize(egl_disp, &major_version, &minor_version)) return NULL;
694 705
706 eglexts = eglQueryString(egl_disp, EGL_EXTENSIONS);
707 if (eglexts && strstr(eglexts, "EGL_KHR_create_context"))
708 {
709 int k, numconfigs = 0, value;
710 EGLConfig *eglconfigs;
711
712 if (eglGetConfigs(egl_disp, NULL, 0, &numconfigs) &&
713 (numconfigs > 0))
714 {
715 eglconfigs = alloca(numconfigs * sizeof(EGLConfig));
716 eglGetConfigs(egl_disp, eglconfigs, numconfigs, &numconfigs);
717 for (k = 0; k < numconfigs; k++)
718 {
719 value = 0;
720 if (eglGetConfigAttrib(egl_disp, eglconfigs[k], EGL_RENDERABLE_TYPE, &value) &&
721 ((value & EGL_OPENGL_ES3_BIT_KHR) != 0) &&
722 eglGetConfigAttrib(egl_disp, eglconfigs[k], EGL_SURFACE_TYPE, &value) &&
723 ((value & EGL_WINDOW_BIT) != 0))
724 {
725 INF("OpenGL ES 3.x is supported!");
726 gles3_supported = EINA_TRUE;
727 break;
728 }
729 }
730 }
731 }
732
733 if (gles3_supported &&
734 (!(s = getenv("EVAS_GL_DISABLE_GLES3")) || (atoi(s) != 1)))
735 {
736 INF("Disabling OpenGL ES 3.x support.");
737 gles3_supported = EINA_FALSE;
738 }
739
695 for (alpha = 0; alpha < 2; alpha++) 740 for (alpha = 0; alpha < 2; alpha++)
696 { 741 {
697 Eina_Bool found; 742 Eina_Bool found;
@@ -703,7 +748,10 @@ eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
703 config_attrs[n++] = EGL_SURFACE_TYPE; 748 config_attrs[n++] = EGL_SURFACE_TYPE;
704 config_attrs[n++] = EGL_WINDOW_BIT; 749 config_attrs[n++] = EGL_WINDOW_BIT;
705 config_attrs[n++] = EGL_RENDERABLE_TYPE; 750 config_attrs[n++] = EGL_RENDERABLE_TYPE;
706 config_attrs[n++] = EGL_OPENGL_ES2_BIT; 751 if (gles3_supported)
752 config_attrs[n++] = EGL_OPENGL_ES3_BIT_KHR;
753 else
754 config_attrs[n++] = EGL_OPENGL_ES2_BIT;
707# if 0 755# if 0
708 // FIXME: n900 - omap3 sgx libs break here 756 // FIXME: n900 - omap3 sgx libs break here
709 config_attrs[n++] = EGL_RED_SIZE; 757 config_attrs[n++] = EGL_RED_SIZE;
@@ -1007,6 +1055,8 @@ eng_gl_context_new(Outbuf *win)
1007 if (!ctx) return NULL; 1055 if (!ctx) return NULL;
1008 1056
1009#if GL_GLES 1057#if GL_GLES
1058 if (win->gles3)
1059 context_attrs[1] = 3;
1010 ctx->context = eglCreateContext(win->egl_disp, win->egl_config, 1060 ctx->context = eglCreateContext(win->egl_disp, win->egl_config,
1011 win->egl_context[0], context_attrs); 1061 win->egl_context[0], context_attrs);
1012 1062