diff options
author | Gert Wollny <gert.wollny@collabora.com> | 2023-09-12 13:44:58 +0200 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-09-12 13:03:22 +0000 |
commit | 30d1cb179b1bb1022d7e01ded95af6e933c2aa8d (patch) | |
tree | 727a6dc3e5c9d97e2615b503822698d4663f0c8a | |
parent | bbb844c0a6df799850cea696bba7f50d028b8732 (diff) |
vrend: Read only as many bytes as were mapped
The width given in glMapBufferRange refers to machine units, i.e. the
format of the underlying buffer is of no consequence. Hence only
info->box->width bytes are mapped and can be copied to the IOV.
In guest mesa this is accounted for so we don't have to calculate the
send_size value.
Closes: https://gitlab.freedesktop.org/virgl/virglrenderer/-/issues/469
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1233>
-rw-r--r-- | src/vrend_renderer.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 1e2707d..98391ad 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -9489,15 +9489,12 @@ static int vrend_renderer_transfer_send_iov(struct vrend_context *ctx, } if (has_bit(res->storage_bits, VREND_STORAGE_GL_BUFFER)) { - uint32_t send_size = info->box->width * util_format_get_blocksize(res->base.format); - void *data; - glBindBufferARB(res->target, res->id); - data = glMapBufferRange(res->target, info->box->x, info->box->width, GL_MAP_READ_BIT); + void *data = glMapBufferRange(res->target, info->box->x, info->box->width, GL_MAP_READ_BIT); if (!data) virgl_error("Unable to open buffer for reading %d\n", res->target); else - vrend_write_to_iovec(iov, num_iovs, info->offset, data, send_size); + vrend_write_to_iovec(iov, num_iovs, info->offset, data, info->box->width); glUnmapBuffer(res->target); glBindBufferARB(res->target, 0); } else { |