vkr: pass ctx to object_array_init

This allows us to use vkr_context_alloc_object.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
macos/master
Chia-I Wu 3 years ago
parent e56b1f08a5
commit 4c93df3719
  1. 14
      src/venus/vkr_common.c
  2. 7
      src/venus/vkr_common.h

@ -8,6 +8,7 @@
#include <stdarg.h>
#include <stdio.h>
#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;
}

@ -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,

Loading…
Cancel
Save