BsRenderTargetManager.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsModule.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Handles render target updates, usually cross-thread updates triggered
  8. * by render targets getting modified on the core thread.
  9. *
  10. * @note Internal class.
  11. */
  12. class BS_CORE_EXPORT RenderTargetManager : public Module<RenderTargetManager>
  13. {
  14. struct RenderTargetData
  15. {
  16. RenderTargetProperties* properties;
  17. bool dirty;
  18. };
  19. public:
  20. ~RenderTargetManager();
  21. /**
  22. * @brief Registers a new render target with the manager.
  23. * Should be called when RT is initialized on the core thread.
  24. *
  25. * @note Core thread only.
  26. */
  27. void registerRenderTarget(RenderTarget* rt);
  28. /**
  29. * @brief Unregisters a render target from the manager.
  30. * Should be called when RT is getting destroyed on the core thread.
  31. *
  32. * @note Core thread only.
  33. */
  34. void unregisterRenderTarget(RenderTarget* rt);
  35. /**
  36. * @brief Called once per frame on the core thread. Should be called at the end of
  37. * the frame once all render target related methods have completed.
  38. *
  39. * @note Core thread only.
  40. */
  41. void updateCore();
  42. /**
  43. * @brief Called once per frame on the sim thread. Should be called at the beginning
  44. * of the frame before the code can access render targets.
  45. */
  46. void update();
  47. private:
  48. UnorderedMap<RenderTarget*, RenderTargetData> mRenderTargets;
  49. BS_MUTEX(mMutex);
  50. };
  51. }