mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-09 23:08:18 +02:00
tu: Implement VK_EXT_device_memory_report
This is a minimal implementation reporting only device memory allocations and frees. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/14687 Signed-off-by: Valentine Burley <valentine.burley@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39406>
This commit is contained in:
parent
8e078fad2a
commit
6d69d7e6bf
2 changed files with 45 additions and 1 deletions
|
|
@ -618,7 +618,7 @@ Khronos extensions that are not part of any Vulkan version:
|
|||
VK_EXT_device_address_binding_report DONE (radv, tu)
|
||||
VK_EXT_device_fault DONE (radv)
|
||||
VK_EXT_device_generated_commands DONE (lvp, nvk/Turing+, radv/gfx8+)
|
||||
VK_EXT_device_memory_report DONE (anv, panvk, radv, vn)
|
||||
VK_EXT_device_memory_report DONE (anv, panvk, radv, tu, vn)
|
||||
VK_EXT_direct_mode_display DONE (anv, hk, lvp, nvk, panvk, radv, tu, v3dv, vn)
|
||||
VK_EXT_discard_rectangles DONE (nvk, radv)
|
||||
VK_EXT_display_control DONE (anv, hasvk, nvk, panvk, radv, tu)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "util/os_misc.h"
|
||||
#include "util/u_process.h"
|
||||
#include "vk_android.h"
|
||||
#include "vk_debug_utils.h"
|
||||
#include "vk_shader_module.h"
|
||||
#include "vk_sampler.h"
|
||||
#include "vk_util.h"
|
||||
|
|
@ -278,6 +279,7 @@ get_device_extensions(const struct tu_physical_device *device,
|
|||
.EXT_descriptor_buffer = true,
|
||||
.EXT_descriptor_indexing = true,
|
||||
.EXT_device_address_binding_report = true,
|
||||
.EXT_device_memory_report = true,
|
||||
#ifdef VK_USE_PLATFORM_DISPLAY_KHR
|
||||
.EXT_display_control = true,
|
||||
#endif
|
||||
|
|
@ -637,6 +639,9 @@ tu_get_features(struct tu_physical_device *pdevice,
|
|||
/* VK_EXT_device_address_binding_report */
|
||||
features->reportAddressBinding = true;
|
||||
|
||||
/* VK_EXT_device_memory_report */
|
||||
features->deviceMemoryReport = true;
|
||||
|
||||
/* VK_EXT_extended_dynamic_state */
|
||||
features->extendedDynamicState = true;
|
||||
|
||||
|
|
@ -3441,6 +3446,40 @@ tu_destroy_memory(struct tu_device *device,
|
|||
vk_object_free(&device->vk, NULL, mem);
|
||||
}
|
||||
|
||||
static void
|
||||
tu_memory_emit_report(struct tu_device *device,
|
||||
const struct tu_device_memory *mem,
|
||||
const VkMemoryAllocateInfo *alloc_info,
|
||||
VkResult result)
|
||||
{
|
||||
if (likely(!device->vk.memory_reports))
|
||||
return;
|
||||
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_emit_device_memory_report(
|
||||
&device->vk, VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATION_FAILED_EXT,
|
||||
/* mem_obj_id */ 0, alloc_info->allocationSize,
|
||||
VK_OBJECT_TYPE_DEVICE_MEMORY,
|
||||
/* obj_handle */ 0, alloc_info->memoryTypeIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
VkDeviceMemoryReportEventTypeEXT type;
|
||||
if (alloc_info) {
|
||||
type = mem->vk.import_handle_type
|
||||
? VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_IMPORT_EXT
|
||||
: VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATE_EXT;
|
||||
} else {
|
||||
type = mem->vk.import_handle_type
|
||||
? VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_UNIMPORT_EXT
|
||||
: VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_FREE_EXT;
|
||||
}
|
||||
|
||||
vk_emit_device_memory_report(&device->vk, type, mem->bo->unique_id,
|
||||
mem->bo->size, VK_OBJECT_TYPE_DEVICE_MEMORY,
|
||||
(uintptr_t)(mem), mem->vk.memory_type_index);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
tu_AllocateMemory(VkDevice _device,
|
||||
const VkMemoryAllocateInfo *pAllocateInfo,
|
||||
|
|
@ -3553,6 +3592,7 @@ tu_AllocateMemory(VkDevice _device,
|
|||
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_device_memory_destroy(&device->vk, pAllocator, &mem->vk);
|
||||
tu_memory_emit_report(device, /* mem */ NULL, pAllocateInfo, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -3566,6 +3606,8 @@ tu_AllocateMemory(VkDevice _device,
|
|||
|
||||
TU_RMV(heap_create, device, pAllocateInfo, mem);
|
||||
|
||||
tu_memory_emit_report(device, mem, pAllocateInfo, VK_SUCCESS);
|
||||
|
||||
*pMem = tu_device_memory_to_handle(mem);
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
|
@ -3631,6 +3673,8 @@ tu_FreeMemory(VkDevice _device,
|
|||
|
||||
TU_RMV(resource_destroy, device, mem);
|
||||
|
||||
tu_memory_emit_report(device, mem, /* alloc_info */ NULL, VK_SUCCESS);
|
||||
|
||||
_tu_destroy_memory(device, mem);
|
||||
|
||||
vk_device_memory_destroy(&device->vk, pAllocator, &mem->vk);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue