DXBuffer.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "Critical.h"
  3. #include "OperatingSystem.h"
  4. #include "ReferenceCounter.h"
  5. namespace Framework
  6. {
  7. class DX12CopyCommandQueue;
  8. class DX12DirectCommandQueue;
  9. //! An interface between main memory and graphics memory
  10. class DXBuffer : public virtual ReferenceCounter
  11. {
  12. protected:
  13. void* data;
  14. bool changed;
  15. __int64 len;
  16. int elLen;
  17. public:
  18. //! Constructor
  19. //! \param bind The usage of the buffer. Example:
  20. //! D3D11_BIND_INDEX_BUFFER, D3D11_BIND_VERTEX_BUFFER. \param eLen
  21. //! Length of a single element in bytes
  22. DLLEXPORT DXBuffer(int eLen);
  23. //! Destructor
  24. DLLEXPORT virtual ~DXBuffer();
  25. //! Sets the changed flag so that the data is copied again on the
  26. //! next call of 'copy'
  27. DLLEXPORT void setChanged();
  28. //! Changes the length of the buffer on the next call of 'copy'
  29. //! \param len The length in bytes
  30. DLLEXPORT void setLength(__int64 len);
  31. //! Sets what will be copied on the next call of 'copy'
  32. //! \param data A pointer to the data
  33. DLLEXPORT void setData(void* data, bool shureChanged);
  34. //! Copies the data into the buffer if it has changed
  35. DLLEXPORT virtual void copyToGPU(__int64 byteCount = -1) = 0;
  36. //! Returns the length of an element in bytes
  37. DLLEXPORT int getElementLength() const;
  38. //! Returns the number of elements in the buffer
  39. DLLEXPORT __int64 getElementCount() const;
  40. };
  41. } // namespace Framework