vkr: add vkr_device_{add,remove}_object

They are wrappers to vkr_context_{add,remove}_object with added sanity
checks.

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 74ee5345ed
commit 98399f37db
  1. 8
      src/venus/vkr_device.c
  2. 36
      src/venus/vkr_device.h

@ -233,6 +233,8 @@ vkr_device_object_destroy(struct vkr_context *ctx,
{
VkDevice device = dev->base.handle.device;
assert(vkr_device_should_track_object(obj));
switch (obj->type) {
case VK_OBJECT_TYPE_SEMAPHORE:
vkDestroySemaphore(device, obj->handle.semaphore, NULL);
@ -315,12 +317,6 @@ vkr_device_object_destroy(struct vkr_context *ctx,
vkDestroyDescriptorUpdateTemplate(device, obj->handle.descriptor_update_template,
NULL);
break;
case VK_OBJECT_TYPE_INSTANCE: /* non-device objects */
case VK_OBJECT_TYPE_PHYSICAL_DEVICE: /* non-device objects */
case VK_OBJECT_TYPE_DEVICE: /* device itself */
case VK_OBJECT_TYPE_QUEUE: /* not tracked as device objects */
case VK_OBJECT_TYPE_COMMAND_BUFFER: /* pool objects */
case VK_OBJECT_TYPE_DESCRIPTOR_SET: /* pool objects */
default:
vkr_log("Unhandled vkr_object(%p) with VkObjectType(%u)", obj, (uint32_t)obj->type);
assert(false);

@ -8,6 +8,8 @@
#include "vkr_common.h"
#include "vkr_context.h"
struct vkr_device {
struct vkr_object base;
@ -53,4 +55,38 @@ vkr_context_init_device_dispatch(struct vkr_context *ctx);
void
vkr_device_destroy(struct vkr_context *ctx, struct vkr_device *dev);
static inline bool
vkr_device_should_track_object(const struct vkr_object *obj)
{
assert(vkr_is_recognized_object_type(obj->type));
switch (obj->type) {
case VK_OBJECT_TYPE_INSTANCE: /* non-device objects */
case VK_OBJECT_TYPE_PHYSICAL_DEVICE: /* non-device objects */
case VK_OBJECT_TYPE_DEVICE: /* device itself */
case VK_OBJECT_TYPE_QUEUE: /* not tracked as device objects */
case VK_OBJECT_TYPE_COMMAND_BUFFER: /* pool objects */
case VK_OBJECT_TYPE_DESCRIPTOR_SET: /* pool objects */
return false;
default:
return true;
}
}
static inline void
vkr_device_add_object(struct vkr_context *ctx, struct vkr_object *obj)
{
assert(vkr_device_should_track_object(obj));
/* TODO add to dev->objects */
vkr_context_add_object(ctx, obj);
}
static inline void
vkr_device_remove_object(struct vkr_context *ctx, struct vkr_object *obj)
{
/* TODO remove from dev->objects */
vkr_context_remove_object(ctx, obj);
}
#endif /* VKR_DEVICE_H */

Loading…
Cancel
Save