v3dv: pretend to initialize a physical device
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 28 Nov 2019 08:48:29 +0000 (09:48 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 13 Oct 2020 21:21:25 +0000 (21:21 +0000)
Just to keep us moving forward for now. Later, we should probably
revisit this after running on real hardware or after enabling
the simulator.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>

src/broadcom/vulkan/v3dv_device.c
src/broadcom/vulkan/v3dv_private.h

index a1b70a3..772d961 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include <assert.h>
+#include <fcntl.h>
 #include <stdbool.h>
 #include <string.h>
 #include <sys/mman.h>
@@ -205,7 +206,9 @@ v3dv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
 static void
 physical_device_finish(struct v3dv_physical_device *device)
 {
-   /* FIXME: stub */
+   close(device->local_fd);
+   if (device->master_fd >= 0)
+      close(device->master_fd);
 }
 
 void
@@ -240,7 +243,25 @@ physical_device_init(struct v3dv_physical_device *device,
                      struct v3dv_instance *instance,
                      drmDevicePtr drm_device)
 {
-   /* FIXME stub */
+   const char *path = drm_device->nodes[DRM_NODE_RENDER];
+   int32_t fd = open(path, O_RDWR | O_CLOEXEC);
+   if (fd < 0)
+      return vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
+
+   device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
+   device->instance = instance;
+
+   assert(strlen(path) < ARRAY_SIZE(device->path));
+   snprintf(device->path, ARRAY_SIZE(device->path), "%s", path);
+
+   /* FIXME: we will have to do plenty more here */
+   device->name = "Broadcom Video Core VI";
+   device->local_fd = fd;
+   device->master_fd = -1;
+
+   uint8_t zeroes[VK_UUID_SIZE] = { 0 };
+   memcpy(device->pipeline_cache_uuid, zeroes, VK_UUID_SIZE);
+
    return VK_SUCCESS;
 }
 
index 653652f..0d70414 100644 (file)
@@ -85,6 +85,12 @@ struct v3dv_physical_device {
    struct v3dv_device_extension_table supported_extensions;
    struct v3dv_physical_device_dispatch_table dispatch;
 
+   char path[20];
+   const char *name;
+   int32_t local_fd;
+   int32_t master_fd;
+   uint8_t pipeline_cache_uuid[VK_UUID_SIZE];
+
    /* FIXME: stub */
 };