diff options
author | Alexandros Frantzis <alexandros.frantzis@collabora.com> | 2019-05-27 19:32:31 +0300 |
---|---|---|
committer | Gurchetan Singh <gurchetansingh@google.com> | 2019-06-03 19:31:17 -0700 |
commit | 0bb764b6cfd302022eecb79fd09ea6bcb75d4c68 (patch) | |
tree | af68fb4d14141d012490f5f00d56227b7242314a /tests/testvirgl_encode.c | |
parent | 2af3a83136235f43b9bf32675a9183beb51b763e (diff) |
vrend: Improve iov bound checking for transfers
This commit improves bound checking by more accurately calculating
the expected transfer size. This improvement is achieved in two ways:
1. Using the image level (layer_)stride when the (layer_)stride is 0,
which matches the interpretation we use for performing the actual
read/write.
2. Calculating the transfer size by using the exact end offset in
the image, instead of using multiples of whole image rows.
The increased accuracy increases safety, and also allows us to support
some transfers with explicit strides that were previously rejected (see
added test).
Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Diffstat (limited to 'tests/testvirgl_encode.c')
-rw-r--r-- | tests/testvirgl_encode.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/testvirgl_encode.c b/tests/testvirgl_encode.c index 5707482..6f7192a 100644 --- a/tests/testvirgl_encode.c +++ b/tests/testvirgl_encode.c @@ -569,10 +569,21 @@ int virgl_encoder_transfer(struct virgl_context *ctx, const struct pipe_box *box, unsigned offset, unsigned direction) { + return virgl_encoder_transfer_with_stride(ctx, res, level, usage, box, + offset, direction, 0, 0); +} + +int virgl_encoder_transfer_with_stride(struct virgl_context *ctx, + struct virgl_resource *res, + unsigned level, unsigned usage, + const struct pipe_box *box, + unsigned offset, unsigned direction, + unsigned stride, unsigned layer_stride) +{ uint32_t command; command = VIRGL_CMD0(VIRGL_CCMD_TRANSFER3D, 0, VIRGL_TRANSFER3D_SIZE); virgl_encoder_write_dword(ctx->cbuf, command); - virgl_encoder_transfer3d_common(ctx, res, level, usage, box, 0, 0); + virgl_encoder_transfer3d_common(ctx, res, level, usage, box, stride, layer_stride); virgl_encoder_write_dword(ctx->cbuf, offset); virgl_encoder_write_dword(ctx->cbuf, direction); return 0; |