2
0

BsD3D9TimerQuery.h 2.0 KB

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