virgl: more robust resource/context table init/cleanup

Track whether the tables have been initialized, and avoid double
init/cleanup.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Chia-I Wu 4 years ago
parent b5777196d5
commit 228fa50acd
  1. 3
      src/virgl_context.c
  2. 14
      src/virglrenderer.c

@ -52,10 +52,7 @@ virgl_context_table_init(void)
void
virgl_context_table_cleanup(void)
{
if (virgl_context_table) {
util_hash_table_destroy(virgl_context_table);
virgl_context_table = NULL;
}
}
void

@ -47,6 +47,8 @@ struct global_state {
void *cookie;
const struct virgl_renderer_callbacks *cbs;
bool resource_initialized;
bool context_initialized;
bool vrend_initialized;
};
@ -442,7 +444,10 @@ void virgl_renderer_cleanup(UNUSED void *cookie)
if (state.vrend_initialized)
vrend_renderer_prepare_reset();
if (state.context_initialized)
virgl_context_table_cleanup();
if (state.resource_initialized)
virgl_resource_table_cleanup();
if (state.vrend_initialized)
@ -476,13 +481,19 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks
if (ret)
return ret;
if (!state.resource_initialized) {
ret = virgl_resource_table_init(vrend_renderer_get_pipe_callbacks());
if (ret)
return ret;
state.resource_initialized = true;
}
if (!state.context_initialized) {
ret = virgl_context_table_init();
if (ret)
return ret;
state.context_initialized = true;
}
if (!state.vrend_initialized) {
uint32_t renderer_flags = 0;
@ -516,7 +527,10 @@ void virgl_renderer_reset(void)
if (state.vrend_initialized)
vrend_renderer_prepare_reset();
if (state.context_initialized)
virgl_context_table_reset();
if (state.resource_initialized)
virgl_resource_table_reset();
if (state.vrend_initialized)

Loading…
Cancel
Save