1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Merge pull request #99257 from darksylinc/matias-TheForge-pr04-excluded-ubo+render_opt

Improvements from TheForge
This commit is contained in:
Thaddeus Crews
2024-12-10 14:15:55 -06:00
24 changed files with 983 additions and 200 deletions

View File

@@ -0,0 +1,55 @@
diff --git a/thirdparty/vulkan/vk_mem_alloc.h b/thirdparty/vulkan/vk_mem_alloc.h
index ecb84094b9..50ff4ea1c2 100644
--- a/thirdparty/vulkan/vk_mem_alloc.h
+++ b/thirdparty/vulkan/vk_mem_alloc.h
@@ -1713,6 +1713,21 @@ VMA_CALL_PRE void VMA_CALL_POST vmaCalculateStatistics(
VmaAllocator VMA_NOT_NULL allocator,
VmaTotalStatistics* VMA_NOT_NULL pStats);
+// -- GODOT begin --
+/** \brief Retrieves lazily allocated bytes
+
+This function is called "calculate" not "get" because it has to traverse all
+internal data structures, so it may be quite slow. Use it for debugging purposes.
+For faster but more brief statistics suitable to be called every frame or every allocation,
+use vmaGetHeapBudgets().
+
+Note that when using allocator from multiple threads, returned information may immediately
+become outdated.
+*/
+VMA_CALL_PRE uint64_t VMA_CALL_POST vmaCalculateLazilyAllocatedBytes(
+ VmaAllocator VMA_NOT_NULL allocator);
+// -- GODOT end --
+
/** \brief Retrieves information about current memory usage and budget for all memory heaps.
\param allocator
@@ -14912,6 +14927,28 @@ VMA_CALL_PRE void VMA_CALL_POST vmaCalculateStatistics(
allocator->CalculateStatistics(pStats);
}
+// -- GODOT begin --
+VMA_CALL_PRE uint64_t VMA_CALL_POST vmaCalculateLazilyAllocatedBytes(
+ VmaAllocator allocator)
+{
+ VMA_ASSERT(allocator);
+ VMA_DEBUG_GLOBAL_MUTEX_LOCK
+ VmaTotalStatistics stats;
+ allocator->CalculateStatistics(&stats);
+ uint64_t total_lazilily_allocated_bytes = 0;
+ for (uint32_t heapIndex = 0; heapIndex < allocator->GetMemoryHeapCount(); ++heapIndex) {
+ for (uint32_t typeIndex = 0; typeIndex < allocator->GetMemoryTypeCount(); ++typeIndex) {
+ if (allocator->MemoryTypeIndexToHeapIndex(typeIndex) == heapIndex) {
+ VkMemoryPropertyFlags flags = allocator->m_MemProps.memoryTypes[typeIndex].propertyFlags;
+ if (flags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT)
+ total_lazilily_allocated_bytes += stats.memoryType[typeIndex].statistics.allocationBytes;
+ }
+ }
+ }
+ return total_lazilily_allocated_bytes;
+}
+// -- GODOT end --
+
VMA_CALL_PRE void VMA_CALL_POST vmaGetHeapBudgets(
VmaAllocator allocator,
VmaBudget* pBudgets)

View File

@@ -1713,6 +1713,21 @@ VMA_CALL_PRE void VMA_CALL_POST vmaCalculateStatistics(
VmaAllocator VMA_NOT_NULL allocator,
VmaTotalStatistics* VMA_NOT_NULL pStats);
// -- GODOT begin --
/** \brief Retrieves lazily allocated bytes
This function is called "calculate" not "get" because it has to traverse all
internal data structures, so it may be quite slow. Use it for debugging purposes.
For faster but more brief statistics suitable to be called every frame or every allocation,
use vmaGetHeapBudgets().
Note that when using allocator from multiple threads, returned information may immediately
become outdated.
*/
VMA_CALL_PRE uint64_t VMA_CALL_POST vmaCalculateLazilyAllocatedBytes(
VmaAllocator VMA_NOT_NULL allocator);
// -- GODOT end --
/** \brief Retrieves information about current memory usage and budget for all memory heaps.
\param allocator
@@ -14912,6 +14927,28 @@ VMA_CALL_PRE void VMA_CALL_POST vmaCalculateStatistics(
allocator->CalculateStatistics(pStats);
}
// -- GODOT begin --
VMA_CALL_PRE uint64_t VMA_CALL_POST vmaCalculateLazilyAllocatedBytes(
VmaAllocator allocator)
{
VMA_ASSERT(allocator);
VMA_DEBUG_GLOBAL_MUTEX_LOCK
VmaTotalStatistics stats;
allocator->CalculateStatistics(&stats);
uint64_t total_lazilily_allocated_bytes = 0;
for (uint32_t heapIndex = 0; heapIndex < allocator->GetMemoryHeapCount(); ++heapIndex) {
for (uint32_t typeIndex = 0; typeIndex < allocator->GetMemoryTypeCount(); ++typeIndex) {
if (allocator->MemoryTypeIndexToHeapIndex(typeIndex) == heapIndex) {
VkMemoryPropertyFlags flags = allocator->m_MemProps.memoryTypes[typeIndex].propertyFlags;
if (flags & VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT)
total_lazilily_allocated_bytes += stats.memoryType[typeIndex].statistics.allocationBytes;
}
}
}
return total_lazilily_allocated_bytes;
}
// -- GODOT end --
VMA_CALL_PRE void VMA_CALL_POST vmaGetHeapBudgets(
VmaAllocator allocator,
VmaBudget* pBudgets)