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>
This commit is contained in:
@@ -443,6 +443,7 @@ enum virgl_formats {
|
||||
#define VIRGL_CAP_V2_MEMINFO (1 << 3)
|
||||
#define VIRGL_CAP_V2_STRING_MARKER (1 << 4)
|
||||
#define VIRGL_CAP_V2_IMPLICIT_MSAA (1 << 6)
|
||||
#define VIRGL_CAP_V2_COPY_TRANSFER_BOTH_DIRECTIONS (1 << 7)
|
||||
|
||||
/* virgl bind flags - these are compatible with mesa 10.5 gallium.
|
||||
* but are fixed, no other should be passed to virgl either.
|
||||
|
||||
@@ -608,11 +608,14 @@ enum virgl_context_cmd {
|
||||
#define VIRGL_TRANSFER3D_DATA_OFFSET 12
|
||||
#define VIRGL_TRANSFER3D_DIRECTION 13
|
||||
|
||||
/* Copy transfer */
|
||||
/* Copy transfer to host and from host*/
|
||||
#define VIRGL_COPY_TRANSFER3D_SIZE 14
|
||||
/* The first 11 dwords are the same as VIRGL_RESOURCE_IW_* */
|
||||
#define VIRGL_COPY_TRANSFER3D_SRC_RES_HANDLE 12
|
||||
#define VIRGL_COPY_TRANSFER3D_SRC_RES_OFFSET 13
|
||||
/* Second bit of this dword is used to identify the direction
|
||||
* 1 << 1 means transfer from host. 0 << 1 means transfer to host.
|
||||
*/
|
||||
#define VIRGL_COPY_TRANSFER3D_SYNCHRONIZED 14
|
||||
|
||||
/* set tweak flags */
|
||||
|
||||
Reference in New Issue
Block a user