Add extensions in layers to main list

Allows apps to find all the extensions available. If they do not enable the layer the
extension comes from, the instance will fail creation due to missing the layer that
implements the extension.
This commit is contained in:
Charles Giessen 2022-02-15 19:42:30 -07:00 committed by Charles Giessen
parent 7aef0dc1c1
commit 1bbeaf2063

View File

@ -515,9 +515,11 @@ SystemInfo::SystemInfo() {
this->available_extensions.clear(); this->available_extensions.clear();
} }
for (auto& ext : this->available_extensions) for (auto& ext : this->available_extensions) {
if (strcmp(ext.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0) if (strcmp(ext.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0) {
debug_utils_available = true; debug_utils_available = true;
}
}
for (auto& layer : this->available_layers) { for (auto& layer : this->available_layers) {
std::vector<VkExtensionProperties> layer_extensions; std::vector<VkExtensionProperties> layer_extensions;
@ -525,11 +527,15 @@ SystemInfo::SystemInfo() {
detail::vulkan_functions().fp_vkEnumerateInstanceExtensionProperties, detail::vulkan_functions().fp_vkEnumerateInstanceExtensionProperties,
layer.layerName); layer.layerName);
if (layer_extensions_ret == VK_SUCCESS) { if (layer_extensions_ret == VK_SUCCESS) {
for (auto& ext : layer_extensions) this->available_extensions.insert(
if (strcmp(ext.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0) this->available_extensions.end(), layer_extensions.begin(), layer_extensions.end());
for (auto& ext : layer_extensions) {
if (strcmp(ext.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) == 0) {
debug_utils_available = true; debug_utils_available = true;
} }
} }
}
}
} }
bool SystemInfo::is_extension_available(const char* extension_name) const { bool SystemInfo::is_extension_available(const char* extension_name) const {
if (!extension_name) return false; if (!extension_name) return false;
@ -612,6 +618,8 @@ detail::Result<Instance> InstanceBuilder::build() const {
app_info.apiVersion = api_version; app_info.apiVersion = api_version;
std::vector<const char*> extensions; std::vector<const char*> extensions;
std::vector<const char*> layers;
for (auto& ext : info.extensions) for (auto& ext : info.extensions)
extensions.push_back(ext); extensions.push_back(ext);
if (info.debug_callback != nullptr && system.debug_utils_available) { if (info.debug_callback != nullptr && system.debug_utils_available) {
@ -653,7 +661,6 @@ detail::Result<Instance> InstanceBuilder::build() const {
return make_error_code(InstanceError::requested_extensions_not_present); return make_error_code(InstanceError::requested_extensions_not_present);
} }
std::vector<const char*> layers;
for (auto& layer : info.layers) for (auto& layer : info.layers)
layers.push_back(layer); layers.push_back(layer);