BsD3D9TimerQuery.h 2.0 KB

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