From b5777196d574f6d4e8256c31ae8092bafd4a2340 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 24 Aug 2020 13:34:22 -0700 Subject: [PATCH] virgl: move resource table init out of vrend The resource table should not be tied to vrend. Signed-off-by: Chia-I Wu Reviewed-by: Gurchetan Singh --- src/virglrenderer.c | 30 +++++++++++++++++++----------- src/vrend_renderer.c | 3 +-- src/vrend_renderer.h | 3 +++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/virglrenderer.c b/src/virglrenderer.c index b9faa07..c9a9772 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -439,14 +439,15 @@ void virgl_renderer_poll(void) void virgl_renderer_cleanup(UNUSED void *cookie) { - if (state.vrend_initialized) { + if (state.vrend_initialized) vrend_renderer_prepare_reset(); - virgl_context_table_reset(); - virgl_resource_table_cleanup(); - vrend_renderer_fini(); - } virgl_context_table_cleanup(); + virgl_resource_table_cleanup(); + + if (state.vrend_initialized) + vrend_renderer_fini(); + vrend_winsys_cleanup(); memset(&state, 0, sizeof(state)); @@ -475,8 +476,13 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks if (ret) return ret; - if (virgl_context_table_init()) - return -1; + ret = virgl_resource_table_init(vrend_renderer_get_pipe_callbacks()); + if (ret) + return ret; + + ret = virgl_context_table_init(); + if (ret) + return ret; if (!state.vrend_initialized) { uint32_t renderer_flags = 0; @@ -507,12 +513,14 @@ int virgl_renderer_get_fd_for_texture2(uint32_t tex_id, int *fd, int *stride, in void virgl_renderer_reset(void) { - if (state.vrend_initialized) { + if (state.vrend_initialized) vrend_renderer_prepare_reset(); - virgl_context_table_reset(); - virgl_resource_table_reset(); + + virgl_context_table_reset(); + virgl_resource_table_reset(); + + if (state.vrend_initialized) vrend_renderer_reset(); - } } int virgl_renderer_get_poll_fd(void) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 6a87a49..e7b9f6c 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -5907,7 +5907,7 @@ static enum virgl_resource_fd_type vrend_pipe_resource_export_fd(UNUSED struct p return VIRGL_RESOURCE_FD_INVALID; } -static const struct virgl_resource_pipe_callbacks * +const struct virgl_resource_pipe_callbacks * vrend_renderer_get_pipe_callbacks(void) { static const struct virgl_resource_pipe_callbacks callbacks = { @@ -5937,7 +5937,6 @@ int vrend_renderer_init(const struct vrend_if_cbs *cbs, uint32_t flags) virgl_gl_context gl_context; struct virgl_gl_ctx_param ctx_params; - virgl_resource_table_init(vrend_renderer_get_pipe_callbacks()); vrend_clicbs = cbs; /* Give some defaults to be able to run the tests */ diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 271c761..cf2e593 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -122,6 +122,9 @@ struct vrend_if_cbs { #define VREND_USE_THREAD_SYNC 1 #define VREND_USE_EXTERNAL_BLOB 2 +const struct virgl_resource_pipe_callbacks * +vrend_renderer_get_pipe_callbacks(void); + int vrend_renderer_init(const struct vrend_if_cbs *cbs, uint32_t flags); void vrend_insert_format(struct vrend_format_table *entry, uint32_t bindings, uint32_t flags);