<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 10, 2019 at 4:42 AM Gerd Hoffmann <<a href="mailto:kraxel@redhat.com" target="_blank">kraxel@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Add new command VIRTIO_GPU_CMD_RESOURCE_CREATE_V2 to create resources.<br>
It adds (a) support planar resources and (b) returns stride and size of<br>
the resource planes. The later will be needed in case we support<br>
mapping host resources into the guest some day.</blockquote><div><br></div><div><div>Thanks for looking into this! Definitely need something like this for sharing buffers between display, gpu and multimedia units. Userspace implementation? Not sure if this is required for kernel api commits or not.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Signed-off-by: Gerd Hoffmann <<a href="mailto:kraxel@redhat.com" target="_blank">kraxel@redhat.com</a>><br>
---<br>
include/uapi/linux/virtio_gpu.h | 31 +++++++++++++++++++++++++++++++<br>
1 file changed, 31 insertions(+)<br>
<br>
diff --git a/include/uapi/linux/virtio_gpu.h b/include/uapi/linux/virtio_gpu.h<br>
index 732bb16a39f8..00010315e500 100644<br>
--- a/include/uapi/linux/virtio_gpu.h<br>
+++ b/include/uapi/linux/virtio_gpu.h<br>
@@ -58,6 +58,11 @@<br>
*/<br>
#define VIRTIO_GPU_F_MEMORY 2<br>
<br>
+/*<br>
+ * VIRTIO_GPU_CMD_RESOURCE_CREATE_V2 command<br>
+ */<br>
+#define VIRTIO_GPU_F_RESSOURCE_V2 3<br>
+<br>
enum virtio_gpu_ctrl_type {<br>
VIRTIO_GPU_UNDEFINED = 0,<br>
<br>
@@ -76,6 +81,7 @@ enum virtio_gpu_ctrl_type {<br>
VIRTIO_GPU_CMD_MEMORY_CREATE,<br>
VIRTIO_GPU_CMD_MEMORY_UNREF,<br>
VIRTIO_GPU_CMD_RESOURCE_ATTACH_MEMORY,<br>
+ VIRTIO_GPU_CMD_RESOURCE_CREATE_V2,<br>
<br>
/* 3d commands */<br>
VIRTIO_GPU_CMD_CTX_CREATE = 0x0200,<br>
@@ -97,6 +103,7 @@ enum virtio_gpu_ctrl_type {<br>
VIRTIO_GPU_RESP_OK_CAPSET_INFO,<br>
VIRTIO_GPU_RESP_OK_CAPSET,<br>
VIRTIO_GPU_RESP_OK_EDID,<br>
+ VIRTIO_GPU_RESP_OK_RESOURCE_INFO,<br>
<br>
/* error responses */<br>
VIRTIO_GPU_RESP_ERR_UNSPEC = 0x1200,<br>
@@ -308,6 +315,30 @@ struct virtio_gpu_cmd_resource_attach_memory {<br>
__le64 offset[4];<br>
};<br>
<br>
+/* VIRTIO_GPU_CMD_RESOURCE_CREATE_V2 */<br>
+struct virtio_gpu_cmd_resource_create_v2 {<br>
+ struct virtio_gpu_ctrl_hdr hdr;<br>
+ __le32 resource_id;<br>
+ __le32 format;<br>
+ __le32 width;<br>
+ __le32 height;<br>
+ /* 3d only */<br>
+ __le32 target;<br>
+ __le32 bind;<br>
+ __le32 depth;<br>
+ __le32 array_size;<br>
+ __le32 last_level;<br>
+ __le32 nr_samples;<br>
+ __le32 flags;<br>
+}; </blockquote><div><br></div><div>I assume this is always backed by some host side allocation, without any guest side pages associated with it?<br></div><div><div><br></div><div>If so, do we want the option for the guest allocate? We're basing this off gbm, which will do the host side allocation for us. But userspace libraries could change (maybe something like the proposed Unix Device Memory Allocator takes off).</div><div>The host, in theory, could return the the metadata required about an allocation to virtio-gpu to use guest pages. With guest allocation we can be more like Vulkan in that regard (see vkGetImageMemoryRequirements, followed by vkAllocateMemory), and use udmabuf to share. But not all hosts can support that, so maybe having an API for both methods would be useful. </div><div></div></div><div> </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+/* VIRTIO_GPU_RESP_OK_RESOURCE_INFO */<br>
+struct virtio_gpu_resp_resource_info {<br>
+ struct virtio_gpu_ctrl_hdr hdr;<br>
+ __le32 stride[4];<br>
+ __le32 size[4];<br>
+};<br></blockquote><div><br></div><div>offsets[4] needed too<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
#define VIRTIO_GPU_CAPSET_VIRGL 1<br>
#define VIRTIO_GPU_CAPSET_VIRGL2 2<br>
<br>
-- <br>
2.18.1<br>
<br>
</blockquote></div></div></div></div>