BsD3D11GpuBufferView.h 2.8 KB

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