From dab339b07e44636a2879d8e99a97f96df7a4a3ac Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 20 Aug 2020 13:06:24 -0700 Subject: [PATCH] virgl: update headers from virglrenderer Signed-off-by: Chia-I Wu Reviewed-by: Ryan Neph Reviewed-by: Gert Wollny Part-of: --- src/virtio/virtio-gpu/venus_hw.h | 38 +++++++ src/virtio/virtio-gpu/virglrenderer_hw.h | 3 + src/virtio/vtest/vtest_protocol.h | 124 ++++++++++++++++++++++- 3 files changed, 162 insertions(+), 3 deletions(-) create mode 100644 src/virtio/virtio-gpu/venus_hw.h diff --git a/src/virtio/virtio-gpu/venus_hw.h b/src/virtio/virtio-gpu/venus_hw.h new file mode 100644 index 00000000000..076e616af41 --- /dev/null +++ b/src/virtio/virtio-gpu/venus_hw.h @@ -0,0 +1,38 @@ +/* + * Copyright 2020 Chromium + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef VENUS_HW_H +#define VENUS_HW_H + +#include + +#ifdef VIRGL_RENDERER_UNSTABLE_APIS +struct virgl_renderer_capset_venus { + uint32_t wire_format_version; + uint32_t vk_xml_version; + uint32_t vk_ext_command_serialization_spec_version; + uint32_t vk_mesa_venus_protocol_spec_version; +}; +#endif + +#endif /* VENUS_HW_H */ diff --git a/src/virtio/virtio-gpu/virglrenderer_hw.h b/src/virtio/virtio-gpu/virglrenderer_hw.h index 65f98cb24f7..0490d777c0a 100644 --- a/src/virtio/virtio-gpu/virglrenderer_hw.h +++ b/src/virtio/virtio-gpu/virglrenderer_hw.h @@ -24,12 +24,15 @@ #ifndef VIRGLRENDERER_HW_H #define VIRGLRENDERER_HW_H +#include "venus_hw.h" #include "virgl_hw.h" #ifdef VIRGL_RENDERER_UNSTABLE_APIS enum virgl_renderer_capset { VIRGL_RENDERER_CAPSET_VIRGL = 1, VIRGL_RENDERER_CAPSET_VIRGL2 = 2, + /* 3 is reserved for gfxstream */ + VIRGL_RENDERER_CAPSET_VENUS = 4, }; #endif diff --git a/src/virtio/vtest/vtest_protocol.h b/src/virtio/vtest/vtest_protocol.h index 68090f21ff5..f31b8e47c31 100644 --- a/src/virtio/vtest/vtest_protocol.h +++ b/src/virtio/vtest/vtest_protocol.h @@ -26,7 +26,12 @@ #define VTEST_PROTOCOL #define VTEST_DEFAULT_SOCKET_NAME "/tmp/.virgl_test" + +#ifdef VIRGL_RENDERER_UNSTABLE_APIS +#define VTEST_PROTOCOL_VERSION 3 +#else #define VTEST_PROTOCOL_VERSION 2 +#endif /* 32-bit length field */ /* 32-bit cmd field */ @@ -60,12 +65,27 @@ #define VCMD_PROTOCOL_VERSION 11 +/* since protocol version 2 */ #define VCMD_RESOURCE_CREATE2 12 #define VCMD_TRANSFER_GET2 13 #define VCMD_TRANSFER_PUT2 14 +#ifdef VIRGL_RENDERER_UNSTABLE_APIS +/* since protocol version 3 */ +#define VCMD_GET_PARAM 15 +#define VCMD_GET_CAPSET 16 +#define VCMD_CONTEXT_INIT 17 +#define VCMD_RESOURCE_CREATE_BLOB 18 +#define VCMD_SYNC_CREATE 19 +#define VCMD_SYNC_UNREF 20 +#define VCMD_SYNC_READ 21 +#define VCMD_SYNC_WRITE 22 +#define VCMD_SYNC_WAIT 23 +#define VCMD_SUBMIT_CMD2 24 +#endif /* VIRGL_RENDERER_UNSTABLE_APIS */ + #define VCMD_RES_CREATE_SIZE 10 -#define VCMD_RES_CREATE_RES_HANDLE 0 +#define VCMD_RES_CREATE_RES_HANDLE 0 /* must be 0 since protocol version 3 */ #define VCMD_RES_CREATE_TARGET 1 #define VCMD_RES_CREATE_FORMAT 2 #define VCMD_RES_CREATE_BIND 3 @@ -75,9 +95,10 @@ #define VCMD_RES_CREATE_ARRAY_SIZE 7 #define VCMD_RES_CREATE_LAST_LEVEL 8 #define VCMD_RES_CREATE_NR_SAMPLES 9 +/* resp res_id since protocol version 3 */ #define VCMD_RES_CREATE2_SIZE 11 -#define VCMD_RES_CREATE2_RES_HANDLE 0 +#define VCMD_RES_CREATE2_RES_HANDLE 0 /* must be 0 since protocol version 3 */ #define VCMD_RES_CREATE2_TARGET 1 #define VCMD_RES_CREATE2_FORMAT 2 #define VCMD_RES_CREATE2_BIND 3 @@ -88,6 +109,7 @@ #define VCMD_RES_CREATE2_LAST_LEVEL 8 #define VCMD_RES_CREATE2_NR_SAMPLES 9 #define VCMD_RES_CREATE2_DATA_SIZE 10 +/* resp res_id since protocol version 3, and fd if data_size >0 */ #define VCMD_RES_UNREF_SIZE 1 #define VCMD_RES_UNREF_RES_HANDLE 0 @@ -128,4 +150,100 @@ #define VCMD_PROTOCOL_VERSION_SIZE 1 #define VCMD_PROTOCOL_VERSION_VERSION 0 -#endif +#ifdef VIRGL_RENDERER_UNSTABLE_APIS + +enum vcmd_param { + VCMD_PARAM_MAX_SYNC_QUEUE_COUNT = 1, +}; +#define VCMD_GET_PARAM_SIZE 1 +#define VCMD_GET_PARAM_PARAM 0 +/* resp param validity and value */ + +#define VCMD_GET_CAPSET_SIZE 2 +#define VCMD_GET_CAPSET_ID 0 +#define VCMD_GET_CAPSET_VERSION 1 +/* resp capset validity and contents */ + +#define VCMD_CONTEXT_INIT_SIZE 1 +#define VCMD_CONTEXT_INIT_CAPSET_ID 0 + +enum vcmd_blob_type { + VCMD_BLOB_TYPE_GUEST = 1, + VCMD_BLOB_TYPE_HOST3D = 2, + VCMD_BLOB_TYPE_HOST3D_GUEST = 3, +}; + +enum vcmd_blob_flag { + VCMD_BLOB_FLAG_MAPPABLE = 1 << 0, + VCMD_BLOB_FLAG_SHAREABLE = 1 << 1, + VCMD_BLOB_FLAG_CROSS_DEVICE = 1 << 2, +}; + +#define VCMD_RES_CREATE_BLOB_SIZE 6 +#define VCMD_RES_CREATE_BLOB_TYPE 0 +#define VCMD_RES_CREATE_BLOB_FLAGS 1 +#define VCMD_RES_CREATE_BLOB_SIZE_LO 2 +#define VCMD_RES_CREATE_BLOB_SIZE_HI 3 +#define VCMD_RES_CREATE_BLOB_ID_LO 4 +#define VCMD_RES_CREATE_BLOB_ID_HI 5 +/* resp res_id and mmap'able fd */ + +#define VCMD_SYNC_CREATE_SIZE 2 +#define VCMD_SYNC_CREATE_VALUE_LO 0 +#define VCMD_SYNC_CREATE_VALUE_HI 1 +/* resp sync id */ + +#define VCMD_SYNC_UNREF_SIZE 1 +#define VCMD_SYNC_UNREF_ID 0 + +#define VCMD_SYNC_READ_SIZE 1 +#define VCMD_SYNC_READ_ID 0 +/* resp sync value */ + +#define VCMD_SYNC_WRITE_SIZE 3 +#define VCMD_SYNC_WRITE_ID 0 +#define VCMD_SYNC_WRITE_VALUE_LO 1 +#define VCMD_SYNC_WRITE_VALUE_HI 2 + +enum vcmd_sync_wait_flag { + VCMD_SYNC_WAIT_FLAG_ANY = 1 << 0, +}; +#define VCMD_SYNC_WAIT_SIZE(count) (2 + 3 * count) +#define VCMD_SYNC_WAIT_FLAGS 0 +#define VCMD_SYNC_WAIT_TIMEOUT 1 +#define VCMD_SYNC_WAIT_ID(n) (2 + 3 * (n) + 0) +#define VCMD_SYNC_WAIT_VALUE_LO(n) (2 + 3 * (n) + 1) +#define VCMD_SYNC_WAIT_VALUE_HI(n) (2 + 3 * (n) + 2) +/* resp poll'able fd */ + +enum vcmd_submit_cmd2_flag { + VCMD_SUBMIT_CMD2_FLAG_SYNC_QUEUE = 1 << 0, +}; + +struct vcmd_submit_cmd2_batch { + uint32_t flags; + + uint32_t cmd_offset; + uint32_t cmd_size; + + /* sync_count pairs of (id, val) starting at sync_offset */ + uint32_t sync_offset; + uint32_t sync_count; + + /* ignored unless VCMD_SUBMIT_CMD2_FLAG_SYNC_QUEUE is set */ + uint32_t sync_queue_index; + uint64_t sync_queue_id; +}; +#define VCMD_SUBMIT_CMD2_BATCH_COUNT 0 +#define VCMD_SUBMIT_CMD2_BATCH_FLAGS(n) (1 + 8 * (n) + 0) +#define VCMD_SUBMIT_CMD2_BATCH_CMD_OFFSET(n) (1 + 8 * (n) + 1) +#define VCMD_SUBMIT_CMD2_BATCH_CMD_SIZE(n) (1 + 8 * (n) + 2) +#define VCMD_SUBMIT_CMD2_BATCH_SYNC_OFFSET(n) (1 + 8 * (n) + 3) +#define VCMD_SUBMIT_CMD2_BATCH_SYNC_COUNT(n) (1 + 8 * (n) + 4) +#define VCMD_SUBMIT_CMD2_BATCH_SYNC_QUEUE_INDEX(n) (1 + 8 * (n) + 5) +#define VCMD_SUBMIT_CMD2_BATCH_SYNC_QUEUE_ID_LO(n) (1 + 8 * (n) + 6) +#define VCMD_SUBMIT_CMD2_BATCH_SYNC_QUEUE_ID_HI(n) (1 + 8 * (n) + 7) + +#endif /* VIRGL_RENDERER_UNSTABLE_APIS */ + +#endif /* VTEST_PROTOCOL */