From 0475d679aaa51c1a3b76a976ebf9016a63480605 Mon Sep 17 00:00:00 2001 From: Gurchetan Singh Date: Fri, 7 Dec 2018 15:07:50 -0800 Subject: [PATCH] vrend: specify if a transfer occurs in context zero or not A transfer won't occur in context zero if the transfer command comes from submit_cmd. We need to restore prior state. With the recent framebuffer binding cleanups, we really only need to worry about the framebuffer. Reviewed-by: Gert Wollny --- src/virglrenderer.c | 2 ++ src/vrend_renderer.c | 8 +++++++- src/vrend_renderer.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/virglrenderer.c b/src/virglrenderer.c index 3695e76..d5cc44b 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -131,6 +131,7 @@ int virgl_renderer_transfer_write_iov(uint32_t handle, transfer_info.offset = offset; transfer_info.iovec = iovec; transfer_info.iovec_cnt = iovec_cnt; + transfer_info.context0 = true; return vrend_renderer_transfer_iov(&transfer_info, VREND_TRANSFER_WRITE); } @@ -153,6 +154,7 @@ int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id, transfer_info.offset = offset; transfer_info.iovec = iovec; transfer_info.iovec_cnt = iovec_cnt; + transfer_info.context0 = true; return vrend_renderer_transfer_iov(&transfer_info, VREND_TRANSFER_READ); } diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 8ef366f..45e0aa6 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -6654,6 +6654,10 @@ static int vrend_transfer_send_readpixels(struct vrend_context *ctx, separate_invert); free(data); } + + if (!info->context0 && ctx->sub) + glBindFramebuffer(GL_FRAMEBUFFER, ctx->sub->fb_id); + return 0; } @@ -6780,7 +6784,8 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info, if (!check_iov_bounds(res, info, iov, num_iovs)) return EINVAL; - vrend_hw_switch_context(vrend_lookup_renderer_ctx(0), true); + if (info->context0) + vrend_hw_switch_context(vrend_lookup_renderer_ctx(0), true); if (transfer_mode == VREND_TRANSFER_WRITE) return vrend_renderer_transfer_write_iov(ctx, res, iov, num_iovs, @@ -8720,6 +8725,7 @@ void vrend_renderer_get_rect(int res_handle, struct iovec *iov, unsigned int num transfer_info.handle = res->handle; transfer_info.iovec = iov; transfer_info.iovec_cnt = num_iovs; + transfer_info.context0 = true; vrend_renderer_transfer_iov(&transfer_info, VREND_TRANSFER_READ); } diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 321c7eb..9aabe83 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -95,6 +95,7 @@ struct vrend_transfer_info { unsigned int iovec_cnt; struct iovec *iovec; uint64_t offset; + bool context0; struct pipe_box *box; };