mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-10-20 12:30:24 +00:00
comp: Introduce XRT_COMPOSITOR_VULKAN_VALIDATION.
For enabling Vulkan validation during runtime. Add CMake option to disable Vulkan validation at build time. By default the DEBUG extension is enabled but the validation layers are not when the ENV variable is not set to true.
This commit is contained in:
parent
5d5d420fb6
commit
00afe442f8
|
@ -11,7 +11,7 @@ endif()
|
|||
|
||||
option(BUILD_TESTS "Build compile and runtime tests" ON)
|
||||
option(OPENXR_USE_LOADER "Application uses loader" ON)
|
||||
|
||||
option(VULKAN_ENABLE_VALIDATION "Enable Vulkan validation for Compositor" ON)
|
||||
|
||||
###
|
||||
# Dependencies
|
||||
|
|
|
@ -45,6 +45,10 @@ if (${XCB_FOUND})
|
|||
add_definitions(-DVK_USE_PLATFORM_XLIB_XRANDR_EXT)
|
||||
endif()
|
||||
|
||||
if (${VULKAN_ENABLE_VALIDATION})
|
||||
add_definitions(-DXRT_ENABLE_VK_VALIDATION)
|
||||
endif()
|
||||
|
||||
# Use OBJECT to not create a archive, since it just gets in the way.
|
||||
add_library(comp OBJECT ${GL_SOURCE_FILES})
|
||||
set_property(TARGET comp PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
|
|
|
@ -258,23 +258,24 @@ create_instance(struct comp_compositor *c)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef XRT_ENABLE_VK_VALIDATION
|
||||
const char *instance_layers[] = {
|
||||
"VK_LAYER_LUNARG_standard_validation",
|
||||
};
|
||||
#endif
|
||||
|
||||
VkInstanceCreateInfo instance_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
.pApplicationInfo = &app_info,
|
||||
.enabledExtensionCount = num_extensions,
|
||||
.ppEnabledExtensionNames = instance_extensions,
|
||||
#ifdef XRT_ENABLE_VK_VALIDATION
|
||||
.enabledLayerCount = ARRAY_SIZE(instance_layers),
|
||||
.ppEnabledLayerNames = instance_layers,
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef XRT_ENABLE_VK_VALIDATION
|
||||
const char *instance_layers[] = {
|
||||
"VK_LAYER_LUNARG_standard_validation",
|
||||
};
|
||||
|
||||
if (c->settings.validate_vulkan) {
|
||||
instance_info.enabledLayerCount = ARRAY_SIZE(instance_layers);
|
||||
instance_info.ppEnabledLayerNames = instance_layers;
|
||||
}
|
||||
#endif
|
||||
|
||||
ret = c->vk.vkCreateInstance(&instance_info, NULL, &c->vk.instance);
|
||||
if (ret != VK_SUCCESS) {
|
||||
COMP_ERROR(c, "vkCreateInstance: %s\n", vk_result_string(ret));
|
||||
|
@ -290,7 +291,8 @@ create_instance(struct comp_compositor *c)
|
|||
}
|
||||
|
||||
#ifdef XRT_ENABLE_VK_VALIDATION
|
||||
vk_init_validation_callback(&c->vk);
|
||||
if (c->settings.validate_vulkan)
|
||||
vk_init_validation_callback(&c->vk);
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -15,6 +15,7 @@ DEBUG_GET_ONCE_BOOL_OPTION(print_debug, "XRT_COMPOSITOR_PRINT_DEBUG", false)
|
|||
DEBUG_GET_ONCE_BOOL_OPTION(force_direct, "XRT_COMPOSITOR_FORCE_DIRECT", false)
|
||||
DEBUG_GET_ONCE_BOOL_OPTION(force_xcb, "XRT_COMPOSITOR_FORCE_XCB", false)
|
||||
DEBUG_GET_ONCE_BOOL_OPTION(force_wayland, "XRT_COMPOSITOR_FORCE_WAYLAND", false)
|
||||
DEBUG_GET_ONCE_BOOL_OPTION(validate_vulkan, "XRT_COMPOSITOR_VULKAN_VALIDATION", false)
|
||||
|
||||
void
|
||||
comp_settings_init(struct comp_settings *s, struct xrt_device *xdev)
|
||||
|
@ -34,6 +35,7 @@ comp_settings_init(struct comp_settings *s, struct xrt_device *xdev)
|
|||
xdev->screens[0].nominal_frame_interval_ns;
|
||||
s->print_spew = debug_get_bool_option_print_spew();
|
||||
s->print_debug = debug_get_bool_option_print_debug();
|
||||
s->validate_vulkan = debug_get_bool_option_validate_vulkan();
|
||||
|
||||
if (debug_get_bool_option_force_direct()) {
|
||||
s->window_type = WINDOW_DIRECT_MODE;
|
||||
|
|
|
@ -70,6 +70,9 @@ struct comp_settings
|
|||
|
||||
//! Nominal frame interval
|
||||
uint64_t nominal_frame_interval_ns;
|
||||
|
||||
//! Enable vulkan validation for compositor
|
||||
bool validate_vulkan;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in a new issue