BsMultiRenderTexture.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. * @brief Returns properties that describe the render texture.
  44. */
  45. const MultiRenderTextureProperties& getProperties() const;
  46. protected:
  47. MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_DESC& desc);
  48. /**
  49. * @copydoc CoreObjectCore::syncFromCore
  50. */
  51. virtual CoreSyncData syncFromCore(FrameAlloc* allocator);
  52. /**
  53. * @copydoc CoreObjectCore::syncToCore
  54. */
  55. virtual void syncToCore(const CoreSyncData& data);
  56. private:
  57. /**
  58. * @brief Checks that all render surfaces and depth/stencil surface match. If they do not match
  59. * an exception is thrown.
  60. */
  61. void throwIfBuffersDontMatch() const;
  62. // TODO - Not implemented
  63. virtual void copyToMemory(PixelData &dst, FrameBuffer buffer = FB_AUTO);
  64. protected:
  65. Vector<TextureViewPtr> mColorSurfaces;
  66. TextureViewPtr mDepthStencilSurface;
  67. MULTI_RENDER_TEXTURE_DESC mDesc;
  68. };
  69. /**
  70. * @brief Object representing multiple render textures. You may bind this to the pipeline
  71. * in order to render to all or some of the textures at once.
  72. *
  73. * @note Sim thread only.
  74. */
  75. class BS_CORE_EXPORT MultiRenderTexture : public RenderTarget
  76. {
  77. public:
  78. virtual ~MultiRenderTexture() { }
  79. /**
  80. * @brief Retrieves a core implementation of a render texture usable only from the
  81. * core thread.
  82. */
  83. SPtr<MultiRenderTextureCore> getCore() const;
  84. /**
  85. * @copydoc TextureManager::createMultiRenderTexture
  86. */
  87. static MultiRenderTexturePtr create(const MULTI_RENDER_TEXTURE_DESC& desc);
  88. /**
  89. * @brief Returns properties that describe the render texture.
  90. */
  91. const MultiRenderTextureProperties& getProperties() const;
  92. protected:
  93. MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
  94. /**
  95. * @copydoc RenderTarget::createCore
  96. */
  97. SPtr<CoreObjectCore> createCore() const;
  98. /**
  99. * @copydoc CoreObjectCore::syncToCore
  100. */
  101. virtual CoreSyncData syncToCore(FrameAlloc* allocator);
  102. /**
  103. * @copydoc CoreObjectCore::syncFromCore
  104. */
  105. virtual void syncFromCore(const CoreSyncData& data);
  106. MULTI_RENDER_TEXTURE_DESC mDesc;
  107. };
  108. }