2
0

BsEventQuery.h 1.7 KB

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