diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index e5e54bd19c1..bce899e3340 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -70,6 +70,7 @@ static const char *sExtensionNames[] = { "GL_ANGLE_instanced_arrays", "GL_ANGLE_texture_compression_dxt3", "GL_ANGLE_texture_compression_dxt5", + "GL_ANGLE_timer_query", "GL_APPLE_client_storage", "GL_APPLE_texture_range", "GL_APPLE_vertex_array_object", @@ -97,6 +98,7 @@ static const char *sExtensionNames[] = { "GL_ARB_texture_rectangle", "GL_ARB_texture_storage", "GL_ARB_texture_swizzle", + "GL_ARB_timer_query", "GL_ARB_transform_feedback2", "GL_ARB_uniform_buffer_object", "GL_ARB_vertex_array_object", @@ -105,6 +107,7 @@ static const char *sExtensionNames[] = { "GL_EXT_color_buffer_float", "GL_EXT_color_buffer_half_float", "GL_EXT_copy_texture", + "GL_EXT_disjoint_timer_query", "GL_EXT_draw_buffers", "GL_EXT_draw_buffers2", "GL_EXT_draw_instanced", @@ -129,6 +132,7 @@ static const char *sExtensionNames[] = { "GL_EXT_texture_format_BGRA8888", "GL_EXT_texture_sRGB", "GL_EXT_texture_storage", + "GL_EXT_timer_query", "GL_EXT_transform_feedback", "GL_EXT_unpack_subimage", "GL_IMG_read_format", @@ -1043,6 +1047,26 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl) } } + if (IsSupported(GLFeature::query_counter)) { + SymLoadStruct coreSymbols[] = { + { (PRFuncPtr*) &mSymbols.fQueryCounter, { "QueryCounter", nullptr } }, + END_SYMBOLS + }; + SymLoadStruct extSymbols[] = { + { (PRFuncPtr*) &mSymbols.fQueryCounter, { "QueryCounterEXT", "QueryCounterANGLE", nullptr } }, + END_SYMBOLS + }; + + bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::query_counter); + + if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) { + NS_ERROR("GL supports query counters without supplying its functions."); + + MarkUnsupported(GLFeature::query_counter); + ClearSymbols(coreSymbols); + } + } + if (IsSupported(GLFeature::query_objects)) { SymLoadStruct coreSymbols[] = { { (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQuery", nullptr } }, @@ -1056,13 +1080,13 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl) }; 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 } }, + { (PRFuncPtr*) &mSymbols.fBeginQuery, { "BeginQueryEXT", "BeginQueryANGLE", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGenQueries, { "GenQueriesEXT", "GenQueriesANGLE", nullptr } }, + { (PRFuncPtr*) &mSymbols.fDeleteQueries, { "DeleteQueriesEXT", "DeleteQueriesANGLE", nullptr } }, + { (PRFuncPtr*) &mSymbols.fEndQuery, { "EndQueryEXT", "EndQueryANGLE", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGetQueryiv, { "GetQueryivEXT", "GetQueryivANGLE", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGetQueryObjectuiv, { "GetQueryObjectuivEXT", "GetQueryObjectuivANGLE", nullptr } }, + { (PRFuncPtr*) &mSymbols.fIsQuery, { "IsQueryEXT", "IsQueryANGLE", nullptr } }, END_SYMBOLS }; @@ -1072,6 +1096,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl) NS_ERROR("GL supports query objects without supplying its functions."); MarkUnsupported(GLFeature::query_objects); + MarkUnsupported(GLFeature::get_query_object_i64v); MarkUnsupported(GLFeature::get_query_object_iv); MarkUnsupported(GLFeature::occlusion_query); MarkUnsupported(GLFeature::occlusion_query_boolean); @@ -1080,6 +1105,29 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl) } } + if (IsSupported(GLFeature::get_query_object_i64v)) { + SymLoadStruct coreSymbols[] = { + { (PRFuncPtr*) &mSymbols.fGetQueryObjecti64v, { "GetQueryObjecti64v", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGetQueryObjectui64v, { "GetQueryObjectui64v", nullptr } }, + END_SYMBOLS + }; + + SymLoadStruct extSymbols[] = { + { (PRFuncPtr*) &mSymbols.fGetQueryObjecti64v, { "GetQueryObjecti64vEXT", "GetQueryObjecti64vANGLE", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGetQueryObjectui64v, { "GetQueryObjectui64vEXT", "GetQueryObjectui64vANGLE", nullptr } }, + END_SYMBOLS + }; + + bool useCore = IsFeatureProvidedByCoreSymbols(GLFeature::get_query_object_i64v); + if (!LoadSymbols(useCore ? coreSymbols : extSymbols, trygl, prefix)) { + NS_ERROR("GL supports 64 bit query object getters without supplying its functions."); + + MarkUnsupported(GLFeature::get_query_object_i64v); + MarkUnsupported(GLFeature::query_counter); + ClearSymbols(coreSymbols); + } + } + if (IsSupported(GLFeature::get_query_object_iv)) { SymLoadStruct coreSymbols[] = { { (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectiv", nullptr } }, @@ -1087,7 +1135,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl) }; SymLoadStruct extSymbols[] = { - { (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectivEXT", nullptr } }, + { (PRFuncPtr*) &mSymbols.fGetQueryObjectiv, { "GetQueryObjectivEXT", "GetQueryObjectivANGLE", nullptr } }, END_SYMBOLS }; diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index b1c146bbe5d..ee338234975 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -99,6 +99,7 @@ enum class GLFeature { framebuffer_object, get_integer_indexed, get_integer64_indexed, + get_query_object_i64v, get_query_object_iv, get_string_indexed, gpu_shader4, @@ -110,7 +111,9 @@ enum class GLFeature { occlusion_query_boolean, occlusion_query2, packed_depth_stencil, + query_counter, query_objects, + query_time_elapsed, read_buffer, renderbuffer_color_float, renderbuffer_color_half_float, @@ -364,6 +367,7 @@ public: ANGLE_instanced_arrays, ANGLE_texture_compression_dxt3, ANGLE_texture_compression_dxt5, + ANGLE_timer_query, APPLE_client_storage, APPLE_texture_range, APPLE_vertex_array_object, @@ -391,6 +395,7 @@ public: ARB_texture_rectangle, ARB_texture_storage, ARB_texture_swizzle, + ARB_timer_query, ARB_transform_feedback2, ARB_uniform_buffer_object, ARB_vertex_array_object, @@ -399,6 +404,7 @@ public: EXT_color_buffer_float, EXT_color_buffer_half_float, EXT_copy_texture, + EXT_disjoint_timer_query, EXT_draw_buffers, EXT_draw_buffers2, EXT_draw_instanced, @@ -423,6 +429,7 @@ public: EXT_texture_format_BGRA8888, EXT_texture_sRGB, EXT_texture_storage, + EXT_timer_query, EXT_transform_feedback, EXT_unpack_subimage, IMG_read_format, @@ -2617,6 +2624,22 @@ public: AFTER_GL_CALL; } +// ----------------------------------------------------------------------------- +// Package XXX_query_counter +/** + * XXX_query_counter: + * - depends on XXX_query_objects + * - provide all followed entry points + * - provide GL_TIMESTAMP + */ +public: + void fQueryCounter(GLuint id, GLenum target) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fQueryCounter); + mSymbols.fQueryCounter(id, target); + AFTER_GL_CALL; + } + // ----------------------------------------------------------------------------- // Package XXX_query_objects @@ -2671,6 +2694,28 @@ public: return retval; } +// ----------------------------------------------------------------------------- +// Package XXX_get_query_object_i64v +/** + * XXX_get_query_object_i64v: + * - depends on XXX_query_objects + * - provide the followed entry point + */ +public: + void fGetQueryObjecti64v(GLuint id, GLenum pname, GLint64* params) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fGetQueryObjecti64v); + mSymbols.fGetQueryObjecti64v(id, pname, params); + AFTER_GL_CALL; + } + + void fGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64* params) { + BEFORE_GL_CALL; + ASSERT_SYMBOL_PRESENT(fGetQueryObjectui64v); + mSymbols.fGetQueryObjectui64v(id, pname, params); + AFTER_GL_CALL; + } + // ----------------------------------------------------------------------------- // Package XXX_get_query_object_iv diff --git a/gfx/gl/GLContextFeatures.cpp b/gfx/gl/GLContextFeatures.cpp index f0ec9225554..7506ca84ccf 100644 --- a/gfx/gl/GLContextFeatures.cpp +++ b/gfx/gl/GLContextFeatures.cpp @@ -260,6 +260,18 @@ static const FeatureInfo sFeatureInfoArr[] = { GLContext::Extensions_End } }, + { + "get_query_object_i64v", + GLVersion::GL3_3, + GLESVersion::NONE, + GLContext::ARB_timer_query, + { + GLContext::ANGLE_timer_query, + GLContext::EXT_disjoint_timer_query, + GLContext::EXT_timer_query, + GLContext::Extensions_End + } + }, { "get_query_object_iv", GLVersion::GL2, @@ -392,21 +404,48 @@ static const FeatureInfo sFeatureInfoArr[] = { GLContext::Extensions_End } }, + { + "query_counter", + GLVersion::GL3_3, + GLESVersion::NONE, + GLContext::ARB_timer_query, + { + GLContext::ANGLE_timer_query, + GLContext::EXT_disjoint_timer_query, + // EXT_timer_query does NOT support GL_TIMESTAMP retrieval with + // QueryCounter. + GLContext::Extensions_End + } + }, { "query_objects", GLVersion::GL2, GLESVersion::ES3, GLContext::Extension_None, { + GLContext::ANGLE_timer_query, + GLContext::EXT_disjoint_timer_query, GLContext::EXT_occlusion_query_boolean, GLContext::Extensions_End } /* * XXX_query_objects only provide entry points commonly supported by - * ARB_occlusion_query (added in OpenGL 2.0) and EXT_occlusion_query_boolean - * (added in OpenGL ES 3.0) + * ARB_occlusion_query (added in OpenGL 2.0), EXT_occlusion_query_boolean + * (added in OpenGL ES 3.0), and ARB_timer_query (added in OpenGL 3.3) */ }, + { + "query_time_elapsed", + GLVersion::GL3_3, + GLESVersion::NONE, + GLContext::ARB_timer_query, + { + GLContext::ANGLE_timer_query, + GLContext::EXT_disjoint_timer_query, + GLContext::EXT_timer_query, + GLContext::Extensions_End + } + }, { "read_buffer", GLVersion::GL2, diff --git a/gfx/gl/GLContextSymbols.h b/gfx/gl/GLContextSymbols.h index 215e4e4c428..66b56cc8b57 100644 --- a/gfx/gl/GLContextSymbols.h +++ b/gfx/gl/GLContextSymbols.h @@ -145,6 +145,12 @@ struct GLContextSymbols PFNGLGETQUERYOBJECTIVPROC fGetQueryObjectiv; typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params); PFNGLGETQUERYOBJECTUIVPROC fGetQueryObjectuiv; + typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64* params); + PFNGLGETQUERYOBJECTI64VPROC fGetQueryObjecti64v; + typedef void (GLAPIENTRY * PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64* params); + PFNGLGETQUERYOBJECTUI64VPROC fGetQueryObjectui64v; + typedef void (GLAPIENTRY * PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); + PFNGLQUERYCOUNTERPROC fQueryCounter; typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); PFNGLTEXPARAMETERIPROC fTexParameteri; typedef void (GLAPIENTRY * PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint* param);