BsEventQuery.h 1.6 KB

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