BsD3D11TextureView.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 "BsTextureView.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup D3D11
  9. * @{
  10. */
  11. /** DirectX implementation of a texture resource view. */
  12. class BS_D3D11_EXPORT 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] readOnly Should the depth stencil view only support read operations (allows the bound texture to
  36. * be also used as a shader resource view while bound as a depth stencil target).
  37. */
  38. ID3D11DepthStencilView* getDSV(bool readOnly) const { return readOnly ? mRODSV : mDSV; }
  39. protected:
  40. friend class D3D11TextureCore;
  41. D3D11TextureView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc);
  42. private:
  43. /**
  44. * Creates a shader resource view that allows the provided surfaces to be bound as normal shader resources.
  45. *
  46. * @param[in] texture Texture to create the resource view for.
  47. * @param[in] mostDetailMip First mip level to create the resource view for (0 - base level).
  48. * @param[in] numMips Number of mip levels to create the view for.
  49. * @param[in] firstArraySlice First array slice to create the view for. This will be array index for 1D and 2D
  50. * array textures, texture slice index for 3D textures, and face index for cube
  51. * textures (cube index * 6).
  52. * @param[in] numArraySlices Number of array slices to create the view for. This will be number of array elements
  53. * for 1D and 2D array textures, number of slices for 3D textures, and number of cubes
  54. * for cube textures.
  55. */
  56. ID3D11ShaderResourceView* createSRV(D3D11TextureCore* texture,
  57. UINT32 mostDetailMip, UINT32 numMips, UINT32 firstArraySlice, UINT32 numArraySlices);
  58. /**
  59. * Creates a shader resource view that allows the provided surfaces to be bound as render targets.
  60. *
  61. * @param[in] texture Texture to create the resource view for.
  62. * @param[in] mipSlice Mip level to create the resource view for (0 - base level).
  63. * @param[in] firstArraySlice First array slice to create the view for. This will be array index for 1D and 2D
  64. * array textures, texture slice index for 3D textures, and face index for cube
  65. * textures (cube index * 6).
  66. * @param[in] numArraySlices Number of array slices to create the view for. This will be number of array elements
  67. * for 1D and 2D array textures, number of slices for 3D textures, and number of cubes
  68. * for cube textures.
  69. */
  70. ID3D11RenderTargetView* createRTV(D3D11TextureCore* texture,
  71. UINT32 mipSlice, UINT32 firstArraySlice, UINT32 numArraySlices);
  72. /**
  73. * Creates a shader resource view that allows the provided surfaces to be bound as unordered access buffers.
  74. *
  75. * @param[in] texture Texture to create the resource view for.
  76. * @param[in] mipSlice Mip level to create the resource view for (0 - base level).
  77. * @param[in] firstArraySlice First array slice to create the view for. This will be array index for 1D and 2D
  78. * array textures, texture slice index for 3D textures, and face index for cube
  79. * textures (cube index * 6).
  80. * @param[in] numArraySlices Number of array slices to create the view for. This will be number of array elements
  81. * for 1D and 2D array textures, number of slices for 3D textures, and number of cubes
  82. * for cube textures.
  83. */
  84. ID3D11UnorderedAccessView* createUAV(D3D11TextureCore* texture,
  85. UINT32 mipSlice, UINT32 firstArraySlice, UINT32 numArraySlices);
  86. /**
  87. * Creates a shader resource view that allows the provided surfaces to be bound as depth stencil buffers.
  88. *
  89. * @param[in] texture Texture to create the resource view for.
  90. * @param[in] mipSlice Mip level to create the resource view for (0 - base level).
  91. * @param[in] firstArraySlice First array slice to create the view for. This will be array index for 1D and 2D
  92. * array textures, texture slice index for 3D textures, and face index for cube
  93. * textures (cube index * 6).
  94. * @param[in] numArraySlices Number of array slices to create the view for. This will be number of array elements
  95. * for 1D and 2D array textures, number of slices for 3D textures, and number of cubes
  96. * for cube textures.
  97. * @param[in] readOnly Should the depth stencil view only support read operations (allows the bound texture
  98. * to be also used as a shader resource view while bound as a depth stencil target).
  99. */
  100. ID3D11DepthStencilView* createDSV(D3D11TextureCore* texture,
  101. UINT32 mipSlice, UINT32 firstArraySlice, UINT32 numArraySlices, bool readOnly);
  102. ID3D11ShaderResourceView* mSRV;
  103. ID3D11RenderTargetView* mRTV;
  104. ID3D11UnorderedAccessView* mUAV;
  105. ID3D11DepthStencilView* mDSV;
  106. ID3D11DepthStencilView* mRODSV;
  107. };
  108. /** @} */
  109. }