BsD3D11TextureView.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsD3D11Prerequisites.h"
  5. #include "RenderAPI/BsTextureView.h"
  6. namespace bs { namespace ct
  7. {
  8. /** @addtogroup D3D11
  9. * @{
  10. */
  11. /** DirectX implementation of a texture resource view. */
  12. class D3D11TextureView : public TextureView
  13. {
  14. public:
  15. ~D3D11TextureView();
  16. /**
  17. * Returns a shader resource view. Caller must take care this texture view actually contains a shader resource view,
  18. * otherwise it returns null.
  19. */
  20. ID3D11ShaderResourceView* getSRV() const { return mSRV; }
  21. /**
  22. * Returns a render target view. Caller must take care this texture view actually contains a render target view,
  23. * otherwise it returns null.
  24. */
  25. ID3D11RenderTargetView* getRTV() const { return mRTV; }
  26. /**
  27. * Returns a unordered access view. Caller must take care this texture view actually contains a unordered access
  28. * view, otherwise it returns null.
  29. */
  30. ID3D11UnorderedAccessView* getUAV() const { return mUAV; }
  31. /**
  32. * Returns a depth stencil view. Caller must take care this texture view actually contains a depth stencil view,
  33. * otherwise it returns null.
  34. *
  35. * @param[in] readOnlyDepth Should the view only support read operations for the depth portion of the
  36. * depth/stencil buffer(allows the bound texture to be also used as a shader resource
  37. * view while bound as a depth stencil target).
  38. * @param[in] readOnlyStencil Should the view only support read operations for the stencil portion of the
  39. * depth/stencil buffer(allows the bound texture to be also used as a shader resource
  40. * view while bound as a depth stencil target).
  41. */
  42. ID3D11DepthStencilView* getDSV(bool readOnlyDepth, bool readOnlyStencil) const;
  43. protected:
  44. friend class D3D11Texture;
  45. D3D11TextureView(const D3D11Texture* texture, const TEXTURE_VIEW_DESC& desc);
  46. private:
  47. /**
  48. * Creates a shader resource view that allows the provided surfaces to be bound as normal shader resources.
  49. *
  50. * @param[in] texture Texture to create the resource view for.
  51. * @param[in] mostDetailMip First mip level to create the resource view for (0 - base level).
  52. * @param[in] numMips Number of mip levels to create the view for.
  53. * @param[in] firstArraySlice First array slice to create the view for. This will be array index for 1D and 2D
  54. * array textures, texture slice index for 3D textures, and face index for cube
  55. * textures (cube index * 6).
  56. * @param[in] numArraySlices Number of array slices to create the view for. This will be number of array elements
  57. * for 1D and 2D array textures, number of slices for 3D textures, and number of cubes
  58. * for cube textures.
  59. */
  60. ID3D11ShaderResourceView* createSRV(const D3D11Texture* texture,
  61. UINT32 mostDetailMip, UINT32 numMips, UINT32 firstArraySlice, UINT32 numArraySlices);
  62. /**
  63. * Creates a shader resource view that allows the provided surfaces to be bound as render targets.
  64. *
  65. * @param[in] texture Texture to create the resource view for.
  66. * @param[in] mipSlice Mip level to create the resource view for (0 - base level).
  67. * @param[in] firstArraySlice First array slice to create the view for. This will be array index for 1D and 2D
  68. * array textures, texture slice index for 3D textures, and face index for cube
  69. * textures (cube index * 6).
  70. * @param[in] numArraySlices Number of array slices to create the view for. This will be number of array elements
  71. * for 1D and 2D array textures, number of slices for 3D textures, and number of cubes
  72. * for cube textures.
  73. */
  74. ID3D11RenderTargetView* createRTV(const D3D11Texture* texture,
  75. UINT32 mipSlice, UINT32 firstArraySlice, UINT32 numArraySlices);
  76. /**
  77. * Creates a shader resource view that allows the provided surfaces to be bound as unordered access buffers.
  78. *
  79. * @param[in] texture Texture to create the resource view for.
  80. * @param[in] mipSlice Mip level to create the resource view for (0 - base level).
  81. * @param[in] firstArraySlice First array slice to create the view for. This will be array index for 1D and 2D
  82. * array textures, texture slice index for 3D textures, and face index for cube
  83. * textures (cube index * 6).
  84. * @param[in] numArraySlices Number of array slices to create the view for. This will be number of array elements
  85. * for 1D and 2D array textures, number of slices for 3D textures, and number of cubes
  86. * for cube textures.
  87. */
  88. ID3D11UnorderedAccessView* createUAV(const D3D11Texture* texture,
  89. UINT32 mipSlice, UINT32 firstArraySlice, UINT32 numArraySlices);
  90. /**
  91. * Creates a shader resource view that allows the provided surfaces to be bound as depth stencil buffers.
  92. *
  93. * @param[in] texture Texture to create the resource view for.
  94. * @param[in] mipSlice Mip level to create the resource view for (0 - base level).
  95. * @param[in] firstArraySlice First array slice to create the view for. This will be array index for 1D and 2D
  96. * array textures, texture slice index for 3D textures, and face index for cube
  97. * textures (cube index * 6).
  98. * @param[in] numArraySlices Number of array slices to create the view for. This will be number of array elements
  99. * for 1D and 2D array textures, number of slices for 3D textures, and number of cubes
  100. * for cube textures.
  101. * @param[in] readOnlyDepth Should the view only support read operations for the depth portion of the
  102. * depth/stencil buffer(allows the bound texture to be also used as a shader resource
  103. * view while bound as a depth stencil target).
  104. * @param[in] readOnlyStencil Should the view only support read operations for the stencil portion of the
  105. * depth/stencil buffer(allows the bound texture to be also used as a shader resource
  106. * view while bound as a depth stencil target).
  107. */
  108. ID3D11DepthStencilView* createDSV(const D3D11Texture* texture, UINT32 mipSlice, UINT32 firstArraySlice,
  109. UINT32 numArraySlices, bool readOnlyDepth, bool readOnlyStencil);
  110. ID3D11ShaderResourceView* mSRV;
  111. ID3D11RenderTargetView* mRTV;
  112. ID3D11UnorderedAccessView* mUAV;
  113. ID3D11DepthStencilView* mWDepthWStencilView;
  114. ID3D11DepthStencilView* mRODepthWStencilView;
  115. ID3D11DepthStencilView* mRODepthROStencilView;
  116. ID3D11DepthStencilView* mWDepthROStencilView;
  117. };
  118. /** @} */
  119. }}