3
0

DynamicBuffer.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/RPI.Public/DynamicDraw/DynamicBufferAllocator.h>
  9. #include <Atom/RPI.Public/DynamicDraw/DynamicBuffer.h>
  10. namespace AZ
  11. {
  12. namespace RPI
  13. {
  14. bool DynamicBuffer::Write(const void* data, uint32_t size)
  15. {
  16. if (m_size >= size)
  17. {
  18. memcpy(m_address, data, size);
  19. return true;
  20. }
  21. AZ_Assert(false, "Can't write data out of range");
  22. return false;
  23. }
  24. uint32_t DynamicBuffer::GetSize()
  25. {
  26. return m_size;
  27. }
  28. void* DynamicBuffer::GetBufferAddress()
  29. {
  30. return m_address;
  31. }
  32. RHI::IndexBufferView DynamicBuffer::GetIndexBufferView(RHI::IndexFormat format)
  33. {
  34. return m_allocator->GetIndexBufferView(this, format);
  35. }
  36. RHI::StreamBufferView DynamicBuffer::GetStreamBufferView(uint32_t strideByteCount)
  37. {
  38. return m_allocator->GetStreamBufferView(this, strideByteCount);
  39. }
  40. void DynamicBuffer::Initialize(void* address, uint32_t size)
  41. {
  42. m_address = address;
  43. m_size = size;
  44. }
  45. }
  46. }