vkr: init and track gbm_device

Currently we do the below:
1. Open one render node fd per renderer process
2. Track gbm_device pointer per vkr_physical_device

The main reason is that the fallback path requiring the gbm_device
does not use drm render node for physical device.

Later we might:
1. Figure out render nodes for different physical devices
2. Open render node and create gbm_device per vkr_physical_device

Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
macos/master
Yiwei Zhang 3 years ago
parent bb4186fc7b
commit c653aa735d
  1. 28
      src/venus/vkr_physical_device.c
  2. 3
      src/venus/vkr_physical_device.h

@ -7,11 +7,36 @@
#include "venus-protocol/vn_protocol_renderer_device.h"
#include "venus-protocol/vn_protocol_renderer_info.h"
#include "vrend_winsys_gbm.h"
#include "vkr_context.h"
#include "vkr_device.h"
#include "vkr_instance.h"
/* TODO open render node and create gbm_device per vkr_physical_device */
static struct gbm_device *vkr_gbm_dev;
static void
vkr_gbm_device_init_once()
{
struct virgl_gbm *vkr_gbm = virgl_gbm_init(-1);
if (!vkr_gbm) {
vkr_log("virgl_gbm_init failed");
exit(-1);
}
vkr_gbm_dev = vkr_gbm->device;
}
static struct gbm_device *
vkr_physical_device_get_gbm_device(UNUSED struct vkr_physical_device *physical_dev)
{
static once_flag gbm_once_flag = ONCE_FLAG_INIT;
call_once(&gbm_once_flag, vkr_gbm_device_init_once);
return vkr_gbm_dev;
}
void
vkr_physical_device_destroy(struct vkr_context *ctx,
struct vkr_physical_device *physical_dev)
@ -120,6 +145,9 @@ vkr_physical_device_init_memory_properties(struct vkr_physical_device *physical_
VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT) &&
(props.externalMemoryProperties.exportFromImportedHandleTypes &
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT);
if (!physical_dev->is_memory_export_supported)
physical_dev->gbm_device = vkr_physical_device_get_gbm_device(physical_dev);
}
static void

@ -8,6 +8,8 @@
#include "vkr_common.h"
struct gbm_device;
struct vkr_physical_device {
struct vkr_object base;
@ -24,6 +26,7 @@ struct vkr_physical_device {
VkPhysicalDeviceMemoryProperties memory_properties;
bool is_memory_export_supported;
struct gbm_device *gbm_device;
struct list_head devices;
};

Loading…
Cancel
Save