UnifiedGeometryBuffer.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <AnKi/GpuMemory/UnifiedGeometryBuffer.h>
  6. #include <AnKi/Gr/GrManager.h>
  7. namespace anki {
  8. ANKI_SVAR(UnifiedGeomBufferAllocatedSize, StatCategory::kGpuMem, "UGB allocated", StatFlag::kBytes | StatFlag::kMainThreadUpdates)
  9. ANKI_SVAR(UnifiedGeomBufferTotal, StatCategory::kGpuMem, "UGB total", StatFlag::kBytes | StatFlag::kMainThreadUpdates)
  10. ANKI_SVAR(UnifiedGeomBufferFragmentation, StatCategory::kGpuMem, "UGB fragmentation", StatFlag::kFloat | StatFlag::kMainThreadUpdates)
  11. void UnifiedGeometryBuffer::init()
  12. {
  13. const PtrSize poolSize = g_cvarCoreUnifiedGeometryBufferSize;
  14. const Array classes = {1_KB, 8_KB, 32_KB, 128_KB, 512_KB, 4_MB, 8_MB, 16_MB, poolSize};
  15. BufferUsageBit buffUsage = BufferUsageBit::kVertexOrIndex | BufferUsageBit::kCopyDestination | BufferUsageBit::kAllSrv;
  16. if(GrManager::getSingleton().getDeviceCapabilities().m_rayTracingEnabled)
  17. {
  18. buffUsage |= BufferUsageBit::kAccelerationStructureBuild | BufferUsageBit::kAccelerationStructure;
  19. }
  20. m_pool.init(buffUsage, classes, poolSize, "UnifiedGeometry", false);
  21. // Allocate something dummy to force creating the GPU buffer
  22. UnifiedGeometryBufferAllocation alloc = allocate(16, 4);
  23. deferredFree(alloc);
  24. }
  25. void UnifiedGeometryBuffer::updateStats() const
  26. {
  27. F32 externalFragmentation;
  28. PtrSize userAllocatedSize, totalSize;
  29. m_pool.getStats(externalFragmentation, userAllocatedSize, totalSize);
  30. g_svarUnifiedGeomBufferAllocatedSize.set(userAllocatedSize);
  31. g_svarUnifiedGeomBufferTotal.set(totalSize);
  32. g_svarUnifiedGeomBufferFragmentation.set(externalFragmentation);
  33. }
  34. } // end namespace anki