venus: use common memory report implementation

Looks to be the same, and there's no regression in the cts group
dEQP-VK.memory.device_memory_report.*

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33955>
This commit is contained in:
Yiwei Zhang 2025-03-07 16:05:38 -08:00 committed by Marge Bot
parent 551770ccf8
commit 7b228ef877
3 changed files with 8 additions and 93 deletions

View file

@ -171,54 +171,6 @@ vn_device_queue_family_fini(struct vn_device *dev)
vk_free(&dev->base.base.alloc, dev->queue_families);
}
static VkResult
vn_device_memory_report_init(struct vn_device *dev,
const VkDeviceCreateInfo *create_info)
{
const struct vk_features *app_feats = &dev->base.base.enabled_features;
if (!app_feats->deviceMemoryReport)
return VK_SUCCESS;
uint32_t count = 0;
vk_foreach_struct_const(pnext, create_info->pNext) {
if (pnext->sType ==
VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT)
count++;
}
struct vn_device_memory_report *mem_reports = NULL;
if (count) {
mem_reports =
vk_alloc(&dev->base.base.alloc, sizeof(*mem_reports) * count,
VN_DEFAULT_ALIGN, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (!mem_reports)
return VK_ERROR_OUT_OF_HOST_MEMORY;
}
count = 0;
vk_foreach_struct_const(pnext, create_info->pNext) {
if (pnext->sType ==
VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT) {
const struct VkDeviceDeviceMemoryReportCreateInfoEXT *report =
(void *)pnext;
mem_reports[count].callback = report->pfnUserCallback;
mem_reports[count].data = report->pUserData;
count++;
}
}
dev->memory_report_count = count;
dev->memory_reports = mem_reports;
return VK_SUCCESS;
}
static inline void
vn_device_memory_report_fini(struct vn_device *dev)
{
vk_free(&dev->base.base.alloc, dev->memory_reports);
}
static bool
find_extension_names(const char *const *exts,
uint32_t ext_count,
@ -517,13 +469,9 @@ vn_device_init(struct vn_device *dev,
if (result != VK_SUCCESS)
return result;
result = vn_device_memory_report_init(dev, create_info);
if (result != VK_SUCCESS)
goto out_destroy_device;
if (!vn_device_queue_family_init(dev, create_info)) {
result = VK_ERROR_OUT_OF_HOST_MEMORY;
goto out_memory_report_fini;
goto out_destroy_device;
}
result = vn_device_feedback_pool_init(dev);
@ -557,9 +505,6 @@ out_feedback_pool_fini:
out_queue_family_fini:
vn_device_queue_family_fini(dev);
out_memory_report_fini:
vn_device_memory_report_fini(dev);
out_destroy_device:
vn_call_vkDestroyDevice(dev->primary_ring, dev_handle, NULL);
@ -640,8 +585,6 @@ vn_DestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator)
vn_device_queue_family_fini(dev);
vn_device_memory_report_fini(dev);
vn_async_vkDestroyDevice(dev->primary_ring, device, NULL);
/* We must emit vn_call_vkDestroyDevice before releasing bound ring_idx.

View file

@ -18,11 +18,6 @@
#include "vn_feedback.h"
#include "vn_image.h"
struct vn_device_memory_report {
PFN_vkDeviceMemoryReportCallbackEXT callback;
void *data;
};
struct vn_device {
struct vn_device_base base;
@ -32,9 +27,6 @@ struct vn_device {
struct vn_renderer *renderer;
struct vn_ring *primary_ring;
struct vn_device_memory_report *memory_reports;
uint32_t memory_report_count;
/* unique queue family indices in which to create the device queues */
uint32_t *queue_families;
uint32_t queue_family_count;
@ -58,27 +50,4 @@ VK_DEFINE_HANDLE_CASTS(vn_device,
VkDevice,
VK_OBJECT_TYPE_DEVICE)
static inline void
vn_device_emit_device_memory_report(struct vn_device *dev,
VkDeviceMemoryReportEventTypeEXT type,
uint64_t mem_obj_id,
VkDeviceSize size,
VkObjectType obj_type,
uint64_t obj_handle,
uint32_t heap_index)
{
assert(dev->memory_reports);
const VkDeviceMemoryReportCallbackDataEXT report = {
.sType = VK_STRUCTURE_TYPE_DEVICE_MEMORY_REPORT_CALLBACK_DATA_EXT,
.type = type,
.memoryObjectId = mem_obj_id,
.size = size,
.objectType = obj_type,
.objectHandle = obj_handle,
.heapIndex = heap_index,
};
for (uint32_t i = 0; i < dev->memory_report_count; i++)
dev->memory_reports[i].callback(&report, dev->memory_reports[i].data);
}
#endif /* VN_DEVICE_H */

View file

@ -12,6 +12,7 @@
#include "venus-protocol/vn_protocol_driver_device_memory.h"
#include "venus-protocol/vn_protocol_driver_transport.h"
#include "vk_debug_utils.h"
#include "vn_android.h"
#include "vn_buffer.h"
@ -323,7 +324,9 @@ vn_device_memory_emit_report(struct vn_device *dev,
bool is_alloc,
VkResult result)
{
if (likely(!dev->memory_reports))
struct vk_device *dev_vk = &dev->base.base;
if (likely(!dev_vk->memory_reports))
return;
const struct vk_device_memory *mem_vk = &mem->base.base;
@ -345,9 +348,9 @@ vn_device_memory_emit_report(struct vn_device *dev,
: mem->base.id;
const VkMemoryType *mem_type = &dev->physical_device->memory_properties
.memoryTypes[mem_vk->memory_type_index];
vn_device_emit_device_memory_report(dev, type, mem_obj_id, mem_vk->size,
VK_OBJECT_TYPE_DEVICE_MEMORY,
(uintptr_t)mem, mem_type->heapIndex);
vk_emit_device_memory_report(dev_vk, type, mem_obj_id, mem_vk->size,
VK_OBJECT_TYPE_DEVICE_MEMORY, (uintptr_t)mem,
mem_type->heapIndex);
}
VkResult