CmGpuResourceData.cpp 725 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "CmGpuResourceData.h"
  2. #include "CmException.h"
  3. namespace CamelotFramework
  4. {
  5. GpuResourceData::GpuResourceData()
  6. :mData(nullptr), mLocked(false)
  7. {
  8. }
  9. GpuResourceData::~GpuResourceData()
  10. {
  11. if(mData != nullptr)
  12. CM_DELETE_BYTES(mData, ScratchAlloc);
  13. }
  14. UINT8* GpuResourceData::getData() const
  15. {
  16. if(mLocked)
  17. CM_EXCEPT(InternalErrorException, "You are not allowed to access buffer data when the buffer is locked.");
  18. return mData;
  19. }
  20. void GpuResourceData::initialize(UINT32 size)
  21. {
  22. mData = CM_NEW_BYTES(size, ScratchAlloc);
  23. }
  24. void GpuResourceData::lock() const
  25. {
  26. mLocked = true;
  27. }
  28. void GpuResourceData::unlock() const
  29. {
  30. mLocked = false;
  31. }
  32. }