diff --git a/src/venus/vkr_common.c b/src/venus/vkr_common.c index f77b88b..8a85e13 100644 --- a/src/venus/vkr_common.c +++ b/src/venus/vkr_common.c @@ -8,6 +8,7 @@ #include #include +#include "vkr_context.h" #include "vkr_cs.h" void @@ -59,12 +60,13 @@ object_array_fini(struct object_array *arr) } bool -object_array_init(struct object_array *arr, +object_array_init(struct vkr_context *ctx, + struct object_array *arr, uint32_t count, VkObjectType obj_type, size_t obj_size, size_t handle_size, - const void *handles) + const void *obj_id_handles) { arr->count = count; @@ -80,17 +82,15 @@ object_array_init(struct object_array *arr, arr->objects_stolen = false; for (uint32_t i = 0; i < count; i++) { - struct vkr_object *obj = calloc(1, obj_size); + const void *obj_id_handle = (const char *)obj_id_handles + handle_size * i; + struct vkr_object *obj = + vkr_context_alloc_object(ctx, obj_size, obj_type, obj_id_handle); if (!obj) { arr->count = i; object_array_fini(arr); return false; } - obj->type = obj_type; - obj->id = vkr_cs_handle_load_id((const void **)((char *)handles + handle_size * i), - obj->type); - arr->objects[i] = obj; } diff --git a/src/venus/vkr_common.h b/src/venus/vkr_common.h index eb98842..e0c5c41 100644 --- a/src/venus/vkr_common.h +++ b/src/venus/vkr_common.h @@ -94,7 +94,7 @@ } \ \ struct object_array arr; \ - if (!object_array_init(&arr, args->pAllocateInfo->arg_count, \ + if (!object_array_init(ctx, &arr, args->pAllocateInfo->arg_count, \ VK_OBJECT_TYPE_##vk_type, sizeof(struct vkr_##vkr_type), \ sizeof(Vk##vk_obj), args->p##vk_obj##s)) { \ args->ret = VK_ERROR_OUT_OF_HOST_MEMORY; \ @@ -149,7 +149,7 @@ struct vkr_device *dev = (struct vkr_device *)args->device; \ \ struct object_array arr; \ - if (!object_array_init(&arr, args->createInfoCount, VK_OBJECT_TYPE_PIPELINE, \ + if (!object_array_init(ctx, &arr, args->createInfoCount, VK_OBJECT_TYPE_PIPELINE, \ sizeof(struct vkr_pipeline), sizeof(VkPipeline), \ args->pPipelines)) { \ args->ret = VK_ERROR_OUT_OF_HOST_MEMORY; \ @@ -272,7 +272,8 @@ void vkr_log(const char *fmt, ...); bool -object_array_init(struct object_array *arr, +object_array_init(struct vkr_context *ctx, + struct object_array *arr, uint32_t count, VkObjectType obj_type, size_t obj_size,