From 85afde43af9120365a4a9ea6899eb7928f4a9269 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 3 Jan 2024 22:08:41 +0100 Subject: [PATCH] Add profiler events to texture tool --- Source/Engine/Tools/TextureTool/TextureTool.astc.cpp | 2 ++ Source/Engine/Tools/TextureTool/TextureTool.cpp | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/Engine/Tools/TextureTool/TextureTool.astc.cpp b/Source/Engine/Tools/TextureTool/TextureTool.astc.cpp index ebb9c07af..725c79152 100644 --- a/Source/Engine/Tools/TextureTool/TextureTool.astc.cpp +++ b/Source/Engine/Tools/TextureTool/TextureTool.astc.cpp @@ -8,10 +8,12 @@ #include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Graphics/PixelFormatExtensions.h" #include "Engine/Graphics/RenderTools.h" +#include "Engine/Profiler/ProfilerCPU.h" #include bool TextureTool::ConvertAstc(TextureData& dst, const TextureData& src, const PixelFormat dstFormat) { + PROFILE_CPU(); ASSERT(PixelFormatExtensions::IsCompressedASTC(dstFormat)); const int32 blockSize = PixelFormatExtensions::ComputeBlockSize(dstFormat); const int32 bytesPerBlock = 16; // All ASTC blocks use 128 bits diff --git a/Source/Engine/Tools/TextureTool/TextureTool.cpp b/Source/Engine/Tools/TextureTool/TextureTool.cpp index 72e9f4558..f5b925255 100644 --- a/Source/Engine/Tools/TextureTool/TextureTool.cpp +++ b/Source/Engine/Tools/TextureTool/TextureTool.cpp @@ -15,6 +15,7 @@ #include "Engine/Scripting/Enums.h" #include "Engine/Graphics/Textures/TextureData.h" #include "Engine/Graphics/PixelFormatExtensions.h" +#include "Engine/Profiler/ProfilerCPU.h" #if USE_EDITOR #include "Engine/Core/Collections/Dictionary.h" @@ -183,6 +184,7 @@ bool TextureTool::HasAlpha(const StringView& path) bool TextureTool::ImportTexture(const StringView& path, TextureData& textureData) { + PROFILE_CPU(); LOG(Info, "Importing texture from \'{0}\'", path); const auto startTime = DateTime::NowUTC(); @@ -219,6 +221,7 @@ bool TextureTool::ImportTexture(const StringView& path, TextureData& textureData bool TextureTool::ImportTexture(const StringView& path, TextureData& textureData, Options options, String& errorMsg) { + PROFILE_CPU(); LOG(Info, "Importing texture from \'{0}\'. Options: {1}", path, options.ToString()); const auto startTime = DateTime::NowUTC(); @@ -267,9 +270,9 @@ bool TextureTool::ImportTexture(const StringView& path, TextureData& textureData bool TextureTool::ExportTexture(const StringView& path, const TextureData& textureData) { + PROFILE_CPU(); LOG(Info, "Exporting texture to \'{0}\'.", path); const auto startTime = DateTime::NowUTC(); - ImageType type; if (GetImageType(path, type)) return true; @@ -279,7 +282,6 @@ bool TextureTool::ExportTexture(const StringView& path, const TextureData& textu return true; } - // Export #if COMPILE_WITH_DIRECTXTEX const auto failed = ExportTextureDirectXTex(type, path, textureData); #elif COMPILE_WITH_STB @@ -303,7 +305,6 @@ bool TextureTool::ExportTexture(const StringView& path, const TextureData& textu bool TextureTool::Convert(TextureData& dst, const TextureData& src, const PixelFormat dstFormat) { - // Validate input if (src.GetMipLevels() == 0) { LOG(Warning, "Missing source data."); @@ -319,6 +320,7 @@ bool TextureTool::Convert(TextureData& dst, const TextureData& src, const PixelF LOG(Warning, "Converting volume texture data is not supported."); return true; } + PROFILE_CPU(); #if COMPILE_WITH_DIRECTXTEX return ConvertDirectXTex(dst, src, dstFormat); @@ -332,7 +334,6 @@ bool TextureTool::Convert(TextureData& dst, const TextureData& src, const PixelF bool TextureTool::Resize(TextureData& dst, const TextureData& src, int32 dstWidth, int32 dstHeight) { - // Validate input if (src.GetMipLevels() == 0) { LOG(Warning, "Missing source data."); @@ -348,7 +349,7 @@ bool TextureTool::Resize(TextureData& dst, const TextureData& src, int32 dstWidt LOG(Warning, "Resizing volume texture data is not supported."); return true; } - + PROFILE_CPU(); #if COMPILE_WITH_DIRECTXTEX return ResizeDirectXTex(dst, src, dstWidth, dstHeight); #elif COMPILE_WITH_STB @@ -777,6 +778,7 @@ bool TextureTool::GetImageType(const StringView& path, ImageType& type) bool TextureTool::Transform(TextureData& texture, const Function& transformation) { + PROFILE_CPU(); auto sampler = TextureTool::GetSampler(texture.Format); if (!sampler) return true;