summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-11-19 15:08:00 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-11-19 16:22:37 +0900
commit1a403849dca1c832c43bf4abf8226da63570fbca (patch)
tree905a4162e94aa527167fd5bfab6351b9f76a0a01
parent18ceed4daf31d2f19261e0fe018c870581357ed0 (diff)
Evas GL: Wrap glGetString for VERSION
- glGetString(GL_VERSION) should not return "OpenGL ES 3.0" because GLESv3 is not supported yet. - GL_EXTENSIONS should return only the list of supported extensions --> disabled for now as the whitelist of safe extensions is way too small.
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api.c81
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_ext.c35
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_ext.h2
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.c2
-rw-r--r--src/modules/evas/engines/software_generic/evas_engine.c1
5 files changed, 99 insertions, 22 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 477e8315d0..6007b7c4f8 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api.c
@@ -531,6 +531,76 @@ _evgl_glGetIntegerv(GLenum pname, GLint* params)
531 glGetIntegerv(pname, params); 531 glGetIntegerv(pname, params);
532} 532}
533 533
534static const GLubyte *
535_evgl_glGetString(GLenum name)
536{
537 static char _version[64] = {0};
538 EVGL_Resource *rsc;
539 const GLubyte *ret;
540 char *r;
541
542 /* We wrap two values here:
543 *
544 * VERSION: Since OpenGL ES 3 is not supported yet, we return OpenGL ES 2.0
545 * The string is not modified on desktop GL (eg. 4.4.0 NVIDIA 343.22)
546 * GLES 3 support is not exposed because apps can't use GLES 3 core
547 * functions yet.
548 *
549 * EXTENSIONS: This should return the list of GL extensions supported by Evas GL
550 * --> FIXME: Unfortunately the whitelist does not contain enough extensions
551 * especially for desktop GL and needs updating as OpenGL evolves.
552 */
553
554 /*
555 * Note from Khronos: "If an error is generated, glGetString returns 0."
556 * I decided not to call glGetString if there is no context as this is
557 * known to cause crashes on certain GL drivers (eg. Nvidia binary blob).
558 * --> crash moved to app side if they blindly call strstr()
559 */
560
561 if ((!(rsc = _evgl_tls_resource_get())) || !rsc->current_ctx)
562 {
563 ERR("Current context is NULL, not calling glGetString");
564 // This sets evas_gl_error_get instead of glGetError...
565 evas_gl_common_error_set(NULL, EVAS_GL_BAD_CONTEXT);
566 return NULL;
567 }
568
569 switch (name)
570 {
571 case GL_VENDOR:
572 case GL_RENDERER:
573 case GL_SHADING_LANGUAGE_VERSION: // wrap me?
574 break;
575 case GL_VERSION:
576 ret = glGetString(GL_VERSION);
577 if (!ret) return NULL;
578 if (strstr((const char *) ret, "OpenGL ES 3"))
579 {
580 // We try not to remove the vendor fluff (contains driver version)
581 strncpy(_version, (const char *) ret, sizeof(_version));
582 r = strchr(_version, '3');
583 *r++ = '2';
584 *r++ = '.';
585 *r++ = '0';
586 *r = ' ';
587 _version[sizeof(_version) - 1] = '\0';
588 return (const GLubyte *) _version;
589 }
590 return ret;
591 case GL_EXTENSIONS:
592 // return (GLubyte *) evgl_api_ext_string_get
593 // (EINA_TRUE, (rsc->current_ctx->version == EVAS_GL_GLES_1_X));
594 break;
595 default:
596 // GL_INVALID_ENUM is generated if name is not an accepted value.
597 WRN("Unknown string requested: %x", (unsigned int) name);
598 break;
599 }
600
601 return glGetString(name);
602}
603
534static void 604static void
535_evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels) 605_evgl_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels)
536{ 606{
@@ -1458,13 +1528,7 @@ _evgld_glGetString(GLenum name)
1458 const GLubyte *ret = NULL; 1528 const GLubyte *ret = NULL;
1459 1529
1460 EVGL_FUNC_BEGIN(); 1530 EVGL_FUNC_BEGIN();
1461#if 0 1531 ret = _evgl_glGetString(name);
1462 if (name == GL_EXTENSIONS)
1463 return (GLubyte *)_gl_ext_string; //glGetString(GL_EXTENSIONS);
1464 else
1465 return glGetString(name);
1466#endif
1467 ret = glGetString(name);
1468 GLERR(__FUNCTION__, __FILE__, __LINE__, ""); 1532 GLERR(__FUNCTION__, __FILE__, __LINE__, "");
1469 EVGL_FUNC_END(); 1533 EVGL_FUNC_END();
1470 return ret; 1534 return ret;
@@ -2487,7 +2551,7 @@ _normal_gl_api_get(Evas_GL_API *funcs)
2487 ORD(glGetShaderInfoLog); 2551 ORD(glGetShaderInfoLog);
2488// ORD(glGetShaderPrecisionFormat); 2552// ORD(glGetShaderPrecisionFormat);
2489 ORD(glGetShaderSource); 2553 ORD(glGetShaderSource);
2490 ORD(glGetString); 2554// ORD(glGetString);
2491 ORD(glGetTexParameterfv); 2555 ORD(glGetTexParameterfv);
2492 ORD(glGetTexParameteriv); 2556 ORD(glGetTexParameteriv);
2493 ORD(glGetUniformfv); 2557 ORD(glGetUniformfv);
@@ -2575,6 +2639,7 @@ _normal_gl_api_get(Evas_GL_API *funcs)
2575 ORD(glDisable); 2639 ORD(glDisable);
2576 ORD(glEnable); 2640 ORD(glEnable);
2577 ORD(glGetIntegerv); 2641 ORD(glGetIntegerv);
2642 ORD(glGetString);
2578 ORD(glReadPixels); 2643 ORD(glReadPixels);
2579 ORD(glScissor); 2644 ORD(glScissor);
2580 ORD(glViewport); 2645 ORD(glViewport);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
index 537b9dd786..d19d2eb279 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
@@ -6,7 +6,10 @@
6 6
7#define MAX_EXTENSION_STRING_BUFFER 10240 7#define MAX_EXTENSION_STRING_BUFFER 10240
8 8
9char _gl_ext_string[10240] = { 0 }; 9// list of exts like "discard_framebuffer GL_EXT_discard_framebuffer multi_draw_arrays GL_EXT_multi_draw_arrays"
10char _gl_ext_string[MAX_EXTENSION_STRING_BUFFER] = { 0 };
11// list of exts by official name only like "GL_EXT_discard_framebuffer GL_EXT_multi_draw_arrays"
12char _gl_ext_string_official[MAX_EXTENSION_STRING_BUFFER] = { 0 };
10 13
11#ifndef EGL_NATIVE_PIXMAP_KHR 14#ifndef EGL_NATIVE_PIXMAP_KHR
12# define EGL_NATIVE_PIXMAP_KHR 0x30b0 15# define EGL_NATIVE_PIXMAP_KHR 0x30b0
@@ -252,7 +255,8 @@ evgl_api_ext_init(void *getproc, const char *glueexts)
252 fp_getproc gp = (fp_getproc)getproc; 255 fp_getproc gp = (fp_getproc)getproc;
253 int _curext_supported = 0; 256 int _curext_supported = 0;
254 257
255 memset(_gl_ext_string, 0x00, MAX_EXTENSION_STRING_BUFFER); 258 memset(_gl_ext_string, 0, MAX_EXTENSION_STRING_BUFFER);
259 memset(_gl_ext_string_official, 0, MAX_EXTENSION_STRING_BUFFER);
256 260
257#define FINDSYM(getproc, dst, sym) \ 261#define FINDSYM(getproc, dst, sym) \
258 if (getproc) { \ 262 if (getproc) { \
@@ -346,9 +350,8 @@ re->info->info.screen);
346#undef GETPROCADDR 350#undef GETPROCADDR
347 ///////////////////////////////////////////////////////////////////////////////////////////////////// 351 /////////////////////////////////////////////////////////////////////////////////////////////////////
348 352
349 353 _gl_ext_string[0] = 0;
350 354 _gl_ext_string_official[0] = 0;
351 _gl_ext_string[0] = 0x00; //NULL;
352 355
353 ///////////////////////////////////////////////////////////////////////////////////////////////////// 356 /////////////////////////////////////////////////////////////////////////////////////////////////////
354 // Extension HEADER 357 // Extension HEADER
@@ -360,7 +363,12 @@ re->info->info.screen);
360#define _EVASGL_EXT_END() 363#define _EVASGL_EXT_END()
361#define _EVASGL_EXT_CHECK_SUPPORT(name) 364#define _EVASGL_EXT_CHECK_SUPPORT(name)
362#define _EVASGL_EXT_DISCARD_SUPPORT() 365#define _EVASGL_EXT_DISCARD_SUPPORT()
363#define _EVASGL_EXT_DRVNAME(name) if (_curext_supported) strcat(_gl_ext_string, #name" "); 366#define _EVASGL_EXT_DRVNAME(name) \
367 if (_curext_supported) \
368 { \
369 strcat(_gl_ext_string, #name" "); \
370 strcat(_gl_ext_string_official, #name" "); \
371 }
364#define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param) 372#define _EVASGL_EXT_FUNCTION_BEGIN(ret, name, param)
365#define _EVASGL_EXT_FUNCTION_END() 373#define _EVASGL_EXT_FUNCTION_END()
366#define _EVASGL_EXT_FUNCTION_DRVFUNC(name) 374#define _EVASGL_EXT_FUNCTION_DRVFUNC(name)
@@ -379,10 +387,7 @@ re->info->info.screen);
379#undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR 387#undef _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR
380 ///////////////////////////////////////////////////////////////////////////////////////////////////// 388 /////////////////////////////////////////////////////////////////////////////////////////////////////
381 389
382 390 _evgl_api_ext_status = 1;
383
384
385 _evgl_api_ext_status = 1;
386 return EINA_TRUE; 391 return EINA_TRUE;
387} 392}
388 393
@@ -488,8 +493,9 @@ evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs)
488#undef ORD 493#undef ORD
489 494
490} 495}
496
491const char * 497const char *
492evgl_api_ext_string_get() 498evgl_api_ext_string_get(Eina_Bool official, Eina_Bool gles1)
493{ 499{
494 if (_evgl_api_ext_status != 1) 500 if (_evgl_api_ext_status != 1)
495 { 501 {
@@ -497,6 +503,11 @@ evgl_api_ext_string_get()
497 return NULL; 503 return NULL;
498 } 504 }
499 505
506 // TODO: Properly distinguish between GLES 2 and GLES 1 extensions.
507 (void) gles1;
508
509 if (official)
510 return _gl_ext_string_official;
511
500 return _gl_ext_string; 512 return _gl_ext_string;
501} 513}
502
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext.h b/src/modules/evas/engines/gl_common/evas_gl_api_ext.h
index d6f4b023d5..91c235831e 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_ext.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext.h
@@ -74,7 +74,7 @@
74extern Eina_Bool evgl_api_ext_init(void *getproc, const char *glueexts); 74extern Eina_Bool evgl_api_ext_init(void *getproc, const char *glueexts);
75extern void evgl_api_ext_get(Evas_GL_API *gl_funcs); 75extern void evgl_api_ext_get(Evas_GL_API *gl_funcs);
76extern void evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs); 76extern void evgl_api_gles1_ext_get(Evas_GL_API *gl_funcs);
77extern const char *evgl_api_ext_string_get(); 77extern const char *evgl_api_ext_string_get(Eina_Bool official, Eina_Bool gles1);
78 78
79#endif //_EVAS_GL_API_EXT_H 79#endif //_EVAS_GL_API_EXT_H
80 80
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 adc027d8c9..09f521d4f4 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -2275,7 +2275,7 @@ evgl_string_query(int name)
2275 switch(name) 2275 switch(name)
2276 { 2276 {
2277 case EVAS_GL_EXTENSIONS: 2277 case EVAS_GL_EXTENSIONS:
2278 return evgl_api_ext_string_get(); 2278 return evgl_api_ext_string_get(EINA_FALSE, EINA_FALSE);
2279 default: 2279 default:
2280 return ""; 2280 return "";
2281 }; 2281 };
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c
index 24cbf21e3b..ccb6ccb840 100644
--- a/src/modules/evas/engines/software_generic/evas_engine.c
+++ b/src/modules/evas/engines/software_generic/evas_engine.c
@@ -3621,6 +3621,7 @@ gl_sym_init(void)
3621 3621
3622 // Checking to see if this function exists is a poor but reasonable way to 3622 // Checking to see if this function exists is a poor but reasonable way to
3623 // check if it's gles but it works for now 3623 // check if it's gles but it works for now
3624 // FIXME: This is wrong as OpenGL 4.1 also supports this function.
3624 if (_sym_glGetShaderPrecisionFormat != (typeof(_sym_glGetShaderPrecisionFormat))sym_missing ) 3625 if (_sym_glGetShaderPrecisionFormat != (typeof(_sym_glGetShaderPrecisionFormat))sym_missing )
3625 { 3626 {
3626 DBG("GL Library is GLES."); 3627 DBG("GL Library is GLES.");