Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
"inherits": "win32",
"displayName": "Windows 32bit Profile",
"cacheVariables": {
"RTS_BUILD_OPTION_PROFILE": "ON"
"RTS_BUILD_OPTION_PROFILE": "ON",
"RTS_BUILD_OPTION_PROFILE_TRACY": "ON"
}
},
{
Expand Down Expand Up @@ -143,7 +144,8 @@
"inherits": "win32-vcpkg",
"displayName": "Windows 32bit VCPKG Profile",
"cacheVariables": {
"RTS_BUILD_OPTION_PROFILE": "ON"
"RTS_BUILD_OPTION_PROFILE": "ON",
"RTS_BUILD_OPTION_PROFILE_TRACY": "ON"
}
},
{
Expand Down Expand Up @@ -488,4 +490,4 @@
]
}
]
}
}
4 changes: 4 additions & 0 deletions Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ target_link_libraries(corei_always_no_pch INTERFACE
resources
)

if(RTS_BUILD_OPTION_PROFILE AND RTS_BUILD_OPTION_PROFILE_TRACY)
target_link_libraries(corei_libraries_include INTERFACE Tracy::TracyClient)
endif()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(RTS_BUILD_OPTION_PROFILE)
    if(RTS_BUILD_OPTION_PROFILE_TRACY)
        target_link_libraries(corei_libraries_include INTERFACE Tracy::TracyClient)
    endif()
endif()

Makes it easier to plugin new ones later.


# Set where the build results will end up
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

Expand Down
2 changes: 2 additions & 0 deletions Core/GameEngine/Source/Common/FrameRateLimit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "PreRTS.h"
#include "Common/FrameRateLimit.h"

#include "rts/profile.h"

