radv: Add VkPhysicalDeviceIDProperties support.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Tue, 23 May 2017 07:22:09 +0000 (09:22 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 5 Jun 2017 00:26:43 +0000 (02:26 +0200)
Signed-off-by: Bas Nieuwenhuizen <basni@google.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_device.c
src/amd/vulkan/radv_private.h

index 2d89e8635e73ff99322b8052dfd4a273bab29702..9a44f657a3cac00bec8f362103be97cd44e0b881 100644 (file)
@@ -61,6 +61,15 @@ radv_device_get_cache_uuid(enum radeon_family family, void *uuid)
        return 0;
 }
 
+static void
+radv_get_device_uuid(drmDevicePtr device, void *uuid) {
+       memset(uuid, 0, VK_UUID_SIZE);
+       memcpy((char*)uuid + 0, &device->businfo.pci->domain, 2);
+       memcpy((char*)uuid + 2, &device->businfo.pci->bus, 1);
+       memcpy((char*)uuid + 3, &device->businfo.pci->dev, 1);
+       memcpy((char*)uuid + 4, &device->businfo.pci->func, 1);
+}
+
 static const VkExtensionProperties instance_extensions[] = {
        {
                .extensionName = VK_KHR_SURFACE_EXTENSION_NAME,
@@ -190,8 +199,9 @@ is_extension_enabled(const VkExtensionProperties *extensions,
 static VkResult
 radv_physical_device_init(struct radv_physical_device *device,
                          struct radv_instance *instance,
-                         const char *path)
+                         drmDevicePtr drm_device)
 {
+       const char *path = drm_device->nodes[DRM_NODE_RENDER];
        VkResult result;
        drmVersionPtr version;
        int fd;
@@ -251,6 +261,8 @@ radv_physical_device_init(struct radv_physical_device *device,
        fprintf(stderr, "WARNING: radv is not a conformant vulkan implementation, testing use only.\n");
        device->name = device->rad_info.name;
 
+       radv_get_device_uuid(drm_device, device->device_uuid);
+
        return VK_SUCCESS;
 
 fail:
@@ -413,7 +425,7 @@ radv_enumerate_devices(struct radv_instance *instance)
                        result = radv_physical_device_init(instance->physicalDevices +
                                                           instance->physicalDeviceCount,
                                                           instance,
-                                                          devices[i]->nodes[DRM_NODE_RENDER]);
+                                                          devices[i]);
                        if (result == VK_SUCCESS)
                                ++instance->physicalDeviceCount;
                        else if (result != VK_ERROR_INCOMPATIBLE_DRIVER)
@@ -689,6 +701,7 @@ void radv_GetPhysicalDeviceProperties2KHR(
        VkPhysicalDevice                            physicalDevice,
        VkPhysicalDeviceProperties2KHR             *pProperties)
 {
+       RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
        radv_GetPhysicalDeviceProperties(physicalDevice, &pProperties->properties);
 
        vk_foreach_struct(ext, pProperties->pNext) {
@@ -699,6 +712,13 @@ void radv_GetPhysicalDeviceProperties2KHR(
                        properties->maxPushDescriptors = MAX_PUSH_DESCRIPTORS;
                        break;
                }
+               case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHX: {
+                       VkPhysicalDeviceIDPropertiesKHX *properties = (VkPhysicalDeviceIDPropertiesKHX*)ext;
+                       radv_device_get_cache_uuid(0, properties->driverUUID);
+                       memcpy(properties->deviceUUID, pdevice->device_uuid, VK_UUID_SIZE);
+                       properties->deviceLUIDValid = false;
+                       break;
+               }
                default:
                        break;
                }
index f3a3b3c6ba5f5d98ac0fe8bf47a96ab35ac926c8..d64f8017e1a2a6244208f42245a8914aed7020d7 100644 (file)
@@ -266,6 +266,7 @@ struct radv_physical_device {
        char                                        path[20];
        const char *                                name;
        uint8_t                                     uuid[VK_UUID_SIZE];
+       uint8_t                                     device_uuid[VK_UUID_SIZE];
 
        int local_fd;
        struct wsi_device                       wsi_device;