loader: Add env var to disable inst ext filter
authorMark Young <marky@lunarg.com>
Fri, 10 Feb 2017 18:19:02 +0000 (11:19 -0700)
committerMark Young <marky@lunarg.com>
Fri, 10 Feb 2017 18:19:02 +0000 (11:19 -0700)
Add an environmental variable to disable the instance extension
filtering.  Simply defining VK_LOADER_DISABLE_INST_EXT_FILTER to
a non-zero number will disable the functionality.

Change-Id: I953814b49e87289a35f154755521d5433474c920

loader/loader.c

index b6adbb1..3d7180c 100644 (file)
@@ -1238,9 +1238,18 @@ VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance
                                                    struct loader_extension_list *inst_exts) {
     struct loader_extension_list icd_exts;
     VkResult res = VK_SUCCESS;
+    char *env_value;
+    bool filter_extensions = true;
 
     loader_log(inst, VK_DEBUG_REPORT_DEBUG_BIT_EXT, 0, "Build ICD instance extension list");
 
+    // Check if a user wants to disable the instance extension filtering behavior
+    env_value = loader_getenv("VK_LOADER_DISABLE_INST_EXT_FILTER", inst);
+    if (NULL != env_value && atoi(env_value) != 0) {
+        filter_extensions = false;
+    }
+    loader_free_getenv(env_value, inst);
+
     // traverse scanned icd list adding non-duplicate extensions to the list
     for (uint32_t i = 0; i < icd_tramp_list->count; i++) {
         res = loader_init_generic_list(inst, (struct loader_generic_list *)&icd_exts, sizeof(VkExtensionProperties));
@@ -1250,24 +1259,26 @@ VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance
         res = loader_add_instance_extensions(inst, icd_tramp_list->scanned_list[i].EnumerateInstanceExtensionProperties,
                                              icd_tramp_list->scanned_list[i].lib_name, &icd_exts);
         if (VK_SUCCESS == res) {
-            // Remove any extensions not recognized by the loader
-            for (int32_t j = 0; j < (int32_t)icd_exts.count; j++) {
-                // See if the extension is in the list of supported extensions
-                bool found = false;
-                for (uint32_t k = 0; LOADER_INSTANCE_EXTENSIONS[k] != NULL; k++) {
-                    if (strcmp(icd_exts.list[j].extensionName, LOADER_INSTANCE_EXTENSIONS[k]) == 0) {
-                        found = true;
-                        break;
+            if (filter_extensions) {
+                // Remove any extensions not recognized by the loader
+                for (int32_t j = 0; j < (int32_t)icd_exts.count; j++) {
+                    // See if the extension is in the list of supported extensions
+                    bool found = false;
+                    for (uint32_t k = 0; LOADER_INSTANCE_EXTENSIONS[k] != NULL; k++) {
+                        if (strcmp(icd_exts.list[j].extensionName, LOADER_INSTANCE_EXTENSIONS[k]) == 0) {
+                            found = true;
+                            break;
+                        }
                     }
-                }
 
-                // If it isn't in the list, remove it
-                if (!found) {
-                    for (uint32_t k = j + 1; k < icd_exts.count; k++) {
-                        icd_exts.list[k - 1] = icd_exts.list[k];
+                    // If it isn't in the list, remove it
+                    if (!found) {
+                        for (uint32_t k = j + 1; k < icd_exts.count; k++) {
+                            icd_exts.list[k - 1] = icd_exts.list[k];
+                        }
+                        --icd_exts.count;
+                        --j;
                     }
-                    --icd_exts.count;
-                    --j;
                 }
             }