Allow error message to be formatted

This commit is contained in:
SirLynix
2023-08-14 23:16:37 +02:00
committed by Jérôme Leclercq
parent 25957c4b7f
commit a741672a51
119 changed files with 707 additions and 490 deletions

View File

@@ -36,7 +36,7 @@ namespace Nz
m_lastErrorCode = m_pool->GetDevice()->vkBeginCommandBuffer(m_handle, &info);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to begin command buffer: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to begin command buffer: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -321,7 +321,7 @@ namespace Nz
m_lastErrorCode = m_pool->GetDevice()->vkEndCommandBuffer(m_handle);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to end command buffer: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to end command buffer: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -23,7 +23,7 @@ namespace Nz::Vk
inline const Device::QueueList& Device::GetEnabledQueues(UInt32 familyQueue) const
{
NazaraAssert(familyQueue < m_enabledQueuesInfos.size(), "Invalid family queue");
NazaraAssert(familyQueue < m_enabledQueuesInfos.size(), "invalid family queue {0}", familyQueue);
return *m_queuesByFamily[familyQueue];
}
@@ -62,7 +62,7 @@ namespace Nz::Vk
{
PFN_vkVoidFunction func;
{
ErrorFlags errFlags(ErrorMode::ThrowExceptionDisabled);
ErrorFlags errFlags({}, ~ErrorMode::ThrowException);
func = m_instance.GetDeviceProcAddr(m_device, name);
}
@@ -71,7 +71,7 @@ namespace Nz::Vk
if (allowInstanceFallback)
return m_instance.GetProcAddr(name);
NazaraError("Failed to get " + std::string(name) + " address");
NazaraError("failed to get {0} address", name);
}
return func;
@@ -126,7 +126,7 @@ namespace Nz::Vk
m_lastErrorCode = vkDeviceWaitIdle(m_device);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to wait for device idle: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to wait for device idle: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -40,7 +40,7 @@ namespace Nz
typeMask <<= 1;
}
NazaraError("Failed to find a memory type suitable for typeBits: " + NumberToString(typeBits) + " and properties: 0x" + NumberToString(properties, 16));
NazaraError("failed to find a memory type suitable for typeBits: {0} and properties: 0x{1}", typeBits, NumberToString(properties, 16));
return false;
}
@@ -62,7 +62,7 @@ namespace Nz
m_lastErrorCode = m_device->vkFlushMappedMemoryRanges(*m_device, 1, &memoryRange);
if (m_lastErrorCode != VK_SUCCESS)
{
NazaraError("Failed to flush memory: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to flush memory: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -85,7 +85,7 @@ namespace Nz
m_lastErrorCode = m_device->vkMapMemory(*m_device, m_handle, offset, size, flags, &mappedPtr);
if (m_lastErrorCode != VK_SUCCESS)
{
NazaraError("Failed to map device memory: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to map device memory: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -40,7 +40,7 @@ namespace Nz::Vk
m_lastErrorCode = C::CreateHelper(*m_device, &createInfo, allocator, &m_handle);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to create Vulkan device object: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to create Vulkan device object: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -25,7 +25,7 @@ namespace Nz
m_lastErrorCode = m_device->vkResetFences(*m_device, 1U, &m_handle);
if (m_lastErrorCode != VK_SUCCESS)
{
NazaraError("Failed to reset fence: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to reset fence: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -42,7 +42,7 @@ namespace Nz
m_lastErrorCode = m_device->vkWaitForFences(*m_device, 1U, &m_handle, VK_TRUE, timeout);
if (m_lastErrorCode != VK_SUCCESS && m_lastErrorCode != VK_TIMEOUT)
{
NazaraError("Failed to wait for fence: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to wait for fence: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -14,7 +14,7 @@ namespace Nz
m_lastErrorCode = m_device->vkBindImageMemory(*m_device, m_handle, memory, offset);
if (m_lastErrorCode != VK_SUCCESS)
{
NazaraError("Failed to bind image memory: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to bind image memory: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -50,7 +50,7 @@ namespace Nz::Vk
{
PFN_vkVoidFunction func = vkGetDeviceProcAddr(device, name);
if (!func)
NazaraError("Failed to get " + std::string(name) + " address");
NazaraError("failed to get {0} address", name);
return func;
}
@@ -69,7 +69,7 @@ namespace Nz::Vk
{
PFN_vkVoidFunction func = Loader::GetInstanceProcAddr(m_instance, name);
if (!func)
NazaraError("Failed to get " + std::string(name) + " address");
NazaraError("failed to get {0} address", name);
return func;
}
@@ -120,7 +120,7 @@ namespace Nz::Vk
m_lastErrorCode = vkGetPhysicalDeviceImageFormatProperties(physicalDevice, format, type, tiling, usage, flags, imageFormatProperties);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to get physical device image format properties: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to get physical device image format properties: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -39,7 +39,7 @@ namespace Nz
m_lastErrorCode = C::CreateHelper(*m_instance, &createInfo, allocator, &m_handle);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to create Vulkan instance object: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to create Vulkan instance object: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -74,7 +74,7 @@ namespace Nz
m_lastErrorCode = result;
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to create Vulkan pipeline: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to create Vulkan pipeline: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -135,7 +135,7 @@ namespace Nz
m_lastErrorCode = m_device->vkQueueSubmit(m_handle, submitCount, submits, signalFence);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to submit queue: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to submit queue: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -147,7 +147,7 @@ namespace Nz
m_lastErrorCode = m_device->vkQueueWaitIdle(m_handle);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to wait for queue: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to wait for queue: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -177,7 +177,7 @@ namespace Nz::Vk
m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physicalDevice, m_surface, surfaceCapabilities);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to query surface capabilities: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to query surface capabilities: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -191,7 +191,7 @@ namespace Nz::Vk
m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, nullptr);
if (m_lastErrorCode != VkResult::VK_SUCCESS || surfaceCount == 0)
{
NazaraError("Failed to query format count: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to query format count: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -200,7 +200,7 @@ namespace Nz::Vk
m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, m_surface, &surfaceCount, surfaceFormats->data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to query formats: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to query formats: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -223,7 +223,7 @@ namespace Nz::Vk
m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfacePresentModesKHR(physicalDevice, m_surface, &presentModeCount, presentModes->data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to query present modes: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to query present modes: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -236,7 +236,7 @@ namespace Nz::Vk
m_lastErrorCode = m_instance.vkGetPhysicalDeviceSurfaceSupportKHR(physicalDevice, queueFamilyIndex, m_surface, &presentationSupported);
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to query surface capabilities: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to query surface capabilities: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -291,7 +291,7 @@ namespace Nz::Vk
{
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to create Vulkan surface: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to create Vulkan surface: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}

View File

@@ -22,7 +22,7 @@ namespace Nz
default:
{
NazaraError("Failed to acquire next swapchain image: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to acquire next swapchain image: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
}
@@ -37,7 +37,7 @@ namespace Nz
m_lastErrorCode = m_device->vkGetSwapchainImagesKHR(*m_device, m_handle, &imageCount, nullptr);
if (m_lastErrorCode != VkResult::VK_SUCCESS || imageCount == 0)
{
NazaraError("Failed to query swapchain image count: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to query swapchain image count: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -45,7 +45,7 @@ namespace Nz
m_lastErrorCode = m_device->vkGetSwapchainImagesKHR(*m_device, m_handle, &imageCount, images.data());
if (m_lastErrorCode != VkResult::VK_SUCCESS)
{
NazaraError("Failed to query swapchain images: " + TranslateVulkanError(m_lastErrorCode));
NazaraError("failed to query swapchain images: {0}", TranslateVulkanError(m_lastErrorCode));
return false;
}
@@ -78,7 +78,7 @@ namespace Nz
if (!m_images[i].view.Create(*m_device, imageViewCreateInfo))
{
NazaraError("Failed to create image view for image #" + NumberToString(i));
NazaraError("failed to create image view for image #{0}", i);
return false;
}
}