diff options
author | Hans-Kristian Arntzen <post@arntzen-software.no> | 2021-11-02 18:51:20 +0300 |
---|---|---|
committer | Hans-Kristian Arntzen <post@arntzen-software.no> | 2022-02-17 14:00:41 +0300 |
commit | 68d2c60256e4ba82b5b1782369492d39e707a792 (patch) | |
tree | 5c030f712722b4bdfee3e93d7fe79d68fb963ac0 | |
parent | 1cc8afcc8e37a2b5a8f7f457fbb5406de84af293 (diff) |
vkd3d: Improve log_memory_budgets logging.log-memory-budgets-fixes
Log current budgets for all types when requested.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
-rw-r--r-- | libs/vkd3d/memory.c | 20 | ||||
-rw-r--r-- | libs/vkd3d/resource.c | 12 |
2 files changed, 25 insertions, 7 deletions
diff --git a/libs/vkd3d/memory.c b/libs/vkd3d/memory.c index cacee1f2..f8048613 100644 --- a/libs/vkd3d/memory.c +++ b/libs/vkd3d/memory.c @@ -165,11 +165,6 @@ void vkd3d_free_device_memory(struct d3d12_device *device, const struct vkd3d_de } pthread_mutex_unlock(&device->memory_info.budget_lock); } - else if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_LOG_MEMORY_BUDGET) - { - INFO("Freeing memory of type %u, %"PRIu64" KiB.\n", - allocation->vk_memory_type, allocation->size / 1024); - } } static HRESULT vkd3d_try_allocate_device_memory(struct d3d12_device *device, @@ -236,8 +231,8 @@ static HRESULT vkd3d_try_allocate_device_memory(struct d3d12_device *device, *type_current += size; if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_LOG_MEMORY_BUDGET) { - INFO("Allocated memory of type %u, new total allocated size %"PRIu64" MiB.\n", - type_index, *type_current / (1024 * 1024)); + INFO("Allocated %"PRIu64" KiB of memory with type %u, new total allocated size %"PRIu64" MiB.\n", + size / 1024, type_index, *type_current / (1024 * 1024)); } } pthread_mutex_unlock(&memory_info->budget_lock); @@ -262,6 +257,17 @@ static HRESULT vkd3d_try_allocate_device_memory(struct d3d12_device *device, * which are also DEVICE_LOCAL. * After failure, the calling code removes the DEVICE_LOCAL_BIT flag and tries again, * where we will fall back to system memory instead. */ + + if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_LOG_MEMORY_BUDGET) + { + pthread_mutex_lock(&memory_info->budget_lock); + INFO("Failed to allocate %"PRIu64" KiB of device memory from memory type %u, " + "currently %"PRIu64" MiB is allocated with this type.\n", + size / 1024, + type_index, memory_info->type_current[type_index] / (1024 * 1024)); + pthread_mutex_unlock(&memory_info->budget_lock); + } + return E_OUTOFMEMORY; } } diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c index 3ff963fd..2087aa5b 100644 --- a/libs/vkd3d/resource.c +++ b/libs/vkd3d/resource.c @@ -6141,6 +6141,18 @@ static void vkd3d_memory_info_init_budgets(struct vkd3d_memory_info *info, } INFO("Applying resizable BAR budget to memory types: 0x%x.\n", info->budget_sensitive_mask); + + /* Force fake budgets so we get the slow-path logging for every allocation. */ + if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_LOG_MEMORY_BUDGET) + { + info->budget_sensitive_mask = UINT32_MAX; + for (i = 0; i < VK_MAX_MEMORY_TYPES; i++) + { + info->type_current[i] = 0; + if (!info->type_budget[i]) + info->type_budget[i] = UINT64_MAX; + } + } } void vkd3d_memory_info_cleanup(struct vkd3d_memory_info *info, |