diff --git a/src/virglrenderer.c b/src/virglrenderer.c index b6b04ba..1bd17ee 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -176,7 +176,6 @@ int virgl_renderer_transfer_write_iov(uint32_t handle, { struct vrend_transfer_info transfer_info; - transfer_info.handle = handle; transfer_info.ctx_id = ctx_id; transfer_info.level = level; transfer_info.stride = stride; @@ -188,7 +187,8 @@ int virgl_renderer_transfer_write_iov(uint32_t handle, transfer_info.context0 = true; transfer_info.synchronized = false; - return vrend_renderer_transfer_iov(&transfer_info, VIRGL_TRANSFER_TO_HOST); + return vrend_renderer_transfer_iov(handle, &transfer_info, + VIRGL_TRANSFER_TO_HOST); } int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id, @@ -200,7 +200,6 @@ int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id, { struct vrend_transfer_info transfer_info; - transfer_info.handle = handle; transfer_info.ctx_id = ctx_id; transfer_info.level = level; transfer_info.stride = stride; @@ -212,7 +211,8 @@ int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id, transfer_info.context0 = true; transfer_info.synchronized = false; - return vrend_renderer_transfer_iov(&transfer_info, VIRGL_TRANSFER_FROM_HOST); + return vrend_renderer_transfer_iov(handle, &transfer_info, + VIRGL_TRANSFER_FROM_HOST); } int virgl_renderer_resource_attach_iov(int res_handle, struct iovec *iov, diff --git a/src/vrend_decode.c b/src/vrend_decode.c index a95ecb1..7281b7f 100644 --- a/src/vrend_decode.c +++ b/src/vrend_decode.c @@ -349,9 +349,12 @@ static int vrend_decode_set_sampler_views(struct vrend_decode_ctx *ctx, uint16_t return 0; } -static void vrend_decode_transfer_common(struct vrend_decode_ctx *ctx, struct vrend_transfer_info *info) +static void vrend_decode_transfer_common(struct vrend_decode_ctx *ctx, + uint32_t *dst_handle, + struct vrend_transfer_info *info) { - info->handle = get_buf_entry(ctx, VIRGL_RESOURCE_IW_RES_HANDLE); + *dst_handle = get_buf_entry(ctx, VIRGL_RESOURCE_IW_RES_HANDLE); + info->level = get_buf_entry(ctx, VIRGL_RESOURCE_IW_LEVEL); info->stride = get_buf_entry(ctx, VIRGL_RESOURCE_IW_STRIDE); info->layer_stride = get_buf_entry(ctx, VIRGL_RESOURCE_IW_LAYER_STRIDE); @@ -366,6 +369,7 @@ static void vrend_decode_transfer_common(struct vrend_decode_ctx *ctx, struct vr static int vrend_decode_resource_inline_write(struct vrend_decode_ctx *ctx, uint16_t length) { struct pipe_box box; + uint32_t dst_handle; struct vrend_transfer_info info; uint32_t data_len; struct iovec dataiovec; @@ -379,7 +383,7 @@ static int vrend_decode_resource_inline_write(struct vrend_decode_ctx *ctx, uint memset(&info, 0, sizeof(info)); info.box = &box; - vrend_decode_transfer_common(ctx, &info); + vrend_decode_transfer_common(ctx, &dst_handle, &info); data_len = (length - 11) * 4; data = get_buf_ptr(ctx, VIRGL_RESOURCE_IW_DATA_START); @@ -391,7 +395,7 @@ static int vrend_decode_resource_inline_write(struct vrend_decode_ctx *ctx, uint info.iovec = &dataiovec; info.iovec_cnt = 1; - return vrend_transfer_inline_write(ctx->grctx, &info); + return vrend_transfer_inline_write(ctx->grctx, dst_handle, &info); } static int vrend_decode_draw_vbo(struct vrend_decode_ctx *ctx, int length) @@ -1343,6 +1347,7 @@ static int vrend_decode_set_tweaks(struct vrend_decode_ctx *ctx, int length) static int vrend_decode_transfer3d(struct vrend_decode_ctx *ctx, int length, uint32_t ctx_id) { struct pipe_box box; + uint32_t dst_handle; struct vrend_transfer_info info; if (length < VIRGL_TRANSFER3D_SIZE) @@ -1351,7 +1356,7 @@ static int vrend_decode_transfer3d(struct vrend_decode_ctx *ctx, int length, uin memset(&info, 0, sizeof(info)); info.box = &box; info.ctx_id = ctx_id; - vrend_decode_transfer_common(ctx, &info); + vrend_decode_transfer_common(ctx, &dst_handle, &info); info.offset = get_buf_entry(ctx, VIRGL_TRANSFER3D_DATA_OFFSET); int transfer_mode = get_buf_entry(ctx, VIRGL_TRANSFER3D_DIRECTION); info.context0 = false; @@ -1360,13 +1365,14 @@ static int vrend_decode_transfer3d(struct vrend_decode_ctx *ctx, int length, uin transfer_mode != VIRGL_TRANSFER_FROM_HOST) return EINVAL; - return vrend_renderer_transfer_iov(&info, transfer_mode); + return vrend_renderer_transfer_iov(dst_handle, &info, transfer_mode); } static int vrend_decode_copy_transfer3d(struct vrend_decode_ctx *ctx, int length) { struct pipe_box box; struct vrend_transfer_info info; + uint32_t dst_handle; uint32_t src_handle; if (length != VIRGL_COPY_TRANSFER3D_SIZE) @@ -1374,13 +1380,14 @@ static int vrend_decode_copy_transfer3d(struct vrend_decode_ctx *ctx, int length memset(&info, 0, sizeof(info)); info.box = &box; - vrend_decode_transfer_common(ctx, &info); + vrend_decode_transfer_common(ctx, &dst_handle, &info); info.offset = get_buf_entry(ctx, VIRGL_COPY_TRANSFER3D_SRC_RES_OFFSET); info.synchronized = (get_buf_entry(ctx, VIRGL_COPY_TRANSFER3D_SYNCHRONIZED) != 0); src_handle = get_buf_entry(ctx, VIRGL_COPY_TRANSFER3D_SRC_RES_HANDLE); - return vrend_renderer_copy_transfer3d(ctx->grctx, &info, src_handle); + return vrend_renderer_copy_transfer3d(ctx->grctx, dst_handle, src_handle, + &info); } static void vrend_decode_ctx_init_base(struct vrend_decode_ctx *dctx, diff --git a/src/vrend_iov.h b/src/vrend_iov.h index 195113f..bd173af 100644 --- a/src/vrend_iov.h +++ b/src/vrend_iov.h @@ -38,7 +38,6 @@ struct iovec { #endif struct vrend_transfer_info { - uint32_t handle; uint32_t ctx_id; int level; uint32_t stride; diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index a227b26..ac34659 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -7624,7 +7624,8 @@ static int vrend_renderer_transfer_send_iov(struct vrend_resource *res, return 0; } -int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info, +int vrend_renderer_transfer_iov(uint32_t dst_handle, + const struct vrend_transfer_info *info, int transfer_mode) { struct vrend_resource *res; @@ -7637,17 +7638,17 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info, if (info->ctx_id == 0) { ctx = vrend_state.ctx0; - res = vrend_renderer_res_lookup(info->handle); + res = vrend_renderer_res_lookup(dst_handle); } 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, dst_handle); } if (!res) { if (info->ctx_id) - vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); + vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle); return EINVAL; } @@ -7672,7 +7673,7 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info, if (!iov) { if (info->ctx_id) - vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); + vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle); return EINVAL; } @@ -7711,23 +7712,24 @@ int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info, } int vrend_transfer_inline_write(struct vrend_context *ctx, - struct vrend_transfer_info *info) + uint32_t dst_handle, + const struct vrend_transfer_info *info) { struct vrend_resource *res; - res = vrend_renderer_ctx_res_lookup(ctx, info->handle); + res = vrend_renderer_ctx_res_lookup(ctx, dst_handle); if (!res) { - vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); + vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle); return EINVAL; } if (!check_transfer_bounds(res, info)) { - vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle); + vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, dst_handle); return EINVAL; } if (!check_iov_bounds(res, info, info->iovec, info->iovec_cnt)) { - vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle); + vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, dst_handle); return EINVAL; } @@ -7736,13 +7738,14 @@ int vrend_transfer_inline_write(struct vrend_context *ctx, } int vrend_renderer_copy_transfer3d(struct vrend_context *ctx, - struct vrend_transfer_info *info, - uint32_t src_handle) + uint32_t dst_handle, + uint32_t src_handle, + const struct vrend_transfer_info *info) { struct vrend_resource *src_res, *dst_res; src_res = vrend_renderer_ctx_res_lookup(ctx, src_handle); - dst_res = vrend_renderer_ctx_res_lookup(ctx, info->handle); + dst_res = vrend_renderer_ctx_res_lookup(ctx, dst_handle); if (!src_res) { vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, src_handle); @@ -7750,22 +7753,22 @@ int vrend_renderer_copy_transfer3d(struct vrend_context *ctx, } if (!dst_res) { - vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); + vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle); return EINVAL; } if (!src_res->iov) { - vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, info->handle); + vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle); return EINVAL; } if (!check_transfer_bounds(dst_res, info)) { - vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle); + vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, dst_handle); return EINVAL; } if (!check_iov_bounds(dst_res, info, src_res->iov, src_res->num_iovs)) { - vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, info->handle); + vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_CMD_BUFFER, dst_handle); return EINVAL; } @@ -10002,11 +10005,11 @@ void vrend_renderer_get_rect(struct pipe_resource *pres, transfer_info.stride = util_format_get_nblocksx(res->base.format, res->base.width0) * elsize; transfer_info.offset = offset; - 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, VIRGL_TRANSFER_FROM_HOST); + vrend_renderer_transfer_iov(res->handle, &transfer_info, + VIRGL_TRANSFER_FROM_HOST); } void vrend_renderer_attach_res_ctx(struct vrend_context *ctx, diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 562eb2c..6022cbf 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -225,11 +225,13 @@ void vrend_set_num_vbo(struct vrend_context *ctx, int num_vbo); int vrend_transfer_inline_write(struct vrend_context *ctx, - struct vrend_transfer_info *info); + uint32_t dst_handle, + const struct vrend_transfer_info *info); int vrend_renderer_copy_transfer3d(struct vrend_context *ctx, - struct vrend_transfer_info *info, - uint32_t src_handle); + uint32_t dst_handle, + uint32_t src_handle, + const struct vrend_transfer_info *info); void vrend_set_viewport_states(struct vrend_context *ctx, uint32_t start_slot, uint32_t num_viewports, @@ -286,7 +288,10 @@ void vrend_set_framebuffer_state_no_attach(struct vrend_context *ctx, uint32_t layers, uint32_t samples); void vrend_texture_barrier(struct vrend_context *ctx, unsigned flags); -int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info, int transfer_mode); + +int vrend_renderer_transfer_iov(uint32_t dst_handle, + const struct vrend_transfer_info *info, + int transfer_mode); void vrend_renderer_resource_copy_region(struct vrend_context *ctx, uint32_t dst_handle, uint32_t dst_level,