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. /**
  9. * @brief DirectX implementation of a texture resource view.
  10. */
  11. class BS_D3D11_EXPORT D3D11TextureView : public TextureView
  12. {
  13. public:
  14. ~D3D11TextureView();
  15. /**
  16. * @brief Returns a shader resource view. Caller must take care this texture view
  17. * actually contains a shader resource view, otherwise it returns null.
  18. */
  19. ID3D11ShaderResourceView* getSRV() const { return mSRV; }
  20. /**
  21. * @brief Returns a render target view. Caller must take care this texture view
  22. * actually contains a render target view, otherwise it returns null.
  23. */
  24. ID3D11RenderTargetView* getRTV() const { return mRTV; }
  25. /**
  26. * @brief Returns a unordered access view. Caller must take care this texture view
  27. * actually contains a unordered access view, otherwise it returns null.
  28. */
  29. ID3D11UnorderedAccessView* getUAV() const { return mUAV; }
  30. /**
  31. * @brief Returns a depth stencil view. Caller must take care this texture view
  32. * actually contains a depth stencil view, otherwise it returns null.
  33. *
  34. * @param[in] readOnly Should the depth stencil view only support read operations (allows the bound texture to
  35. * be also used as a shader resource view while bound as a depth stencil target).
  36. */
  37. ID3D11DepthStencilView* getDSV(bool readOnly) const { return readOnly ? mRODSV : mDSV; }
  38. protected:
  39. friend class D3D11TextureCore;
  40. D3D11TextureView(const SPtr<TextureCore>& texture, const TEXTURE_VIEW_DESC& desc);
  41. private:
  42. /**
  43. * @brief Creates a shader resource view that allows the provided surfaces
  44. * to be bound as normal shader resources.
  45. *
  46. * @param texture Texture to create the resource view for.
  47. * @param mostDetailMip First mip level to create the resource view for (0 - base level).
  48. * @param numMips Number of mip levels to create the view for.
  49. * @param firstArraySlice First array slice to create the view for. This will be array index
  50. * for 1D and 2D array textures, texture slice index for 3D textures, and face
  51. * index for cube textures (cube index * 6).
  52. * @param numArraySlices Number of array slices to create the view for. This will be number of
  53. * array elements for 1D and 2D array textures, number of slices for 3D textures,
  54. * and number of cubes for cube textures.
  55. */
  56. ID3D11ShaderResourceView* createSRV(D3D11TextureCore* texture,
  57. UINT32 mostDetailMip, UINT32 numMips, UINT32 firstArraySlice, UINT32 numArraySlices);
  58. /**
  59. * @brief Creates a shader resource view that allows the provided surfaces
  60. * to be bound as render targets.
  61. *
  62. * @param texture Texture to create the resource view for.
  63. * @param mipSlice Mip level to create the resource view for (0 - base level).
  64. * @param firstArraySlice First array slice to create the view for. This will be array index
  65. * for 1D and 2D array textures, texture slice index for 3D textures, and face
  66. * index for cube textures (cube index * 6).
  67. * @param numArraySlices Number of array slices to create the view for. This will be number of
  68. * array elements for 1D and 2D array textures, number of slices for 3D textures,
  69. * and number of cubes for cube textures.
  70. */
  71. ID3D11RenderTargetView* createRTV(D3D11TextureCore* texture,
  72. UINT32 mipSlice, UINT32 firstArraySlice, UINT32 numArraySlices);
  73. /**
  74. * @brief Creates a shader resource view that allows the provided surfaces
  75. * to be bound as unordered access buffers.
  76. *
  77. * @param texture Texture to create the resource view for.
  78. * @param mipSlice Mip level to create the resource view for (0 - base level).
  79. * @param firstArraySlice First array slice to create the view for. This will be array index
  80. * for 1D and 2D array textures, texture slice index for 3D textures, and face
  81. * index for cube textures (cube index * 6).
  82. * @param numArraySlices Number of array slices to create the view for. This will be number of
  83. * array elements for 1D and 2D array textures, number of slices for 3D textures,
  84. * and number of cubes for cube textures.
  85. */
  86. ID3D11UnorderedAccessView* createUAV(D3D11TextureCore* texture,
  87. UINT32 mipSlice, UINT32 firstArraySlice, UINT32 numArraySlices);
  88. /**
  89. * @brief Creates a shader resource view that allows the provided surfaces
  90. * to be bound as depth stencil buffers.
  91. *
  92. * @param texture Texture to create the resource view for.
  93. * @param mipSlice Mip level to create the resource view for (0 - base level).
  94. * @param firstArraySlice First array slice to create the view for. This will be array index
  95. * for 1D and 2D array textures, texture slice index for 3D textures, and face
  96. * index for cube textures (cube index * 6).
  97. * @param numArraySlices Number of array slices to create the view for. This will be number of
  98. * array elements for 1D and 2D array textures, number of slices for 3D textures,
  99. * and number of cubes for cube textures.
  100. * @param readOnly Should the depth stencil view only support read operations (allows the bound texture to
  101. * be also used as a shader resource view while bound as a depth stencil target).
  102. */
  103. ID3D11DepthStencilView* createDSV(D3D11TextureCore* texture,
  104. UINT32 mipSlice, UINT32 firstArraySlice, UINT32 numArraySlices, bool readOnly);
  105. ID3D11ShaderResourceView* mSRV;
  106. ID3D11RenderTargetView* mRTV;
  107. ID3D11UnorderedAccessView* mUAV;
  108. ID3D11DepthStencilView* mDSV;
  109. ID3D11DepthStencilView* mRODSV;
  110. };
  111. }