CmGpuParamBlockBuffer.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. GpuParamBlock* getParamBlock() const { return mParamBlock; }
  32. protected:
  33. GpuParamBlockUsage mUsage;
  34. UINT32 mSize;
  35. GpuParamBlock* mParamBlock;
  36. };
  37. class CM_EXPORT GenericGpuParamBlockBuffer : public GpuParamBlockBuffer
  38. {
  39. public:
  40. /**
  41. * @brief Writes all of the data to the buffer.
  42. * Data size must be the same size as the buffer;
  43. */
  44. void writeData(const UINT8* data);
  45. /**
  46. * @copydoc GpuParamBlockBuffer::readAll.
  47. */
  48. void readData(UINT8* data) const;
  49. protected:
  50. UINT8* mData;
  51. /**
  52. * @copydoc CoreGpuObject::initialize_internal.
  53. */
  54. virtual void initialize_internal();
  55. /**
  56. * @copydoc CoreGpuObject::destroy_internal.
  57. */
  58. virtual void destroy_internal();
  59. };
  60. }