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