b=1009965, be explicit about whether we're quering for core GL symbols or extension GL symbols; r=bjacob,jrmuizel

This commit is contained in:
Vladimir Vukicevic 2014-05-13 17:18:42 -07:00
Родитель 7b45e7e0d5
Коммит e1bf45ca83
3 изменённых файлов: 290 добавлений и 251 удалений

Просмотреть файл

@ -58,9 +58,11 @@ uint32_t GLContext::sDebugMode = 0;
#define MAX_SYMBOL_LENGTH 128
#define MAX_SYMBOL_NAMES 5
#define END_SYMBOLS { nullptr, { nullptr } }
// should match the order of GLExtensions, and be null-terminated.
static const char *sExtensionNames[] = {
"NO_EXTENSION",
"GL_EXT_framebuffer_object",
"GL_ARB_framebuffer_object",
"GL_ARB_texture_rectangle",
@ -317,6 +319,15 @@ GLContext::StaticDebugCallback(GLenum source,
gl->DebugCallback(source, type, id, severity, length, message);
}
static void
ClearSymbols(GLLibraryLoader::SymLoadStruct *symbols)
{
while (symbols->symPointer) {
*symbols->symPointer = nullptr;
symbols++;
}
}
bool
GLContext::InitWithPrefix(const char *prefix, bool trygl)
{
@ -470,7 +481,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
{ (PRFuncPtr*) &mSymbols.fDeleteFramebuffers, { "DeleteFramebuffers", "DeleteFramebuffersEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteRenderbuffers, { "DeleteRenderbuffers", "DeleteRenderbuffersEXT", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
@ -502,7 +513,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
{ (PRFuncPtr*) &mSymbols.fGetShaderPrecisionFormat, { "GetShaderPrecisionFormat", nullptr } },
{ (PRFuncPtr*) &mSymbols.fClearDepthf, { "ClearDepthf", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDepthRangef, { "DepthRangef", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&symbols_ES2[0], trygl, prefix)) {
@ -531,7 +542,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
{ (PRFuncPtr*) &mSymbols.fTexGenf, { "TexGenf", nullptr } },
{ (PRFuncPtr*) &mSymbols.fTexGenfv, { "TexGenfv", nullptr } },
{ (PRFuncPtr*) &mSymbols.fVertexPointer, { "VertexPointer", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&symbols_desktop[0], trygl, prefix)) {
@ -682,7 +693,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
if (IsExtensionSupported(ARB_robustness)) {
SymLoadStruct robustnessSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatusARB", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&robustnessSymbols[0], trygl, prefix)) {
@ -697,7 +708,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
IsExtensionSupported(EXT_robustness)) {
SymLoadStruct robustnessSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetGraphicsResetStatus, { "GetGraphicsResetStatusEXT", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&robustnessSymbols[0], trygl, prefix)) {
@ -717,45 +728,45 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
// Check for aux symbols based on extensions
if (IsSupported(GLFeature::framebuffer_blit))
{
SymLoadStruct auxSymbols[] = {
{
(PRFuncPtr*) &mSymbols.fBlitFramebuffer,
{
"BlitFramebuffer",
"BlitFramebufferEXT",
"BlitFramebufferANGLE",
nullptr
}
},
{ nullptr, { nullptr } },
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBlitFramebuffer, { "BlitFramebuffer", nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&auxSymbols[0], trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBlitFramebuffer, { "BlitFramebufferEXT", "BlitFramebufferANGLE", nullptr } },
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::framebuffer_blit);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports framebuffer_blit without supplying glBlitFramebuffer");
MarkUnsupported(GLFeature::framebuffer_blit);
mSymbols.fBlitFramebuffer = nullptr;
ClearSymbols(coreSymbols);
}
}
if (IsSupported(GLFeature::framebuffer_multisample))
{
SymLoadStruct auxSymbols[] = {
{
(PRFuncPtr*) &mSymbols.fRenderbufferStorageMultisample,
{
"RenderbufferStorageMultisample",
"RenderbufferStorageMultisampleEXT",
"RenderbufferStorageMultisampleANGLE",
nullptr
}
},
{ nullptr, { nullptr } },
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fRenderbufferStorageMultisample, { "RenderbufferStorageMultisample", nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&auxSymbols[0], trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fRenderbufferStorageMultisample, { "RenderbufferStorageMultisampleEXT", "RenderbufferStorageMultisampleANGLE", nullptr } },
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::framebuffer_multisample);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports framebuffer_multisample without supplying glRenderbufferStorageMultisample");
MarkUnsupported(GLFeature::framebuffer_multisample);
mSymbols.fRenderbufferStorageMultisample = nullptr;
ClearSymbols(coreSymbols);
}
}
@ -768,249 +779,200 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
{ (PRFuncPtr*) &mSymbols.fWaitSync, { "WaitSync", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetInteger64v, { "GetInteger64v", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetSynciv, { "GetSynciv", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&syncSymbols[0], trygl, prefix)) {
NS_ERROR("GL supports ARB_sync without supplying its functions.");
MarkExtensionUnsupported(ARB_sync);
mSymbols.fFenceSync = nullptr;
mSymbols.fIsSync = nullptr;
mSymbols.fDeleteSync = nullptr;
mSymbols.fClientWaitSync = nullptr;
mSymbols.fWaitSync = nullptr;
mSymbols.fGetInteger64v = nullptr;
mSymbols.fGetSynciv = nullptr;
ClearSymbols(syncSymbols);
}
}
if (IsExtensionSupported(OES_EGL_image)) {
SymLoadStruct imageSymbols[] = {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fEGLImageTargetTexture2D, { "EGLImageTargetTexture2DOES", nullptr } },
{ (PRFuncPtr*) &mSymbols.fEGLImageTargetRenderbufferStorage, { "EGLImageTargetRenderbufferStorageOES", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&imageSymbols[0], trygl, prefix)) {
if (!LoadSymbols(extSymbols, trygl, prefix)) {
NS_ERROR("GL supports OES_EGL_image without supplying its functions.");
MarkExtensionUnsupported(OES_EGL_image);
mSymbols.fEGLImageTargetTexture2D = nullptr;
mSymbols.fEGLImageTargetRenderbufferStorage = nullptr;
ClearSymbols(extSymbols);
}
}
if (IsExtensionSupported(APPLE_texture_range)) {
SymLoadStruct vaoSymbols[] = {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fTextureRangeAPPLE, { "TextureRangeAPPLE", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&vaoSymbols[0], trygl, prefix)) {
mSymbols.fTextureRangeAPPLE = nullptr;
if (!LoadSymbols(extSymbols, trygl, prefix)) {
NS_ERROR("GL supports APPLE_texture_range without supplying its functions.");
ClearSymbols(extSymbols);
}
}
if (IsExtensionSupported(ARB_vertex_array_object) ||
IsExtensionSupported(OES_vertex_array_object)) {
SymLoadStruct vaoSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArray", "IsVertexArrayOES", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenVertexArrays, { "GenVertexArrays", "GenVertexArraysOES", nullptr } },
{ (PRFuncPtr*) &mSymbols.fBindVertexArray, { "BindVertexArray", "BindVertexArrayOES", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteVertexArrays, { "DeleteVertexArrays", "DeleteVertexArraysOES", nullptr } },
{ nullptr, { nullptr } },
if (IsSupported(GLFeature::vertex_array_object)) {
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArray", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenVertexArrays, { "GenVertexArrays", nullptr } },
{ (PRFuncPtr*) &mSymbols.fBindVertexArray, { "BindVertexArray", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteVertexArrays, { "DeleteVertexArrays", nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&vaoSymbols[0], trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArrayARB", "IsVertexArrayOES", "IsVertexArrayAPPLE", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenVertexArrays, { "GenVertexArraysARB", "GenVertexArraysOES", "GenVertexArraysAPPLE", nullptr } },
{ (PRFuncPtr*) &mSymbols.fBindVertexArray, { "BindVertexArrayARB", "BindVertexArrayOES", "BindVertexArrayAPPLE", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteVertexArrays, { "DeleteVertexArraysARB", "DeleteVertexArraysOES", "DeleteVertexArraysAPPLE", nullptr } },
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::vertex_array_object);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports Vertex Array Object without supplying its functions.");
MarkUnsupported(GLFeature::vertex_array_object);
mSymbols.fIsVertexArray = nullptr;
mSymbols.fGenVertexArrays = nullptr;
mSymbols.fBindVertexArray = nullptr;
mSymbols.fDeleteVertexArrays = nullptr;
}
}
else if (IsExtensionSupported(APPLE_vertex_array_object)) {
/*
* separate call to LoadSymbols with APPLE_vertex_array_object to work around
* a driver bug : the IsVertexArray symbol (without suffix) can be present but unusable.
*/
SymLoadStruct vaoSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fIsVertexArray, { "IsVertexArrayAPPLE", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenVertexArrays, { "GenVertexArraysAPPLE", nullptr } },
{ (PRFuncPtr*) &mSymbols.fBindVertexArray, { "BindVertexArrayAPPLE", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteVertexArrays, { "DeleteVertexArraysAPPLE", nullptr } },
{ nullptr, { nullptr } },
};
if (!LoadSymbols(&vaoSymbols[0], trygl, prefix)) {
NS_ERROR("GL supports Vertex Array Object without supplying its functions.");
MarkUnsupported(GLFeature::vertex_array_object);
mSymbols.fIsVertexArray = nullptr;
mSymbols.fGenVertexArrays = nullptr;
mSymbols.fBindVertexArray = nullptr;
mSymbols.fDeleteVertexArrays = nullptr;
ClearSymbols(coreSymbols);
}
}
if (IsSupported(GLFeature::draw_instanced)) {
SymLoadStruct drawInstancedSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fDrawArraysInstanced,
{ "DrawArraysInstanced",
"DrawArraysInstancedARB",
"DrawArraysInstancedEXT",
"DrawArraysInstancedNV",
"DrawArraysInstancedANGLE",
nullptr
}
},
{ (PRFuncPtr*) &mSymbols.fDrawElementsInstanced,
{ "DrawElementsInstanced",
"DrawElementsInstancedARB",
"DrawElementsInstancedEXT",
"DrawElementsInstancedNV",
"DrawElementsInstancedANGLE",
nullptr
}
},
{ nullptr, { nullptr } },
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fDrawArraysInstanced, { "DrawArraysInstanced", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDrawElementsInstanced, { "DrawElementsInstanced", nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(drawInstancedSymbols, trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fDrawArraysInstanced, { "DrawArraysInstancedARB", "DrawArraysInstancedEXT", "DrawArraysInstancedNV", "DrawArraysInstancedANGLE", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDrawElementsInstanced, { "DrawElementsInstancedARB", "DrawElementsInstancedEXT", "DrawElementsInstancedNV", "DrawElementsInstancedANGLE", nullptr }
},
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::draw_instanced);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports instanced draws without supplying its functions.");
MarkUnsupported(GLFeature::draw_instanced);
mSymbols.fDrawArraysInstanced = nullptr;
mSymbols.fDrawElementsInstanced = nullptr;
ClearSymbols(coreSymbols);
}
}
if (IsSupported(GLFeature::instanced_arrays)) {
SymLoadStruct instancedArraySymbols[] = {
{ (PRFuncPtr*) &mSymbols.fVertexAttribDivisor,
{ "VertexAttribDivisor",
"VertexAttribDivisorARB",
"VertexAttribDivisorNV",
"VertexAttribDivisorANGLE",
nullptr
}
},
{ nullptr, { nullptr } },
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fVertexAttribDivisor, { "VertexAttribDivisor", nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(instancedArraySymbols, trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fVertexAttribDivisor, { "VertexAttribDivisorARB", "VertexAttribDivisorNV", "VertexAttribDivisorANGLE", nullptr } },
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::instanced_arrays);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports array instanced without supplying it function.");
MarkUnsupported(GLFeature::instanced_arrays);
mSymbols.fVertexAttribDivisor = nullptr;
ClearSymbols(coreSymbols);
}
}
if (IsSupported(GLFeature::transform_feedback)) {
SymLoadStruct transformFeedbackSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBindBufferBase,
{ "BindBufferBase",
"BindBufferBaseEXT",
"BindBufferBaseNV",
nullptr
}
},
{ (PRFuncPtr*) &mSymbols.fBindBufferRange,
{ "BindBufferRange",
"BindBufferRangeEXT",
"BindBufferRangeNV",
nullptr
}
},
{ (PRFuncPtr*) &mSymbols.fBeginTransformFeedback,
{ "BeginTransformFeedback",
"BeginTransformFeedbackEXT",
"BeginTransformFeedbackNV",
nullptr
}
},
{ (PRFuncPtr*) &mSymbols.fEndTransformFeedback,
{ "EndTransformFeedback",
"EndTransformFeedbackEXT",
"EndTransformFeedbackNV",
nullptr
}
},
{ (PRFuncPtr*) &mSymbols.fTransformFeedbackVaryings,
{ "TransformFeedbackVaryings",
"TransformFeedbackVaryingsEXT",
"TransformFeedbackVaryingsNV",
nullptr
}
},
{ (PRFuncPtr*) &mSymbols.fGetTransformFeedbackVarying,
{ "GetTransformFeedbackVarying",
"GetTransformFeedbackVaryingEXT",
"GetTransformFeedbackVaryingNV",
nullptr
}
},
{ (PRFuncPtr*) &mSymbols.fGetIntegeri_v,
{ "GetIntegeri_v",
"GetIntegerIndexedvEXT",
"GetIntegerIndexedvNV",
nullptr
}
},
{ nullptr, { nullptr } },
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBindBufferBase, { "BindBufferBase", nullptr } },
{ (PRFuncPtr*) &mSymbols.fBindBufferRange, { "BindBufferRange", nullptr } },
{ (PRFuncPtr*) &mSymbols.fBeginTransformFeedback, { "BeginTransformFeedback", nullptr } },
{ (PRFuncPtr*) &mSymbols.fEndTransformFeedback, { "EndTransformFeedback", nullptr } },
{ (PRFuncPtr*) &mSymbols.fTransformFeedbackVaryings, { "TransformFeedbackVaryings", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetTransformFeedbackVarying, { "GetTransformFeedbackVarying", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetIntegeri_v, { "GetIntegeri_v", nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(transformFeedbackSymbols, trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBindBufferBase, { "BindBufferBaseEXT", "BindBufferBaseNV", nullptr } },
{ (PRFuncPtr*) &mSymbols.fBindBufferRange, { "BindBufferRangeEXT", "BindBufferRangeNV", nullptr } },
{ (PRFuncPtr*) &mSymbols.fBeginTransformFeedback, { "BeginTransformFeedbackEXT", "BeginTransformFeedbackNV", nullptr } },
{ (PRFuncPtr*) &mSymbols.fEndTransformFeedback, { "EndTransformFeedbackEXT", "EndTransformFeedbackNV", nullptr } },
{ (PRFuncPtr*) &mSymbols.fTransformFeedbackVaryings, { "TransformFeedbackVaryingsEXT", "TransformFeedbackVaryingsNV", nullptr }},
{ (PRFuncPtr*) &mSymbols.fGetTransformFeedbackVarying, { "GetTransformFeedbackVaryingEXT", "GetTransformFeedbackVaryingNV", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetIntegeri_v, { "GetIntegerIndexedvEXT", "GetIntegerIndexedvNV", nullptr } },
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::transform_feedback);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports transform feedback without supplying its functions.");
MarkUnsupported(GLFeature::transform_feedback);
MarkUnsupported(GLFeature::bind_buffer_offset);
mSymbols.fBindBufferBase = nullptr;
mSymbols.fBindBufferRange = nullptr;
mSymbols.fBeginTransformFeedback = nullptr;
mSymbols.fEndTransformFeedback = nullptr;
mSymbols.fTransformFeedbackVaryings = nullptr;
mSymbols.fGetTransformFeedbackVarying = nullptr;
mSymbols.fGetIntegeri_v = nullptr;
ClearSymbols(coreSymbols);
}
}
if (IsSupported(GLFeature::bind_buffer_offset)) {
SymLoadStruct bindBufferOffsetSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBindBufferOffset,
{ "BindBufferOffset",
"BindBufferOffsetEXT",
"BindBufferOffsetNV",
nullptr
}
},
{ nullptr, { nullptr } },
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBindBufferOffset, { "BindBufferOffset", nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(bindBufferOffsetSymbols, trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBindBufferOffset,
{ "BindBufferOffsetEXT", "BindBufferOffsetNV", nullptr }
},
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::bind_buffer_offset);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports BindBufferOffset without supplying its function.");
MarkUnsupported(GLFeature::bind_buffer_offset);
mSymbols.fBindBufferOffset = nullptr;
ClearSymbols(coreSymbols);
}
}
if (IsSupported(GLFeature::query_objects)) {
SymLoadStruct queryObjectsSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQuery", "BeginQueryEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueries", "GenQueriesEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteQueries, { "DeleteQueries", "DeleteQueriesEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fEndQuery, { "EndQuery", "EndQueryEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryiv, { "GetQueryiv", "GetQueryivEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectuiv, { "GetQueryObjectuiv", "GetQueryObjectuivEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fIsQuery, { "IsQuery", "IsQueryEXT", nullptr } },
{ nullptr, { nullptr } },
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQuery", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueries", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteQueries, { "DeleteQueries", nullptr } },
{ (PRFuncPtr*) &mSymbols.fEndQuery, { "EndQuery", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryiv, { "GetQueryiv", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectuiv, { "GetQueryObjectuiv", nullptr } },
{ (PRFuncPtr*) &mSymbols.fIsQuery, { "IsQuery", nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(queryObjectsSymbols, trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQueryEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueriesEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fDeleteQueries, { "DeleteQueriesEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fEndQuery, { "EndQueryEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryiv, { "GetQueryivEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectuiv, { "GetQueryObjectuivEXT", nullptr } },
{ (PRFuncPtr*) &mSymbols.fIsQuery, { "IsQueryEXT", nullptr } },
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::query_objects);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports query objects without supplying its functions.");
MarkUnsupported(GLFeature::query_objects);
@ -1018,41 +980,70 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
MarkUnsupported(GLFeature::occlusion_query);
MarkUnsupported(GLFeature::occlusion_query_boolean);
MarkUnsupported(GLFeature::occlusion_query2);
mSymbols.fBeginQuery = nullptr;
mSymbols.fGenQueries = nullptr;
mSymbols.fDeleteQueries = nullptr;
mSymbols.fEndQuery = nullptr;
mSymbols.fGetQueryiv = nullptr;
mSymbols.fGetQueryObjectuiv = nullptr;
mSymbols.fIsQuery = nullptr;
ClearSymbols(coreSymbols);
}
}
if (IsSupported(GLFeature::get_query_object_iv)) {
SymLoadStruct queryObjectsSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectiv", "GetQueryObjectivEXT", nullptr } },
{ nullptr, { nullptr } },
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectiv", nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(queryObjectsSymbols, trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectivEXT", nullptr } },
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::get_query_object_iv);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports query objects iv getter without supplying its function.");
MarkUnsupported(GLFeature::get_query_object_iv);
mSymbols.fGetQueryObjectiv = nullptr;
ClearSymbols(coreSymbols);
}
}
if (IsSupported(GLFeature::draw_buffers)) {
SymLoadStruct drawBuffersSymbols[] = {
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffers", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(drawBuffersSymbols, trygl, prefix)) {
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fDrawBuffers, { "DrawBuffersARB", "DrawBuffersEXT", nullptr } },
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::draw_buffers);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports draw_buffers without supplying its functions.");
MarkUnsupported(GLFeature::draw_buffers);
mSymbols.fDrawBuffers = nullptr;
ClearSymbols(coreSymbols);
}
}
if (IsSupported(GLFeature::draw_range_elements)) {
SymLoadStruct coreSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fDrawRangeElements, { "DrawRangeElements", nullptr } },
END_SYMBOLS
};
SymLoadStruct extSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fDrawRangeElements, { "DrawRangeElementsEXT", nullptr } },
END_SYMBOLS
};
bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::draw_range_elements);
if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) {
NS_ERROR("GL supports draw_range_elements without supplying its functions.");
MarkUnsupported(GLFeature::draw_range_elements);
ClearSymbols(coreSymbols);
}
}
@ -1069,38 +1060,14 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
{ (PRFuncPtr*) &mSymbols.fGetObjectLabel, { "GetObjectLabel", "GetObjectLabelKHR", nullptr } },
{ (PRFuncPtr*) &mSymbols.fObjectPtrLabel, { "ObjectPtrLabel", "ObjectPtrLabelKHR", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetObjectPtrLabel, { "GetObjectPtrLabel", "GetObjectPtrLabelKHR", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
if (!LoadSymbols(&extSymbols[0], trygl, prefix)) {
NS_ERROR("GL supports KHR_debug without supplying its functions.");
MarkExtensionUnsupported(KHR_debug);
mSymbols.fDebugMessageControl = nullptr;
mSymbols.fDebugMessageInsert = nullptr;
mSymbols.fDebugMessageCallback = nullptr;
mSymbols.fGetDebugMessageLog = nullptr;
mSymbols.fGetPointerv = nullptr;
mSymbols.fPushDebugGroup = nullptr;
mSymbols.fPopDebugGroup = nullptr;
mSymbols.fObjectLabel = nullptr;
mSymbols.fGetObjectLabel = nullptr;
mSymbols.fObjectPtrLabel = nullptr;
mSymbols.fGetObjectPtrLabel = nullptr;
}
}
if (IsSupported(GLFeature::draw_range_elements)) {
SymLoadStruct imageSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fDrawRangeElements, { "DrawRangeElementsEXT", "DrawRangeElements", nullptr } },
{ nullptr, { nullptr } },
};
if (!LoadSymbols(&imageSymbols[0], trygl, prefix)) {
NS_ERROR("GL supports draw_range_elements without supplying its functions.");
MarkUnsupported(GLFeature::draw_range_elements);
mSymbols.fDrawRangeElements = nullptr;
ClearSymbols(extSymbols);
}
}
@ -1108,7 +1075,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
SymLoadStruct auxSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fGetTexImage, { "GetTexImage", nullptr } },
{ (PRFuncPtr*) &mSymbols.fGetTexLevelParameteriv, { "GetTexLevelParameteriv", nullptr } },
{ nullptr, { nullptr } },
END_SYMBOLS
};
bool warnOnFailures = DebugMode();
LoadSymbols(&auxSymbols[0], trygl, prefix, warnOnFailures);

Просмотреть файл

@ -331,6 +331,7 @@ public:
* in GLContext.cpp.
*/
enum GLExtensions {
Extension_None = 0,
EXT_framebuffer_object,
ARB_framebuffer_object,
ARB_texture_rectangle,
@ -494,6 +495,11 @@ private:
*/
void MarkUnsupported(GLFeature feature);
/**
* Is this feature supported using the core (unsuffixed) symbols?
*/
bool IsFeatureProvidedByCoreSymbols(GLFeature feature);
// -----------------------------------------------------------------------------
// Robustness handling
public:

Просмотреть файл

@ -25,8 +25,26 @@ static const unsigned int kGLCoreVersionForES3Compat = 430;
struct FeatureInfo
{
const char* mName;
/* The (desktop) OpenGL version that provides this feature */
unsigned int mOpenGLVersion;
/* The OpenGL ES version that provides this feature */
unsigned int mOpenGLESVersion;
/* If there is an ARB extension, and its function symbols are
* not decorated with an ARB suffix, then its extension ID should go
* here, and NOT in mExtensions. For example, ARB_vertex_array_object
* functions do not have an ARB suffix, because it is an extension that
* was created to match core GL functionality and will never differ.
* Some ARB extensions do have a suffix, if they were created before
* a core version of the functionality existed.
*
* If there is no such ARB extension, pass 0 (GLContext::Extension_None)
*/
GLContext::GLExtensions mARBExtensionWithoutARBSuffix;
/* Extensions that also provide this feature */
GLContext::GLExtensions mExtensions[kMAX_EXTENSION_GROUP_SIZE];
};
@ -35,7 +53,9 @@ static const FeatureInfo sFeatureInfoArr[] = {
"bind_buffer_offset",
0, // OpenGL version
0, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_transform_feedback,
GLContext::NV_transform_feedback,
GLContext::Extensions_End
@ -45,6 +65,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"blend_minmax",
200, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_blend_minmax,
GLContext::Extensions_End
@ -54,6 +75,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"depth_texture",
200, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_depth_texture,
GLContext::OES_depth_texture,
@ -66,6 +88,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"draw_buffers",
200, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_draw_buffers,
GLContext::EXT_draw_buffers,
@ -76,6 +99,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"draw_instanced",
310, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_draw_instanced,
GLContext::EXT_draw_instanced,
@ -88,6 +112,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"draw_range_elements",
120, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_draw_range_elements,
GLContext::Extensions_End
@ -97,6 +122,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"element_index_uint",
200, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::OES_element_index_uint,
GLContext::Extensions_End
@ -106,8 +132,8 @@ static const FeatureInfo sFeatureInfoArr[] = {
"ES2_compatibility",
kGLCoreVersionForES2Compat,
200, // OpenGL ES version
GLContext::ARB_ES2_compatibility, // no suffix on ARB extension
{
GLContext::ARB_ES2_compatibility,
GLContext::Extensions_End
}
},
@ -115,8 +141,8 @@ static const FeatureInfo sFeatureInfoArr[] = {
"ES3_compatibility",
kGLCoreVersionForES3Compat,
300, // OpenGL ES version
GLContext::ARB_ES3_compatibility, // no suffix on ARB extension
{
GLContext::ARB_ES3_compatibility,
GLContext::Extensions_End
}
},
@ -125,6 +151,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"frag_color_float",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_color_buffer_float,
GLContext::EXT_color_buffer_float,
@ -136,6 +163,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"frag_depth",
200, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_frag_depth,
GLContext::Extensions_End
@ -145,6 +173,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"framebuffer_blit",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_framebuffer_blit,
GLContext::ANGLE_framebuffer_blit,
@ -155,6 +184,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"framebuffer_multisample",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_framebuffer_multisample,
GLContext::ANGLE_framebuffer_multisample,
@ -165,8 +195,8 @@ static const FeatureInfo sFeatureInfoArr[] = {
"framebuffer_object",
300, // OpenGL version
200, // OpenGL ES version
GLContext::ARB_framebuffer_object,
{
GLContext::ARB_framebuffer_object,
GLContext::EXT_framebuffer_object,
GLContext::Extensions_End
}
@ -175,6 +205,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"get_query_object_iv",
200, // OpenGL version
0, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::Extensions_End
}
@ -187,6 +218,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"instanced_arrays",
330, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_instanced_arrays,
GLContext::NV_instanced_arrays,
@ -198,6 +230,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"instanced_non_arrays",
330, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_instanced_arrays,
GLContext::Extensions_End
@ -212,6 +245,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"occlusion_query",
200, // OpenGL version
0, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::Extensions_End
}
@ -221,8 +255,8 @@ static const FeatureInfo sFeatureInfoArr[] = {
"occlusion_query_boolean",
kGLCoreVersionForES3Compat,
300, // OpenGL ES version
GLContext::ARB_ES3_compatibility,
{
GLContext::ARB_ES3_compatibility,
GLContext::EXT_occlusion_query_boolean,
GLContext::Extensions_End
}
@ -237,6 +271,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"occlusion_query2",
330, // = min(330, kGLCoreVersionForES3Compat),
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_occlusion_query2,
GLContext::ARB_ES3_compatibility,
@ -253,6 +288,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"packed_depth_stencil",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_packed_depth_stencil,
GLContext::OES_packed_depth_stencil,
@ -263,6 +299,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"query_objects",
200, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_occlusion_query_boolean,
GLContext::Extensions_End
@ -277,6 +314,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"renderbuffer_float",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_texture_float,
GLContext::EXT_color_buffer_float,
@ -287,6 +325,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"renderbuffer_half_float",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_texture_float,
GLContext::EXT_color_buffer_half_float,
@ -297,6 +336,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"robustness",
0, // OpenGL version
0, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_robustness,
GLContext::EXT_robustness,
@ -307,6 +347,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"sRGB",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_sRGB,
GLContext::Extensions_End
@ -316,6 +357,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"standard_derivatives",
200, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::OES_standard_derivatives,
GLContext::Extensions_End
@ -325,6 +367,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"texture_float",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_texture_float,
GLContext::OES_texture_float,
@ -335,6 +378,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"texture_float_linear",
310, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_texture_float,
GLContext::OES_texture_float_linear,
@ -345,6 +389,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"texture_half_float",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_half_float_pixel,
GLContext::ARB_texture_float,
@ -364,6 +409,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"texture_half_float_linear",
310, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_half_float_pixel,
GLContext::ARB_texture_float,
@ -376,6 +422,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"texture_non_power_of_two",
200, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::ARB_texture_non_power_of_two,
GLContext::OES_texture_npot,
@ -386,6 +433,7 @@ static const FeatureInfo sFeatureInfoArr[] = {
"transform_feedback",
300, // OpenGL version
300, // OpenGL ES version
GLContext::Extension_None,
{
GLContext::EXT_transform_feedback,
GLContext::NV_transform_feedback,
@ -396,8 +444,8 @@ static const FeatureInfo sFeatureInfoArr[] = {
"vertex_array_object",
300, // OpenGL version
300, // OpenGL ES version
GLContext::ARB_vertex_array_object, // ARB extension
{
GLContext::ARB_vertex_array_object,
GLContext::OES_vertex_array_object,
GLContext::APPLE_vertex_array_object,
GLContext::Extensions_End
@ -432,9 +480,9 @@ ProfileVersionForFeature(GLFeature feature, ContextProfile profile)
return featureInfo.mOpenGLVersion;
}
static inline bool
IsFeatureIsPartOfProfileVersion(GLFeature feature,
ContextProfile profile, unsigned int version)
bool
IsFeaturePartOfProfileVersion(GLFeature feature,
ContextProfile profile, unsigned int version)
{
unsigned int profileVersion = ProfileVersionForFeature(feature, profile);
@ -445,6 +493,18 @@ IsFeatureIsPartOfProfileVersion(GLFeature feature,
return profileVersion && version >= profileVersion;
}
bool
GLContext::IsFeatureProvidedByCoreSymbols(GLFeature feature)
{
if (IsFeaturePartOfProfileVersion(feature, mProfile, mVersion))
return true;
if (IsExtensionSupported(GetFeatureInfo(feature).mARBExtensionWithoutARBSuffix))
return true;
return false;
}
const char*
GLContext::GetFeatureName(GLFeature feature)
{
@ -476,7 +536,7 @@ GLContext::InitFeatures()
{
GLFeature feature = GLFeature(feature_index);
if (IsFeatureIsPartOfProfileVersion(feature, mProfile, mVersion)) {
if (IsFeaturePartOfProfileVersion(feature, mProfile, mVersion)) {
mAvailableFeatures[feature_index] = true;
continue;
}
@ -485,6 +545,12 @@ GLContext::InitFeatures()
const FeatureInfo& featureInfo = GetFeatureInfo(feature);
if (IsExtensionSupported(featureInfo.mARBExtensionWithoutARBSuffix))
{
mAvailableFeatures[feature_index] = true;
continue;
}
for (size_t j = 0; true; j++)
{
MOZ_ASSERT(j < kMAX_EXTENSION_GROUP_SIZE, "kMAX_EXTENSION_GROUP_SIZE too small");