vrend: add check_transfer_iovec

In preparation for vrend_resource::handle removal.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Chia-I Wu 5 years ago committed by Gurchetan Singh
parent cca3132795
commit 29a87d629c
  1. 22
      src/vrend_renderer.c

@ -6902,6 +6902,12 @@ static void write_transfer_data(struct pipe_resource *res,
} }
} }
static bool check_transfer_iovec(struct vrend_resource *res,
const struct vrend_transfer_info *info)
{
return (info->iovec && info->iovec_cnt) || res->iov;
}
static bool check_transfer_bounds(struct vrend_resource *res, static bool check_transfer_bounds(struct vrend_resource *res,
const struct vrend_transfer_info *info) const struct vrend_transfer_info *info)
{ {
@ -7672,20 +7678,15 @@ static int vrend_renderer_transfer_internal(struct vrend_context *ctx,
vrend_hw_switch_context(ctx, true); vrend_hw_switch_context(ctx, true);
assert(check_transfer_iovec(res, info));
if (info->iovec && info->iovec_cnt) {
iov = info->iovec; iov = info->iovec;
num_iovs = info->iovec_cnt; num_iovs = info->iovec_cnt;
} else {
if (res->iov && (!iov || num_iovs == 0)) {
iov = res->iov; iov = res->iov;
num_iovs = res->num_iovs; num_iovs = res->num_iovs;
} }
if (!iov) {
if (ctx != vrend_state.ctx0)
vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, res->handle);
return EINVAL;
}
#ifdef ENABLE_MINIGBM_ALLOCATION #ifdef ENABLE_MINIGBM_ALLOCATION
if (res->gbm_bo && (transfer_mode == VIRGL_TRANSFER_TO_HOST || if (res->gbm_bo && (transfer_mode == VIRGL_TRANSFER_TO_HOST ||
!has_bit(res->storage_bits, VREND_STORAGE_EGL_IMAGE))) { !has_bit(res->storage_bits, VREND_STORAGE_EGL_IMAGE))) {
@ -7724,7 +7725,7 @@ int vrend_renderer_transfer_iov(struct vrend_context *ctx,
struct vrend_resource *res; struct vrend_resource *res;
res = vrend_renderer_ctx_res_lookup(ctx, dst_handle); res = vrend_renderer_ctx_res_lookup(ctx, dst_handle);
if (!res) { if (!res || !check_transfer_iovec(res, info)) {
vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle); vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_RESOURCE, dst_handle);
return EINVAL; return EINVAL;
} }
@ -7738,6 +7739,9 @@ int vrend_renderer_transfer_pipe(struct pipe_resource *pres,
int transfer_mode) int transfer_mode)
{ {
struct vrend_resource *res = (struct vrend_resource *)pres; struct vrend_resource *res = (struct vrend_resource *)pres;
if (!check_transfer_iovec(res, info))
return EINVAL;
return vrend_renderer_transfer_internal(vrend_state.ctx0, res, info, return vrend_renderer_transfer_internal(vrend_state.ctx0, res, info,
transfer_mode); transfer_mode);
} }

Loading…
Cancel
Save