vkr: fix invalid use of RELEASE_TRACKED_OBJECTS

RELEASE_TRACKED_OBJECTS did not like track_list to include "obj" after
expansion.  Fix the callers and fix the gotcha.

v2: replace RELEASE_TRACKED_OBJECTS by an inline function (Ryan)

Fixes: 9da6721 ("vkr: add RELEASE_TRACKED_OBJECTS for tracked vkr_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 f279e91013
commit 1d1783fce1
  1. 3
      src/venus/vkr_command_buffer.c
  2. 11
      src/venus/vkr_common.h
  3. 9
      src/venus/vkr_context.h
  4. 6
      src/venus/vkr_descriptor_set.c
  5. 6
      src/venus/vkr_device.c

@ -32,8 +32,7 @@ vkr_dispatch_vkDestroyCommandPool(struct vn_dispatch_context *dispatch,
DESTROY_OBJECT(pool, command_pool, COMMAND_POOL, vkDestroyCommandPool, commandPool);
RELEASE_TRACKED_OBJECTS(&pool->command_buffers);
vkr_context_remove_objects(ctx, &pool->command_buffers);
util_hash_table_remove_u64(ctx->object_table, pool->base.id);
}

@ -48,6 +48,8 @@
/*
* TODO Most of the functions are generated. Some of them are then
* hand-edited. Find a better/cleaner way to reduce manual works.
*
* These macros may shadow your variables. Use with care.
*/
#define CREATE_OBJECT(obj, vkr_type, vk_obj, vk_cmd, vk_arg) \
struct vkr_device *_dev = (struct vkr_device *)args->device; \
@ -134,13 +136,6 @@
object_array_fini(&arr); \
} while (0)
#define RELEASE_TRACKED_OBJECTS(track_list) \
do { \
struct vkr_object *obj, *tmp; \
LIST_FOR_EACH_ENTRY_SAFE (obj, tmp, track_list, track_head) \
util_hash_table_remove_u64(ctx->object_table, obj->id); \
} while (0)
#define FREE_POOL_OBJECTS(vkr_type, vk_type, vk_cmd, arg_obj, arg_count, arg_pool) \
do { \
struct list_head free_list; \
@ -162,7 +157,7 @@
vn_replace_##vk_cmd##_args_handle(args); \
vk_cmd(args->device, args->arg_pool, args->arg_count, args->arg_obj); \
\
RELEASE_TRACKED_OBJECTS(&free_list); \
vkr_context_remove_objects(ctx, &free_list); \
} while (0)
#define CREATE_PIPELINES(vk_cmd) \

@ -63,4 +63,13 @@ struct vkr_context {
struct vkr_instance *instance;
};
static inline void
vkr_context_remove_objects(struct vkr_context *ctx, struct list_head *objects)
{
struct vkr_object *obj, *tmp;
LIST_FOR_EACH_ENTRY_SAFE (obj, tmp, objects, track_head)
util_hash_table_remove_u64(ctx->object_table, obj->id);
/* objects should be reinitialized if to be reused */
}
#endif /* VKR_CONTEXT_H */

@ -71,8 +71,7 @@ vkr_dispatch_vkDestroyDescriptorPool(struct vn_dispatch_context *dispatch,
DESTROY_OBJECT(pool, descriptor_pool, DESCRIPTOR_POOL, vkDestroyDescriptorPool,
descriptorPool);
RELEASE_TRACKED_OBJECTS(&pool->descriptor_sets);
vkr_context_remove_objects(ctx, &pool->descriptor_sets);
util_hash_table_remove_u64(ctx->object_table, pool->base.id);
}
@ -92,8 +91,7 @@ vkr_dispatch_vkResetDescriptorPool(struct vn_dispatch_context *dispatch,
vn_replace_vkResetDescriptorPool_args_handle(args);
args->ret = vkResetDescriptorPool(args->device, args->descriptorPool, args->flags);
RELEASE_TRACKED_OBJECTS(&pool->descriptor_sets);
vkr_context_remove_objects(ctx, &pool->descriptor_sets);
list_inithead(&pool->descriptor_sets);
}

@ -241,7 +241,8 @@ vkr_device_object_destroy(struct vkr_context *ctx,
*/
vkDestroyDescriptorPool(device, obj->handle.descriptor_pool, NULL);
RELEASE_TRACKED_OBJECTS(&((struct vkr_descriptor_pool *)obj)->descriptor_sets);
struct vkr_descriptor_pool *pool = (struct vkr_descriptor_pool *)obj;
vkr_context_remove_objects(ctx, &pool->descriptor_sets);
break;
}
case VK_OBJECT_TYPE_FRAMEBUFFER:
@ -253,7 +254,8 @@ vkr_device_object_destroy(struct vkr_context *ctx,
*/
vkDestroyCommandPool(device, obj->handle.command_pool, NULL);
RELEASE_TRACKED_OBJECTS(&((struct vkr_command_pool *)obj)->command_buffers);
struct vkr_command_pool *pool = (struct vkr_command_pool *)obj;
vkr_context_remove_objects(ctx, &pool->command_buffers);
break;
}
case VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION:

Loading…
Cancel
Save