forked from 0ad/0ad
Adds printing error names to Vulkan backend.
Differential Revision: https://code.wildfiregames.com/D5121 This was SVN commit r27839.
This commit is contained in:
parent
5ac0b48639
commit
af13be489e
@ -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 @@ std::unique_ptr<CBuffer> CBuffer::Create(
|
||||
&buffer->m_Buffer, &buffer->m_Allocation, &buffer->m_AllocationInfo);
|
||||
if (createBufferResult != VK_SUCCESS)
|
||||
{
|
||||
LOGERROR("Failed to create VkBuffer: %d", static_cast<int>(createBufferResult));
|
||||
LOGERROR("Failed to create VkBuffer: %d (%s)", static_cast<int>(createBufferResult), Utilities::GetVkResultName(createBufferResult));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,8 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
|
||||
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<int>(createInstanceResult));
|
||||
LOGERROR("Unknown error during Vulkan instance creation: %d (%s)",
|
||||
static_cast<int>(createInstanceResult), Utilities::GetVkResultName(createInstanceResult));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -518,8 +519,8 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
|
||||
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<int>(createDeviceResult));
|
||||
LOGERROR("Unknown error during Vulkan device creation: %d (%s)",
|
||||
static_cast<int>(createDeviceResult), Utilities::GetVkResultName(createDeviceResult));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -560,8 +561,8 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
|
||||
vmaCreateAllocator(&allocatorCreateInfo, &device->m_VMAAllocator);
|
||||
if (createVMAAllocatorResult != VK_SUCCESS)
|
||||
{
|
||||
LOGERROR("Failed to create VMA allocator: %d",
|
||||
static_cast<int>(createDeviceResult));
|
||||
LOGERROR("Failed to create VMA allocator: %d (%s)",
|
||||
static_cast<int>(createVMAAllocatorResult), Utilities::GetVkResultName(createVMAAllocatorResult));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -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 <algorithm>
|
||||
#include <limits>
|
||||
@ -63,9 +64,11 @@ VkShaderModule CreateShaderModule(CDevice* device, const VfsPath& path)
|
||||
createInfo.pCode = reinterpret_cast<const uint32_t*>(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<int>(result), Utilities::GetVkResultName(result));
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
device->SetObjectName(VK_OBJECT_TYPE_SHADER_MODULE, shaderModule, path.string8().c_str());
|
||||
@ -491,7 +494,8 @@ std::unique_ptr<CShaderProgram> CShaderProgram::Create(
|
||||
&shaderProgram->m_PipelineLayout);
|
||||
if (result != VK_SUCCESS)
|
||||
{
|
||||
LOGERROR("Failed to create a pipeline layout: %d", static_cast<int>(result));
|
||||
LOGERROR("Failed to create a pipeline layout: %d (%s)",
|
||||
static_cast<int>(result), Utilities::GetVkResultName(result));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,8 @@ bool CSwapChain::AcquireNextImage(VkSemaphore acquireImageSemaphore)
|
||||
m_IsValid = false;
|
||||
else if (acquireResult != VK_SUBOPTIMAL_KHR)
|
||||
{
|
||||
LOGERROR("Acquire result: %d", static_cast<int>(acquireResult));
|
||||
LOGERROR("Acquire result: %d (%s)",
|
||||
static_cast<int>(acquireResult), Utilities::GetVkResultName(acquireResult));
|
||||
debug_warn("Unknown acquire error.");
|
||||
}
|
||||
}
|
||||
@ -339,7 +340,8 @@ void CSwapChain::Present(VkSemaphore submitDone, VkQueue queue)
|
||||
m_IsValid = false;
|
||||
else if (presentResult != VK_SUBOPTIMAL_KHR)
|
||||
{
|
||||
LOGERROR("Present result: %d", static_cast<int>(presentResult));
|
||||
LOGERROR("Present result: %d (%s)",
|
||||
static_cast<int>(presentResult), Utilities::GetVkResultName(presentResult));
|
||||
debug_warn("Unknown present error.");
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,8 @@ std::unique_ptr<CTexture> CTexture::Create(
|
||||
&texture->m_Image, &texture->m_Allocation, nullptr);
|
||||
if (createImageResult != VK_SUCCESS)
|
||||
{
|
||||
LOGERROR("Failed to create VkImage: %d", static_cast<int>(createImageResult));
|
||||
LOGERROR("Failed to create VkImage: %d (%s)",
|
||||
static_cast<int>(createImageResult), Utilities::GetVkResultName(createImageResult));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -321,7 +322,8 @@ std::unique_ptr<CTexture> CTexture::CreateReadback(
|
||||
&texture->m_Image, &texture->m_Allocation, &texture->m_AllocationInfo);
|
||||
if (createImageResult != VK_SUCCESS)
|
||||
{
|
||||
LOGERROR("Failed to create VkImage: %d", static_cast<int>(createImageResult));
|
||||
LOGERROR("Failed to create VkImage: %d (%s)",
|
||||
static_cast<int>(createImageResult), Utilities::GetVkResultName(createImageResult));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -161,6 +161,45 @@ void SubmitDebugSyncMemoryBarrier(VkCommandBuffer commandBuffer)
|
||||
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
|
||||
|
@ -28,7 +28,7 @@
|
||||
const VkResult result = (EXPR); \
|
||||
if (result != VK_SUCCESS) \
|
||||
{ \
|
||||
LOGERROR(#EXPR " returned %d instead of VK_SUCCESS", static_cast<int>(result)); \
|
||||
LOGERROR(#EXPR " returned %d (%s) instead of VK_SUCCESS", static_cast<int>(result), Utilities::GetVkResultName(result)); \
|
||||
ENSURE(false && #EXPR); \
|
||||
} \
|
||||
} while (0)
|
||||
@ -80,6 +80,8 @@ void SubmitPipelineBarrier(
|
||||
|
||||
void SubmitDebugSyncMemoryBarrier(VkCommandBuffer commandBuffer);
|
||||
|
||||
const char* GetVkResultName(const VkResult result);
|
||||
|
||||
} // namespace Utilities
|
||||
|
||||
} // namespace Vulkan
|
||||
|
Loading…
Reference in New Issue
Block a user