Added function for checking against VK_SUCCESS, updated error list to latest SDK

This commit is contained in:
saschawillems 2016-03-17 22:07:42 +01:00
parent 25c38e7312
commit a6a897f244
2 changed files with 25 additions and 2 deletions

View file

@ -53,7 +53,6 @@ namespace vkTools
{
switch (errorCode)
{
// todo : update to SDK 0.10.1
#define STR(r) case VK_ ##r: return #r
STR(NOT_READY);
STR(TIMEOUT);
@ -67,13 +66,34 @@ namespace vkTools
STR(ERROR_MEMORY_MAP_FAILED);
STR(ERROR_LAYER_NOT_PRESENT);
STR(ERROR_EXTENSION_NOT_PRESENT);
STR(ERROR_FEATURE_NOT_PRESENT);
STR(ERROR_INCOMPATIBLE_DRIVER);
STR(ERROR_TOO_MANY_OBJECTS);
STR(ERROR_FORMAT_NOT_SUPPORTED);
STR(ERROR_SURFACE_LOST_KHR);
STR(ERROR_NATIVE_WINDOW_IN_USE_KHR);
STR(SUBOPTIMAL_KHR);
STR(ERROR_OUT_OF_DATE_KHR);
STR(ERROR_INCOMPATIBLE_DISPLAY_KHR);
STR(ERROR_VALIDATION_FAILED_EXT);
STR(ERROR_INVALID_SHADER_NV);
#undef STR
default:
return "UNKNOWN_ERROR";
}
}
VkResult checkResult(VkResult result)
{
if (result != VK_SUCCESS)
{
std::string errorMsg = "Fatal : VkResult returned " + errorString(result) + "!";
std::cout << errorMsg << std::endl;
assert(result == VK_SUCCESS);
}
return result;
}
VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat)
{
// Since all depth formats may be optional, we need to find a suitable depth format to use

View file

@ -19,6 +19,7 @@
#include <stdio.h>
#include <vector>
#include <iostream>
#include <stdexcept>
#ifdef _WIN32
#include <windows.h>
#include <fcntl.h>
@ -37,7 +38,9 @@ namespace vkTools
VkBool32 checkDeviceExtensionPresent(VkPhysicalDevice physicalDevice, const char* extensionName);
// Return string representation of a vulkan error string
std::string errorString(VkResult errorCode);
// Asserts and outputs the error message if the result is not VK_SUCCESS
VkResult checkResult(VkResult result);
// Selected a suitable supported depth format starting with 32 bit down to 16 bit
// Returns false if none of the depth formats in the list is supported by the device
VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat);