CmGpuParamBlock.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmCommonEnums.h"
  4. #include "CmCoreObject.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Stores data (e.g. int, float, Vector2) GPU parameters in a raw buffer.
  9. * Used primarily for caching GPU parameters on the CPU before they're submitted
  10. * to the actual GPU parameter buffer.
  11. */
  12. class CM_EXPORT GpuParamBlock
  13. {
  14. public:
  15. GpuParamBlock(UINT32 size);
  16. GpuParamBlock(GpuParamBlock* otherBlock);
  17. virtual ~GpuParamBlock();
  18. /**
  19. * @brief Write some data to the specified offset in the buffer.
  20. * Marks the block as dirty.
  21. * All values are in bytes.
  22. */
  23. void write(UINT32 offset, const void* data, UINT32 size);
  24. /**
  25. * @brief Read some data from the specified offset in the buffer.
  26. * All values are in bytes.
  27. */
  28. void read(UINT32 offset, void* data, UINT32 size);
  29. /**
  30. * @brief Clear specified section of the buffer to zero.
  31. * All values are in bytes.
  32. */
  33. void zeroOut(UINT32 offset, UINT32 size);
  34. /**
  35. * @brief Returns size of the internal buffer in bytes.
  36. */
  37. UINT32 getSize() const { return mSize; }
  38. /**
  39. * @brief Returns a raw pointer to the internal buffer.
  40. */
  41. UINT8* getData() const { return mData; }
  42. /**
  43. * @brief Checks if something has been written to the buffer
  44. * since the last time object was clean.
  45. */
  46. bool isDirty() const { return mDirty; }
  47. /**
  48. * @brief Marks the object as dirty or clean. Signifies
  49. * whether or not some new data has been written in the buffer.
  50. */
  51. void setDirty() { mDirty = true; }
  52. protected:
  53. UINT8* mData;
  54. UINT32 mSize;
  55. bool mDirty;
  56. };
  57. }