diff --git a/test/test_apps/common/test_app_base.cpp b/test/test_apps/common/test_app_base.cpp index 2c6c94006..f017cb2bc 100644 --- a/test/test_apps/common/test_app_base.cpp +++ b/test/test_apps/common/test_app_base.cpp @@ -558,11 +558,11 @@ const char* to_string(SwapchainError err) } } -std::exception to_exception(InstanceError error) +std::runtime_error to_exception(InstanceError error) { return std::runtime_error(to_string(error)); } -std::exception to_exception(InstanceError error, VkResult result) +std::runtime_error to_exception(InstanceError error, VkResult result) { std::string message{}; message.append(to_string(error)); @@ -571,11 +571,11 @@ std::exception to_exception(InstanceError error, VkResult result) return std::runtime_error(message); } -std::exception to_exception(PhysicalDeviceError error) +std::runtime_error to_exception(PhysicalDeviceError error) { return std::runtime_error(to_string(error)); } -std::exception to_exception(PhysicalDeviceError error, VkResult result) +std::runtime_error to_exception(PhysicalDeviceError error, VkResult result) { std::string message{}; message.append(to_string(error)); @@ -584,11 +584,11 @@ std::exception to_exception(PhysicalDeviceError error, VkResult result) return std::runtime_error(message); } -std::exception to_exception(QueueError error) +std::runtime_error to_exception(QueueError error) { return std::runtime_error(to_string(error)); } -std::exception to_exception(QueueError error, VkResult result) +std::runtime_error to_exception(QueueError error, VkResult result) { std::string message{}; message.append(to_string(error)); @@ -597,11 +597,11 @@ std::exception to_exception(QueueError error, VkResult result) return std::runtime_error(message); } -std::exception to_exception(DeviceError error) +std::runtime_error to_exception(DeviceError error) { return std::runtime_error(to_string(error)); } -std::exception to_exception(DeviceError error, VkResult result) +std::runtime_error to_exception(DeviceError error, VkResult result) { std::string message{}; message.append(to_string(error)); @@ -610,11 +610,11 @@ std::exception to_exception(DeviceError error, VkResult result) return std::runtime_error(message); } -std::exception to_exception(SwapchainError error) +std::runtime_error to_exception(SwapchainError error) { return std::runtime_error(to_string(error)); } -std::exception to_exception(SwapchainError error, VkResult result) +std::runtime_error to_exception(SwapchainError error, VkResult result) { std::string message{}; message.append(to_string(error)); @@ -2178,11 +2178,11 @@ const char* to_string(SurfaceSupportError err) } } -std::exception to_exception(SurfaceSupportError error) +std::runtime_error to_exception(SurfaceSupportError error) { return std::runtime_error(to_string(error)); } -std::exception to_exception(SurfaceSupportError error, VkResult result) +std::runtime_error to_exception(SurfaceSupportError error, VkResult result) { std::string message{}; message.append(to_string(error)); @@ -2819,18 +2819,19 @@ std::exception sdl_exception() return std::runtime_error(SDL_GetError()); } -void device_initialization_phase_1(const std::string& window_name, InitInfo& init) +void device_initialization_phase_2(const std::string& window_name, InitInfo& init) { - init.window = create_window_sdl(window_name.data(), true, 1024, 1024); + if (!init.instance.headless) { + init.window = create_window_sdl(window_name.data(), true, 1024, 1024); + init.surface = create_surface_sdl(init.instance, init.window); + } } -void device_initialization_phase_2(InstanceBuilder const& instance_builder, InitInfo& init) +void device_initialization_phase_1(InstanceBuilder const& instance_builder, InitInfo& init) { init.instance = instance_builder.build(); init.inst_disp = init.instance.make_table(); - - init.surface = create_surface_sdl(init.instance, init.window); } PhysicalDevice device_initialization_phase_3(PhysicalDeviceSelector& phys_device_selector, InitInfo& init) @@ -2857,10 +2858,10 @@ InitInfo device_initialization(const std::string& window_name) { InitInfo init; - device_initialization_phase_1(window_name, init); - InstanceBuilder instance_builder; - device_initialization_phase_2(instance_builder, init); + device_initialization_phase_1(instance_builder, init); + + device_initialization_phase_2(window_name, init); PhysicalDeviceSelector phys_device_selector(init.instance); init.physical_device = device_initialization_phase_3(phys_device_selector, init); @@ -2900,11 +2901,11 @@ void recreate_init_swapchain(SwapchainBuilder& swapchain_builder, InitInfo& init void TestAppBase::run(const std::string& window_name) { - device_initialization_phase_1(window_name, init); - InstanceBuilder instance_builder; configure_instance_builder(instance_builder); - device_initialization_phase_2(instance_builder, init); + device_initialization_phase_1(instance_builder, init); + + device_initialization_phase_2(window_name, init); PhysicalDeviceSelector phys_device_selector(init.instance); configure_physical_device_selector(phys_device_selector); @@ -2914,9 +2915,11 @@ void TestAppBase::run(const std::string& window_name) configure_device_builder(device_builder, init.physical_device); device_initialization_phase_4(device_builder, init); - SwapchainBuilder swapchain_builder{ init.device }; - configure_swapchain_builder(swapchain_builder); - device_initialization_phase_5(swapchain_builder, init); + if (!init.instance.headless) { + SwapchainBuilder swapchain_builder{ init.device }; + configure_swapchain_builder(swapchain_builder); + device_initialization_phase_5(swapchain_builder, init); + } setup(); diff --git a/test/test_apps/common/test_app_base.h b/test/test_apps/common/test_app_base.h index 114d77b81..59e303c02 100644 --- a/test/test_apps/common/test_app_base.h +++ b/test/test_apps/common/test_app_base.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include @@ -176,17 +176,17 @@ const char* to_string(QueueError err); const char* to_string(DeviceError err); const char* to_string(SwapchainError err); -std::exception to_exception(InstanceError err); -std::exception to_exception(PhysicalDeviceError err); -std::exception to_exception(QueueError err); -std::exception to_exception(DeviceError err); -std::exception to_exception(SwapchainError err); +std::runtime_error to_exception(InstanceError err); +std::runtime_error to_exception(PhysicalDeviceError err); +std::runtime_error to_exception(QueueError err); +std::runtime_error to_exception(DeviceError err); +std::runtime_error to_exception(SwapchainError err); -std::exception to_exception(InstanceError err, VkResult result); -std::exception to_exception(PhysicalDeviceError err, VkResult result); -std::exception to_exception(QueueError err, VkResult result); -std::exception to_exception(DeviceError err, VkResult result); -std::exception to_exception(SwapchainError err, VkResult result); +std::runtime_error to_exception(InstanceError err, VkResult result); +std::runtime_error to_exception(PhysicalDeviceError err, VkResult result); +std::runtime_error to_exception(QueueError err, VkResult result); +std::runtime_error to_exception(DeviceError err, VkResult result); +std::runtime_error to_exception(SwapchainError err, VkResult result); // Gathers useful information about the available vulkan capabilities, like layers and instance // extensions. Use this for enabling features conditionally, ie if you would like an extension but @@ -249,8 +249,8 @@ struct Instance // Return a loaded instance dispatch table vkb::InstanceDispatchTable make_table() const; - private: bool headless = false; + private: bool properties2_ext_enabled = false; uint32_t instance_version = VKB_VK_API_VERSION_1_0; uint32_t api_version = VKB_VK_API_VERSION_1_0;