BsMultiRenderTexture.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsRenderTarget.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Descriptor class used for initializing a MultiRenderTexture.
  8. * Contains descriptors for each individual color render surface and
  9. * their common depth/stencil surface.
  10. */
  11. struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_DESC
  12. {
  13. Vector<RENDER_SURFACE_DESC> colorSurfaces;
  14. RENDER_SURFACE_DESC depthStencilSurface;
  15. };
  16. /**
  17. * @brief Contains various properties that describe a render texture.
  18. */
  19. class BS_CORE_EXPORT MultiRenderTextureProperties : public RenderTargetProperties
  20. {
  21. public:
  22. MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_DESC& desc);
  23. virtual ~MultiRenderTextureProperties() { }
  24. protected:
  25. friend class MultiRenderTextureCore;
  26. friend class MultiRenderTexture;
  27. };
  28. /**
  29. * @brief Object representing multiple render textures. You may bind this to the pipeline
  30. * in order to render to all or some of the textures at once.
  31. *
  32. * @note Core thread only.
  33. */
  34. class BS_CORE_EXPORT MultiRenderTextureCore : public RenderTargetCore
  35. {
  36. public:
  37. virtual ~MultiRenderTextureCore();
  38. /**
  39. * @copydoc CoreObjectCore::initialize
  40. */
  41. virtual void initialize();
  42. /**
  43. * @copydoc CoreObjectCore::destroy
  44. */
  45. virtual void destroy();
  46. /**
  47. * @brief Returns properties that describe the render texture.
  48. */
  49. const MultiRenderTextureProperties& getProperties() const;
  50. protected:
  51. MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc);
  52. /**
  53. * @copydoc CoreObjectCore::syncFromCore
  54. */
  55. virtual CoreSyncData syncFromCore(FrameAlloc* allocator);
  56. /**
  57. * @copydoc CoreObjectCore::syncToCore
  58. */
  59. virtual void syncToCore(const CoreSyncData& data);
  60. private:
  61. /**
  62. * @brief Checks that all render surfaces and depth/stencil surface match. If they do not match
  63. * an exception is thrown.
  64. */
  65. void throwIfBuffersDontMatch() const;
  66. // TODO - Not implemented
  67. virtual void copyToMemory(PixelData &dst, FrameBuffer buffer = FB_AUTO);
  68. protected:
  69. Vector<TextureViewPtr> mColorSurfaces;
  70. TextureViewPtr mDepthStencilSurface;
  71. MULTI_RENDER_TEXTURE_DESC mDesc;
  72. };
  73. /**
  74. * @brief Object representing multiple render textures. You may bind this to the pipeline
  75. * in order to render to all or some of the textures at once.
  76. *
  77. * @note Sim thread only.
  78. */
  79. class BS_CORE_EXPORT MultiRenderTexture : public RenderTarget
  80. {
  81. public:
  82. virtual ~MultiRenderTexture() { }
  83. /**
  84. * @brief Retrieves a core implementation of a render texture usable only from the
  85. * core thread.
  86. */
  87. SPtr<MultiRenderTextureCore> getCore() const;
  88. /**
  89. * @copydoc TextureManager::createMultiRenderTexture
  90. */
  91. static MultiRenderTexturePtr create(const MULTI_RENDER_TEXTURE_DESC& desc);
  92. /**
  93. * @brief Returns properties that describe the render texture.
  94. */
  95. const MultiRenderTextureProperties& getProperties() const;
  96. protected:
  97. MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
  98. /**
  99. * @copydoc RenderTarget::createCore
  100. */
  101. SPtr<CoreObjectCore> createCore() const;
  102. /**
  103. * @copydoc CoreObjectCore::syncToCore
  104. */
  105. virtual CoreSyncData syncToCore(FrameAlloc* allocator);
  106. /**
  107. * @copydoc CoreObjectCore::syncFromCore
  108. */
  109. virtual void syncFromCore(const CoreSyncData& data);
  110. MULTI_RENDER_TEXTURE_DESC mDesc;
  111. };
  112. }