BsD3D11GpuBufferView.h 2.5 KB

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