BsD3D9TimerQuery.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /** @addtogroup D3D9
  10. * @{
  11. */
  12. /** @copydoc TimerQuery */
  13. class BS_D3D9_EXPORT D3D9TimerQuery : public TimerQuery, public D3D9Resource
  14. {
  15. public:
  16. D3D9TimerQuery();
  17. ~D3D9TimerQuery();
  18. /** @copydoc TimerQuery::begin */
  19. void begin() override;
  20. /** @copydoc TimerQuery::end */
  21. void end() override;
  22. /** @copydoc TimerQuery::isReady */
  23. bool isReady() const override;
  24. /** @copydoc TimerQuery::getTimeMs */
  25. float getTimeMs() override;
  26. /** @copydoc D3D9Resource::notifyOnDeviceCreate */
  27. void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device) override;
  28. /** @copydoc D3D9Resource::notifyOnDeviceDestroy */
  29. void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device) override;
  30. /** @copydoc D3D9Resource::notifyOnDeviceLost */
  31. void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device) override;
  32. /** @copydoc D3D9Resource::notifyOnDeviceReset */
  33. void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device) override;
  34. private:
  35. /** Resolve timing information after the query has finished. */
  36. void finalize();
  37. /** Creates the internal DX9 query. */
  38. void createQuery();
  39. /** Releases the internal DX9 query. */
  40. void releaseQuery();
  41. /** Checks if the internal query object is valid. */
  42. bool isQueryValid() const;
  43. private:
  44. bool mFinalized;
  45. bool mQueryIssued;
  46. float mTimeDelta;
  47. IDirect3DDevice9* mDevice;
  48. IDirect3DQuery9* mBeginQuery;
  49. IDirect3DQuery9* mEndQuery;
  50. IDirect3DQuery9* mDisjointQuery;
  51. IDirect3DQuery9* mFreqQuery;
  52. };
  53. /** @} */
  54. }