mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 16:43:05 -05:00
Merge pull request #5893 from ThatsLeo/perf/agc-unified-memory-budgets
perf(agc): keep a smaller staging pool on system-memory heaps
This commit is contained in:
2 files changed
+25
-1
No files matched your search
@@ -22,6 +22,16 @@ bool exactSizes() {
|
||||
return exact;
|
||||
}
|
||||
|
||||
bool systemMemoryHeap(const VkPhysicalDeviceMemoryProperties& memory, std::uint32_t heap) {
|
||||
bool typed = false;
|
||||
for (std::uint32_t type = 0; type < std::min<std::uint32_t>(memory.memoryTypeCount, VK_MAX_MEMORY_TYPES); ++type) {
|
||||
if (memory.memoryTypes[type].heapIndex != heap) continue;
|
||||
if ((memory.memoryTypes[type].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) return false;
|
||||
typed = true;
|
||||
}
|
||||
return typed;
|
||||
}
|
||||
|
||||
constexpr VkBufferUsageFlags deviceUsage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
|
||||
}
|
||||
@@ -169,9 +179,13 @@ VkDeviceSize BufferPool::DeviceBudget(const VkPhysicalDeviceMemoryProperties& me
|
||||
static const char* value = std::getenv("APS5_STAGING_POOL_MIB");
|
||||
if (value != nullptr) return static_cast<VkDeviceSize>(std::strtoull(value, nullptr, 10)) << 20u;
|
||||
VkDeviceSize largest = 0;
|
||||
bool systemMemory = false;
|
||||
for (std::uint32_t heap = 0; heap < memory.memoryHeapCount && heap < VK_MAX_MEMORY_HEAPS; ++heap) {
|
||||
if ((memory.memoryHeaps[heap].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) != 0) largest = std::max(largest, memory.memoryHeaps[heap].size);
|
||||
if ((memory.memoryHeaps[heap].flags & VK_MEMORY_HEAP_DEVICE_LOCAL_BIT) == 0 || memory.memoryHeaps[heap].size <= largest) continue;
|
||||
largest = memory.memoryHeaps[heap].size;
|
||||
systemMemory = systemMemoryHeap(memory, heap);
|
||||
}
|
||||
if (systemMemory) return std::max<VkDeviceSize>(VkDeviceSize{128} << 20u, largest / 64u);
|
||||
return std::max<VkDeviceSize>(VkDeviceSize{512} << 20u, largest / 8u);
|
||||
}
|
||||
|
||||
|
||||
@@ -6458,6 +6458,16 @@ void stagingPoolBudgetTests() {
|
||||
Require(AgcDriver::Graphics::BufferPool::DeviceBudget(memory) == VkDeviceSize{512} << 20u, "the staging pool budget fell below 512 MiB");
|
||||
memory.memoryHeapCount = 1;
|
||||
Require(AgcDriver::Graphics::BufferPool::DeviceBudget(memory) == VkDeviceSize{512} << 20u, "a host heap sized the staging pool budget");
|
||||
memory.memoryHeapCount = 2;
|
||||
memory.memoryHeaps[1].size = VkDeviceSize{16} << 30u;
|
||||
memory.memoryTypeCount = 2;
|
||||
memory.memoryTypes[0] = {VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 0};
|
||||
memory.memoryTypes[1] = {VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, 1};
|
||||
Require(AgcDriver::Graphics::BufferPool::DeviceBudget(memory) == VkDeviceSize{256} << 20u, "the staging pool budget on a 16 GiB heap of system memory is not a sixty-fourth of it");
|
||||
memory.memoryHeaps[1].size = VkDeviceSize{4} << 30u;
|
||||
Require(AgcDriver::Graphics::BufferPool::DeviceBudget(memory) == VkDeviceSize{128} << 20u, "the staging pool budget on system memory fell below 128 MiB");
|
||||
memory.memoryTypes[0] = {VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, 1};
|
||||
Require(AgcDriver::Graphics::BufferPool::DeviceBudget(memory) == VkDeviceSize{512} << 20u, "a heap with a device-only memory type was taken for system memory");
|
||||
}
|
||||
|
||||
void meshArgumentTests() {
|
||||
|
||||
Reference in new issue
Block a user