From: Gurchetan Singh Date: Thu, 13 Dec 2018 02:01:06 +0000 (-0800) Subject: virgl/vtest: modify sending and receiving data for shared memory X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=581ab2bc7003aff99cb861578826b6c0d5b343dc;p=mesa.git virgl/vtest: modify sending and receiving data for shared memory We need to copy the shared memory region to the display target. Signed-off-by: Gurchetan Singh Reviewed-By: Gert Wollny Reviewed-By: Piotr Rak --- diff --git a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c index 42c608e1b83..48f9c306a0e 100644 --- a/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c +++ b/src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c @@ -21,6 +21,7 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include +#include "util/u_surface.h" #include "util/u_memory.h" #include "util/u_format.h" #include "util/u_inlines.h" @@ -83,6 +84,10 @@ virgl_vtest_transfer_put(struct virgl_winsys *vws, virgl_vtest_send_transfer_put(vtws, res->res_handle, level, stride, layer_stride, box, size, buf_offset); + + if (vtws->protocol_version >= 2) + return 0; + ptr = virgl_vtest_resource_map(vws, res); virgl_vtest_send_transfer_put_data(vtws, ptr + buf_offset, size); virgl_vtest_resource_unmap(vws, res); @@ -108,12 +113,38 @@ virgl_vtest_transfer_get_internal(struct virgl_winsys *vws, level, stride, layer_stride, box, size, buf_offset); - ptr = virgl_vtest_resource_map(vws, res); + if (vtws->protocol_version >= 2) { + if (flush_front_buffer) { + if (box->depth > 1 || box->z > 1) { + fprintf(stderr, "Expected a 2D resource, received a 3D resource\n"); + return -1; + } - virgl_vtest_recv_transfer_get_data(vtws, ptr + buf_offset, size, - valid_stride, box, res->format); + void *dt_map; + uint32_t shm_stride; + + /* + * The display target is aligned to 64 bytes, while the shared resource + * between the client/server is not. + */ + shm_stride = util_format_get_stride(res->format, res->width); + ptr = virgl_vtest_resource_map(vws, res); + dt_map = vtws->sws->displaytarget_map(vtws->sws, res->dt, 0); + + util_copy_rect(dt_map, res->format, res->stride, box->x, box->y, + box->width, box->height, ptr, shm_stride, box->x, + box->y); + + virgl_vtest_resource_unmap(vws, res); + vtws->sws->displaytarget_unmap(vtws->sws, res->dt); + } + } else { + ptr = virgl_vtest_resource_map(vws, res); + virgl_vtest_recv_transfer_get_data(vtws, ptr + buf_offset, size, + valid_stride, box, res->format); + virgl_vtest_resource_unmap(vws, res); + } - virgl_vtest_resource_unmap(vws, res); return 0; }