49 lines
1.9 KiB
C++
49 lines
1.9 KiB
C++
#include "./except.hpp"
|
|
|
|
#include <cruft/util/debug.hpp>
|
|
|
|
using vk::error;
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
void
|
|
error::try_code (VkResult res)
|
|
{
|
|
if (__builtin_expect (res >= 0, true))
|
|
return;
|
|
|
|
throw_code (res);
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void
|
|
error::throw_code (VkResult res)
|
|
{
|
|
switch (res) {
|
|
case VK_SUCCESS: throw error_code<VK_SUCCESS> ();
|
|
|
|
// partial successes
|
|
case VK_NOT_READY: throw error_code<VK_NOT_READY> ();
|
|
case VK_TIMEOUT: throw error_code<VK_TIMEOUT> ();
|
|
case VK_EVENT_SET: throw error_code<VK_EVENT_SET> ();
|
|
case VK_EVENT_RESET: throw error_code<VK_EVENT_RESET> ();
|
|
case VK_INCOMPLETE: throw error_code<VK_INCOMPLETE> ();
|
|
|
|
// errors
|
|
case VK_ERROR_OUT_OF_HOST_MEMORY: throw error_code<VK_ERROR_OUT_OF_HOST_MEMORY> ();
|
|
case VK_ERROR_OUT_OF_DEVICE_MEMORY: throw error_code<VK_ERROR_OUT_OF_DEVICE_MEMORY> ();
|
|
case VK_ERROR_INITIALIZATION_FAILED: throw error_code<VK_ERROR_INITIALIZATION_FAILED> ();
|
|
case VK_ERROR_DEVICE_LOST: throw error_code<VK_ERROR_DEVICE_LOST> ();
|
|
case VK_ERROR_MEMORY_MAP_FAILED: throw error_code<VK_ERROR_MEMORY_MAP_FAILED> ();
|
|
case VK_ERROR_LAYER_NOT_PRESENT: throw error_code<VK_ERROR_LAYER_NOT_PRESENT> ();
|
|
case VK_ERROR_EXTENSION_NOT_PRESENT: throw error_code<VK_ERROR_EXTENSION_NOT_PRESENT> ();
|
|
case VK_ERROR_FEATURE_NOT_PRESENT: throw error_code<VK_ERROR_FEATURE_NOT_PRESENT> ();
|
|
case VK_ERROR_INCOMPATIBLE_DRIVER: throw error_code<VK_ERROR_INCOMPATIBLE_DRIVER> ();
|
|
case VK_ERROR_TOO_MANY_OBJECTS: throw error_code<VK_ERROR_TOO_MANY_OBJECTS> ();
|
|
case VK_ERROR_FORMAT_NOT_SUPPORTED: throw error_code<VK_ERROR_FORMAT_NOT_SUPPORTED> ();
|
|
}
|
|
|
|
unreachable ();
|
|
}
|