| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "BsGLPrerequisites.h" |
| 6 | #include "RenderAPI/BsTimerQuery.h" |
| 7 | |
| 8 | namespace bs { namespace ct |
| 9 | { |
| 10 | /** @addtogroup GL |
| 11 | * @{ |
| 12 | */ |
| 13 | |
| 14 | /** OpenGL implementation of a timer query. */ |
| 15 | class GLTimerQuery : public TimerQuery |
| 16 | { |
| 17 | public: |
| 18 | GLTimerQuery(UINT32 deviceIdx); |
| 19 | ~GLTimerQuery(); |
| 20 | |
| 21 | /** @copydoc TimerQuery::begin */ |
| 22 | void begin(const SPtr<CommandBuffer>& cb = nullptr) override; |
| 23 | |
| 24 | /** @copydoc TimerQuery::end */ |
| 25 | void end(const SPtr<CommandBuffer>& cb = nullptr) override; |
| 26 | |
| 27 | /** @copydoc TimerQuery::isReady */ |
| 28 | bool isReady() const override; |
| 29 | |
| 30 | /** @copydoc TimerQuery::getTimeMs */ |
| 31 | float getTimeMs() override; |
| 32 | |
| 33 | private: |
| 34 | friend class QueryManager; |
| 35 | |
| 36 | /** Processes query results and saves them for later use. To be called when query has completed. */ |
| 37 | void finalize(); |
| 38 | |
| 39 | private: |
| 40 | GLuint mQueryStartObj = 0; |
| 41 | GLuint mQueryEndObj = 0; |
| 42 | bool mFinalized = false; |
| 43 | bool mEndIssued = false; |
| 44 | |
| 45 | float mTimeDelta = 0.0f; |
| 46 | }; |
| 47 | |
| 48 | /** @} */ |
| 49 | }} |