anv: Report 0 physical devices when not on Broadwell or Ivy Bridge
authorJason Ekstrand <jason.ekstrand@intel.com>
Mon, 2 Nov 2015 20:14:37 +0000 (12:14 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Mon, 2 Nov 2015 20:14:37 +0000 (12:14 -0800)
Right now, Broadweel and Ivy Bridge are the only supported platforms.
Hopefully, this reduces the chances that someone will try the driver on
unsupported hardware and be confused that it doesn't work.

src/vulkan/anv_device.c
src/vulkan/anv_private.h

index 9def97801c258c9ce82ea7166bcf95c95a15260e..3ab2a245de4607bcf2378578bcc783f53d4e3144 100644 (file)
@@ -80,7 +80,18 @@ anv_physical_device_init(struct anv_physical_device *device,
                          "failed to get device info");
       goto fail;
    }
-   
+
+   if (device->info->gen == 7 &&
+       !device->info->is_haswell && !device->info->is_baytrail) {
+      fprintf(stderr, "WARNING: Ivy Bridge Vulkan support is incomplete");
+   } else if (device->info->gen == 8 && !device->info->is_cherryview) {
+      /* Briadwell is as fully supported as anything */
+   } else {
+      result = vk_errorf(VK_UNSUPPORTED,
+                         "Vulkan not yet supported on %s", device->name);
+      goto fail;
+   }
+
    if (anv_gem_get_aperture(fd, &device->aperture_size) == -1) {
       result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
                          "failed to get aperture size: %m");
@@ -206,7 +217,7 @@ VkResult anv_CreateInstance(
    instance->pfnAlloc = alloc_callbacks->pfnAlloc;
    instance->pfnFree = alloc_callbacks->pfnFree;
    instance->apiVersion = pCreateInfo->pAppInfo->apiVersion;
-   instance->physicalDeviceCount = 0;
+   instance->physicalDeviceCount = -1;
 
    _mesa_locale_init();
 
@@ -271,13 +282,16 @@ VkResult anv_EnumeratePhysicalDevices(
    ANV_FROM_HANDLE(anv_instance, instance, _instance);
    VkResult result;
 
-   if (instance->physicalDeviceCount == 0) {
+   if (instance->physicalDeviceCount < 0) {
       result = anv_physical_device_init(&instance->physicalDevice,
                                         instance, "/dev/dri/renderD128");
-      if (result != VK_SUCCESS)
+      if (result == VK_UNSUPPORTED) {
+         instance->physicalDeviceCount = 0;
+      } else if (result == VK_SUCCESS) {
+         instance->physicalDeviceCount = 1;
+      } else {
          return result;
-
-      instance->physicalDeviceCount = 1;
+      }
    }
 
    /* pPhysicalDeviceCount is an out parameter if pPhysicalDevices is NULL;
index ac3d18fdcbeeec4e429fb2b1e1f05ec2fcfb471b..8e921afb5fbbf605db57cfcc364db2ef9c637c59 100644 (file)
@@ -437,7 +437,7 @@ struct anv_instance {
     PFN_vkAllocFunction                         pfnAlloc;
     PFN_vkFreeFunction                          pfnFree;
     uint32_t                                    apiVersion;
-    uint32_t                                    physicalDeviceCount;
+    int                                         physicalDeviceCount;
     struct anv_physical_device                  physicalDevice;
 
     struct anv_wsi_implementation *             wsi_impl[VK_PLATFORM_NUM_KHR];