CmEventQuery.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. namespace CamelotFramework
  4. {
  5. /**
  6. * @brief Represents a GPU query that gets triggered when GPU starts processing the query.
  7. *
  8. * @note Normally GPU will have many commands in its command buffer. When EventQuery::begin is called it is placed
  9. * in that command buffer. Once the buffer empties and GPU reaches the EventQuery command, the query
  10. * callback is triggered.
  11. *
  12. * Core thread only.
  13. */
  14. class CM_EXPORT EventQuery
  15. {
  16. public:
  17. EventQuery()
  18. :mActive(false) {}
  19. virtual ~EventQuery() {}
  20. /**
  21. * @brief Starts the query.
  22. *
  23. * @note Once the query is started you may poll "isReady" method to check when query has finished,
  24. * or you may hook up an "onTriggered" callback and be notified that way.
  25. */
  26. virtual void begin() = 0;
  27. /**
  28. * @brief Check if GPU has processed the query.
  29. */
  30. virtual bool isReady() const = 0;
  31. boost::signal<void()> onTriggered;
  32. static EventQueryPtr create();
  33. protected:
  34. friend class QueryManager;
  35. bool isActive() const { return mActive; }
  36. void setActive(bool active) { mActive = active; }
  37. protected:
  38. bool mActive;
  39. };
  40. }