BsD3D9TimerQuery.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #pragma once
  2. #include "BsD3D9Prerequisites.h"
  3. #include "BsD3D9Resource.h"
  4. #include "BsTimerQuery.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @copydoc TimerQuery
  9. */
  10. class BS_D3D9_EXPORT D3D9TimerQuery : public TimerQuery, public D3D9Resource
  11. {
  12. public:
  13. D3D9TimerQuery();
  14. ~D3D9TimerQuery();
  15. /**
  16. * @copydoc TimerQuery::begin
  17. */
  18. virtual void begin();
  19. /**
  20. * @copydoc TimerQuery::end
  21. */
  22. virtual void end();
  23. /**
  24. * @copydoc TimerQuery::isReady
  25. */
  26. virtual bool isReady() const;
  27. /**
  28. * @copydoc TimerQuery::getTimeMs
  29. */
  30. virtual float getTimeMs();
  31. /**
  32. * @copydoc D3D9Resource::notifyOnDeviceCreate
  33. */
  34. virtual void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
  35. /**
  36. * @copydoc D3D9Resource::notifyOnDeviceDestroy
  37. */
  38. virtual void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
  39. /**
  40. * @copydoc D3D9Resource::notifyOnDeviceLost
  41. */
  42. virtual void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
  43. /**
  44. * @copydoc D3D9Resource::notifyOnDeviceReset
  45. */
  46. virtual void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
  47. private:
  48. /**
  49. * @brief Resolve timing information after the query has finished.
  50. */
  51. void finalize();
  52. /**
  53. * @brief Creates the internal DX9 query.
  54. */
  55. void createQuery();
  56. /**
  57. * @brief Releases the internal DX9 query.
  58. */
  59. void releaseQuery();
  60. /**
  61. * @brief Checks if the internal query object is valid.
  62. */
  63. bool isQueryValid() const;
  64. private:
  65. bool mFinalized;
  66. bool mQueryIssued;
  67. float mTimeDelta;
  68. IDirect3DDevice9* mDevice;
  69. IDirect3DQuery9* mBeginQuery;
  70. IDirect3DQuery9* mEndQuery;
  71. IDirect3DQuery9* mDisjointQuery;
  72. IDirect3DQuery9* mFreqQuery;
  73. };
  74. }