From: Jason Ekstrand Date: Mon, 2 Nov 2015 20:14:37 +0000 (-0800) Subject: anv: Report 0 physical devices when not on Broadwell or Ivy Bridge X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=584f9d444238baaaacc138c81c46c88af98438f9;p=mesa.git anv: Report 0 physical devices when not on Broadwell or Ivy Bridge 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. --- diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index 9def97801c2..3ab2a245de4 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -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; diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index ac3d18fdcbe..8e921afb5fb 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -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];