BsD3D11TextureView.h 5.0 KB

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