|
|
@ -155,11 +155,31 @@ vk::Instance CreateInstance(Common::DynamicLibrary& library, vk::InstanceDispatc |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static constexpr std::array layers_data{"VK_LAYER_LUNARG_standard_validation"}; |
|
|
|
|
|
vk::Span<const char*> layers = layers_data; |
|
|
|
|
|
if (!enable_layers) { |
|
|
|
|
|
layers = {}; |
|
|
|
|
|
|
|
|
std::vector<const char*> layers; |
|
|
|
|
|
layers.reserve(1); |
|
|
|
|
|
if (enable_layers) { |
|
|
|
|
|
layers.push_back("VK_LAYER_KHRONOS_validation"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const std::optional layer_properties = vk::EnumerateInstanceLayerProperties(dld); |
|
|
|
|
|
if (!layer_properties) { |
|
|
|
|
|
LOG_ERROR(Render_Vulkan, "Failed to query layer properties, disabling layers"); |
|
|
|
|
|
layers.clear(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (auto layer_it = layers.begin(); layer_it != layers.end();) { |
|
|
|
|
|
const char* const layer = *layer_it; |
|
|
|
|
|
const auto it = std::find_if( |
|
|
|
|
|
layer_properties->begin(), layer_properties->end(), |
|
|
|
|
|
[layer](const VkLayerProperties& prop) { return !std::strcmp(layer, prop.layerName); }); |
|
|
|
|
|
if (it == layer_properties->end()) { |
|
|
|
|
|
LOG_ERROR(Render_Vulkan, "Layer {} not available, removing it", layer); |
|
|
|
|
|
layer_it = layers.erase(layer_it); |
|
|
|
|
|
} else { |
|
|
|
|
|
++layer_it; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
vk::Instance instance = vk::Instance::Create(layers, extensions, dld); |
|
|
vk::Instance instance = vk::Instance::Create(layers, extensions, dld); |
|
|
if (!instance) { |
|
|
if (!instance) { |
|
|
LOG_ERROR(Render_Vulkan, "Failed to create Vulkan instance"); |
|
|
LOG_ERROR(Render_Vulkan, "Failed to create Vulkan instance"); |
|
|
|