3
0

DeviceBuffer.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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/RHI/DeviceBuffer.h>
  9. #include <Atom/RHI/BufferFrameAttachment.h>
  10. #include <Atom/RHI/MemoryStatisticsBuilder.h>
  11. namespace AZ::RHI
  12. {
  13. void DeviceBuffer::SetDescriptor(const BufferDescriptor& descriptor)
  14. {
  15. m_descriptor = descriptor;
  16. }
  17. const RHI::BufferDescriptor& DeviceBuffer::GetDescriptor() const
  18. {
  19. return m_descriptor;
  20. }
  21. const BufferFrameAttachment* DeviceBuffer::GetFrameAttachment() const
  22. {
  23. return static_cast<const BufferFrameAttachment*>(DeviceResource::GetFrameAttachment());
  24. }
  25. void DeviceBuffer::ReportMemoryUsage(MemoryStatisticsBuilder& builder) const
  26. {
  27. const BufferDescriptor& descriptor = GetDescriptor();
  28. MemoryStatistics::Buffer* bufferStats = builder.AddBuffer();
  29. bufferStats->m_name = GetName();
  30. bufferStats->m_bindFlags = descriptor.m_bindFlags;
  31. bufferStats->m_sizeInBytes = descriptor.m_byteCount;
  32. }
  33. Ptr<DeviceBufferView> DeviceBuffer::GetBufferView(const BufferViewDescriptor& bufferViewDescriptor)
  34. {
  35. return Base::GetResourceView(bufferViewDescriptor);
  36. }
  37. const HashValue64 DeviceBuffer::GetHash() const
  38. {
  39. HashValue64 hash = HashValue64{ 0 };
  40. hash = m_descriptor.GetHash();
  41. return hash;
  42. }
  43. }