panvk: support VK_EXT_device_memory_report

This change adds the minimum support for VK_EXT_device_memory_report,
which only reports device memory events at this point. We can make it
more useful later (like what's done in ANV) if desired by some tools.

Reviewed-by: Christoph Pillmayer <christoph.pillmayer@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37987>
This commit is contained in:
Yiwei Zhang 2025-10-20 22:29:33 -07:00 committed by Marge Bot
parent 317345cc98
commit c6ff8ce373
4 changed files with 47 additions and 1 deletions

View file

@ -612,7 +612,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, radv, vn)
VK_EXT_device_memory_report DONE (anv, panvk, radv, 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)

View file

@ -8,3 +8,4 @@ VK_KHR_present_wait on HoneyKrisp
VK_KHR_present_wait2 on HoneyKrisp
VK_KHR_maintenance10 on ANV, NVK
VK_EXT_shader_uniform_buffer_unsized_array on RADV
VK_EXT_device_memory_report on panvk

View file

@ -14,8 +14,43 @@
#include "pan_props.h"
#include "vk_debug_utils.h"
#include "vk_log.h"
static void
panvk_memory_emit_report(struct panvk_device *device,
const struct panvk_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->handle,
mem->bo->size, VK_OBJECT_TYPE_DEVICE_MEMORY,
(uintptr_t)(mem), mem->vk.memory_type_index);
}
static void *
panvk_memory_mmap(struct panvk_device_memory *mem)
{
@ -164,6 +199,8 @@ panvk_AllocateMemory(VkDevice _device,
NULL);
}
panvk_memory_emit_report(device, mem, pAllocateInfo, VK_SUCCESS);
*pMem = panvk_device_memory_to_handle(mem);
return VK_SUCCESS;
@ -178,6 +215,8 @@ err_put_bo:
err_destroy_mem:
vk_device_memory_destroy(&device->vk, pAllocator, &mem->vk);
panvk_memory_emit_report(device, /* mem */ NULL, pAllocateInfo, result);
return result;
}
@ -217,6 +256,8 @@ panvk_FreeMemory(VkDevice _device, VkDeviceMemory _mem,
panvk_as_free(device, op.va.start, op.va.size);
}
panvk_memory_emit_report(device, mem, /* alloc_info */ NULL, VK_SUCCESS);
pan_kmod_bo_put(mem->bo);
vk_device_memory_destroy(&device->vk, pAllocator, &mem->vk);
}

View file

@ -132,6 +132,7 @@ panvk_per_arch(get_physical_device_extensions)(
.EXT_depth_clamp_zero_one = true,
.EXT_depth_clip_enable = true,
.EXT_depth_clip_control = true,
.EXT_device_memory_report = true,
#ifdef VK_USE_PLATFORM_DISPLAY_KHR
.EXT_display_control = true,
#endif
@ -535,6 +536,9 @@ panvk_per_arch(get_physical_device_features)(
.presentWait2 = true,
#endif
/* VK_EXT_device_memory_report */
.deviceMemoryReport = true,
/* VK_ARM_shader_core_builtins */
.shaderCoreBuiltins = PAN_ARCH >= 9,
};