Result (exit) codes for fatal terminations
This commit is contained in:
parent
90d7e09890
commit
df223f5b9b
29 changed files with 56 additions and 52 deletions
|
|
@ -186,7 +186,7 @@ namespace vks
|
|||
pScene = Importer.ReadFile(filename.c_str(), flags);
|
||||
if (!pScene) {
|
||||
std::string error = Importer.GetErrorString();
|
||||
vks::tools::exitFatal(error + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", "Error");
|
||||
vks::tools::exitFatal(error + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ public:
|
|||
#endif
|
||||
|
||||
if (err != VK_SUCCESS) {
|
||||
vks::tools::exitFatal("Could not create surface!", "Fatal error");
|
||||
vks::tools::exitFatal("Could not create surface!", err);
|
||||
}
|
||||
|
||||
// Get available queue family properties
|
||||
|
|
@ -194,13 +194,13 @@ public:
|
|||
// Exit if either a graphics or a presenting queue hasn't been found
|
||||
if (graphicsQueueNodeIndex == UINT32_MAX || presentQueueNodeIndex == UINT32_MAX)
|
||||
{
|
||||
vks::tools::exitFatal("Could not find a graphics and/or presenting queue!", "Fatal error");
|
||||
vks::tools::exitFatal("Could not find a graphics and/or presenting queue!", -1);
|
||||
}
|
||||
|
||||
// todo : Add support for separate graphics and presenting queue
|
||||
if (graphicsQueueNodeIndex != presentQueueNodeIndex)
|
||||
{
|
||||
vks::tools::exitFatal("Separate graphics and presenting queues are not supported yet!", "Fatal error");
|
||||
vks::tools::exitFatal("Separate graphics and presenting queues are not supported yet!", -1);
|
||||
}
|
||||
|
||||
queueNodeIndex = graphicsQueueNodeIndex;
|
||||
|
|
@ -563,7 +563,7 @@ public:
|
|||
|
||||
if(!foundMode)
|
||||
{
|
||||
vks::tools::exitFatal("Can't find a display and a display mode!", "Fatal error");
|
||||
vks::tools::exitFatal("Can't find a display and a display mode!", -1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -600,7 +600,7 @@ public:
|
|||
|
||||
if(bestPlaneIndex == UINT32_MAX)
|
||||
{
|
||||
vks::tools::exitFatal("Can't find a plane for displaying!", "Fatal error");
|
||||
vks::tools::exitFatal("Can't find a plane for displaying!", -1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -639,9 +639,8 @@ public:
|
|||
surfaceInfo.imageExtent.height = height;
|
||||
|
||||
VkResult result = vkCreateDisplayPlaneSurfaceKHR(instance, &surfaceInfo, NULL, &surface);
|
||||
if(result !=VK_SUCCESS)
|
||||
{
|
||||
vks::tools::exitFatal("Failed to create surface!", "Fatal error");
|
||||
if (result !=VK_SUCCESS) {
|
||||
vks::tools::exitFatal("Failed to create surface!", result);
|
||||
}
|
||||
|
||||
delete[] pDisplays;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ namespace vks
|
|||
// So they need to be loaded via the asset manager
|
||||
AAsset* asset = AAssetManager_open(androidApp->activity->assetManager, filename.c_str(), AASSET_MODE_STREAMING);
|
||||
if (!asset) {
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", "Error");
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
|
||||
}
|
||||
size_t size = AAsset_getLength(asset);
|
||||
assert(size > 0);
|
||||
|
|
@ -107,7 +107,7 @@ namespace vks
|
|||
free(textureData);
|
||||
#else
|
||||
if (!vks::tools::fileExists(filename)) {
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", "Error");
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
|
||||
}
|
||||
gli::texture2d tex2D(gli::load(filename.c_str()));
|
||||
#endif
|
||||
|
|
@ -573,7 +573,7 @@ namespace vks
|
|||
// So they need to be loaded via the asset manager
|
||||
AAsset* asset = AAssetManager_open(androidApp->activity->assetManager, filename.c_str(), AASSET_MODE_STREAMING);
|
||||
if (!asset) {
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", "Error");
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
|
||||
}
|
||||
size_t size = AAsset_getLength(asset);
|
||||
assert(size > 0);
|
||||
|
|
@ -587,7 +587,7 @@ namespace vks
|
|||
free(textureData);
|
||||
#else
|
||||
if (!vks::tools::fileExists(filename)) {
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", "Error");
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
|
||||
}
|
||||
gli::texture2d_array tex2DArray(gli::load(filename));
|
||||
#endif
|
||||
|
|
@ -785,7 +785,7 @@ namespace vks
|
|||
// So they need to be loaded via the asset manager
|
||||
AAsset* asset = AAssetManager_open(androidApp->activity->assetManager, filename.c_str(), AASSET_MODE_STREAMING);
|
||||
if (!asset) {
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", "Error");
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
|
||||
}
|
||||
size_t size = AAsset_getLength(asset);
|
||||
assert(size > 0);
|
||||
|
|
@ -799,7 +799,7 @@ namespace vks
|
|||
free(textureData);
|
||||
#else
|
||||
if (!vks::tools::fileExists(filename)) {
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", "Error");
|
||||
vks::tools::exitFatal("Could not load texture from " + filename + "\n\nThe file may be part of the additional asset pack.\n\nRun \"download_assets.py\" in the repository root to download the latest version.", -1);
|
||||
}
|
||||
gli::texture_cube texCube(gli::load(filename));
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -262,17 +262,22 @@ namespace vks
|
|||
1, &imageMemoryBarrier);
|
||||
}
|
||||
|
||||
void exitFatal(std::string message, std::string caption, bool silent)
|
||||
void exitFatal(std::string message, int32_t exitCode)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
if (!errorModeSilent) {
|
||||
MessageBox(NULL, message.c_str(), caption.c_str(), MB_OK | MB_ICONERROR);
|
||||
MessageBox(NULL, message.c_str(), NULL, MB_OK | MB_ICONERROR);
|
||||
}
|
||||
#elif defined(__ANDROID__)
|
||||
LOGE("Fatal error: %s", message.c_str());
|
||||
#endif
|
||||
std::cerr << message << "\n";
|
||||
exit(1);
|
||||
exit(exitCode);
|
||||
}
|
||||
|
||||
void exitFatal(std::string message, VkResult resultCode)
|
||||
{
|
||||
exitFatal(message, (int32_t)resultCode);
|
||||
}
|
||||
|
||||
std::string readTextFile(const char *fileName)
|
||||
|
|
|
|||
|
|
@ -114,7 +114,8 @@ namespace vks
|
|||
VkImageSubresourceRange subresourceRange);
|
||||
|
||||
// Display error message and exit on fatal error
|
||||
void exitFatal(std::string message, std::string caption, bool silent = false);
|
||||
void exitFatal(std::string message, int32_t exitCode);
|
||||
void exitFatal(std::string message, VkResult resultCode);
|
||||
|
||||
// Load a SPIR-V shader (binary)
|
||||
#if defined(__ANDROID__)
|
||||
|
|
|
|||
|
|
@ -831,7 +831,7 @@ void VulkanExampleBase::initVulkan()
|
|||
// Vulkan instance
|
||||
err = createInstance(settings.validation);
|
||||
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), err);
|
||||
}
|
||||
|
||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
||||
|
|
@ -857,7 +857,7 @@ void VulkanExampleBase::initVulkan()
|
|||
std::vector<VkPhysicalDevice> physicalDevices(gpuCount);
|
||||
err = vkEnumeratePhysicalDevices(instance, &gpuCount, physicalDevices.data());
|
||||
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), err);
|
||||
}
|
||||
|
||||
// GPU selection
|
||||
|
|
@ -932,7 +932,7 @@ void VulkanExampleBase::initVulkan()
|
|||
vulkanDevice = new vks::VulkanDevice(physicalDevice);
|
||||
VkResult res = vulkanDevice->createLogicalDevice(enabledFeatures, enabledExtensions);
|
||||
if (res != VK_SUCCESS) {
|
||||
vks::tools::exitFatal("Could not create Vulkan device: \n" + vks::tools::errorString(res), "Fatal error", benchmark.active);
|
||||
vks::tools::exitFatal("Could not create Vulkan device: \n" + vks::tools::errorString(res), res);
|
||||
}
|
||||
device = vulkanDevice->logicalDevice;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue