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.
This commit is contained in:
Ryan Houdek 2015-07-21 11:29:15 -05:00
parent 3d6ee7313d
commit c4f0515141

View File

@ -29,14 +29,23 @@ void cInterfaceEGL::DetectMode()
EGLint num_configs; EGLint num_configs;
EGLConfig *config = nullptr; EGLConfig *config = nullptr;
bool supportsGL = false, supportsGLES2 = false, supportsGLES3 = false; 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,
};
for (auto renderable_type : renderable_types)
{
// attributes for a visual in RGBA format with at least // attributes for a visual in RGBA format with at least
// 8 bits per color // 8 bits per color
int attribs[] = { int attribs[] = {
EGL_RED_SIZE, 8, EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8, EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8, EGL_BLUE_SIZE, 8,
EGL_NONE }; EGL_RENDERABLE_TYPE, renderable_type,
EGL_NONE
};
// Get how many configs there are // Get how many configs there are
if (!eglChooseConfig( egl_dpy, attribs, nullptr, 0, &num_configs)) if (!eglChooseConfig( egl_dpy, attribs, nullptr, 0, &num_configs))
@ -69,12 +78,15 @@ void cInterfaceEGL::DetectMode()
supportsGLES2 = true; supportsGLES2 = true;
} }
} }
}
if (supportsGL) if (supportsGL)
s_opengl_mode = GLInterfaceMode::MODE_OPENGL; s_opengl_mode = GLInterfaceMode::MODE_OPENGL;
else if (supportsGLES3) else if (supportsGLES3)
s_opengl_mode = GLInterfaceMode::MODE_OPENGLES3; s_opengl_mode = GLInterfaceMode::MODE_OPENGLES3;
else if (supportsGLES2) else if (supportsGLES2)
s_opengl_mode = GLInterfaceMode::MODE_OPENGLES2; s_opengl_mode = GLInterfaceMode::MODE_OPENGLES2;
err_exit: err_exit:
if (s_opengl_mode == GLInterfaceMode::MODE_DETECT) // Errored before we found a mode if (s_opengl_mode == GLInterfaceMode::MODE_DETECT) // Errored before we found a mode
s_opengl_mode = GLInterfaceMode::MODE_OPENGL; // Fall back to OpenGL s_opengl_mode = GLInterfaceMode::MODE_OPENGL; // Fall back to OpenGL