BsD3D11GpuBufferView.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "BsGpuBufferView.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup D3D11
  9. * @{
  10. */
  11. /**
  12. * Represents a specific view of a GpuBuffer. Different views all of the same buffer be used in different situations
  13. * (for example for reading from a shader, or for a unordered read/write operation).
  14. */
  15. class BS_D3D11_EXPORT D3D11GpuBufferView : public GpuBufferView
  16. {
  17. public:
  18. D3D11GpuBufferView();
  19. virtual ~D3D11GpuBufferView();
  20. /** @copydoc GpuBufferView::initialize */
  21. void initialize(const SPtr<GpuBufferCore>& buffer, GPU_BUFFER_DESC& desc) override;
  22. private:
  23. /**
  24. * Creates a DX11 shader resource view that allows a buffer to be bound to a shader for reading (the most common
  25. * option).
  26. *
  27. * @param[in] buffer Buffer to create the view for.
  28. * @param[in] firstElement Index of the first element the view manages. Interpretation of this value depends on
  29. * exact buffer type. It may be byte offset for raw buffers, or number of elements for
  30. * structured buffers.
  31. * @param[in] elementWidth Width of a single element in the buffer. Size of the structure in structured buffers
  32. * and ignored for raw buffers as they always operate on single byte basis.
  33. * @param[in] numElements Number of elements the view manages, starting after the "firstElement". This means
  34. * number of bytes for raw buffers or number of structures for structured buffers.
  35. * @return Constructed DX11 shader resource view object.
  36. */
  37. ID3D11ShaderResourceView* createSRV(D3D11GpuBufferCore* buffer, UINT32 firstElement, UINT32 elementWidth, UINT32 numElements);
  38. /**
  39. * Creates a DX11 unordered access view that allows a buffer to be bound to a shader for random reading or writing.
  40. *
  41. * @param[in] buffer Buffer to create the view for.
  42. * @param[in] firstElement Index of the first element the view manages. Interpretation of this value depends on
  43. * exact buffer type. It may be byte offset for raw buffers, or number of elements for
  44. * structured buffers.
  45. * @param[in] numElements Number of elements the view manages, starting after the @p firstElement. This means
  46. * number of bytes for raw buffers or number of structures for structured buffers.
  47. * @return Constructed DX11 unordered access view object.
  48. */
  49. ID3D11UnorderedAccessView* createUAV(D3D11GpuBufferCore* buffer, UINT32 firstElement, UINT32 numElements, bool useCounter);
  50. ID3D11ShaderResourceView* mSRV;
  51. ID3D11UnorderedAccessView* mUAV;
  52. };
  53. /** @} */
  54. }