CmGpuParamBlockBuffer.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmCommonEnums.h"
  4. #include "CmCoreObject.h"
  5. namespace CamelotFramework
  6. {
  7. /**
  8. * @brief Represents an actual GPU buffer.
  9. * Should only be accessed directly from core thread.
  10. */
  11. class CM_EXPORT GpuParamBlockBuffer : public CoreObject
  12. {
  13. public:
  14. GpuParamBlockBuffer();
  15. virtual ~GpuParamBlockBuffer();
  16. void initialize(UINT32 size, GpuParamBlockUsage usage);
  17. /**
  18. * @brief Writes all of the data to the buffer.
  19. * Data size must be the same size as the buffer;
  20. */
  21. virtual void writeData(const UINT8* data) = 0;
  22. /**
  23. * @brief Copies data from the internal buffer to a pre-allocated array.
  24. * Be aware this generally isn't a very fast operation.
  25. *
  26. * @param [in,out] data Array where the data will be written to. Must be of
  27. * "getSize()" bytes.
  28. */
  29. virtual void readData(UINT8* data) const = 0;
  30. UINT32 getSize() const { return mSize; }
  31. protected:
  32. GpuParamBlockUsage mUsage;
  33. UINT32 mSize;
  34. };
  35. class CM_EXPORT GenericGpuParamBlockBuffer : public GpuParamBlockBuffer
  36. {
  37. public:
  38. /**
  39. * @brief Writes all of the data to the buffer.
  40. * Data size must be the same size as the buffer;
  41. */
  42. void writeData(const UINT8* data);
  43. /**
  44. * @copydoc GpuParamBlockBuffer::readAll.
  45. */
  46. void readData(UINT8* data) const;
  47. protected:
  48. UINT8* mData;
  49. /**
  50. * @copydoc CoreGpuObject::initialize_internal.
  51. */
  52. virtual void initialize_internal();
  53. /**
  54. * @copydoc CoreGpuObject::destroy_internal.
  55. */
  56. virtual void destroy_internal();
  57. };
  58. }