BsEventQuery.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. namespace BansheeEngine
  4. {
  5. /** @cond INTERNAL */
  6. /** @addtogroup RenderAPI
  7. * @{
  8. */
  9. /**
  10. * Represents a GPU query that gets triggered when GPU starts processing the query.
  11. *
  12. * @note
  13. * Normally GPU will have many commands in its command buffer. When begin() is called it is placed in that command
  14. * buffer. Once the buffer empties and GPU reaches the EventQuery command, the query callback is triggered.
  15. * @note
  16. * Core thread only.
  17. */
  18. class BS_CORE_EXPORT EventQuery
  19. {
  20. public:
  21. EventQuery()
  22. :mActive(false) {}
  23. virtual ~EventQuery() {}
  24. /**
  25. * Starts the query.
  26. *
  27. * @note
  28. * Once the query is started you may poll isReady() method to check when query has finished, or you may hook up
  29. * an ::onTriggered callback and be notified that way.
  30. */
  31. virtual void begin() = 0;
  32. /** Check if GPU has processed the query. */
  33. virtual bool isReady() const = 0;
  34. /** Triggered when GPU starts processing the query. */
  35. Event<void()> onTriggered;
  36. /** Creates a new query, but does not schedule it on GPU. */
  37. static EventQueryPtr create();
  38. protected:
  39. friend class QueryManager;
  40. /** Returns true if the has still not been completed by the GPU. */
  41. bool isActive() const { return mActive; }
  42. void setActive(bool active) { mActive = active; }
  43. protected:
  44. bool mActive;
  45. };
  46. /** @} */
  47. /** @endcond */
  48. }