GLboolean (*glsym_glUnmapBuffer) (GLenum a) = NULL;
void (*glsym_glStartTiling) (GLuint a, GLuint b, GLuint c, GLuint d, GLuint e) = NULL;
void (*glsym_glEndTiling) (GLuint a) = NULL;
+void (*glsym_glRenderbufferStorageMultisample)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) = NULL;
const char *(*glsym_glGetStringi) (GLenum name, GLuint index) = NULL;
FINDSYM(glsym_glUnmapBuffer, "glUnmapBufferEXT", NULL, glsym_func_boolean);
}
+ FINDSYM(glsym_glRenderbufferStorageMultisample, "glRenderbufferStorageMultisample", NULL, glsym_func_void);
+
#ifdef GL_GLES
// yes - gl core looking for egl stuff. i know it's odd. a reverse-layer thing
// but it will work as the egl/glx layer calls gl core common stuff and thus
m[15] = (m[3] * tx) + (m[7] * ty) + orth;
}
-static int
-_evas_gl_common_version_check(int *gles_ver)
+int
+evas_gl_common_version_check(void)
{
char *version;
char *tmp;
char *tmp2;
int major = 0;
int minor = 0;
- *gles_ver = 0;
/*
* glGetString returns a string describing the current GL connection.
if (strstr(version, "OpenGL ES 3"))
{
/* Supported */
- *gles_ver = 3;
- return 1;
+ return 3;
}
/* OpenGL ES 2.* ? */
if (strstr(version, "OpenGL ES "))
{
/* Supported */
- *gles_ver = 2;
- return 1;
+ return 2;
}
/*
{
/* Map GL to GLES version: Refer http://en.wikipedia.org/wiki/OpenGL_ES */
if ((major >= 4) && (minor >= 3))
- *gles_ver = 3;
+ return 3;
else if ((major > 3) || ((major == 3) && (minor >= 3))) /* >= 3.3 */
{
const char *exts = NULL;
int num = 0;
+
if (_has_ext("GL_ARB_ES3_compatibility", &exts, &num))
- *gles_ver = 3;
- else
- *gles_ver = 2;
+ return 3;
}
- else
- *gles_ver = 2; /* emulated support */
- return 1;
+ return 2; /* emulated support */
}
return 0;
if (!glsym_glGetStringi)
glsym_glGetStringi = dlsym(RTLD_DEFAULT, "glGetStringi");
- if (!_evas_gl_common_version_check(&gles_version))
- return NULL;
+ gles_version = evas_gl_common_version_check();
+ if (!gles_version) return NULL;
+
gc = calloc(1, sizeof(Evas_Engine_GL_Context));
if (!gc) return NULL;
static void
_texture_attach_2d(GLuint tex, GLenum attach, GLenum attach2, int samples, Evas_GL_Context_Version version)
{
- if (samples)
+ if (samples && (version == EVAS_GL_GLES_2_X))
{
#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(glFramebufferTexture2DMultisample))
+ {
+ 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
#endif
+ ERR("MSAA not supported. Should not have come in here...!");
}
else if (version == EVAS_GL_GLES_1_X)
{
{
glBindRenderbuffer(GL_RENDERBUFFER, buf);
if (samples)
+ {
+ if (glsym_glRenderbufferStorageMultisample)
+ glsym_glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, fmt, w, h);
+ else
+ {
#ifdef GL_GLES
- EXT_FUNC(glRenderbufferStorageMultisample)(GL_RENDERBUFFER, samples, fmt, w, h);
-#else
- ERR("MSAA not supported. Should not have come in here...!");
+ if (EXT_FUNC(glRenderbufferStorageMultisample))
+ EXT_FUNC(glRenderbufferStorageMultisample)(GL_RENDERBUFFER, samples, fmt, w, h);
+ else
#endif
+ ERR("MSAA not supported. Should not have come in here...!");
+ }
+ }
else
- glRenderbufferStorage(GL_RENDERBUFFER, fmt, w, h);
+ glRenderbufferStorage(GL_RENDERBUFFER, fmt, w, h);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
-
- return;
- samples = 0;
}
static void
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?
+ Evas_GL_Context_Version ver = evas_gl_common_version_check();
// Gen FBO
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+ // FIXME: GLES 3 support for MSAA is NOT IMPLEMENTED!
+ // Needs to use RenderbufferStorageMultisample + FramebufferRenderbuffer
+
// 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);
- _texture_attach_2d(color_buf, GL_COLOR_ATTACHMENT0, 0, mult_samples, EVAS_GL_GLES_2_X);
+ _texture_attach_2d(color_buf, GL_COLOR_ATTACHMENT0, 0, mult_samples, ver);
}
// Check Depth_Stencil Format First
static int
_surface_cap_init(void *eng_data)
{
+ int gles_version;
int ret = 0;
int max_size = 0;
+ int max_samples = 0;
// Do internal make current
if (!_internal_resource_make_current(eng_data, NULL, NULL))
evgl_engine->caps.max_h = max_size;
DBG("Max Surface Width: %d Height: %d", evgl_engine->caps.max_w, evgl_engine->caps.max_h);
+ gles_version = evas_gl_common_version_check();
+
// Check for MSAA support
+ if (gles_version == 3)
+ {
+ glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
+ INF("MSAA support for GLES 3 is not implemented yet!");
+ max_samples = 0;
+ }
#ifdef GL_GLES
- int max_samples = 0;
-
- if (EXTENSION_SUPPORT(IMG_multisampled_render_to_texture))
+ else if (EXTENSION_SUPPORT(IMG_multisampled_render_to_texture))
{
glGetIntegerv(GL_MAX_SAMPLES_IMG, &max_samples);
}
{
glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_samples);
}
+ else
+ {
+ const char *exts = (const char *) glGetString(GL_EXTENSIONS);
+
+ if (exts && strstr(exts, "EXT_multisampled_render_to_texture"))
+ glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_samples);
+ else if (exts && strstr(exts, "IMG_multisampled_render_to_texture"))
+ glGetIntegerv(GL_MAX_SAMPLES_IMG, &max_samples);
+ }
+#endif
if (max_samples >= 2)
{
evgl_engine->caps.msaa_samples[2] = max_samples;
evgl_engine->caps.msaa_supported = 1;
}
-#endif
// Load Surface Cap
if (!_surface_cap_cache_load())
if (cfg_index < 0)
{
- ERR("Unable to find a matching config format.");
+ ERR("Unable to find a matching config format (depth:%d, stencil:%d, msaa:%d)",
+ depth_size, stencil_bit, msaa_samples);
if ((stencil_bit > 8) || (depth_size > 24))
{
INF("Please note that Evas GL might not support 32-bit depth or "
DBG("Fallback to depth:%d, stencil:%d", depth_size, stencil_bit);
goto try_again;
}
+ else if (msaa_samples > 0)
+ {
+ msaa_samples /= 2;
+ if (msaa_samples == 1) msaa_samples = 0;
+ DBG("Fallback to msaa:%d", msaa_samples);
+ goto try_again;
+ }
return 0;
}
else