Merge pull request #3336 from Sonicadvance1/improve_glextensions

[GLExtensions] Improve the extension loader.
This commit is contained in:
Ryan Houdek 2016-01-01 13:01:51 -05:00
commit b4e9bbb551
3 changed files with 638 additions and 682 deletions

File diff suppressed because it is too large Load Diff

View File

@ -296,6 +296,14 @@ Renderer::Renderer()
InitDriverInfo(); InitDriverInfo();
if (GLExtensions::Version() < 300)
{
// integer vertex attributes require a gl3 only function
PanicAlert("GPU: OGL ERROR: Need OpenGL version 3.\n"
"GPU: Does your video card support OpenGL 3?");
bSuccess = false;
}
// check for the max vertex attributes // check for the max vertex attributes
GLint numvertexattribs = 0; GLint numvertexattribs = 0;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs); glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs);
@ -317,6 +325,8 @@ Renderer::Renderer()
bSuccess = false; bSuccess = false;
} }
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
{
if (!GLExtensions::Supports("GL_ARB_framebuffer_object")) if (!GLExtensions::Supports("GL_ARB_framebuffer_object"))
{ {
// We want the ogl3 framebuffer instead of the ogl2 one for better blitting support. // We want the ogl3 framebuffer instead of the ogl2 one for better blitting support.
@ -368,22 +378,15 @@ Renderer::Renderer()
bSuccess = false; bSuccess = false;
} }
if (GLExtensions::Version() < 300)
{
// integer vertex attributes require a gl3 only function
PanicAlert("GPU: OGL ERROR: Need OpenGL version 3.\n"
"GPU: Does your video card support OpenGL 3?");
bSuccess = false;
}
// OpenGL 3 doesn't provide GLES like float functions for depth. // OpenGL 3 doesn't provide GLES like float functions for depth.
// They are in core in OpenGL 4.1, so almost every driver should support them. // They are in core in OpenGL 4.1, so almost every driver should support them.
// But for the oldest ones, we provide fallbacks to the old double functions. // But for the oldest ones, we provide fallbacks to the old double functions.
if (!GLExtensions::Supports("GL_ARB_ES2_compatibility") && GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL) if (!GLExtensions::Supports("GL_ARB_ES2_compatibility"))
{ {
glDepthRangef = DepthRangef; glDepthRangef = DepthRangef;
glClearDepthf = ClearDepthf; glClearDepthf = ClearDepthf;
} }
}
g_Config.backend_info.bSupportsDualSourceBlend = GLExtensions::Supports("GL_ARB_blend_func_extended") || g_Config.backend_info.bSupportsDualSourceBlend = GLExtensions::Supports("GL_ARB_blend_func_extended") ||
GLExtensions::Supports("GL_EXT_blend_func_extended"); GLExtensions::Supports("GL_EXT_blend_func_extended");
@ -416,7 +419,6 @@ Renderer::Renderer()
g_ogl_config.bSupportsGLBufferStorage = GLExtensions::Supports("GL_ARB_buffer_storage") || g_ogl_config.bSupportsGLBufferStorage = GLExtensions::Supports("GL_ARB_buffer_storage") ||
GLExtensions::Supports("GL_EXT_buffer_storage"); GLExtensions::Supports("GL_EXT_buffer_storage");
g_ogl_config.bSupportsMSAA = GLExtensions::Supports("GL_ARB_texture_multisample"); g_ogl_config.bSupportsMSAA = GLExtensions::Supports("GL_ARB_texture_multisample");
g_ogl_config.bSupportOGL31 = GLExtensions::Version() >= 310;
g_ogl_config.bSupportViewportFloat = GLExtensions::Supports("GL_ARB_viewport_array"); g_ogl_config.bSupportViewportFloat = GLExtensions::Supports("GL_ARB_viewport_array");
g_ogl_config.bSupportsDebug = GLExtensions::Supports("GL_KHR_debug") || g_ogl_config.bSupportsDebug = GLExtensions::Supports("GL_KHR_debug") ||
GLExtensions::Supports("GL_ARB_debug_output"); GLExtensions::Supports("GL_ARB_debug_output");
@ -434,6 +436,9 @@ Renderer::Renderer()
GLExtensions::Supports("GL_OES_texture_buffer") ? ES_TEXBUF_TYPE::TEXBUF_OES : GLExtensions::Supports("GL_OES_texture_buffer") ? ES_TEXBUF_TYPE::TEXBUF_OES :
GLExtensions::Supports("GL_EXT_texture_buffer") ? ES_TEXBUF_TYPE::TEXBUF_EXT : ES_TEXBUF_TYPE::TEXBUF_NONE; GLExtensions::Supports("GL_EXT_texture_buffer") ? ES_TEXBUF_TYPE::TEXBUF_EXT : ES_TEXBUF_TYPE::TEXBUF_NONE;
g_ogl_config.bSupportsGLSLCache = true;
g_ogl_config.bSupportsGLSync = true;
if (strstr(g_ogl_config.glsl_version, "3.0") || DriverDetails::HasBug(DriverDetails::BUG_BROKENGLES31)) if (strstr(g_ogl_config.glsl_version, "3.0") || DriverDetails::HasBug(DriverDetails::BUG_BROKENGLES31))
{ {
g_ogl_config.eSupportedGLSLVersion = GLSLES_300; g_ogl_config.eSupportedGLSLVersion = GLSLES_300;
@ -647,7 +652,7 @@ Renderer::Renderer()
} }
else else
{ {
if (g_ogl_config.bSupportOGL31) if (GLExtensions::Version() >= 310)
{ {
glEnable(GL_PRIMITIVE_RESTART); glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(65535); glPrimitiveRestartIndex(65535);

View File

@ -41,7 +41,6 @@ struct VideoConfig
bool bSupportsGLBufferStorage; bool bSupportsGLBufferStorage;
bool bSupportsMSAA; bool bSupportsMSAA;
GLSL_VERSION eSupportedGLSLVersion; GLSL_VERSION eSupportedGLSLVersion;
bool bSupportOGL31;
bool bSupportViewportFloat; bool bSupportViewportFloat;
bool bSupportsAEP; bool bSupportsAEP;
bool bSupportsDebug; bool bSupportsDebug;