Uee new VK_LAYER_KHRONOS_validation layer on all platforms
Check if validation layer is actually present
This commit is contained in:
parent
0356b62f81
commit
01bf10f9a8
2 changed files with 23 additions and 25 deletions
|
|
@ -1,9 +1,7 @@
|
|||
/*
|
||||
* Vulkan examples debug wrapper
|
||||
*
|
||||
* Appendix for VK_EXT_Debug_Report can be found at https://github.com/KhronosGroup/Vulkan-Docs/blob/1.0-VK_EXT_debug_report/doc/specs/vulkan/appendices/debug_report.txt
|
||||
*
|
||||
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
|
||||
* Copyright (C) by Sascha Willems - www.saschawillems.de
|
||||
*
|
||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||
*/
|
||||
|
|
@ -15,25 +13,6 @@ namespace vks
|
|||
{
|
||||
namespace debug
|
||||
{
|
||||
#if !defined(__ANDROID__)
|
||||
// On desktop the LunarG loaders exposes a meta layer that contains all layers
|
||||
int32_t validationLayerCount = 1;
|
||||
const char *validationLayerNames[] = {
|
||||
"VK_LAYER_LUNARG_standard_validation"
|
||||
};
|
||||
#else
|
||||
// On Android we need to explicitly select all layers
|
||||
int32_t validationLayerCount = 6;
|
||||
const char *validationLayerNames[] = {
|
||||
"VK_LAYER_GOOGLE_threading",
|
||||
"VK_LAYER_LUNARG_parameter_validation",
|
||||
"VK_LAYER_LUNARG_object_tracker",
|
||||
"VK_LAYER_LUNARG_core_validation",
|
||||
"VK_LAYER_LUNARG_swapchain",
|
||||
"VK_LAYER_GOOGLE_unique_objects"
|
||||
};
|
||||
#endif
|
||||
|
||||
PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallback = VK_NULL_HANDLE;
|
||||
PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallback = VK_NULL_HANDLE;
|
||||
PFN_vkDebugReportMessageEXT dbgBreakCallback = VK_NULL_HANDLE;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Vulkan Example base class
|
||||
*
|
||||
* Copyright (C) 2016-2017 by Sascha Willems - www.saschawillems.de
|
||||
* Copyright (C) by Sascha Willems - www.saschawillems.de
|
||||
*
|
||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||
*/
|
||||
|
|
@ -65,8 +65,27 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
|||
}
|
||||
if (settings.validation)
|
||||
{
|
||||
instanceCreateInfo.enabledLayerCount = vks::debug::validationLayerCount;
|
||||
instanceCreateInfo.ppEnabledLayerNames = vks::debug::validationLayerNames;
|
||||
// The VK_LAYER_KHRONOS_validation contains all current validation functionality.
|
||||
// Note that on Android this layer requires at least NDK r20
|
||||
const char* validationLayerName = "VK_LAYER_KHRONOS_validation";
|
||||
// Check if this layer is available at instance level
|
||||
uint32_t instanceLayerCount;
|
||||
vkEnumerateInstanceLayerProperties(&instanceLayerCount, nullptr);
|
||||
std::vector<VkLayerProperties> instanceLayerProperties(instanceLayerCount);
|
||||
vkEnumerateInstanceLayerProperties(&instanceLayerCount, instanceLayerProperties.data());
|
||||
bool validationLayerPresent = false;
|
||||
for each (VkLayerProperties layer in instanceLayerProperties) {
|
||||
if (strcmp(layer.layerName, validationLayerName) == 0) {
|
||||
validationLayerPresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (validationLayerPresent) {
|
||||
instanceCreateInfo.ppEnabledLayerNames = &validationLayerName;
|
||||
instanceCreateInfo.enabledLayerCount = 1;
|
||||
} else {
|
||||
std::cerr << "Validation layer VK_LAYER_KHRONOS_validation not present, validation is disabled";
|
||||
}
|
||||
}
|
||||
return vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue