vrend: add a common decoding function

This can be shared by VIRGL_CCMD_TRANSFER3D and
VIRGL_CCMD_RESOURCE_INLINE_WRITE.

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
Gurchetan Singh 6 years ago committed by Gert Wollny
parent 5a6c9404b4
commit cc4f8c933c
  1. 41
      src/vrend_decode.c
  2. 1
      src/vrend_renderer.h

@ -336,12 +336,26 @@ static int vrend_decode_set_sampler_views(struct vrend_decode_ctx *ctx, uint16_t
return 0; return 0;
} }
static void vrend_decode_transfer_common(struct vrend_decode_ctx *ctx, struct vrend_transfer_info *info)
{
info->handle = get_buf_entry(ctx, VIRGL_RESOURCE_IW_RES_HANDLE);
info->level = get_buf_entry(ctx, VIRGL_RESOURCE_IW_LEVEL);
info->usage = get_buf_entry(ctx, VIRGL_RESOURCE_IW_USAGE);
info->stride = get_buf_entry(ctx, VIRGL_RESOURCE_IW_STRIDE);
info->layer_stride = get_buf_entry(ctx, VIRGL_RESOURCE_IW_LAYER_STRIDE);
info->box->x = get_buf_entry(ctx, VIRGL_RESOURCE_IW_X);
info->box->y = get_buf_entry(ctx, VIRGL_RESOURCE_IW_Y);
info->box->z = get_buf_entry(ctx, VIRGL_RESOURCE_IW_Z);
info->box->width = get_buf_entry(ctx, VIRGL_RESOURCE_IW_W);
info->box->height = get_buf_entry(ctx, VIRGL_RESOURCE_IW_H);
info->box->depth = get_buf_entry(ctx, VIRGL_RESOURCE_IW_D);
}
static int vrend_decode_resource_inline_write(struct vrend_decode_ctx *ctx, uint16_t length) static int vrend_decode_resource_inline_write(struct vrend_decode_ctx *ctx, uint16_t length)
{ {
struct vrend_transfer_info info;
struct pipe_box box; struct pipe_box box;
uint32_t res_handle; struct vrend_transfer_info info;
uint32_t level, usage, stride, layer_stride, data_len; uint32_t data_len;
struct iovec dataiovec; struct iovec dataiovec;
void *data; void *data;
@ -351,27 +365,12 @@ static int vrend_decode_resource_inline_write(struct vrend_decode_ctx *ctx, uint
if (length + ctx->ds->buf_offset > ctx->ds->buf_total) if (length + ctx->ds->buf_offset > ctx->ds->buf_total)
return EINVAL; return EINVAL;
res_handle = get_buf_entry(ctx, VIRGL_RESOURCE_IW_RES_HANDLE); info.box = &box;
vrend_decode_transfer_common(ctx, &info);
data_len = (length - 11) * 4; data_len = (length - 11) * 4;
level = get_buf_entry(ctx, VIRGL_RESOURCE_IW_LEVEL);
usage = get_buf_entry(ctx, VIRGL_RESOURCE_IW_USAGE);
stride = get_buf_entry(ctx, VIRGL_RESOURCE_IW_STRIDE);
layer_stride = get_buf_entry(ctx, VIRGL_RESOURCE_IW_LAYER_STRIDE);
box.x = get_buf_entry(ctx, VIRGL_RESOURCE_IW_X);
box.y = get_buf_entry(ctx, VIRGL_RESOURCE_IW_Y);
box.z = get_buf_entry(ctx, VIRGL_RESOURCE_IW_Z);
box.width = get_buf_entry(ctx, VIRGL_RESOURCE_IW_W);
box.height = get_buf_entry(ctx, VIRGL_RESOURCE_IW_H);
box.depth = get_buf_entry(ctx, VIRGL_RESOURCE_IW_D);
data = get_buf_ptr(ctx, VIRGL_RESOURCE_IW_DATA_START); data = get_buf_ptr(ctx, VIRGL_RESOURCE_IW_DATA_START);
info.handle = res_handle;
info.ctx_id = 0; info.ctx_id = 0;
info.level = level;
info.stride = stride;
info.layer_stride = layer_stride;
info.box = &box;
info.offset = 0; info.offset = 0;
dataiovec.iov_base = data; dataiovec.iov_base = data;
@ -379,7 +378,7 @@ static int vrend_decode_resource_inline_write(struct vrend_decode_ctx *ctx, uint
info.iovec = &dataiovec; info.iovec = &dataiovec;
info.iovec_cnt = 1; info.iovec_cnt = 1;
return vrend_transfer_inline_write(ctx->grctx, &info, usage); return vrend_transfer_inline_write(ctx->grctx, &info, info.usage);
} }
static int vrend_decode_draw_vbo(struct vrend_decode_ctx *ctx, int length) static int vrend_decode_draw_vbo(struct vrend_decode_ctx *ctx, int length)

@ -91,6 +91,7 @@ struct vrend_transfer_info {
int level; int level;
uint32_t stride; uint32_t stride;
uint32_t layer_stride; uint32_t layer_stride;
uint32_t usage;
unsigned int iovec_cnt; unsigned int iovec_cnt;
struct iovec *iovec; struct iovec *iovec;
uint64_t offset; uint64_t offset;

Loading…
Cancel
Save