aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCourtney Goeltzenleuchter <courtney@LunarG.com>2015-07-06 09:06:34 -0600
committerCourtney Goeltzenleuchter <courtney@LunarG.com>2015-07-07 17:57:48 -0600
commitac439421f765069c1132ff3aefc6fba411995d34 (patch)
tree5b17e41a3397421760407701a803035fbdb3b6fe
parente9157aacaf546a2c16f0dc5bf07be52d0e8d4a44 (diff)
downloadusermoji-ac439421f765069c1132ff3aefc6fba411995d34.tar.xz
loader: Add error return to detect invalid layers
The code already checks that a named layer can be found on the system, but that result was not being returned to the caller. That is now plumbed so that CreateInstance and CreateDevice can return an VK_ERROR_INVALID_LAYER if a named layer cannot be found.
-rw-r--r--loader/loader.c47
-rw-r--r--loader/loader.h2
2 files changed, 35 insertions, 14 deletions
diff --git a/loader/loader.c b/loader/loader.c
index 43e344b7..0527738b 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -673,24 +673,28 @@ void loader_destroy_ext_list(struct loader_extension_list *ext_info)
* Search the given search_list for any layers in the props list.
* Add these to the output layer_list. Don't add duplicates to the output layer_list.
*/
-static void loader_add_layer_names_to_list(
+static VkResult loader_add_layer_names_to_list(
struct loader_layer_list *output_list,
uint32_t name_count,
const char * const *names,
const struct loader_layer_list *search_list)
{
struct loader_layer_properties *layer_prop;
+ VkResult err = VK_SUCCESS;
for (uint32_t i = 0; i < name_count; i++) {
const char *search_target = names[i];
layer_prop = get_layer_property(search_target, search_list);
if (!layer_prop) {
- loader_log(VK_DBG_REPORT_WARN_BIT, 0, "Unable to find extension %s", search_target);
+ loader_log(VK_DBG_REPORT_ERROR_BIT, 0, "Unable to find layer %s", search_target);
+ err = VK_ERROR_INVALID_LAYER;
continue;
}
loader_add_to_layer_list(output_list, 1, layer_prop);
}
+
+ return err;
}
/*
@@ -1970,16 +1974,18 @@ void loader_deactivate_instance_layers(struct loader_instance *instance)
loader_destroy_layer_list(&instance->activated_layer_list);
}
-void loader_enable_instance_layers(
+VkResult loader_enable_instance_layers(
struct loader_instance *inst,
const VkInstanceCreateInfo *pCreateInfo)
{
+ VkResult err;
+
if (inst == NULL)
- return;
+ return VK_ERROR_UNKNOWN;
if (!loader_init_layer_list(&inst->activated_layer_list)) {
loader_log(VK_DBG_REPORT_ERROR_BIT, 0, "Failed to malloc Instance activated layer list");
- return;
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
}
/* Add any implicit layers first */
@@ -1995,11 +2001,13 @@ void loader_enable_instance_layers(
&loader.global_layer_list);
/* Add layers specified by the application */
- loader_add_layer_names_to_list(
+ err = loader_add_layer_names_to_list(
&inst->activated_layer_list,
pCreateInfo->layerCount,
pCreateInfo->ppEnabledLayerNames,
&loader.global_layer_list);
+
+ return err;
}
uint32_t loader_activate_instance_layers(struct loader_instance *inst)
@@ -2087,13 +2095,15 @@ void loader_activate_instance_layer_extensions(struct loader_instance *inst)
(VkInstance) inst);
}
-static void loader_enable_device_layers(
+static VkResult loader_enable_device_layers(
struct loader_icd *icd,
struct loader_device *dev,
const VkDeviceCreateInfo *pCreateInfo)
{
+ VkResult err;
+
if (dev == NULL)
- return;
+ return VK_ERROR_UNKNOWN;
if (dev->activated_layer_list.list == NULL || dev->activated_layer_list.capacity == 0) {
loader_init_layer_list(&dev->activated_layer_list);
@@ -2101,7 +2111,7 @@ static void loader_enable_device_layers(
if (dev->activated_layer_list.list == NULL) {
loader_log(VK_DBG_REPORT_ERROR_BIT, 0, "Failed to malloc device activated layer list");
- return;
+ return VK_ERROR_OUT_OF_HOST_MEMORY;
}
/* Add any implicit layers first */
@@ -2117,11 +2127,13 @@ static void loader_enable_device_layers(
&icd->layer_properties_cache);
/* Add layers specified by the application */
- loader_add_layer_names_to_list(
+ err = loader_add_layer_names_to_list(
&dev->activated_layer_list,
pCreateInfo->layerCount,
pCreateInfo->ppEnabledLayerNames,
&icd->layer_properties_cache);
+
+ return err;
}
/*
@@ -2221,7 +2233,7 @@ VkResult loader_CreateInstance(
struct loader_instance *ptr_instance = *(struct loader_instance **) pInstance;
struct loader_scanned_icds *scanned_icds;
struct loader_icd *icd;
- VkResult res;
+ VkResult res = VK_SUCCESS;
scanned_icds = loader.scanned_icd_list;
while (scanned_icds) {
@@ -2244,11 +2256,20 @@ VkResult loader_CreateInstance(
scanned_icds = scanned_icds->next;
}
+ /*
+ * If no ICDs were added to instance list and res is unchanged
+ * from it's initial value, the loader was unable to find
+ * a suitable ICD.
+ */
if (ptr_instance->icds == NULL) {
- return VK_ERROR_INCOMPATIBLE_DRIVER;
+ if (res == VK_SUCCESS) {
+ return VK_ERROR_INCOMPATIBLE_DRIVER;
+ } else {
+ return res;
+ }
}
- return res;
+ return VK_SUCCESS;
}
VkResult loader_DestroyInstance(
diff --git a/loader/loader.h b/loader/loader.h
index d6ef538e..a336238a 100644
--- a/loader/loader.h
+++ b/loader/loader.h
@@ -423,7 +423,7 @@ void loader_coalesce_extensions(void);
struct loader_icd * loader_get_icd(const VkPhysicalDevice gpu,
uint32_t *gpu_index);
void loader_remove_logical_device(VkDevice device);
-void loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo);
+VkResult loader_enable_instance_layers(struct loader_instance *inst, const VkInstanceCreateInfo *pCreateInfo);
void loader_deactivate_instance_layers(struct loader_instance *instance);
uint32_t loader_activate_instance_layers(struct loader_instance *inst);
void loader_activate_instance_layer_extensions(struct loader_instance *inst);