BsQueryManager.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsEventQuery.h"
  4. #include "BsModule.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Handles creation and destruction of GPU queries.
  9. *
  10. * @note Core thread only.
  11. */
  12. class BS_CORE_EXPORT QueryManager : public Module<QueryManager>
  13. {
  14. public:
  15. QueryManager();
  16. /**
  17. * @brief Creates a new event query that allows you to get notified
  18. * when GPU starts executing the query.
  19. */
  20. virtual EventQueryPtr createEventQuery() const = 0;
  21. /**
  22. * @brief Creates a new timer query that allows you to get notified
  23. * of how much time has passed between query start and end.
  24. */
  25. virtual TimerQueryPtr createTimerQuery() const = 0;
  26. /**
  27. * @brief Creates a new occlusion query that allows you to know
  28. * how many fragments were rendered between query start and end.
  29. *
  30. * @param binary If query is binary it will not give you an exact count of fragments rendered, but will instead
  31. * just return 0 (no fragments were rendered) or 1 (one or more fragments were rendered). Binary
  32. * queries can return sooner as they potentially do not need to wait until all of the geometry is rendered.
  33. */
  34. virtual OcclusionQueryPtr createOcclusionQuery(bool binary) const = 0;
  35. /**
  36. * @note Internal method, called every frame.
  37. */
  38. void _update();
  39. protected:
  40. friend class EventQuery;
  41. friend class TimerQuery;
  42. friend class OcclusionQuery;
  43. /**
  44. * @brief Deletes an Event query. Always use this method and don't delete them manually.
  45. */
  46. static void deleteEventQuery(EventQuery* query);
  47. /**
  48. * @brief Deletes a Timer query. Always use this method and don't delete them manually.
  49. */
  50. static void deleteTimerQuery(TimerQuery* query);
  51. /**
  52. * @brief Deletes an Occlusion query. Always use this method and don't delete them manually.
  53. */
  54. static void deleteOcclusionQuery(OcclusionQuery* query);
  55. protected:
  56. mutable Vector<EventQuery*> mEventQueries;
  57. mutable Vector<TimerQuery*> mTimerQueries;
  58. mutable Vector<OcclusionQuery*> mOcclusionQueries;
  59. };
  60. }