Add logging PixelFormat as string instead of integer value for better readability

This commit is contained in:
Wojtek Figat
2023-04-13 10:31:40 +02:00
parent bedb056645
commit b0966c9114
9 changed files with 23 additions and 15 deletions

View File

@@ -35,6 +35,7 @@
#include "Engine/Engine/Base/GameBase.h"
#include "Engine/Engine/Globals.h"
#include "Engine/Tools/TextureTool/TextureTool.h"
#include "Engine/Scripting/Enums.h"
#if PLATFORM_TOOLS_WINDOWS
#include "Engine/Platform/Windows/WindowsPlatformSettings.h"
#endif
@@ -647,7 +648,7 @@ bool ProcessTextureBase(CookAssetsStep::AssetCookData& data)
// Convert texture data to the target format
if (TextureTool::Convert(textureDataTmp1, *textureData, targetFormat))
{
LOG(Error, "Failed to convert texture {0} from format {1} to {2}", asset->ToString(), (int32)format, (int32)targetFormat);
LOG(Error, "Failed to convert texture {0} from format {1} to {2}", asset->ToString(), ScriptingEnum::ToString(format), ScriptingEnum::ToString(targetFormat));
return true;
}
textureData = &textureDataTmp1;

View File

@@ -12,6 +12,7 @@
#include "Engine/Debug/Exceptions/InvalidOperationException.h"
#include "Engine/Debug/Exceptions/ArgumentNullException.h"
#include "Engine/Debug/Exceptions/ArgumentOutOfRangeException.h"
#include "Engine/Scripting/Enums.h"
#include "Engine/Threading/ThreadPoolTask.h"
#include "Engine/Threading/Threading.h"
@@ -107,7 +108,7 @@ String GPUBufferDescription::ToString() const
Size,
Stride,
flags,
(int32)Format,
ScriptingEnum::ToString(Format),
(int32)Usage);
}

View File

@@ -273,7 +273,7 @@ void MaterialParameter::SetValue(const Variant& value)
}
if (invalidType)
{
LOG(Error, "Invalid material parameter value type {0} to set (param type: {1})", value.Type, ScriptingEnum::ToString<MaterialParameterType>(_type));
LOG(Error, "Invalid material parameter value type {0} to set (param type: {1})", value.Type, ScriptingEnum::ToString(_type));
}
}
@@ -530,7 +530,7 @@ bool MaterialParameter::operator==(const MaterialParameter& other) const
String MaterialParameter::ToString() const
{
return String::Format(TEXT("\'{0}\' ({1}:{2}:{3})"), _name, ScriptingEnum::ToString<MaterialParameterType>(_type), _paramId, _isPublic);
return String::Format(TEXT("\'{0}\' ({1}:{2}:{3})"), _name, ScriptingEnum::ToString(_type), _paramId, _isPublic);
}
MaterialParameter* MaterialParams::Get(const Guid& id)

View File

@@ -15,6 +15,7 @@
#include "Engine/Graphics/GPULimits.h"
#include "Engine/Threading/ThreadPoolTask.h"
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Scripting/Enums.h"
namespace
{
@@ -187,7 +188,7 @@ String GPUTextureDescription::ToString() const
ArraySize,
::ToString(Dimensions),
MipLevels,
(int32)Format,
ScriptingEnum::ToString(Format),
::ToString(MultiSampleLevel),
flags,
(int32)Usage);

View File

