Index: ps/trunk/source/renderer/backend/vulkan/Buffer.cpp =================================================================== --- ps/trunk/source/renderer/backend/vulkan/Buffer.cpp +++ ps/trunk/source/renderer/backend/vulkan/Buffer.cpp @@ -20,6 +20,7 @@ #include "Buffer.h" #include "renderer/backend/vulkan/Device.h" +#include "renderer/backend/vulkan/Utilities.h" namespace Renderer { @@ -87,7 +88,7 @@ &buffer->m_Buffer, &buffer->m_Allocation, &buffer->m_AllocationInfo); if (createBufferResult != VK_SUCCESS) { - LOGERROR("Failed to create VkBuffer: %d", static_cast(createBufferResult)); + LOGERROR("Failed to create VkBuffer: %d (%s)", static_cast(createBufferResult), Utilities::GetVkResultName(createBufferResult)); return nullptr; } Index: ps/trunk/source/renderer/backend/vulkan/Device.cpp =================================================================== --- ps/trunk/source/renderer/backend/vulkan/Device.cpp +++ ps/trunk/source/renderer/backend/vulkan/Device.cpp @@ -302,7 +302,8 @@ else if (createInstanceResult == VK_ERROR_LAYER_NOT_PRESENT) LOGERROR("Can't create Vulkan instance: layer not present."); else - LOGERROR("Unknown error during Vulkan instance creation: %d", static_cast(createInstanceResult)); + LOGERROR("Unknown error during Vulkan instance creation: %d (%s)", + static_cast(createInstanceResult), Utilities::GetVkResultName(createInstanceResult)); return nullptr; } @@ -518,8 +519,8 @@ else if (createDeviceResult == VK_ERROR_EXTENSION_NOT_PRESENT) LOGERROR("Can't create Vulkan device: extension not present."); else - LOGERROR("Unknown error during Vulkan device creation: %d", - static_cast(createDeviceResult)); + LOGERROR("Unknown error during Vulkan device creation: %d (%s)", + static_cast(createDeviceResult), Utilities::GetVkResultName(createDeviceResult)); return nullptr; } @@ -560,8 +561,8 @@ vmaCreateAllocator(&allocatorCreateInfo, &device->m_VMAAllocator); if (createVMAAllocatorResult != VK_SUCCESS) { - LOGERROR("Failed to create VMA allocator: %d", - static_cast(createDeviceResult)); + LOGERROR("Failed to create VMA allocator: %d (%s)", + static_cast(createVMAAllocatorResult), Utilities::GetVkResultName(createVMAAllocatorResult)); return nullptr; } Index: ps/trunk/source/renderer/backend/vulkan/ShaderProgram.cpp =================================================================== --- ps/trunk/source/renderer/backend/vulkan/ShaderProgram.cpp +++ ps/trunk/source/renderer/backend/vulkan/ShaderProgram.cpp @@ -29,6 +29,7 @@ #include "renderer/backend/vulkan/DescriptorManager.h" #include "renderer/backend/vulkan/Device.h" #include "renderer/backend/vulkan/Texture.h" +#include "renderer/backend/vulkan/Utilities.h" #include #include @@ -63,9 +64,11 @@ createInfo.pCode = reinterpret_cast(file.GetBuffer()); VkShaderModule shaderModule; - if (vkCreateShaderModule(device->GetVkDevice(), &createInfo, nullptr, &shaderModule) != VK_SUCCESS) + const VkResult result = vkCreateShaderModule(device->GetVkDevice(), &createInfo, nullptr, &shaderModule); + if (result != VK_SUCCESS) { - LOGERROR("Failed to create shader module from file: '%s'", path.string8()); + LOGERROR("Failed to create shader module from file: '%s' %d (%s)", + path.string8(), static_cast(result), Utilities::GetVkResultName(result)); return VK_NULL_HANDLE; } device->SetObjectName(VK_OBJECT_TYPE_SHADER_MODULE, shaderModule, path.string8().c_str()); @@ -491,7 +494,8 @@ &shaderProgram->m_PipelineLayout); if (result != VK_SUCCESS) { - LOGERROR("Failed to create a pipeline layout: %d", static_cast(result)); + LOGERROR("Failed to create a pipeline layout: %d (%s)", + static_cast(result), Utilities::GetVkResultName(result)); return nullptr; } Index: ps/trunk/source/renderer/backend/vulkan/SwapChain.cpp =================================================================== --- ps/trunk/source/renderer/backend/vulkan/SwapChain.cpp +++ ps/trunk/source/renderer/backend/vulkan/SwapChain.cpp @@ -276,7 +276,8 @@ m_IsValid = false; else if (acquireResult != VK_SUBOPTIMAL_KHR) { - LOGERROR("Acquire result: %d", static_cast(acquireResult)); + LOGERROR("Acquire result: %d (%s)", + static_cast(acquireResult), Utilities::GetVkResultName(acquireResult)); debug_warn("Unknown acquire error."); } } @@ -339,7 +340,8 @@ m_IsValid = false; else if (presentResult != VK_SUBOPTIMAL_KHR) { - LOGERROR("Present result: %d", static_cast(presentResult)); + LOGERROR("Present result: %d (%s)", + static_cast(presentResult), Utilities::GetVkResultName(presentResult)); debug_warn("Unknown present error."); } } Index: ps/trunk/source/renderer/backend/vulkan/Texture.cpp =================================================================== --- ps/trunk/source/renderer/backend/vulkan/Texture.cpp +++ ps/trunk/source/renderer/backend/vulkan/Texture.cpp @@ -157,7 +157,8 @@ &texture->m_Image, &texture->m_Allocation, nullptr); if (createImageResult != VK_SUCCESS) { - LOGERROR("Failed to create VkImage: %d", static_cast(createImageResult)); + LOGERROR("Failed to create VkImage: %d (%s)", + static_cast(createImageResult), Utilities::GetVkResultName(createImageResult)); return nullptr; } @@ -321,7 +322,8 @@ &texture->m_Image, &texture->m_Allocation, &texture->m_AllocationInfo); if (createImageResult != VK_SUCCESS) { - LOGERROR("Failed to create VkImage: %d", static_cast(createImageResult)); + LOGERROR("Failed to create VkImage: %d (%s)", + static_cast(createImageResult), Utilities::GetVkResultName(createImageResult)); return nullptr; } Index: ps/trunk/source/renderer/backend/vulkan/Utilities.h =================================================================== --- ps/trunk/source/renderer/backend/vulkan/Utilities.h +++ ps/trunk/source/renderer/backend/vulkan/Utilities.h @@ -28,7 +28,7 @@ const VkResult result = (EXPR); \ if (result != VK_SUCCESS) \ { \ - LOGERROR(#EXPR " returned %d instead of VK_SUCCESS", static_cast(result)); \ + LOGERROR(#EXPR " returned %d (%s) instead of VK_SUCCESS", static_cast(result), Utilities::GetVkResultName(result)); \ ENSURE(false && #EXPR); \ } \ } while (0) @@ -80,6 +80,8 @@ void SubmitDebugSyncMemoryBarrier(VkCommandBuffer commandBuffer); +const char* GetVkResultName(const VkResult result); + } // namespace Utilities } // namespace Vulkan Index: ps/trunk/source/renderer/backend/vulkan/Utilities.cpp =================================================================== --- ps/trunk/source/renderer/backend/vulkan/Utilities.cpp +++ ps/trunk/source/renderer/backend/vulkan/Utilities.cpp @@ -161,6 +161,45 @@ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT); } +const char* GetVkResultName(const VkResult result) +{ +#define CASE(NAME) case NAME: return #NAME + switch (result) + { + CASE(VK_SUCCESS); + CASE(VK_NOT_READY); + CASE(VK_TIMEOUT); + CASE(VK_EVENT_SET); + CASE(VK_EVENT_RESET); + CASE(VK_INCOMPLETE); + CASE(VK_ERROR_OUT_OF_HOST_MEMORY); + CASE(VK_ERROR_OUT_OF_DEVICE_MEMORY); + CASE(VK_ERROR_INITIALIZATION_FAILED); + CASE(VK_ERROR_DEVICE_LOST); + CASE(VK_ERROR_MEMORY_MAP_FAILED); + CASE(VK_ERROR_LAYER_NOT_PRESENT); + CASE(VK_ERROR_EXTENSION_NOT_PRESENT); + CASE(VK_ERROR_FEATURE_NOT_PRESENT); + CASE(VK_ERROR_INCOMPATIBLE_DRIVER); + CASE(VK_ERROR_TOO_MANY_OBJECTS); + CASE(VK_ERROR_FORMAT_NOT_SUPPORTED); + CASE(VK_ERROR_FRAGMENTED_POOL); + CASE(VK_ERROR_UNKNOWN); + CASE(VK_ERROR_OUT_OF_POOL_MEMORY); + CASE(VK_ERROR_INVALID_EXTERNAL_HANDLE); + CASE(VK_ERROR_FRAGMENTATION); + CASE(VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS); + CASE(VK_ERROR_SURFACE_LOST_KHR); + CASE(VK_ERROR_NATIVE_WINDOW_IN_USE_KHR); + CASE(VK_SUBOPTIMAL_KHR); + CASE(VK_ERROR_OUT_OF_DATE_KHR); + default: + break; + } +#undef CASE + return "UNLISTED"; +} + } // namespace Utilities } // namespace Vulkan