vkr: add vkr_context_add_instance

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
macos/master
Chia-I Wu 3 years ago
parent 0097858dc7
commit 3bebc4de7f
  1. 18
      src/venus/vkr_context.c
  2. 6
      src/venus/vkr_context.h
  3. 8
      src/venus/vkr_instance.c

@ -27,6 +27,24 @@
#include "vkr_ring.h" #include "vkr_ring.h"
#include "vkr_transport.h" #include "vkr_transport.h"
void
vkr_context_add_instance(struct vkr_context *ctx, struct vkr_instance *instance)
{
vkr_context_add_object(ctx, &instance->base);
assert(!ctx->instance);
ctx->instance = instance;
}
void
vkr_context_remove_instance(struct vkr_context *ctx, struct vkr_instance *instance)
{
assert(ctx->instance && ctx->instance == instance);
ctx->instance = NULL;
vkr_context_remove_object(ctx, &instance->base);
}
static void static void
vkr_dispatch_debug_log(UNUSED struct vn_dispatch_context *dispatch, const char *msg) vkr_dispatch_debug_log(UNUSED struct vn_dispatch_context *dispatch, const char *msg)
{ {

@ -93,4 +93,10 @@ vkr_context_remove_objects(struct vkr_context *ctx, struct list_head *objects)
/* objects should be reinitialized if to be reused */ /* objects should be reinitialized if to be reused */
} }
void
vkr_context_add_instance(struct vkr_context *ctx, struct vkr_instance *instance);
void
vkr_context_remove_instance(struct vkr_context *ctx, struct vkr_instance *instance);
#endif /* VKR_CONTEXT_H */ #endif /* VKR_CONTEXT_H */

@ -222,9 +222,7 @@ vkr_dispatch_vkCreateInstance(struct vn_dispatch_context *dispatch,
} }
} }
vkr_context_add_object(ctx, &instance->base); vkr_context_add_instance(ctx, instance);
ctx->instance = instance;
} }
void void
@ -248,7 +246,7 @@ vkr_instance_destroy(struct vkr_context *ctx, struct vkr_instance *instance)
free(instance->physical_device_handles); free(instance->physical_device_handles);
free(instance->physical_devices); free(instance->physical_devices);
vkr_context_remove_object(ctx, &instance->base); vkr_context_remove_instance(ctx, instance);
} }
static void static void
@ -264,8 +262,6 @@ vkr_dispatch_vkDestroyInstance(struct vn_dispatch_context *dispatch,
} }
vkr_instance_destroy(ctx, instance); vkr_instance_destroy(ctx, instance);
ctx->instance = NULL;
} }
void void

Loading…
Cancel
Save