2
0

CmTimerQuery.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /**
  6. * @brief Represents a GPU query that measures execution time of GPU operations. The query will measure
  7. * any GPU operations that take place between its "begin" and "end" calls.
  8. *
  9. * @note Core thread only.
  10. */
  11. class CM_EXPORT TimerQuery
  12. {
  13. public:
  14. virtual ~TimerQuery() {}
  15. /**
  16. * @brief Starts the counter.
  17. *
  18. * @note Place any commands you want to measure after this call. Call "end" when done.
  19. */
  20. virtual void begin() = 0;
  21. /**
  22. * @brief Stops the counter.
  23. */
  24. virtual void end() = 0;
  25. /**
  26. * @brief Check if GPU has processed the query.
  27. */
  28. virtual bool isReady() const = 0;
  29. /**
  30. * @brief Returns the time it took for the query to execute.
  31. *
  32. * @return The time milliseconds.
  33. *
  34. * @note Only valid after "isReady" returns true.
  35. */
  36. virtual float getTimeMs() = 0;
  37. Event<void(float)> onTriggered;
  38. static TimerQueryPtr create();
  39. protected:
  40. friend class QueryManager;
  41. virtual void finalize() = 0;
  42. bool isActive() const { return mActive; }
  43. void setActive(bool active) { mActive = active; }
  44. protected:
  45. bool mActive;
  46. };
  47. }