|
| 1 | +package vkerr |
| 2 | + |
| 3 | +import ( |
| 4 | + "errors" |
| 5 | + |
| 6 | + "github.com/sparkkoori/go-vulkan/v1.1/vk" |
| 7 | +) |
| 8 | + |
| 9 | +//Success Codes: |
| 10 | +var SUCCESS = error(nil) //Command successfully completed |
| 11 | +var NOT_READY = errors.New("VK_NOT_READY: A fence or query has not yet completed") |
| 12 | +var TIMEOUT = errors.New("VK_TIMEOUT: A wait operation has not completed in the specified time") |
| 13 | +var EVENT_SET = errors.New("VK_EVENT_SET: An event is signaled") |
| 14 | +var EVENT_RESET = errors.New("VK_EVENT_RESET: An event is unsignaled") |
| 15 | +var INCOMPLETE = errors.New("VK_INCOMPLETE: A return array was too small for the result") |
| 16 | +var SUBOPTIMAL_KHR = errors.New("VK_SUBOPTIMAL_KHR: A swapchain no longer matches the surface properties exactly, but can still be used to present to the surface successfully") |
| 17 | + |
| 18 | +//Error codes: |
| 19 | +var ERROR_OUT_OF_HOST_MEMORY = errors.New("VK_ERROR_OUT_OF_HOST_MEMORY: A host memory allocation has failed") |
| 20 | +var ERROR_OUT_OF_DEVICE_MEMORY = errors.New("VK_ERROR_OUT_OF_DEVICE_MEMORY: A device memory allocation has failed") |
| 21 | +var ERROR_INITIALIZATION_FAILED = errors.New("VK_ERROR_INITIALIZATION_FAILED: Initialization of an object could not be completed for implementation-specific reasons") |
| 22 | +var ERROR_DEVICE_LOST = errors.New("VK_ERROR_DEVICE_LOST: The logical or physical device has been lost") |
| 23 | +var ERROR_MEMORY_MAP_FAILED = errors.New("VK_ERROR_MEMORY_MAP_FAILED: Mapping of a memory object has failed") |
| 24 | +var ERROR_LAYER_NOT_PRESENT = errors.New("VK_ERROR_LAYER_NOT_PRESENT: A requested layer is not present or could not be loaded") |
| 25 | +var ERROR_EXTENSION_NOT_PRESENT = errors.New("VK_ERROR_EXTENSION_NOT_PRESENT: A requested extension is not supported") |
| 26 | +var ERROR_FEATURE_NOT_PRESENT = errors.New("VK_ERROR_FEATURE_NOT_PRESENT: A requested feature is not supported") |
| 27 | +var ERROR_INCOMPATIBLE_DRIVER = errors.New("VK_ERROR_INCOMPATIBLE_DRIVER: The requested version of Vulkan is not supported by the driver or is otherwise incompatible for implementation-specific reasons") |
| 28 | +var ERROR_TOO_MANY_OBJECTS = errors.New("VK_ERROR_TOO_MANY_OBJECTS: Too many objects of the type have already been created") |
| 29 | +var ERROR_FORMAT_NOT_SUPPORTED = errors.New("VK_ERROR_FORMAT_NOT_SUPPORTED: A requested format is not supported on this device") |
| 30 | +var ERROR_FRAGMENTED_POOL = errors.New("VK_ERROR_FRAGMENTED_POOL: A pool allocation has failed due to fragmentation of the pool’s memory") |
| 31 | +var ERROR_OUT_OF_POOL_MEMORY = errors.New("VK_ERROR_OUT_OF_POOL_MEMORY: A pool memory allocation has failed") |
| 32 | +var ERROR_INVALID_EXTERNAL_HANDLE = errors.New("VK_ERROR_INVALID_EXTERNAL_HANDLE: An external handle is not a valid handle of the specified type") |
| 33 | + |
| 34 | +var ERROR_SURFACE_LOST_KHR = errors.New("VK_ERROR_SURFACE_LOST_KHR: A surface is no longer available") |
| 35 | +var ERROR_NATIVE_WINDOW_IN_USE_KHR = errors.New("VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: The requested window is already in use by Vulkan or another API in a manner which prevents it from being used again") |
| 36 | +var ERROR_OUT_OF_DATE_KHR = errors.New("VK_ERROR_OUT_OF_DATE_KHR: A surface has changed in such a way that it is no longer compatible with the swapchain, and further presentation requests using the swapchain will fail") |
| 37 | +var ERROR_INCOMPATIBLE_DISPLAY_KHR = errors.New("VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: The display used by a swapchain does not use the same presentable image layout, or is incompatible in a way that prevents sharing an image") |
| 38 | +var ERROR_INVALID_SHADER_NV = errors.New("VK_ERROR_INVALID_SHADER_NV: One or more shaders failed to compile or link") |
| 39 | +var ERROR_FRAGMENTATION_EXT = errors.New("VK_ERROR_FRAGMENTATION_EXT: A descriptor pool creation has failed due to fragmentation") |
| 40 | +var ERROR_VALIDATION_FAILED_EXT = errors.New("ERROR_VALIDATION_FAILED_EXT") |
| 41 | +var ERROR_NOT_PERMITTED_EXT = errors.New("ERROR_NOT_PERMITTED_EXT") |
| 42 | +var ERROR_OUT_OF_POOL_MEMORY_KHR = errors.New("ERROR_OUT_OF_POOL_MEMORY_KHR") |
| 43 | +var ERROR_INVALID_EXTERNAL_HANDLE_KHR = errors.New("ERROR_INVALID_EXTERNAL_HANDLE_KHR") |
| 44 | + |
| 45 | +var UNKOWN = errors.New("Unknown VkResult") |
| 46 | + |
| 47 | +func Convert(rs vk.Result) error { |
| 48 | + switch rs { |
| 49 | + case vk.SUCCESS: |
| 50 | + return SUCCESS |
| 51 | + case vk.NOT_READY: |
| 52 | + return NOT_READY |
| 53 | + case vk.TIMEOUT: |
| 54 | + return TIMEOUT |
| 55 | + case vk.EVENT_SET: |
| 56 | + return EVENT_SET |
| 57 | + case vk.EVENT_RESET: |
| 58 | + return EVENT_RESET |
| 59 | + case vk.INCOMPLETE: |
| 60 | + return INCOMPLETE |
| 61 | + case vk.SUBOPTIMAL_KHR: |
| 62 | + return SUBOPTIMAL_KHR |
| 63 | + |
| 64 | + case vk.ERROR_OUT_OF_HOST_MEMORY: |
| 65 | + return ERROR_OUT_OF_HOST_MEMORY |
| 66 | + case vk.ERROR_OUT_OF_DEVICE_MEMORY: |
| 67 | + return ERROR_OUT_OF_DEVICE_MEMORY |
| 68 | + case vk.ERROR_INITIALIZATION_FAILED: |
| 69 | + return ERROR_INITIALIZATION_FAILED |
| 70 | + case vk.ERROR_DEVICE_LOST: |
| 71 | + return ERROR_DEVICE_LOST |
| 72 | + case vk.ERROR_MEMORY_MAP_FAILED: |
| 73 | + return ERROR_MEMORY_MAP_FAILED |
| 74 | + case vk.ERROR_LAYER_NOT_PRESENT: |
| 75 | + return ERROR_LAYER_NOT_PRESENT |
| 76 | + case vk.ERROR_EXTENSION_NOT_PRESENT: |
| 77 | + return ERROR_EXTENSION_NOT_PRESENT |
| 78 | + case vk.ERROR_FEATURE_NOT_PRESENT: |
| 79 | + return ERROR_FEATURE_NOT_PRESENT |
| 80 | + case vk.ERROR_INCOMPATIBLE_DRIVER: |
| 81 | + return ERROR_INCOMPATIBLE_DRIVER |
| 82 | + case vk.ERROR_TOO_MANY_OBJECTS: |
| 83 | + return ERROR_TOO_MANY_OBJECTS |
| 84 | + case vk.ERROR_FORMAT_NOT_SUPPORTED: |
| 85 | + return ERROR_FORMAT_NOT_SUPPORTED |
| 86 | + case vk.ERROR_FRAGMENTED_POOL: |
| 87 | + return ERROR_FRAGMENTED_POOL |
| 88 | + case vk.ERROR_OUT_OF_POOL_MEMORY: |
| 89 | + return ERROR_OUT_OF_POOL_MEMORY |
| 90 | + case vk.ERROR_INVALID_EXTERNAL_HANDLE: |
| 91 | + return ERROR_INVALID_EXTERNAL_HANDLE |
| 92 | + |
| 93 | + case vk.ERROR_SURFACE_LOST_KHR: |
| 94 | + return ERROR_SURFACE_LOST_KHR |
| 95 | + case vk.ERROR_NATIVE_WINDOW_IN_USE_KHR: |
| 96 | + return ERROR_NATIVE_WINDOW_IN_USE_KHR |
| 97 | + case vk.ERROR_OUT_OF_DATE_KHR: |
| 98 | + return ERROR_OUT_OF_DATE_KHR |
| 99 | + case vk.ERROR_INCOMPATIBLE_DISPLAY_KHR: |
| 100 | + return ERROR_INCOMPATIBLE_DISPLAY_KHR |
| 101 | + case vk.ERROR_INVALID_SHADER_NV: |
| 102 | + return ERROR_INVALID_SHADER_NV |
| 103 | + case vk.ERROR_FRAGMENTATION_EXT: |
| 104 | + return ERROR_FRAGMENTATION_EXT |
| 105 | + case vk.ERROR_VALIDATION_FAILED_EXT: |
| 106 | + return ERROR_VALIDATION_FAILED_EXT |
| 107 | + case vk.ERROR_NOT_PERMITTED_EXT: |
| 108 | + return ERROR_NOT_PERMITTED_EXT |
| 109 | + // case vk.ERROR_OUT_OF_POOL_MEMORY_KHR: |
| 110 | + // return ERROR_OUT_OF_POOL_MEMORY_KHR |
| 111 | + // case vk.ERROR_INVALID_EXTERNAL_HANDLE_KHR: |
| 112 | + // return ERROR_INVALID_EXTERNAL_HANDLE_KHR |
| 113 | + |
| 114 | + default: |
| 115 | + return UNKOWN |
| 116 | + } |
| 117 | +} |
0 commit comments