Silent error mode

This commit is contained in:
saschawillems 2017-08-26 15:05:59 +02:00
parent b4870a6e7e
commit d271098464
3 changed files with 11 additions and 12 deletions

View file

@ -260,15 +260,16 @@ namespace vks
1, &imageMemoryBarrier); 1, &imageMemoryBarrier);
} }
void exitFatal(std::string message, std::string caption) void exitFatal(std::string message, std::string caption, bool silent)
{ {
#if defined(_WIN32) #if defined(_WIN32)
MessageBox(NULL, message.c_str(), caption.c_str(), MB_OK | MB_ICONERROR); if (!silent) {
MessageBox(NULL, message.c_str(), caption.c_str(), MB_OK | MB_ICONERROR);
}
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
LOGE("Fatal error: %s", message.c_str()); LOGE("Fatal error: %s", message.c_str());
#else
std::cerr << message << "\n";
#endif #endif
std::cerr << message << "\n";
exit(1); exit(1);
} }

View file

@ -111,7 +111,7 @@ namespace vks
VkImageSubresourceRange subresourceRange); VkImageSubresourceRange subresourceRange);
// Display error message and exit on fatal error // Display error message and exit on fatal error
void exitFatal(std::string message, std::string caption); void exitFatal(std::string message, std::string caption, bool silent = false);
// Load a SPIR-V shader (binary) // Load a SPIR-V shader (binary)
#if defined(__ANDROID__) #if defined(__ANDROID__)

View file

@ -772,9 +772,8 @@ void VulkanExampleBase::initVulkan()
// Vulkan instance // Vulkan instance
err = createInstance(settings.validation); err = createInstance(settings.validation);
if (err) if (err) {
{ vks::tools::exitFatal("Could not create Vulkan instance : \n" + vks::tools::errorString(err), "Fatal error", !benchmark.active);
vks::tools::exitFatal("Could not create Vulkan instance : \n" + vks::tools::errorString(err), "Fatal error");
} }
#if defined(VK_USE_PLATFORM_ANDROID_KHR) #if defined(VK_USE_PLATFORM_ANDROID_KHR)
@ -799,9 +798,8 @@ void VulkanExampleBase::initVulkan()
// Enumerate devices // Enumerate devices
std::vector<VkPhysicalDevice> physicalDevices(gpuCount); std::vector<VkPhysicalDevice> physicalDevices(gpuCount);
err = vkEnumeratePhysicalDevices(instance, &gpuCount, physicalDevices.data()); err = vkEnumeratePhysicalDevices(instance, &gpuCount, physicalDevices.data());
if (err) if (err) {
{ vks::tools::exitFatal("Could not enumerate physical devices : \n" + vks::tools::errorString(err), "Fatal error", !benchmark.active);
vks::tools::exitFatal("Could not enumerate physical devices : \n" + vks::tools::errorString(err), "Fatal error");
} }
// GPU selection // GPU selection
@ -876,7 +874,7 @@ void VulkanExampleBase::initVulkan()
vulkanDevice = new vks::VulkanDevice(physicalDevice); vulkanDevice = new vks::VulkanDevice(physicalDevice);
VkResult res = vulkanDevice->createLogicalDevice(enabledFeatures, enabledExtensions); VkResult res = vulkanDevice->createLogicalDevice(enabledFeatures, enabledExtensions);
if (res != VK_SUCCESS) { if (res != VK_SUCCESS) {
vks::tools::exitFatal("Could not create Vulkan device: \n" + vks::tools::errorString(res), "Fatal error"); vks::tools::exitFatal("Could not create Vulkan device: \n" + vks::tools::errorString(res), "Fatal error", !benchmark.active);
} }
device = vulkanDevice->logicalDevice; device = vulkanDevice->logicalDevice;