virgl: Use buffer copy transfers to avoid waiting when mapping
authorAlexandros Frantzis <alexandros.frantzis@collabora.com>
Wed, 8 May 2019 09:10:21 +0000 (12:10 +0300)
committerChia-I Wu <olvaffe@gmail.com>
Sat, 8 Jun 2019 04:45:39 +0000 (21:45 -0700)
commita22c5df0794515369ce0c2b35ef8cd089b6975f3
treec9e680d71d25ae20b44dbf5a4df670149a0c1f22
parent6e7726e50c44c28969b20dc79e5c6f7a26eb6edd
virgl: Use buffer copy transfers to avoid waiting when mapping

We typically need to wait for a buffer to become ready before mapping,
so that we don't write new contents while the host is still using the
old contents. However, if we are allowed to discard the contents of the
mapped buffer range, then we can avoid waiting by using a staging buffer
range which we guarantee to never be busy, copying from the staging
buffer range to the target buffer in the host.

This commit implements this optimization by utilizing a dedicated
u_upload_mgr for the staging buffer.

Performance results:
Twilight Struggle (Steam/Proton), qemu before: 7 FPS after: 25 FPS
glmark2 ubo, qemu before: 38 FPS after: 331 FPS

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Suggested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
src/gallium/drivers/virgl/virgl_buffer.c
src/gallium/drivers/virgl/virgl_context.c
src/gallium/drivers/virgl/virgl_context.h
src/gallium/drivers/virgl/virgl_resource.c
src/gallium/drivers/virgl/virgl_resource.h
src/gallium/drivers/virgl/virgl_transfer_queue.c