v3dv: pretend to initialize a physical device
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>
diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c
index a1b70a3..772d961 100644
--- a/src/broadcom/vulkan/v3dv_device.c
+++ b/src/broadcom/vulkan/v3dv_device.c
@@ -22,6 +22,7 @@
*/
#include <assert.h>
+#include <fcntl.h>
#include <stdbool.h>
#include <string.h>
#include <sys/mman.h>
@@ -205,7 +206,9 @@
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 @@
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;
}
diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h
index 653652f..0d70414 100644
--- a/src/broadcom/vulkan/v3dv_private.h
+++ b/src/broadcom/vulkan/v3dv_private.h
@@ -85,6 +85,12 @@
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 */
};