FrameRateLimit::FrameRateLimit()
{
Expand All @@ -32,6 +33,7 @@ FrameRateLimit::FrameRateLimit()

Real FrameRateLimit::wait(UnsignedInt maxFps)
{
ZoneScopedN("FrameRateLimit::wait");
LARGE_INTEGER tick;
QueryPerformanceCounter(&tick);
double elapsedSeconds = static_cast<double>(tick.QuadPart - m_start) / m_freq;
Expand Down
8 changes: 8 additions & 0 deletions Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@

#include "W3DDevice/GameClient/CameraShakeSystem.h"

#include <rts/profile.h>

constexpr const Real NearZ = MAP_XY_FACTOR; ///< Set the near to MAP_XY_FACTOR. Improves z buffer resolution.

// 30 fps
Expand Down Expand Up @@ -1488,6 +1490,7 @@ void W3DView::drawView( void )
void W3DView::draw( void )
{
//USE_PERF_TIMER(W3DView_drawView)
ZoneScopedN("Render::DisplayDraw::W3DView");
Bool skipRender = false;
Bool doExtraRender = false;
CustomScenePassModes customScenePassMode = SCENE_PASS_DEFAULT;
Expand All @@ -1497,6 +1500,7 @@ void W3DView::draw( void )
m_viewFilter > FT_NULL_FILTER &&
m_viewFilter < FT_MAX)
{
ZoneScopedN("Render::DisplayDraw::FilterPre");
// Most likely will redirect rendering to a texture.
preRenderResult=W3DShaderManager::filterPreRender(m_viewFilter, skipRender, customScenePassMode);
if (!skipRender && getCameraLock())
Expand All @@ -1512,6 +1516,7 @@ void W3DView::draw( void )

if (!skipRender)
{
ZoneScopedN("Render::DisplayDraw::SceneRender");
// Render 3D scene from our camera
W3DDisplay::m_3DScene->setCustomPassMode(customScenePassMode);
if (m_isWireFrameEnabled)
Expand All @@ -1525,6 +1530,7 @@ void W3DView::draw( void )
m_viewFilter > FT_NULL_FILTER &&
m_viewFilter < FT_MAX)
{
ZoneScopedN("Render::DisplayDraw::FilterPost");
Coord2D deltaScroll;
calcDeltaScroll(deltaScroll);
Bool continueTheEffect = false;
Expand Down Expand Up @@ -1558,6 +1564,7 @@ void W3DView::draw( void )
//was turned off by filterPostRender().
if (doExtraRender)
{
ZoneScopedN("Render::DisplayDraw::ExtraRender");
//Reset to normal scene rendering.
//The pass that rendered into a texture may have left the z-buffer in a weird state
//so clear it before rendering normal scene.
Expand All @@ -1571,6 +1578,7 @@ void W3DView::draw( void )

if( TheGlobalData->m_debugAI )
{
ZoneScopedN("Render::DisplayDraw::DebugAI");
if (TheAI->pathfinder()->getDebugPath())
{
// setup screen clipping region
Expand Down
15 changes: 14 additions & 1 deletion Core/Libraries/Include/rts/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@
// Proxy header for profile module
//////////////////////////////////////////////////////////////////////////////

# pragma once
#pragma once

#ifdef TRACY_ENABLE
#include <tracy/Tracy.hpp>
#define TRACY_FRAMEIMAGE_SIZE 256
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this value come to be?

I see in Tracy docsthat max image size is 256 KB and recommended resolution of images is around 320 x 180.

#else
#include "../../Source/profile/profile.h"
#define ZoneScopedN(name) ((void)0)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use abstracted names for profiler functions, so that we would be able to plugin different kinds of Profilers behind the same macros.

Find example here:
https://github.com/TheAssemblyArmada/Thyme/pull/801/changes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK will check that out

#define ZoneScopedNC(name, color) ((void)0)
#define TracyPlot(name, value) ((void)0)
#define FrameMark ((void)0)
#define FrameMarkNamed(name) ((void)0)
#define FrameImage(image, width, height, offset, flip) ((void)0)
#define TracyMessage(txt, size) ((void)0)
#define TracyIsConnected false
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use MACRO_CASE for macros

Copy link
Author

@stephanmeesters stephanmeesters Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FrameMarkNamed , FrameImage, TracyMessage etc. are macros defined by Tracy and the code here are stubs of those macros when we don't include the Tracy library.

We could do MACRO_CASE like this (but you will get the ones emitted by Tracy too)

// when enabled
#define TRACY_MESSAGE(text, size) TracyMessage(text, size)
// when disabled
#define TRACY_MESSAGE(text, size) ((void)0)

#endif
6 changes: 6 additions & 0 deletions GeneralsMD/Code/GameEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,12 @@ target_link_libraries(z_gameengine PRIVATE
zi_always
)

if(RTS_BUILD_OPTION_PROFILE AND RTS_BUILD_OPTION_PROFILE_TRACY)
target_link_libraries(z_gameengine PRIVATE
Tracy::TracyClient
)
endif()

target_link_libraries(z_gameengine PUBLIC
corei_gameengine_public
z_wwvegas
Expand Down
4 changes: 4 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameClient/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
//#include "GameLogic/ScriptEngine.h"
//#include "GameLogic/GameLogic.h"

#include <rts/profile.h>

/// The Display singleton instance.
Display *TheDisplay = nullptr;

Expand Down Expand Up @@ -110,6 +112,7 @@ void Display::attachView( View *view )
*/
void Display::drawViews( void )
{
ZoneScopedN("Render::W3DDisplay::DrawViews");

for( View *v = m_viewList; v; v = v->getNextView() )
v->drawView();
Expand All @@ -122,6 +125,7 @@ void Display::drawViews( void )
*/
void Display::updateViews( void )
{
ZoneScopedN("Render::W3DDisplay::UpdateViews");

for( View *v = m_viewList; v; v = v->getNextView() )
v->updateView();
Expand Down
13 changes: 13 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
#include "GameLogic/Object.h"
#include "GameLogic/ScriptEngine.h" // For TheScriptEngine - jkmcd

#include <rts/profile.h>

#define DRAWABLE_HASH_SIZE 8192

/// The GameClient singleton instance
Expand Down Expand Up @@ -511,6 +513,7 @@ DECLARE_PERF_TIMER(GameClient_draw)
void GameClient::update( void )
{
USE_PERF_TIMER(GameClient_update)
FrameMark;
// create the FRAME_TICK message
GameMessage *frameMsg = TheMessageStream->appendMessage( GameMessage::MSG_FRAME_TICK );
frameMsg->appendTimestampArgument( getFrame() );
Expand Down Expand Up @@ -618,21 +621,26 @@ void GameClient::update( void )
TheInGameUI->setCameraTrackingDrawable( FALSE );
}

ZoneScopedNC("Render", 0x2196F3);

if(TheGlobalData->m_playIntro || TheGlobalData->m_afterIntro)
{
// redraw all views, update the GUI
ZoneScopedN("Render::IntroDisplay");
TheDisplay->DRAW();
TheDisplay->UPDATE();
return;
}

// update the window system itself
{
ZoneScopedN("Render::WindowManager");
TheWindowManager->UPDATE();
}

// update the video player
{
ZoneScopedN("Render::VideoPlayer");
TheVideoPlayer->UPDATE();
}

Expand Down Expand Up @@ -743,11 +751,13 @@ void GameClient::update( void )

// update the terrain visuals
{
ZoneScopedN("Render::TerrainVisual");
TheTerrainVisual->UPDATE();
}

// update display
{
ZoneScopedN("Render::DisplayUpdate");
TheDisplay->UPDATE();
}

Expand All @@ -762,16 +772,19 @@ void GameClient::update( void )

{
// let display string factory handle its update
ZoneScopedN("Render::DisplayStrings");
TheDisplayStringManager->update();
}

{
// update the shell
ZoneScopedN("Render::Shell");
TheShell->UPDATE();
}

{
// update the in game UI
ZoneScopedN("Render::InGameUI");
TheInGameUI->UPDATE();
}
}
Expand Down
14 changes: 9 additions & 5 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

#include "Common/UnitTimings.h" //Contains the DO_UNIT_TIMINGS define jba.

#include <rts/profile.h>

#define no_INTENSE_DEBUG

#define DEBUG_QPF
Expand Down Expand Up @@ -5756,6 +5758,7 @@ Path *Pathfinder::getAircraftPath( const Object *obj, const Coord3D *to )
void Pathfinder::processPathfindQueue(void)
{
//USE_PERF_TIMER(processPathfindQueue)
ZoneScopedN("Pathfinder::processPathfindQueue");
if (!m_isMapReady) {
return;
}
Expand All @@ -5777,6 +5780,7 @@ void Pathfinder::processPathfindQueue(void)
#endif
m_zoneManager.needToCalculateZones())
{
ZoneScopedN("Pathfinder::calculateZones");
m_zoneManager.calculateZones(m_map, m_layers, m_extent);
return;
}
Expand All @@ -5794,9 +5798,7 @@ void Pathfinder::processPathfindQueue(void)
m_logicalExtent = bounds;

m_cumulativeCellsAllocated = 0; // Number of pathfind cells examined.
#ifdef DEBUG_QPF
Int pathsFound = 0;
#endif
while (m_cumulativeCellsAllocated < PATHFIND_CELLS_PER_FRAME &&
m_queuePRTail!=m_queuePRHead) {
Object *obj = TheGameLogic->findObjectByID(m_queuedPathfindRequests[m_queuePRHead]);
Expand All @@ -5805,18 +5807,20 @@ void Pathfinder::processPathfindQueue(void)
AIUpdateInterface *ai = obj->getAIUpdateInterface();
if (ai) {
ai->doPathfind(this);
#ifdef DEBUG_QPF
pathsFound++;
#endif
}
}
m_queuePRHead = m_queuePRHead+1;
if (m_queuePRHead >= PATHFIND_QUEUE_LEN) {
m_queuePRHead = 0;
}
}
if (pathsFound>0) {
if (pathsFound > 0) {
TracyPlot("PathfindCells", (double)m_cumulativeCellsAllocated);
TracyPlot("PathfindPaths", (double)pathsFound);
}
#ifdef DEBUG_QPF
if (pathsFound>0) {
#ifdef DEBUG_LOGGING
QueryPerformanceCounter((LARGE_INTEGER *)&endTime64);
timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
#include "GameLogic/Weapon.h"
#include "Common/Radar.h" // For TheRadar

#include <rts/profile.h>

#define SLEEPY_AI


Expand Down Expand Up @@ -395,6 +397,7 @@ except by the pathfinder during pathfind queue processing. jba */
//-------------------------------------------------------------------------------------------------
void AIUpdateInterface::doPathfind( PathfindServicesInterface *pathfinder )
{
ZoneScopedN("AIUpdateInterface::doPathfind");
if (!m_waitingForPath) {
return;
}
Expand Down Expand Up @@ -1667,6 +1670,7 @@ Bool AIUpdateInterface::computeQuickPath( const Coord3D *destination )
*/
Bool AIUpdateInterface::computePath( PathfindServicesInterface *pathServices, Coord3D *destination )
{
ZoneScopedN("AIUpdateInterface::computePath");

if (!m_isBlockedAndStuck) {
destroyPath();
Expand Down Expand Up @@ -1781,6 +1785,7 @@ Bool AIUpdateInterface::computePath( PathfindServicesInterface *pathServices, Co
*/
Bool AIUpdateInterface::computeAttackPath( PathfindServicesInterface *pathServices, const Object *victim, const Coord3D* victimPos )
{
ZoneScopedN("AIUpdateInterface::computeAttackPath");
//CRCDEBUG_LOG(("AIUpdateInterface::computeAttackPath() for object %d", getObject()->getID()));
// See if it has been too soon.
if (m_pathTimestamp >= TheGameLogic->getFrame()-2)
Expand Down
Loading
Loading