@@ -9,6 +9,7 @@
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Graphics/RenderTools.h"
#include "Engine/Graphics/Async/Tasks/GPUUploadTextureMipTask.h"
#include "Engine/Scripting/Enums.h"
TextureHeader_Deprecated::TextureHeader_Deprecated()
{
@@ -354,7 +355,7 @@ protected:
// Ensure that texture has been allocated before this task and has proper format
if (!texture->IsAllocated() || texture->Format() != _streamingTexture->GetHeader()->Format)
{
LOG(Error, "Cannot stream texture {0} (streaming format: {1})", texture->ToString(), (int32)_streamingTexture->GetHeader()->Format);
LOG(Error, "Cannot stream texture {0} (streaming format: {1})", texture->ToString(), ScriptingEnum::ToString(_streamingTexture->GetHeader()->Format));
return Result::Failed;
}

View File

@@ -11,6 +11,7 @@
#include "Engine/Debug/Exceptions/InvalidOperationException.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Content/Factories/BinaryAssetFactory.h"
#include "Engine/Scripting/Enums.h"
#include "Engine/Tools/TextureTool/TextureTool.h"
#include "Engine/Threading/Threading.h"
@@ -112,7 +113,7 @@ bool TextureMipData::GetPixels(Array<Color32>& pixels, int32 width, int32 height
}
return false;
}
LOG(Error, "Unsupported texture data format {0}.", (int32)format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(format));
return true;
}
}
@@ -161,7 +162,7 @@ bool TextureMipData::GetPixels(Array<Color>& pixels, int32 width, int32 height,
}
return false;
}
LOG(Error, "Unsupported texture data format {0}.", (int32)format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(format));
return true;
}
}
@@ -453,7 +454,7 @@ bool TextureBase::SetPixels(const Span<Color32>& pixels, int32 mipIndex, int32 a
}
if (error)
{
LOG(Error, "Unsupported texture data format {0}.", (int32)format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(format));
return true;
}
@@ -531,7 +532,7 @@ bool TextureBase::SetPixels(const Span<Color>& pixels, int32 mipIndex, int32 arr
}
if (error)
{
LOG(Error, "Unsupported texture data format {0}.", (int32)format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(format));
return true;
}
@@ -844,7 +845,7 @@ bool TextureBase::InitData::GenerateMip(int32 mipIndex, bool linear)
break;
}
default:
LOG(Error, "Unsupported texture data format {0}.", (int32)Format);
LOG(Error, "Unsupported texture data format {0}.", ScriptingEnum::ToString(Format));
return true;
}
}

View File

@@ -34,6 +34,7 @@
#include "Engine/Utilities/StringConverter.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Threading/Threading.h"
#include "Engine/Scripting/Enums.h"
#if !USE_EDITOR && (PLATFORM_WINDOWS || PLATFORM_LINUX)
#include "Engine/Core/Config/PlatformSettings.h"
@@ -1380,7 +1381,7 @@ PixelFormat GPUDeviceVulkan::GetClosestSupportedPixelFormat(PixelFormat format,
#if !BUILD_RELEASE
if (format != remap)
{
LOG(Warning, "Unsupported Vulkan format {0}. Remapping to {1}", (int32)format, (int32)remap);
LOG(Warning, "Unsupported Vulkan format {0}. Remapping to {1}", ScriptingEnum::ToString(format), ScriptingEnum::ToString(remap));
format = GetClosestSupportedPixelFormat(remap, flags, optimalTiling);
}
#endif

View File

@@ -10,6 +10,7 @@
#include "CmdBufferVulkan.h"
#include "Engine/Core/Log.h"
#include "Engine/Graphics/GPULimits.h"
#include "Engine/Scripting/Enums.h"
void BackBufferVulkan::Setup(GPUSwapChainVulkan* window, VkImage backbuffer, PixelFormat format, VkExtent3D extent)
{
@@ -231,13 +232,13 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height)
if (!found)
{
LOG(Warning, "Requested pixel format {0} not supported by this swapchain. Falling back to supported swapchain formats...", (uint32)resultFormat);
LOG(Warning, "Requested pixel format {0} not supported by this swapchain. Falling back to supported swapchain formats...", ScriptingEnum::ToString(resultFormat));
resultFormat = PixelFormat::Unknown;
}
}
else
{
LOG(Warning, "Requested pixel format {0} is not supported by this Vulkan implementation", (uint32)resultFormat);
LOG(Warning, "Requested pixel format {0} is not supported by this Vulkan implementation", ScriptingEnum::ToString(resultFormat));
resultFormat = PixelFormat::Unknown;
}
}

View File

@@ -9,6 +9,7 @@
#include "Engine/Core/Log.h"
#include "Engine/Graphics/PixelFormatExtensions.h"
#include "Engine/Graphics/Textures/TextureData.h"
#include "Engine/Scripting/Enums.h"
void GPUTextureViewVulkan::Init(GPUDeviceVulkan* device, ResourceOwnerVulkan* owner, VkImage image, int32 totalMipLevels, PixelFormat format, MSAALevel msaa, VkExtent3D extent, VkImageViewType viewType, int32 mipLevels, int32 firstMipIndex, int32 arraySize, int32 firstArraySlice, bool readOnlyDepth)
{
@@ -241,7 +242,7 @@ bool GPUTextureVulkan::OnInit()
_desc.Format = _device->GetClosestSupportedPixelFormat(format, _desc.Flags, optimalTiling);
if (_desc.Format == PixelFormat::Unknown)
{
LOG(Error, "Unsupported texture format {0}.", (int32)format);
LOG(Error, "Unsupported texture format {0}.", ScriptingEnum::ToString(format));
return true;
}