BsD3D11TextureView.h 5.1 KB

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