diff --git a/src/Magnum/AbstractQuery.cpp b/src/Magnum/AbstractQuery.cpp index 5cc789740..6221e3fad 100644 --- a/src/Magnum/AbstractQuery.cpp +++ b/src/Magnum/AbstractQuery.cpp @@ -29,19 +29,20 @@ #include "Magnum/Context.h" #include "Magnum/Implementation/DebugState.h" +#include "Magnum/Implementation/QueryState.h" #include "Magnum/Implementation/State.h" namespace Magnum { +AbstractQuery::AbstractQuery(GLenum target): _target{target} { + (this->*Context::current()->state().query->createImplementation)(); +} + +#ifdef MAGNUM_BUILD_DEPRECATED AbstractQuery::AbstractQuery(): _target{} { - #ifndef MAGNUM_TARGET_GLES2 - glGenQueries(1, &_id); - #elif !defined(CORRADE_TARGET_EMSCRIPTEN) - glGenQueriesEXT(1, &_id); - #else - CORRADE_ASSERT_UNREACHABLE(); - #endif + createImplementationDefault(); } +#endif AbstractQuery::~AbstractQuery() { /* Moved out, nothing to do */ @@ -56,6 +57,22 @@ AbstractQuery::~AbstractQuery() { #endif } +void AbstractQuery::createImplementationDefault() { + #ifndef MAGNUM_TARGET_GLES2 + glGenQueries(1, &_id); + #elif !defined(CORRADE_TARGET_EMSCRIPTEN) + glGenQueriesEXT(1, &_id); + #else + CORRADE_ASSERT_UNREACHABLE(); + #endif +} + +#ifndef MAGNUM_TARGET_GLES +void AbstractQuery::createImplementationDSA() { + glCreateQueries(_target, 1, &_id); +} +#endif + std::string AbstractQuery::label() const { #ifndef MAGNUM_TARGET_GLES return Context::current()->state().debug->getLabelImplementation(GL_QUERY, _id); @@ -74,8 +91,6 @@ AbstractQuery& AbstractQuery::setLabelInternal(const Containers::ArrayReference< } bool AbstractQuery::resultAvailable() { - CORRADE_ASSERT(!_target, "AbstractQuery::resultAvailable(): the query is currently running", false); - GLuint result; #ifndef MAGNUM_TARGET_GLES2 glGetQueryObjectuiv(_id, GL_QUERY_RESULT_AVAILABLE, &result); @@ -89,8 +104,6 @@ bool AbstractQuery::resultAvailable() { #ifndef DOXYGEN_GENERATING_OUTPUT template<> UnsignedInt AbstractQuery::result() { - CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); - UnsignedInt result; #ifndef MAGNUM_TARGET_GLES2 glGetQueryObjectuiv(_id, GL_QUERY_RESULT, &result); @@ -105,8 +118,6 @@ template<> UnsignedInt AbstractQuery::result() { template<> bool AbstractQuery::result() { return result() != 0; } template<> Int AbstractQuery::result() { - CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); - Int result; #ifndef MAGNUM_TARGET_GLES glGetQueryObjectiv(_id, GL_QUERY_RESULT, &result); @@ -120,8 +131,6 @@ template<> Int AbstractQuery::result() { #ifndef MAGNUM_TARGET_WEBGL template<> UnsignedLong AbstractQuery::result() { - CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); - UnsignedLong result; #ifndef MAGNUM_TARGET_GLES glGetQueryObjectui64v(_id, GL_QUERY_RESULT, &result); @@ -134,8 +143,6 @@ template<> UnsignedLong AbstractQuery::result() { } template<> Long AbstractQuery::result() { - CORRADE_ASSERT(!_target, "AbstractQuery::result(): the query is currently running", {}); - Long result; #ifndef MAGNUM_TARGET_GLES glGetQueryObjecti64v(_id, GL_QUERY_RESULT, &result); @@ -149,21 +156,33 @@ template<> Long AbstractQuery::result() { #endif #endif -void AbstractQuery::begin(const GLenum target) { - CORRADE_ASSERT(!_target, "AbstractQuery::begin(): the query is already running", ); +void AbstractQuery::begin() { + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(_target); + #endif #ifndef MAGNUM_TARGET_GLES2 - glBeginQuery(_target = target, _id); + glBeginQuery(_target, _id); #elif !defined(CORRADE_TARGET_EMSCRIPTEN) - glBeginQueryEXT(_target = target, _id); + glBeginQueryEXT(_target, _id); #else - static_cast(target); CORRADE_ASSERT_UNREACHABLE(); #endif } +#ifdef MAGNUM_BUILD_DEPRECATED +void AbstractQuery::begin(const GLenum target) { + CORRADE_INTERNAL_ASSERT(!_target || _target == target); + + _target = target; + begin(); +} +#endif + void AbstractQuery::end() { - CORRADE_ASSERT(_target, "AbstractQuery::end(): the query is not running", ); + #ifdef MAGNUM_BUILD_DEPRECATED + CORRADE_INTERNAL_ASSERT(_target); + #endif #ifndef MAGNUM_TARGET_GLES2 glEndQuery(_target); @@ -172,7 +191,6 @@ void AbstractQuery::end() { #else CORRADE_ASSERT_UNREACHABLE(); #endif - _target = {}; } } diff --git a/src/Magnum/AbstractQuery.h b/src/Magnum/AbstractQuery.h index 0dcd628d4..9077a635f 100644 --- a/src/Magnum/AbstractQuery.h +++ b/src/Magnum/AbstractQuery.h @@ -37,6 +37,8 @@ namespace Magnum { +namespace Implementation { class QueryState; } + /** @brief Base class for queries @@ -45,6 +47,8 @@ more information. @todo `QUERY_COUNTER_BITS` (not sure since when this is supported) */ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { + friend class Implementation::QueryState; + public: /** @brief Copying is not allowed */ AbstractQuery(const AbstractQuery&) = delete; @@ -120,6 +124,14 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { */ template T result(); + /** + * @brief Begin query + * + * Begins counting until @ref end() is called. + * @see @fn_gl{BeginQuery} + */ + void begin(); + /** * @brief End query * @@ -129,14 +141,6 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { void end(); protected: - /** - * @brief Constructor - * - * Generates one OpenGL query. - * @see @fn_gl{GenQueries} - */ - explicit AbstractQuery(); - /** * @brief Destructor * @@ -148,11 +152,21 @@ class MAGNUM_EXPORT AbstractQuery: public AbstractObject { #ifdef DOXYGEN_GENERATING_OUTPUT private: #endif + explicit AbstractQuery(GLenum target); + + #ifdef MAGNUM_BUILD_DEPRECATED + explicit AbstractQuery(); void begin(GLenum target); + #endif private: AbstractQuery& setLabelInternal(Containers::ArrayReference label); + void MAGNUM_LOCAL createImplementationDefault(); + #ifndef MAGNUM_TARGET_GLES + void MAGNUM_LOCAL createImplementationDSA(); + #endif + GLuint _id; GLenum _target; }; diff --git a/src/Magnum/CMakeLists.txt b/src/Magnum/CMakeLists.txt index b560ce451..588bc6d3e 100644 --- a/src/Magnum/CMakeLists.txt +++ b/src/Magnum/CMakeLists.txt @@ -58,6 +58,7 @@ set(Magnum_SRCS Implementation/DebugState.cpp Implementation/FramebufferState.cpp Implementation/MeshState.cpp + Implementation/QueryState.cpp Implementation/RendererState.cpp Implementation/ShaderProgramState.cpp Implementation/State.cpp @@ -128,6 +129,7 @@ set(Magnum_PRIVATE_HEADERS Implementation/FramebufferState.h Implementation/maxTextureSize.h Implementation/MeshState.h + Implementation/QueryState.h Implementation/RendererState.h Implementation/ShaderProgramState.h Implementation/ShaderState.h diff --git a/src/Magnum/Implementation/QueryState.cpp b/src/Magnum/Implementation/QueryState.cpp new file mode 100644 index 000000000..bec5f3d00 --- /dev/null +++ b/src/Magnum/Implementation/QueryState.cpp @@ -0,0 +1,52 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include "QueryState.h" + +#include "Magnum/Context.h" +#include "Magnum/Extensions.h" + +namespace Magnum { namespace Implementation { + +QueryState::QueryState(Context& context, std::vector& extensions) { + /* Create implementation */ + #ifndef MAGNUM_TARGET_GLES + if(context.isExtensionSupported()) { + extensions.push_back(Extensions::GL::ARB::direct_state_access::string()); + createImplementation = &AbstractQuery::createImplementationDSA; + + } else + #endif + { + createImplementation = &AbstractQuery::createImplementationDefault; + } + + #ifdef MAGNUM_TARGET_GLES + static_cast(context); + static_cast(extensions); + #endif +} + +}} diff --git a/src/Magnum/Implementation/QueryState.h b/src/Magnum/Implementation/QueryState.h new file mode 100644 index 000000000..75d0f3d45 --- /dev/null +++ b/src/Magnum/Implementation/QueryState.h @@ -0,0 +1,44 @@ +#ifndef Magnum_Implementation_QueryState_h +#define Magnum_Implementation_QueryState_h +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014 + Vladimír Vondruš + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + +#include + +#include "Magnum/AbstractQuery.h" + +namespace Magnum { namespace Implementation { + +struct QueryState { + explicit QueryState(Context& context, std::vector& extensions); + + void reset(); + + void(AbstractQuery::*createImplementation)(); +}; + +}} + +#endif diff --git a/src/Magnum/Implementation/State.cpp b/src/Magnum/Implementation/State.cpp index 82354e734..490989a1a 100644 --- a/src/Magnum/Implementation/State.cpp +++ b/src/Magnum/Implementation/State.cpp @@ -34,6 +34,7 @@ #include "DebugState.h" #include "FramebufferState.h" #include "MeshState.h" +#include "QueryState.h" #include "RendererState.h" #include "ShaderState.h" #include "ShaderProgramState.h" @@ -55,6 +56,7 @@ State::State(Context& context) { debug = new DebugState(context, extensions); framebuffer = new FramebufferState(context, extensions); mesh = new MeshState(context, extensions); + query = new QueryState(context, extensions); renderer = new RendererState(context, extensions); shader = new ShaderState; shaderProgram = new ShaderProgramState(context, extensions); diff --git a/src/Magnum/Implementation/State.h b/src/Magnum/Implementation/State.h index f8e9c6a7f..481e6ad73 100644 --- a/src/Magnum/Implementation/State.h +++ b/src/Magnum/Implementation/State.h @@ -34,6 +34,7 @@ struct BufferState; struct DebugState; struct FramebufferState; struct MeshState; +struct QueryState; struct RendererState; struct ShaderState; struct ShaderProgramState; @@ -51,6 +52,7 @@ struct State { DebugState* debug; FramebufferState* framebuffer; MeshState* mesh; + QueryState* query; RendererState* renderer; ShaderState* shader; ShaderProgramState* shaderProgram; diff --git a/src/Magnum/PrimitiveQuery.h b/src/Magnum/PrimitiveQuery.h index d196e95ca..ad7649f19 100644 --- a/src/Magnum/PrimitiveQuery.h +++ b/src/Magnum/PrimitiveQuery.h @@ -79,18 +79,38 @@ class PrimitiveQuery: public AbstractQuery { TransformFeedbackPrimitivesWritten = GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN }; - explicit PrimitiveQuery() {} + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief PrimitiveQuery(Target) + * @deprecated Use @ref Magnum::PrimitiveQuery::PrimitiveQuery(Target) "PrimitiveQuery(Target)" + * instead. + */ + CORRADE_DEPRECATED("use PrimitiveQuery(Target) instead") explicit PrimitiveQuery() {} + #endif /** - * @brief Begin query + * @brief Constructor * - * Begins counting of given @p target until @ref end() is called. - * @see @fn_gl{BeginQuery} + * Creates new OpenGL query object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the query is created on first + * use. + * @see @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries} + */ + explicit PrimitiveQuery(Target target): AbstractQuery(GLenum(target)) {} + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief AbstractQuery::begin() + * @deprecated Use @ref Magnum::AbstractQuery::begin() "begin()" + * instead. */ - void begin(Target target) { + CORRADE_DEPRECATED("use begin() instead") void begin(Target target) { AbstractQuery::begin(GLenum(target)); } + using AbstractQuery::begin; + #endif + /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT PrimitiveQuery& setLabel(const std::string& label) { diff --git a/src/Magnum/SampleQuery.h b/src/Magnum/SampleQuery.h index 9fee36ccf..594659eb8 100644 --- a/src/Magnum/SampleQuery.h +++ b/src/Magnum/SampleQuery.h @@ -172,13 +172,39 @@ class SampleQuery: public AbstractQuery { }; #endif - explicit SampleQuery() {} - /** @copydoc PrimitiveQuery::begin() */ - void begin(Target target) { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief SampleQuery(Target) + * @deprecated Use @ref Magnum::SampleQuery::SampleQuery(Target) "SampleQuery(Target)" + * instead. + */ + CORRADE_DEPRECATED("use SampleQuery(Target) instead") explicit SampleQuery() {} + #endif + + /** + * @brief Constructor + * + * Creates new OpenGL query object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the query is created on first + * use. + * @see @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries} + */ + explicit SampleQuery(Target target): AbstractQuery(GLenum(target)) {} + + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief AbstractQuery::begin() + * @deprecated Use @ref Magnum::AbstractQuery::begin() "begin()" + * instead. + */ + CORRADE_DEPRECATED("use begin() instead") void begin(Target target) { AbstractQuery::begin(GLenum(target)); } + using AbstractQuery::begin; + #endif + #ifndef MAGNUM_TARGET_GLES /** * @brief Begin conditional rendering based on result value diff --git a/src/Magnum/Test/AbstractQueryGLTest.cpp b/src/Magnum/Test/AbstractQueryGLTest.cpp index 256fc236e..241133f62 100644 --- a/src/Magnum/Test/AbstractQueryGLTest.cpp +++ b/src/Magnum/Test/AbstractQueryGLTest.cpp @@ -54,7 +54,11 @@ void AbstractQueryGLTest::construct() { #endif { - const SampleQuery query; + #ifndef MAGNUM_TARGET_GLES + const SampleQuery query{SampleQuery::Target::SamplesPassed}; + #else + const SampleQuery query{SampleQuery::Target::AnySamplesPassed}; + #endif MAGNUM_VERIFY_NO_ERROR(); CORRADE_VERIFY(query.id() > 0); @@ -74,7 +78,11 @@ void AbstractQueryGLTest::constructMove() { CORRADE_SKIP(Extensions::GL::EXT::occlusion_query_boolean::string() + std::string(" is not supported.")); #endif - SampleQuery a; + #ifndef MAGNUM_TARGET_GLES + SampleQuery a{SampleQuery::Target::SamplesPassed}; + #else + SampleQuery a{SampleQuery::Target::AnySamplesPassed}; + #endif const Int id = a.id(); MAGNUM_VERIFY_NO_ERROR(); @@ -85,7 +93,11 @@ void AbstractQueryGLTest::constructMove() { CORRADE_COMPARE(a.id(), 0); CORRADE_COMPARE(b.id(), id); - SampleQuery c; + #ifndef MAGNUM_TARGET_GLES + SampleQuery c{SampleQuery::Target::SamplesPassed}; + #else + SampleQuery c{SampleQuery::Target::AnySamplesPassed}; + #endif const Int cId = c.id(); c = std::move(b); @@ -106,14 +118,21 @@ void AbstractQueryGLTest::label() { !Context::current()->isExtensionSupported()) CORRADE_SKIP("Required extension is not available"); + #ifndef MAGNUM_TARGET_GLES + SampleQuery query{SampleQuery::Target::SamplesPassed}; + #else + SampleQuery query{SampleQuery::Target::AnySamplesPassed}; + #endif + + #ifndef MAGNUM_TARGET_GLES + if(!Context::current()->isExtensionSupported()) + #endif { - /** @todo Is this even legal optimization? */ - CORRADE_EXPECT_FAIL("The object must be used at least once before setting/querying label."); + query.begin(); query.end(); + + CORRADE_EXPECT_FAIL("Without ARB_direct_state_access, the object must be used at least once before setting/querying label."); CORRADE_VERIFY(false); } - SampleQuery query; - query.begin(SampleQuery::Target::AnySamplesPassed); - query.end(); CORRADE_COMPARE(query.label(), ""); diff --git a/src/Magnum/Test/PrimitiveQueryGLTest.cpp b/src/Magnum/Test/PrimitiveQueryGLTest.cpp index dcb2574a1..399f11c0a 100644 --- a/src/Magnum/Test/PrimitiveQueryGLTest.cpp +++ b/src/Magnum/Test/PrimitiveQueryGLTest.cpp @@ -94,8 +94,8 @@ void PrimitiveQueryGLTest::query() { MAGNUM_VERIFY_NO_ERROR(); - PrimitiveQuery q; - q.begin(PrimitiveQuery::Target::PrimitivesGenerated); + PrimitiveQuery q{PrimitiveQuery::Target::PrimitivesGenerated}; + q.begin(); framebuffer.bind(FramebufferTarget::ReadDraw); mesh.draw(shader); diff --git a/src/Magnum/Test/SampleQueryGLTest.cpp b/src/Magnum/Test/SampleQueryGLTest.cpp index 9d71a36bd..6e87c9621 100644 --- a/src/Magnum/Test/SampleQueryGLTest.cpp +++ b/src/Magnum/Test/SampleQueryGLTest.cpp @@ -117,12 +117,12 @@ void SampleQueryGLTest::querySamplesPassed() { MAGNUM_VERIFY_NO_ERROR(); - SampleQuery q; #ifndef MAGNUM_TARGET_GLES - q.begin(SampleQuery::Target::SamplesPassed); + SampleQuery q{SampleQuery::Target::SamplesPassed}; #else - q.begin(SampleQuery::Target::AnySamplesPassed); + SampleQuery q{SampleQuery::Target::AnySamplesPassed}; #endif + q.begin(); framebuffer.bind(FramebufferTarget::ReadDraw); mesh.draw(shader); @@ -167,16 +167,18 @@ void SampleQueryGLTest::conditionalRender() { MAGNUM_VERIFY_NO_ERROR(); - SampleQuery qYes, qNo, q; + SampleQuery qYes{SampleQuery::Target::SamplesPassed}, + qNo{SampleQuery::Target::SamplesPassed}, + q{SampleQuery::Target::SamplesPassed}; /* This should generate some samples */ - qYes.begin(SampleQuery::Target::SamplesPassed); + qYes.begin(); mesh.draw(shader); qYes.end(); /* Thus this should be rendered */ qYes.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait); - q.begin(SampleQuery::Target::SamplesPassed); + q.begin(); mesh.draw(shader); q.end(); qYes.endConditionalRender(); @@ -186,12 +188,12 @@ void SampleQueryGLTest::conditionalRender() { CORRADE_VERIFY(q.result()); /* This shouldn't generate any samples */ - qNo.begin(SampleQuery::Target::SamplesPassed); + qNo.begin(); qNo.end(); /* Thus this should not be rendered */ qNo.beginConditionalRender(SampleQuery::ConditionalRenderMode::Wait); - q.begin(SampleQuery::Target::SamplesPassed); + q.begin(); mesh.draw(shader); q.end(); qNo.endConditionalRender(); diff --git a/src/Magnum/Test/TimeQueryGLTest.cpp b/src/Magnum/Test/TimeQueryGLTest.cpp index c1741bd1f..440f5861d 100644 --- a/src/Magnum/Test/TimeQueryGLTest.cpp +++ b/src/Magnum/Test/TimeQueryGLTest.cpp @@ -50,15 +50,15 @@ void TimeQueryGLTest::queryTime() { CORRADE_SKIP(Extensions::GL::EXT::disjoint_timer_query::string() + std::string(" is not available")); #endif - TimeQuery q1; - q1.begin(TimeQuery::Target::TimeElapsed); + TimeQuery q1{TimeQuery::Target::TimeElapsed}; + q1.begin(); q1.end(); const auto result1 = q1.result(); MAGNUM_VERIFY_NO_ERROR(); - TimeQuery q2; - q2.begin(TimeQuery::Target::TimeElapsed); + TimeQuery q2{TimeQuery::Target::TimeElapsed}; + q2.begin(); Renderer::enable(Renderer::Feature::Blending); Renderer::finish(); q2.end(); @@ -74,11 +74,13 @@ void TimeQueryGLTest::queryTimestamp() { CORRADE_SKIP(Extensions::GL::EXT::disjoint_timer_query::string() + std::string(" is not available")); #endif - TimeQuery q1, q2, q; + TimeQuery q1{TimeQuery::Target::Timestamp}, + q2{TimeQuery::Target::Timestamp}, + q{TimeQuery::Target::TimeElapsed}; q1.timestamp(); - q.begin(TimeQuery::Target::TimeElapsed); + q.begin(); Renderer::enable(Renderer::Feature::Blending); Renderer::finish(); q.end(); diff --git a/src/Magnum/TimeQuery.h b/src/Magnum/TimeQuery.h index 23a005b21..497715fee 100644 --- a/src/Magnum/TimeQuery.h +++ b/src/Magnum/TimeQuery.h @@ -75,13 +75,37 @@ class TimeQuery: public AbstractQuery { enum class Target: GLenum { /** Elapsed time */ #ifndef MAGNUM_TARGET_GLES - TimeElapsed = GL_TIME_ELAPSED + TimeElapsed = GL_TIME_ELAPSED, #else - TimeElapsed = GL_TIME_ELAPSED_EXT + TimeElapsed = GL_TIME_ELAPSED_EXT, + #endif + + /** Timestamp (for use with @ref timestamp() only) */ + #ifndef MAGNUM_TARGET_GLES + Timestamp = GL_TIMESTAMP + #else + Timestamp = GL_TIMESTAMP_EXT #endif }; - explicit TimeQuery() {} + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief TimeQuery(Target) + * @deprecated Use @ref Magnum::TimeQuery::TimeQuery(Target) "TimeQuery(Target)" + * instead. + */ + CORRADE_DEPRECATED("use TimeQuery(Target) instead") explicit TimeQuery() {} + #endif + + /** + * @brief Constructor + * + * Creates new OpenGL query object. If @extension{ARB,direct_state_access} + * (part of OpenGL 4.5) is not supported, the query is created on first + * use. + * @see @fn_gl{CreateQueries}, eventually @fn_gl{GenQueries} + */ + explicit TimeQuery(Target target): AbstractQuery(GLenum(target)) {} /** * @brief Query timestamp @@ -98,11 +122,19 @@ class TimeQuery: public AbstractQuery { #endif } - /** @copydoc PrimitiveQuery::begin() */ - void begin(Target target) { + #ifdef MAGNUM_BUILD_DEPRECATED + /** + * @copybrief AbstractQuery::begin() + * @deprecated Use @ref Magnum::AbstractQuery::begin() "begin()" + * instead. + */ + CORRADE_DEPRECATED("use begin() instead") void begin(Target target) { AbstractQuery::begin(GLenum(target)); } + using AbstractQuery::begin; + #endif + /* Overloads to remove WTF-factor from method chaining order */ #ifndef DOXYGEN_GENERATING_OUTPUT TimeQuery& setLabel(const std::string& label) {