Changeset 8b823e7 in opengl-game for vulkan-utils.cpp


Ignore:
Timestamp:
Jan 24, 2021, 11:38:43 PM (4 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
feature/imgui-sdl
Children:
d8cf709
Parents:
ce9dc9f
Message:

Create an error-checking macro to check Vulkan function results, which will print a custom message, the error code, and the line number for all results besides VK_SUCCESS, and update the imgui error-checking callback with similar functionality.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vulkan-utils.cpp

    rce9dc9f r8b823e7  
    88#define STB_IMAGE_IMPLEMENTATION
    99#include "stb_image.h" // TODO: Probably switch to SDL_image
     10
     11string VulkanUtils::resultString(VkResult result) {
     12#define STR(r) case VK_ ##r: return #r
     13
     14   switch (result) {
     15      STR(NOT_READY);
     16      STR(TIMEOUT);
     17      STR(EVENT_SET);
     18      STR(EVENT_RESET);
     19      STR(INCOMPLETE);
     20      STR(ERROR_OUT_OF_HOST_MEMORY);
     21      STR(ERROR_OUT_OF_DEVICE_MEMORY);
     22      STR(ERROR_INITIALIZATION_FAILED);
     23      STR(ERROR_DEVICE_LOST);
     24      STR(ERROR_MEMORY_MAP_FAILED);
     25      STR(ERROR_LAYER_NOT_PRESENT);
     26      STR(ERROR_EXTENSION_NOT_PRESENT);
     27      STR(ERROR_FEATURE_NOT_PRESENT);
     28      STR(ERROR_INCOMPATIBLE_DRIVER);
     29      STR(ERROR_TOO_MANY_OBJECTS);
     30      STR(ERROR_FORMAT_NOT_SUPPORTED);
     31      STR(ERROR_SURFACE_LOST_KHR);
     32      STR(ERROR_NATIVE_WINDOW_IN_USE_KHR);
     33      STR(SUBOPTIMAL_KHR);
     34      STR(ERROR_OUT_OF_DATE_KHR);
     35      STR(ERROR_INCOMPATIBLE_DISPLAY_KHR);
     36      STR(ERROR_VALIDATION_FAILED_EXT);
     37      STR(ERROR_INVALID_SHADER_NV);
     38   default:
     39      return "UNKNOWN_ERROR";
     40   }
     41
     42#undef STR
     43}
    1044
    1145bool VulkanUtils::checkValidationLayerSupport(const vector<const char*> &validationLayers) {
Note: See TracChangeset for help on using the changeset viewer.