/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Copyright: * 2016, Danny Robson */ #include "./except.hpp" #include #include using cruft::vk::error; using cruft::vk::error_code; /////////////////////////////////////////////////////////////////////////////// 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 (); // partial successes case VK_NOT_READY: throw error_code (); case VK_TIMEOUT: throw error_code (); case VK_EVENT_SET: throw error_code (); case VK_EVENT_RESET: throw error_code (); case VK_INCOMPLETE: throw error_code (); // errors case VK_ERROR_OUT_OF_HOST_MEMORY: throw error_code (); case VK_ERROR_OUT_OF_DEVICE_MEMORY: throw error_code (); case VK_ERROR_INITIALIZATION_FAILED: throw error_code (); case VK_ERROR_DEVICE_LOST: throw error_code (); case VK_ERROR_MEMORY_MAP_FAILED: throw error_code (); case VK_ERROR_LAYER_NOT_PRESENT: throw error_code (); case VK_ERROR_EXTENSION_NOT_PRESENT: throw error_code (); case VK_ERROR_FEATURE_NOT_PRESENT: throw error_code (); case VK_ERROR_INCOMPATIBLE_DRIVER: throw error_code (); case VK_ERROR_TOO_MANY_OBJECTS: throw error_code (); case VK_ERROR_FORMAT_NOT_SUPPORTED: throw error_code (); } unreachable (); }