feat(profiling): Integrate Tracy profiler#2202
Conversation
12b8fbf to
8ede749
Compare
…ells/paths to Tracy profiling (TheSuperHackers#2202)
|
| Filename | Overview |
|---|---|
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DProfilerFrameCapture.cpp | New file implementing Tracy frame image capture with BGRA→RGBA pixel shader swizzle; null/error checks throughout, correct COM refcount handling. |
| Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DProfilerFrameCapture.h | New header for W3DProfilerFrameCapture, guarded by PROFILER_ENABLED, uses #pragma once, all members have default initializers. |
| Core/Libraries/Include/rts/profile.h | Adds Tracy macro wrappers and no-op fallbacks; splits RTS_PROFILE_LEGACY and RTS_PROFILE_TRACY paths cleanly. |
| cmake/tracy.cmake | New CMake module that fetches Tracy via FetchContent from TheSuperHackers fork at a pinned commit, validates the TracyClient target, and exposes core_profile_tracy alias. |
| cmake/config-build.cmake | Adds RTS_BUILD_OPTION_PROFILE_TRACY option; renames RTS_PROFILE→RTS_PROFILE_LEGACY compile definition; creates a dummy interface target when Tracy is disabled. |
| Core/Libraries/Source/debug/debug.h | Updates HAS_ASSERTS/HAS_LOGS guard from RTS_PROFILE to RTS_PROFILE_LEGACY; Tracy builds intentionally omit these (confirmed acceptable by team). |
| GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp | Adds W3DProfilerFrameCapture construction/destruction and Capture() call per render frame, guarded by PROFILER_ENABLED. |
| Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp | Lifts pathsFound counter out of DEBUG_QPF guard to enable Tracy PROFILER_PLOT instrumentation; semantically correct. |
| Core/Libraries/Source/WWVegas/WWLib/WWCommon.h | Adds #include <rts/profile.h> to this fundamental header so that files which removed their direct include still compile; propagates the include broadly. |
Sequence Diagram
sequenceDiagram
participant WinMain
participant GameClient
participant GameLogic
participant W3DDisplay
participant W3DProfilerFrameCapture
participant Tracy
WinMain->>GameClient: update() [PROFILER_FRAME_MARK]
GameClient->>Tracy: FrameMark (frame boundary)
GameClient->>Tracy: ZoneScopedC (blue zone)
GameClient->>GameLogic: update() [PROFILER_SECTION_COLOR green]
GameLogic->>Tracy: ZoneScopedC (green zone)
GameLogic->>Tracy: TracyPlot("LogicFrame", frame)
GameLogic->>Tracy: TracyPlot("PathfindCells/Paths", counts)
GameClient->>W3DDisplay: draw()
W3DDisplay->>W3DProfilerFrameCapture: Capture(width, height)
W3DProfilerFrameCapture->>Tracy: TracyIsConnected?
alt connected
W3DProfilerFrameCapture->>W3DProfilerFrameCapture: ShouldReuseLastCapture?
alt reuse
W3DProfilerFrameCapture->>Tracy: FrameImage(cached pixels)
else capture
W3DProfilerFrameCapture->>W3DProfilerFrameCapture: Compile swizzle shader BGRA to RGBA
W3DProfilerFrameCapture->>W3DProfilerFrameCapture: Copy backbuffer to intermediate texture
W3DProfilerFrameCapture->>W3DProfilerFrameCapture: Render scaled-down to render target
W3DProfilerFrameCapture->>W3DProfilerFrameCapture: GPU to CPU copy via SurfaceClass lock
W3DProfilerFrameCapture->>Tracy: FrameImage(pixels, width, height)
end
end
Reviews (18): Last reviewed commit: "docs(readme): Add section about profilin..." | Re-trigger Greptile
|
Would you mind adding a few images or a short video to the first post? |
Done. Added examples.
Nevermind I accidentally had DXVK DLL's in the binary dir and that changed the profile: the |
8ede749 to
38cf6dd
Compare
…ells/paths to Tracy profiling (TheSuperHackers#2202)
38cf6dd to
a36e02c
Compare
…ells/paths to Tracy profiling (TheSuperHackers#2202)
xezon
left a comment
There was a problem hiding this comment.
Is this meant to be merged with Rebase? If yes, then the individual commits need polishing and testing that they all compile one after the other.
Yes preferably, if it's alright with you I can tidy it up after the replicate to Generals? As I was planning to do the replicate per-commit as well.
Tested that two days ago but will give a final check |
Yes it is fine to commit small steps. |
…ells/paths to Tracy profiling (TheSuperHackers#2202)
5d198b0 to
56c527f
Compare
|
Switched to new fork, replicated to Generals, improved commit titles a bit and added pull ID, checked that each commit compiled, tested Tracy capture on ZH and Generals. Replicate was done using the git diff, git apply approach. Also did a quick check that there were no dangling "rts_profile" and "core_profile" and "rts/profile.h". |
56c527f to
115f267
Compare
…ells/paths to Tracy profiling (#2202)
Merge by rebase
This PR adds Tracy profiler to the CMake preset
win32-profile.Library include
Tracy is added as CMake
FetchContent_Declare(version 0.13.1). Tracy themselves recommend adding the library as a CMake include because the version of the library that is included in the game must match exactly with the version of their main executabletracy-profiler.exe. This can be guaranteed by building and copyingtracy-profiler.exeto the build dir, however we can not do this right now as it requires a 64 bit compile.What are we tracing?
A very minimal set of sections are added as part of this PR.
Performance impact
Tracy itself has a negligible impact. The frame capturing does have a minor impact (0.5ms average per capture), but this does not capture on every frame unless configured to do so.
Future work
It should be determined whether this will be sufficient to replace the old profiling code.
Example of a capture. Render bound frame (top), update bound frame (bottom)
Note: image is outdated.
Todo