SkinnedMeshOutputStreamManager.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #pragma once
  9. #include <Atom/Feature/SkinnedMesh/SkinnedMeshOutputStreamManagerInterface.h>
  10. #include <Atom/RHI/FreeListAllocator.h>
  11. #include <AzCore/Component/TickBus.h>
  12. #include <AzCore/Console/IConsole.h>
  13. namespace AZ
  14. {
  15. namespace RPI
  16. {
  17. class BufferAsset;
  18. class Buffer;
  19. }
  20. namespace Render
  21. {
  22. class SkinnedMeshOutputStreamManager
  23. : public SkinnedMeshOutputStreamManagerInterface
  24. , private SystemTickBus::Handler
  25. {
  26. public:
  27. AZ_RTTI(AZ::Render::SkinnedMeshOutputStreamManager, "{3107EC84-DDF6-46FD-8B2C-00431D1BB67C}", AZ::Render::SkinnedMeshOutputStreamManagerInterface);
  28. SkinnedMeshOutputStreamManager();
  29. ~SkinnedMeshOutputStreamManager();
  30. void Init();
  31. // SkinnedMeshOutputStreamManagerInterface
  32. AZStd::intrusive_ptr<SkinnedMeshOutputStreamAllocation> Allocate(size_t byteCount) override;
  33. void DeAllocate(RHI::VirtualAddress allocation) override;
  34. void DeAllocateNoSignal(RHI::VirtualAddress allocation) override;
  35. Data::Asset<RPI::BufferAsset> GetBufferAsset() override;
  36. Data::Instance<RPI::Buffer> GetBuffer() override;
  37. private:
  38. // SystemTickBus
  39. void OnSystemTick() override;
  40. void EnsureInit();
  41. void GarbageCollect();
  42. void CalculateAlignment();
  43. void CreateBufferAsset();
  44. Data::Asset<RPI::BufferAsset> m_bufferAsset;
  45. Data::Instance<RPI::Buffer> m_buffer;
  46. RHI::FreeListAllocator m_freeListAllocator;
  47. AZStd::mutex m_allocatorMutex;
  48. uint64_t m_alignment = 1;
  49. size_t m_sizeInBytes = 0;
  50. bool m_memoryWasFreed = false;
  51. bool m_broadcastMemoryAvailableEvent = false;
  52. bool m_needsInit = true;
  53. };
  54. } // namespace Render
  55. } // namespace AZ