diff --git a/Source/Engine/Content/Asset.cpp b/Source/Engine/Content/Asset.cpp index 86801b078..5a9e62993 100644 --- a/Source/Engine/Content/Asset.cpp +++ b/Source/Engine/Content/Asset.cpp @@ -494,6 +494,9 @@ bool Asset::WaitForLoaded(double timeoutInMilliseconds) const } PROFILE_CPU(); + ZoneColor(TracyWaitZoneColor); + const StringView path(GetPath()); + ZoneText(*path, path.Length()); Content::WaitForTask(loadingTask, timeoutInMilliseconds); diff --git a/Source/Engine/Content/Content.cpp b/Source/Engine/Content/Content.cpp index 4ba6cbc44..2178579cc 100644 --- a/Source/Engine/Content/Content.cpp +++ b/Source/Engine/Content/Content.cpp @@ -1128,6 +1128,8 @@ void Content::WaitForTask(ContentLoadTask* loadingTask, double timeoutInMillisec localQueue.Clear(); } + PROFILE_CPU_NAMED("Inline"); + ZoneColor(0xffaaaaaa); thread->Run(tmp); } else diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp index 7a106d377..3856a7cd0 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp @@ -3,11 +3,12 @@ #if GRAPHICS_API_DIRECTX11 #include "GPUSwapChainDX11.h" +#include "GPUContextDX11.h" #include "Engine/Platform/Window.h" #include "Engine/Graphics/RenderTools.h" #include "Engine/GraphicsDevice/DirectX/RenderToolsDX.h" +#include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Profiler/ProfilerMemory.h" -#include "GPUContextDX11.h" GPUSwapChainDX11::GPUSwapChainDX11(GPUDeviceDX11* device, Window* window) : GPUResourceDX11(device, StringView::Empty) @@ -140,6 +141,9 @@ GPUTextureView* GPUSwapChainDX11::GetBackBufferView() void GPUSwapChainDX11::Present(bool vsync) { + PROFILE_CPU(); + ZoneColor(TracyWaitZoneColor); + // Present frame ASSERT(_swapChain); UINT presentFlags = 0; diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/CommandQueueDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/CommandQueueDX12.cpp index 2488480af..81fef4965 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/CommandQueueDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/CommandQueueDX12.cpp @@ -6,6 +6,7 @@ #include "GPUDeviceDX12.h" #include "Engine/Threading/Threading.h" #include "Engine/GraphicsDevice/DirectX/RenderToolsDX.h" +#include "Engine/Profiler/ProfilerCPU.h" FenceDX12::FenceDX12(GPUDeviceDX12* device) : _currentValue(1) @@ -64,12 +65,12 @@ void FenceDX12::WaitCPU(uint64 value) { if (IsFenceComplete(value)) return; - + PROFILE_CPU(); + ZoneColor(TracyWaitZoneColor); ScopeLock lock(_locker); _fence->SetEventOnCompletion(value, _event); WaitForSingleObject(_event, INFINITE); - _lastCompletedValue = _fence->GetCompletedValue(); } diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp index fa6dfa881..83ecf020d 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp @@ -6,6 +6,7 @@ #include "GPUContextDX12.h" #include "../IncludeDirectXHeaders.h" #include "Engine/GraphicsDevice/DirectX/RenderToolsDX.h" +#include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Profiler/ProfilerMemory.h" void BackBufferDX12::Setup(GPUSwapChainDX12* window, ID3D12Resource* backbuffer) @@ -364,6 +365,8 @@ void GPUSwapChainDX12::End(RenderTask* task) void GPUSwapChainDX12::Present(bool vsync) { + PROFILE_CPU(); + ZoneColor(TracyWaitZoneColor); #if PLATFORM_XBOX_SCARLETT || PLATFORM_XBOX_ONE ID3D12Resource* backBuffer = _backBuffers[_currentFrameIndex].GetResource(); D3D12XBOX_PRESENT_PLANE_PARAMETERS planeParameters = {}; diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp index 73eb90755..f2d0aad7d 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.cpp @@ -2094,6 +2094,7 @@ void GPUDeviceVulkan::WaitForGPU() if (Device != VK_NULL_HANDLE) { PROFILE_CPU(); + ZoneColor(TracyWaitZoneColor); VALIDATE_VULKAN_RESULT(vkDeviceWaitIdle(Device)); } } diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp index 801ba1fc1..21971c5ca 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp @@ -553,6 +553,7 @@ void GPUSwapChainVulkan::Present(bool vsync) if (_acquiredImageIndex == -1) return; PROFILE_CPU(); + ZoneColor(TracyWaitZoneColor); // Ensure that backbuffer has been acquired before presenting it to the window const auto backBuffer = (GPUTextureViewVulkan*)GetBackBufferView(); diff --git a/Source/Engine/Profiler/ProfilerCPU.h b/Source/Engine/Profiler/ProfilerCPU.h index e8d0523f4..77ecfe7b2 100644 --- a/Source/Engine/Profiler/ProfilerCPU.h +++ b/Source/Engine/Profiler/ProfilerCPU.h @@ -412,3 +412,6 @@ struct TIsPODType #define PROFILE_CPU_ACTOR(actor) #endif + +// CPU-wait zones can be marked with red color for better readability +#define TracyWaitZoneColor 0xba1904 diff --git a/Source/Engine/Threading/JobSystem.cpp b/Source/Engine/Threading/JobSystem.cpp index 612584c40..e90a2e847 100644 --- a/Source/Engine/Threading/JobSystem.cpp +++ b/Source/Engine/Threading/JobSystem.cpp @@ -385,6 +385,7 @@ void JobSystem::Wait(int64 label) { #if JOB_SYSTEM_ENABLED PROFILE_CPU(); + ZoneColor(TracyWaitZoneColor); while (Platform::AtomicRead(&ExitFlag) == 0) { diff --git a/Source/Engine/Threading/Task.cpp b/Source/Engine/Threading/Task.cpp index 601079e85..911e1e3e8 100644 --- a/Source/Engine/Threading/Task.cpp +++ b/Source/Engine/Threading/Task.cpp @@ -40,6 +40,7 @@ void Task::Cancel() bool Task::Wait(double timeoutMilliseconds) const { PROFILE_CPU(); + ZoneColor(TracyWaitZoneColor); const double startTime = Platform::GetTimeSeconds(); // TODO: no active waiting! use a semaphore! @@ -76,6 +77,7 @@ bool Task::Wait(double timeoutMilliseconds) const bool Task::WaitAll(const Span& tasks, double timeoutMilliseconds) { PROFILE_CPU(); + ZoneColor(TracyWaitZoneColor); for (int32 i = 0; i < tasks.Length(); i++) { if (tasks[i]->Wait())