DX11Buffer.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #include "DXBuffer.h"
  3. #ifdef WIN32
  4. struct ID3D11Buffer;
  5. struct D3D11_BUFFER_DESC;
  6. struct ID3D11ShaderResourceView;
  7. struct ID3D11Device;
  8. struct ID3D11DeviceContext;
  9. #endif
  10. namespace Framework
  11. {
  12. #ifdef WIN32
  13. //! A buffer with data in graphics memory
  14. class DX11Buffer : public DXBuffer
  15. {
  16. protected:
  17. D3D11_BUFFER_DESC* description;
  18. ID3D11Buffer* buffer;
  19. ID3D11Device* device;
  20. ID3D11DeviceContext* context;
  21. Critical& deviceLock;
  22. public:
  23. //! Constructor
  24. //! eSize: The length of an element in bytes
  25. DLLEXPORT DX11Buffer(int eSize,
  26. ID3D11Device* device,
  27. ID3D11DeviceContext* context,
  28. int bindFlags,
  29. Critical& deviceLock);
  30. //! Destructor
  31. DLLEXPORT virtual ~DX11Buffer();
  32. //! Copies the data into the buffer if it has changed
  33. DLLEXPORT virtual void copyToGPU(__int64 byteCount = -1) override;
  34. //! Returns the buffer
  35. DLLEXPORT ID3D11Buffer* zBuffer() const;
  36. };
  37. //! A buffer of indices from the vertex buffer, where every three
  38. //! form a triangle that is drawn
  39. class DX11StructuredBuffer : public DX11Buffer
  40. {
  41. private:
  42. ID3D11ShaderResourceView* view;
  43. public:
  44. //! Constructor
  45. //! eSize: The length of an element in bytes
  46. DLLEXPORT DX11StructuredBuffer(int eSize,
  47. ID3D11Device* device,
  48. ID3D11DeviceContext* context,
  49. Critical& deviceLock);
  50. //! Destructor
  51. DLLEXPORT virtual ~DX11StructuredBuffer();
  52. //! Copies the data into the buffer if it has changed
  53. DLLEXPORT void copyToGPU(__int64 byteCount = -1) override;
  54. //! Returns the used shader resource view
  55. DLLEXPORT operator ID3D11ShaderResourceView*() const;
  56. };
  57. #endif
  58. } // namespace Framework