|
|
@ -49,7 +49,7 @@ struct vkr_context { |
|
|
|
mtx_t mutex; |
|
|
|
mtx_t mutex; |
|
|
|
|
|
|
|
|
|
|
|
struct list_head rings; |
|
|
|
struct list_head rings; |
|
|
|
struct util_hash_table *object_table; |
|
|
|
struct hash_table *object_table; |
|
|
|
struct hash_table *resource_table; |
|
|
|
struct hash_table *resource_table; |
|
|
|
struct list_head newly_exported_memories; |
|
|
|
struct list_head newly_exported_memories; |
|
|
|
|
|
|
|
|
|
|
@ -95,7 +95,7 @@ vkr_context_get_resource(struct vkr_context *ctx, uint32_t res_id) |
|
|
|
static inline bool |
|
|
|
static inline bool |
|
|
|
vkr_context_validate_object_id(struct vkr_context *ctx, vkr_object_id id) |
|
|
|
vkr_context_validate_object_id(struct vkr_context *ctx, vkr_object_id id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (unlikely(!id || util_hash_table_get(ctx->object_table, &id))) { |
|
|
|
if (unlikely(!id || _mesa_hash_table_search(ctx->object_table, &id))) { |
|
|
|
vkr_cs_decoder_set_fatal(&ctx->decoder); |
|
|
|
vkr_cs_decoder_set_fatal(&ctx->decoder); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -116,23 +116,29 @@ vkr_context_alloc_object(UNUSED struct vkr_context *ctx, |
|
|
|
return vkr_object_alloc(size, type, id); |
|
|
|
return vkr_object_alloc(size, type, id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
vkr_context_free_object(struct hash_entry *entry); |
|
|
|
|
|
|
|
|
|
|
|
static inline void |
|
|
|
static inline void |
|
|
|
vkr_context_add_object(struct vkr_context *ctx, struct vkr_object *obj) |
|
|
|
vkr_context_add_object(struct vkr_context *ctx, struct vkr_object *obj) |
|
|
|
{ |
|
|
|
{ |
|
|
|
assert(vkr_is_recognized_object_type(obj->type)); |
|
|
|
assert(vkr_is_recognized_object_type(obj->type)); |
|
|
|
assert(obj->id); |
|
|
|
assert(obj->id); |
|
|
|
assert(!util_hash_table_get(ctx->object_table, &obj->id)); |
|
|
|
assert(!_mesa_hash_table_search(ctx->object_table, &obj->id)); |
|
|
|
|
|
|
|
|
|
|
|
util_hash_table_set(ctx->object_table, &obj->id, obj); |
|
|
|
_mesa_hash_table_insert(ctx->object_table, &obj->id, obj); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static inline void |
|
|
|
static inline void |
|
|
|
vkr_context_remove_object(struct vkr_context *ctx, struct vkr_object *obj) |
|
|
|
vkr_context_remove_object(struct vkr_context *ctx, struct vkr_object *obj) |
|
|
|
{ |
|
|
|
{ |
|
|
|
assert(util_hash_table_get(ctx->object_table, &obj->id)); |
|
|
|
assert(_mesa_hash_table_search(ctx->object_table, &obj->id)); |
|
|
|
|
|
|
|
|
|
|
|
/* this frees obj */ |
|
|
|
struct hash_entry *entry = _mesa_hash_table_search(ctx->object_table, &obj->id); |
|
|
|
util_hash_table_remove(ctx->object_table, &obj->id); |
|
|
|
if (likely(entry)) { |
|
|
|
|
|
|
|
vkr_context_free_object(entry); |
|
|
|
|
|
|
|
_mesa_hash_table_remove(ctx->object_table, entry); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static inline void |
|
|
|
static inline void |
|
|
@ -147,7 +153,8 @@ vkr_context_remove_objects(struct vkr_context *ctx, struct list_head *objects) |
|
|
|
static inline void * |
|
|
|
static inline void * |
|
|
|
vkr_context_get_object(struct vkr_context *ctx, vkr_object_id obj_id) |
|
|
|
vkr_context_get_object(struct vkr_context *ctx, vkr_object_id obj_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return util_hash_table_get(ctx->object_table, &obj_id); |
|
|
|
const struct hash_entry *entry = _mesa_hash_table_search(ctx->object_table, &obj_id); |
|
|
|
|
|
|
|
return likely(entry) ? entry->data : NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static inline const char * |
|
|
|
static inline const char * |
|
|
|