proxy: add proxy_context_resource helpers

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
macos/master
Yiwei Zhang 3 years ago
parent d9f090a20a
commit 9c5ca936c7
  1. 1
      src/proxy/proxy_common.h
  2. 36
      src/proxy/proxy_context.c
  3. 3
      src/proxy/proxy_context.h

@ -16,6 +16,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "util/hash_table.h"
#include "util/list.h" #include "util/list.h"
#include "util/macros.h" #include "util/macros.h"
#include "virgl_util.h" #include "virgl_util.h"

@ -23,6 +23,38 @@ struct proxy_fence {
struct list_head head; struct list_head head;
}; };
static inline void
proxy_context_resource_add(struct proxy_context *ctx, uint32_t res_id)
{
assert(!_mesa_hash_table_search(ctx->resource_table, (void *)res_id));
_mesa_hash_table_insert(ctx->resource_table, (void *)res_id, NULL);
}
static inline bool
proxy_context_resource_find(struct proxy_context *ctx, uint32_t res_id)
{
return _mesa_hash_table_search(ctx->resource_table, (void *)res_id);
}
static inline void
proxy_context_resource_remove(struct proxy_context *ctx, uint32_t res_id)
{
_mesa_hash_table_remove_key(ctx->resource_table, (void *)res_id);
}
static inline bool
proxy_context_resource_table_init(struct proxy_context *ctx)
{
ctx->resource_table = _mesa_hash_table_create_u32_keys(NULL);
return ctx->resource_table;
}
static inline void
proxy_context_resource_table_fini(struct proxy_context *ctx)
{
_mesa_hash_table_destroy(ctx->resource_table, NULL);
}
static bool static bool
proxy_fence_is_signaled(const struct proxy_fence *fence, uint32_t cur_seqno) proxy_fence_is_signaled(const struct proxy_fence *fence, uint32_t cur_seqno)
{ {
@ -465,6 +497,8 @@ proxy_context_destroy(struct virgl_context *base)
free(fence); free(fence);
mtx_destroy(&ctx->free_fences_mutex); mtx_destroy(&ctx->free_fences_mutex);
proxy_context_resource_table_fini(ctx);
proxy_socket_fini(&ctx->socket); proxy_socket_fini(&ctx->socket);
free(ctx); free(ctx);
@ -552,7 +586,7 @@ static bool
proxy_context_init(struct proxy_context *ctx, uint32_t ctx_flags) proxy_context_init(struct proxy_context *ctx, uint32_t ctx_flags)
{ {
if (!proxy_context_init_shmem(ctx) || !proxy_context_init_timelines(ctx) || if (!proxy_context_init_shmem(ctx) || !proxy_context_init_timelines(ctx) ||
!proxy_context_init_fencing(ctx)) !proxy_context_init_fencing(ctx) || !proxy_context_resource_table_init(ctx))
return false; return false;
const struct render_context_op_init_request req = { const struct render_context_op_init_request req = {

@ -30,6 +30,9 @@ struct proxy_context {
struct proxy_client *client; struct proxy_client *client;
struct proxy_socket socket; struct proxy_socket socket;
/* this tracks resources early attached in get_blob */
struct hash_table *resource_table;
/* this is shared with the render worker */ /* this is shared with the render worker */
struct { struct {
int fd; int fd;

Loading…
Cancel
Save