CmGpuParamBlock.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "CmGpuParamBlock.h"
  2. #include "CmException.h"
  3. namespace CamelotEngine
  4. {
  5. GpuParamBlock::GpuParamBlock(UINT32 size)
  6. :mSize(size), mDirty(true)
  7. {
  8. mData = new UINT8[size];
  9. memset(mData, 0, size);
  10. }
  11. GpuParamBlock::~GpuParamBlock()
  12. {
  13. delete [] mData;
  14. }
  15. void GpuParamBlock::write(UINT32 offset, const void* data, UINT32 size)
  16. {
  17. if(offset < 0 || (offset + size) >= mSize)
  18. {
  19. CM_EXCEPT(InvalidParametersException, "Wanted range is out of buffer bounds. " \
  20. "Available range: 0 .. " + toString(mSize) + ". " \
  21. "Wanted range: " + toString(offset) + " .. " + toString(offset + size) + ".");
  22. }
  23. memcpy(mData + offset, data, size);
  24. mDirty = true;
  25. }
  26. void GpuParamBlock::zeroOut(UINT32 offset, UINT32 size)
  27. {
  28. if(offset < 0 || (offset + size) >= mSize)
  29. {
  30. CM_EXCEPT(InvalidParametersException, "Wanted range is out of buffer bounds. " \
  31. "Available range: 0 .. " + toString(mSize) + ". " \
  32. "Wanted range: " + toString(offset) + " .. " + toString(offset + size) + ".");
  33. }
  34. memset(mData + offset, 0, size);
  35. mDirty = true;
  36. }
  37. void GpuParamBlock::updateIfDirty()
  38. {
  39. // Do nothing
  40. }
  41. }