From 488c82568dc7975bcd66d7f958880fa85ec124cd Mon Sep 17 00:00:00 2001 From: Andrii Pauk Date: Fri, 26 Nov 2021 10:19:05 +0200 Subject: [PATCH] vkr: Add support of GUEST_VRAM type of mem blob This is dedicated heap memory allocations approach. This type of blob should be used in the following way: 1) Guest virtio-gpu driver on start checks for dedicated memory region. 2) On create_blob drm ioctl guest driver reserves chunk of required memory and send it to host using sg list. Heap is managed on guest. 3) Device creates dmabuf fd from this sg entry and sends it to virglrenderer on create_blob virtio-gpu command. Blob is created using virgl_renderer_resource_import_blob call. 4) On next vkAllocateMemory call from mesa, virglrenderer will allocate vk memory handle from this dmabuf fd. It will receive resource id in VK_STRUCTURE_TYPE_IMPORT_MEMORY_RESOURCE_INFO_MESA vkAllocateMemory structure. The flow is opposite to the way it's done for HOST_3D types of blob, where vkAllocateMemory is called first, vk memory is allocated from random host place. Then create_blob is called, where dmabuf fd is exported from VkDeviceMemory. Signed-off-by: Andrii Pauk Reviewed-by: Chia-I Wu --- src/virglrenderer.c | 1 + src/virglrenderer.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/virglrenderer.c b/src/virglrenderer.c index 2f65f24..a0d173a 100644 --- a/src/virglrenderer.c +++ b/src/virglrenderer.c @@ -1044,6 +1044,7 @@ virgl_renderer_resource_import_blob(const struct virgl_renderer_resource_import_ switch (args->blob_mem) { case VIRGL_RENDERER_BLOB_MEM_HOST3D: + case VIRGL_RENDERER_BLOB_MEM_GUEST_VRAM: break; default: return -EINVAL; diff --git a/src/virglrenderer.h b/src/virglrenderer.h index 223aed5..c6988af 100644 --- a/src/virglrenderer.h +++ b/src/virglrenderer.h @@ -298,6 +298,7 @@ VIRGL_EXPORT int virgl_renderer_context_create_with_flags(uint32_t ctx_id, #define VIRGL_RENDERER_BLOB_MEM_GUEST 0x0001 #define VIRGL_RENDERER_BLOB_MEM_HOST3D 0x0002 #define VIRGL_RENDERER_BLOB_MEM_HOST3D_GUEST 0x0003 +#define VIRGL_RENDERER_BLOB_MEM_GUEST_VRAM 0x0004 #define VIRGL_RENDERER_BLOB_FLAG_USE_MAPPABLE 0x0001 #define VIRGL_RENDERER_BLOB_FLAG_USE_SHAREABLE 0x0002