From fc52dc8d7dc0676593ba922045befeda9b6f3769 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Thu, 28 Nov 2019 09:48:29 +0100 Subject: [PATCH] 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: --- src/broadcom/vulkan/v3dv_device.c | 25 +++++++++++++++++++++++-- src/broadcom/vulkan/v3dv_private.h | 6 ++++++ 2 files changed, 29 insertions(+), 2 deletions(-) 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 +#include #include #include #include @@ -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; } 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_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 */ }; -- 2.7.4