2
0

BsD3D9ResourceManager.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. namespace BansheeEngine
  6. {
  7. /** @addtogroup D3D9
  8. * @{
  9. */
  10. /** Types of resource creation policies. */
  11. enum D3D9ResourceCreationPolicy
  12. {
  13. /**
  14. * Creates resources only on active device. Meaning those resources will be unavailable
  15. * for other devices.
  16. */
  17. RCP_CREATE_ON_ACTIVE_DEVICE,
  18. /**
  19. * Creates resources on all devices making them available to all of them.
  20. */
  21. RCP_CREATE_ON_ALL_DEVICES
  22. };
  23. /** Handles DirectX 9 resource life, notifying them about relevant device changes. */
  24. class BS_D3D9_EXPORT D3D9ResourceManager
  25. {
  26. public:
  27. D3D9ResourceManager();
  28. ~D3D9ResourceManager();
  29. /** Called after the device has been created. */
  30. void notifyOnDeviceCreate(IDirect3DDevice9* d3d9Device);
  31. /** Called before the device is destroyed. */
  32. void notifyOnDeviceDestroy(IDirect3DDevice9* d3d9Device);
  33. /** Called after the device has entered the lost state. */
  34. void notifyOnDeviceLost(IDirect3DDevice9* d3d9Device);
  35. /** Called after the device has been reset. */
  36. void notifyOnDeviceReset(IDirect3DDevice9* d3d9Device);
  37. /** Called when device state is changing. Access to any device should be locked. */
  38. void lockDeviceAccess();
  39. /** Called when device state change completed. Access to any device is allowed. */
  40. void unlockDeviceAccess();
  41. /** Called when new resource is created. */
  42. void _notifyResourceCreated(D3D9Resource* pResource);
  43. /** Called before resource is destroyed. */
  44. void _notifyResourceDestroyed(D3D9Resource* pResource);
  45. /** Sets creation policy that specifies on what devices will resources be created on. */
  46. void setCreationPolicy(D3D9ResourceCreationPolicy creationPolicy);
  47. /** Returns creation policy that specifies on what devices will resources be created on. */
  48. D3D9ResourceCreationPolicy getCreationPolicy() const;
  49. protected:
  50. friend class D3D9Resource;
  51. Mutex mResourcesMutex;
  52. Vector<D3D9Resource*> mResources;
  53. D3D9ResourceCreationPolicy mResourceCreationPolicy;
  54. long mDeviceAccessLockCount;
  55. };
  56. /** @} */
  57. }