summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2015-07-21 11:29:15 -0500
committerRyan Houdek <Sonicadvance1@gmail.com>2015-07-22 11:11:23 -0500
commitc4f0515141cd451468b29501b9c1d8925f7a9502 (patch)
tree648bf4671c09f0e4c0820c516bb483e7e9dcbcf5 /Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp
parent3d6ee7313d10d9be47f9ed3d3f0dbaa737aed954 (diff)
Work around devices that choose to only return the default EGL_RENDERABLE_TYPE
The default EGL_RENDERABLE_TYPE is GLES1, so vendors have the ability to choose between returning only the bits requested, or all of the bits supported in addition to the one requested. PowerVR chose to take the route where they only return the bits requested, everyone else returns all of the bits supported. Instead of letting the vendor have control of this, let's incrementally go through each renderable type and make sure it supports everything we want. This will cover all devices for now, and for the future.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp76
1 files changed, 44 insertions, 32 deletions
diff --git a/Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp b/Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp
index f83b540cbd..43678e1acc 100644
--- a/Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp
+++ b/Source/Core/VideoBackends/OGL/GLInterface/EGL.cpp
@@ -29,52 +29,64 @@ void cInterfaceEGL::DetectMode()
EGLint num_configs;
EGLConfig *config = nullptr;
bool supportsGL = false, supportsGLES2 = false, supportsGLES3 = false;
+ std::array<int, 3> renderable_types = {
+ EGL_OPENGL_BIT,
+ (1 << 6), /* EGL_OPENGL_ES3_BIT_KHR */
+ EGL_OPENGL_ES2_BIT,
+ };
- // attributes for a visual in RGBA format with at least
- // 8 bits per color
- int attribs[] = {
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_NONE };
-
- // Get how many configs there are
- if (!eglChooseConfig( egl_dpy, attribs, nullptr, 0, &num_configs))
+ for (auto renderable_type : renderable_types)
{
- INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
- goto err_exit;
- }
+ // attributes for a visual in RGBA format with at least
+ // 8 bits per color
+ int attribs[] = {
+ EGL_RED_SIZE, 8,
+ EGL_GREEN_SIZE, 8,
+ EGL_BLUE_SIZE, 8,
+ EGL_RENDERABLE_TYPE, renderable_type,
+ EGL_NONE
+ };
+
+ // Get how many configs there are
+ if (!eglChooseConfig( egl_dpy, attribs, nullptr, 0, &num_configs))
+ {
+ INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
+ goto err_exit;
+ }
- config = new EGLConfig[num_configs];
+ config = new EGLConfig[num_configs];
- // Get all the configurations
- if (!eglChooseConfig(egl_dpy, attribs, config, num_configs, &num_configs))
- {
- INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
- goto err_exit;
- }
+ // Get all the configurations
+ if (!eglChooseConfig(egl_dpy, attribs, config, num_configs, &num_configs))
+ {
+ INFO_LOG(VIDEO, "Error: couldn't get an EGL visual config\n");
+ goto err_exit;
+ }
- for (int i = 0; i < num_configs; ++i)
- {
- EGLint attribVal;
- bool ret;
- ret = eglGetConfigAttrib(egl_dpy, config[i], EGL_RENDERABLE_TYPE, &attribVal);
- if (ret)
+ for (int i = 0; i < num_configs; ++i)
{
- if (attribVal & EGL_OPENGL_BIT)
- supportsGL = true;
- if (attribVal & (1 << 6)) /* EGL_OPENGL_ES3_BIT_KHR */
- supportsGLES3 = true;
- if (attribVal & EGL_OPENGL_ES2_BIT)
- supportsGLES2 = true;
+ EGLint attribVal;
+ bool ret;
+ ret = eglGetConfigAttrib(egl_dpy, config[i], EGL_RENDERABLE_TYPE, &attribVal);
+ if (ret)
+ {
+ if (attribVal & EGL_OPENGL_BIT)
+ supportsGL = true;
+ if (attribVal & (1 << 6)) /* EGL_OPENGL_ES3_BIT_KHR */
+ supportsGLES3 = true;
+ if (attribVal & EGL_OPENGL_ES2_BIT)
+ supportsGLES2 = true;
+ }
}
}
+
if (supportsGL)
s_opengl_mode = GLInterfaceMode::MODE_OPENGL;
else if (supportsGLES3)
s_opengl_mode = GLInterfaceMode::MODE_OPENGLES3;
else if (supportsGLES2)
s_opengl_mode = GLInterfaceMode::MODE_OPENGLES2;
+
err_exit:
if (s_opengl_mode == GLInterfaceMode::MODE_DETECT) // Errored before we found a mode
s_opengl_mode = GLInterfaceMode::MODE_OPENGL; // Fall back to OpenGL