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 <Andrii.Pauk@opensynergy.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
macos/master
Andrii Pauk 3 years ago
parent da9effc518
commit 488c82568d
  1. 1
      src/virglrenderer.c
  2. 1
      src/virglrenderer.h

@ -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;

@ -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

Loading…
Cancel
Save