diff options
author | Gurchetan Singh <[email protected]> | 2018-12-12 18:01:06 -0800 |
---|---|---|
committer | Gurchetan Singh <[email protected]> | 2019-04-18 15:39:12 -0700 |
commit | 581ab2bc7003aff99cb861578826b6c0d5b343dc (patch) | |
tree | 417ae1e028f1720c7ed380153e4fb42e547399f8 /src/gallium/winsys | |
parent | 96c3418e063d0a2e2ac1b83dc11a5a25cbef9555 (diff) |
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 <[email protected]>
Reviewed-By: Gert Wollny <[email protected]>
Reviewed-By: Piotr Rak <[email protected]>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c | 39 |
1 files changed, 35 insertions, 4 deletions
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 <stdio.h> +#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; } |