Mesa (master): anv: Re-arrange physical_device_init

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 20 22:25:53 UTC 2020


Module: Mesa
Branch: master
Commit: e963e151d83072e97ddb1cf7b729bc404f7737e8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e963e151d83072e97ddb1cf7b729bc404f7737e8

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Fri Jan 17 23:48:12 2020 -0600

anv: Re-arrange physical_device_init

This commit simply moves fetching the device info and checking if ANV
supports the device a bit higher up.  This way we fail earlier and it'll
make error checking easier in the next commit.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3461>

---

 src/intel/vulkan/anv_device.c | 50 +++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index b0ff56aa801..509f92a5034 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -345,44 +345,48 @@ anv_physical_device_init(struct anv_physical_device *device,
    if (fd < 0)
       return vk_error(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);
-
-   if (!gen_get_device_info_from_fd(fd, &device->info)) {
+   struct gen_device_info devinfo;
+   if (!gen_get_device_info_from_fd(fd, &devinfo)) {
       result = vk_error(VK_ERROR_INCOMPATIBLE_DRIVER);
       goto fail;
    }
-   device->no_hw = device->info.no_hw;
-
-   if (getenv("INTEL_NO_HW") != NULL)
-      device->no_hw = true;
-
-   device->pci_info.domain = drm_device->businfo.pci->domain;
-   device->pci_info.bus = drm_device->businfo.pci->bus;
-   device->pci_info.device = drm_device->businfo.pci->dev;
-   device->pci_info.function = drm_device->businfo.pci->func;
 
-   device->name = gen_get_device_name(device->info.chipset_id);
+   const char *device_name = gen_get_device_name(devinfo.chipset_id);
 
-   if (device->info.is_haswell) {
+   if (devinfo.is_haswell) {
       intel_logw("Haswell Vulkan support is incomplete");
-   } else if (device->info.gen == 7 && !device->info.is_baytrail) {
+   } else if (devinfo.gen == 7 && !devinfo.is_baytrail) {
       intel_logw("Ivy Bridge Vulkan support is incomplete");
-   } else if (device->info.gen == 7 && device->info.is_baytrail) {
+   } else if (devinfo.gen == 7 && devinfo.is_baytrail) {
       intel_logw("Bay Trail Vulkan support is incomplete");
-   } else if (device->info.gen >= 8 && device->info.gen <= 11) {
+   } else if (devinfo.gen >= 8 && devinfo.gen <= 11) {
       /* Gen8-11 fully supported */
-   } else if (device->info.gen == 12) {
+   } else if (devinfo.gen == 12) {
       intel_logw("Vulkan is not yet fully supported on gen12");
    } else {
       result = vk_errorfi(instance, NULL, VK_ERROR_INCOMPATIBLE_DRIVER,
-                          "Vulkan not yet supported on %s", device->name);
+                          "Vulkan not yet supported on %s", device_name);
       goto fail;
    }
 
+   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);
+
+   device->info = devinfo;
+   device->name = device_name;
+
+   device->no_hw = device->info.no_hw;
+   if (getenv("INTEL_NO_HW") != NULL)
+      device->no_hw = true;
+
+   device->pci_info.domain = drm_device->businfo.pci->domain;
+   device->pci_info.bus = drm_device->businfo.pci->bus;
+   device->pci_info.device = drm_device->businfo.pci->dev;
+   device->pci_info.function = drm_device->businfo.pci->func;
+
    device->cmd_parser_version = -1;
    if (device->info.gen == 7) {
       device->cmd_parser_version =



More information about the mesa-commit mailing list