vrend: ctx0 does not need to be a vrend_decode_ctx

It can just be a vrend_context.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Chia-I Wu 5 years ago
parent acc7fc7c11
commit 660eaa2126
  1. 21
      src/vrend_decode.c
  2. 35
      src/vrend_renderer.c
  3. 2
      src/vrend_renderer.h

@ -54,8 +54,6 @@ struct vrend_decode_ctx {
struct vrend_context *grctx; struct vrend_context *grctx;
}; };
static struct vrend_decode_ctx *dec_ctx0;
static inline uint32_t get_buf_entry(struct vrend_decode_ctx *ctx, uint32_t offset) static inline uint32_t get_buf_entry(struct vrend_decode_ctx *ctx, uint32_t offset)
{ {
return ctx->ds->buf[ctx->ds->buf_offset + offset]; return ctx->ds->buf[ctx->ds->buf_offset + offset];
@ -1407,17 +1405,13 @@ struct virgl_context *vrend_renderer_context_create(uint32_t handle,
dctx->ds = &dctx->ids; dctx->ds = &dctx->ids;
if (handle == 0)
dec_ctx0 = dctx;
return &dctx->base; return &dctx->base;
} }
struct vrend_context *vrend_lookup_renderer_ctx(uint32_t ctx_id) struct vrend_context *vrend_lookup_renderer_ctx(uint32_t ctx_id)
{ {
struct vrend_decode_ctx *dctx = ctx_id ? struct vrend_decode_ctx *dctx =
(struct vrend_decode_ctx *)virgl_context_lookup(ctx_id) : (struct vrend_decode_ctx *)virgl_context_lookup(ctx_id);
dec_ctx0;
return dctx ? dctx->grctx : NULL; return dctx ? dctx->grctx : NULL;
} }
@ -1641,14 +1635,7 @@ static void vrend_decode_ctx_init_base(struct vrend_decode_ctx *dctx,
ctx->submit_cmd = vrend_decode_ctx_submit_cmd; ctx->submit_cmd = vrend_decode_ctx_submit_cmd;
} }
void vrend_decode_reset(bool ctx_0_only) void vrend_decode_reset(void)
{ {
vrend_hw_switch_context(dec_ctx0->grctx, true); virgl_context_table_reset();
if (!ctx_0_only) {
virgl_context_table_reset();
} else {
vrend_decode_ctx_destroy(&dec_ctx0->base);
dec_ctx0 = NULL;
}
} }

@ -297,6 +297,8 @@ struct global_renderer_state {
struct list_head fence_wait_list; struct list_head fence_wait_list;
pipe_condvar fence_cond; pipe_condvar fence_cond;
struct vrend_context *ctx0;
pipe_thread sync_thread; pipe_thread sync_thread;
virgl_gl_context sync_context; virgl_gl_context sync_context;
@ -5868,7 +5870,7 @@ int vrend_renderer_init(struct vrend_if_cbs *cbs, uint32_t flags)
list_inithead(&vrend_state.waiting_query_list); list_inithead(&vrend_state.waiting_query_list);
list_inithead(&vrend_state.active_ctx_list); list_inithead(&vrend_state.active_ctx_list);
/* create 0 context */ /* create 0 context */
vrend_renderer_context_create(0, strlen("HOST"), "HOST"); vrend_state.ctx0 = vrend_create_context(0, strlen("HOST"), "HOST");
vrend_state.eventfd = -1; vrend_state.eventfd = -1;
if (flags & VREND_USE_THREAD_SYNC) { if (flags & VREND_USE_THREAD_SYNC) {
@ -5894,9 +5896,11 @@ vrend_renderer_fini(void)
} }
vrend_blitter_fini(); vrend_blitter_fini();
vrend_decode_reset(false);
vrend_hw_switch_context(vrend_state.ctx0, true);
vrend_decode_reset();
vrend_object_fini_resource_table(); vrend_object_fini_resource_table();
vrend_decode_reset(true); vrend_destroy_context(vrend_state.ctx0);
vrend_state.current_ctx = NULL; vrend_state.current_ctx = NULL;
vrend_state.current_hw_ctx = NULL; vrend_state.current_hw_ctx = NULL;
@ -7651,14 +7655,15 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info,
if (!info->box) if (!info->box)
return EINVAL; return EINVAL;
ctx = vrend_lookup_renderer_ctx(info->ctx_id); if (info->ctx_id == 0) {
if (!ctx) ctx = vrend_state.ctx0;
return EINVAL;
if (info->ctx_id == 0)
res = vrend_resource_lookup(info->handle, 0); res = vrend_resource_lookup(info->handle, 0);
else } else {
ctx = vrend_lookup_renderer_ctx(info->ctx_id);
if (!ctx)
return EINVAL;
res = vrend_renderer_ctx_res_lookup(ctx, info->handle); res = vrend_renderer_ctx_res_lookup(ctx, info->handle);
}
if (!res) { if (!res) {
if (info->ctx_id) if (info->ctx_id)
@ -9990,10 +9995,9 @@ void *vrend_renderer_get_cursor_contents(uint32_t res_handle, uint32_t *width, u
void vrend_renderer_force_ctx_0(void) void vrend_renderer_force_ctx_0(void)
{ {
struct vrend_context *ctx0 = vrend_lookup_renderer_ctx(0);
vrend_state.current_ctx = NULL; vrend_state.current_ctx = NULL;
vrend_state.current_hw_ctx = NULL; vrend_state.current_hw_ctx = NULL;
vrend_hw_switch_context(ctx0, true); vrend_hw_switch_context(vrend_state.ctx0, true);
} }
void vrend_renderer_get_rect(int res_handle, struct iovec *iov, unsigned int num_iovs, void vrend_renderer_get_rect(int res_handle, struct iovec *iov, unsigned int num_iovs,
@ -10279,11 +10283,14 @@ void vrend_renderer_reset(void)
} }
vrend_reset_fences(); vrend_reset_fences();
vrend_blitter_fini(); vrend_blitter_fini();
vrend_decode_reset(false);
vrend_hw_switch_context(vrend_state.ctx0, true);
vrend_decode_reset();
vrend_object_fini_resource_table(); vrend_object_fini_resource_table();
vrend_decode_reset(true); vrend_destroy_context(vrend_state.ctx0);
vrend_object_init_resource_table(); vrend_object_init_resource_table();
vrend_renderer_context_create(0, strlen("HOST"), "HOST"); vrend_state.ctx0 = vrend_create_context(0, strlen("HOST"), "HOST");
} }
int vrend_renderer_get_poll_fd(void) int vrend_renderer_get_poll_fd(void)

@ -445,7 +445,7 @@ void vrend_blitter_fini(void);
void vrend_renderer_reset(void); void vrend_renderer_reset(void);
int vrend_renderer_get_poll_fd(void); int vrend_renderer_get_poll_fd(void);
void vrend_decode_reset(bool ctx_0_only); void vrend_decode_reset(void);
unsigned vrend_context_has_debug_flag(struct vrend_context *ctx, unsigned vrend_context_has_debug_flag(struct vrend_context *ctx,
enum virgl_debug_flags flag); enum virgl_debug_flags flag);

Loading…
Cancel
Save