virgl/drm: New optimization for uploading textures
authormwezdeck <maksym.wezdecki@collabora.co.uk>
Fri, 5 Nov 2021 12:13:01 +0000 (13:13 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 8 Dec 2021 14:01:48 +0000 (14:01 +0000)
commitcdc480585c9be368ddfdc33e2eb73e3582f25fe7
treeda13c1ae7f388f6c16ad1f74a14f1e4124e663f6
parent420170fabc1152339ca81b8c962c1884b3d9f856
virgl/drm: New optimization for uploading textures

1. We can create resource with size of "1" on drm, because size
   is not passed to the renderer.
2. We can't create resource with size of "1" on vtest, because shmem
   is created based on that.
3. If renderer supports copy_transfer_from_host, then use staging
   buffer for transfer in both ways to and from host.

This will allow to reduce memory consumption in the guest.

v2:
   - add inline function for checking if we can use this optimization
   - add check in readback path. If renderer doesn't support
     copy transfer from host, then we need to go with previous
     path in readback (through transfer_get ioctl)

v3:
   - fix logic for readback

v4:
   - refactor the implementation to integrate it more to
     existing code base

v5:
   - reuse COPY_TRANSFER3D in both directions

v6:
   - encode direction in COPY_TRANSFER3D if host supports it

v7:
   - renamed cap bit
   - introduced COPY_TRANSFER3D_SIZE_LEGACY define

Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13689>
src/gallium/drivers/virgl/virgl_buffer.c
src/gallium/drivers/virgl/virgl_encode.c
src/gallium/drivers/virgl/virgl_resource.c
src/gallium/drivers/virgl/virgl_resource.h
src/gallium/drivers/virgl/virgl_texture.c
src/gallium/winsys/virgl/vtest/virgl_vtest_winsys.c
src/virtio/virtio-gpu/virgl_hw.h
src/virtio/virtio-gpu/virgl_protocol.h