MCPcopy Create free account
hub / github.com/crownengine/crown / recycle

Method recycle

3rdparty/bgfx/src/renderer_vk.cpp:4805–4836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4803 }
4804
4805 void MemoryLruVK::recycle(DeviceMemoryAllocationVK& _alloc)
4806 {
4807 if (MAX_ENTRIES == lru.getNumHandles() )
4808 {
4809 // Evict LRU
4810 uint16_t handle = lru.getBack();
4811 DeviceMemoryAllocationVK& alloc = entries[handle];
4812 totalSizeCached -= alloc.size;
4813 release(alloc.mem);
4814
4815 // Touch slot and overwrite
4816 lru.touch(handle);
4817 alloc = _alloc;
4818 }
4819 else
4820 {
4821 uint16_t handle = lru.alloc();
4822 entries[handle] = _alloc;
4823 }
4824
4825 totalSizeCached += _alloc.size;
4826
4827 while (totalSizeCached > BGFX_CONFIG_CACHED_DEVICE_MEMORY_ALLOCATIONS_SIZE)
4828 {
4829 BX_ASSERT(lru.getNumHandles() > 0, "Memory badly counted.");
4830 uint16_t handle = lru.getBack();
4831 DeviceMemoryAllocationVK& alloc = entries[handle];
4832 totalSizeCached -= alloc.size;
4833 release(alloc.mem);
4834 lru.free(handle);
4835 }
4836 }
4837
4838 bool MemoryLruVK::find(uint32_t _size, int32_t _memoryTypeIndex, DeviceMemoryAllocationVK *_alloc)
4839 {

Callers 1

consumeMethod · 0.80

Calls 5

getNumHandlesMethod · 0.80
releaseFunction · 0.70
touchMethod · 0.45
allocMethod · 0.45
freeMethod · 0.45

Tested by

no test coverage detected