Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3c67c93
perf(gui): Implement batched GUI rendering for improved performance
githubawn Mar 30, 2026
dd7e822
centralized logic into setup2DRenderState
githubawn Mar 30, 2026
bfd6c1e
prevent some possible state leakage
githubawn Mar 30, 2026
f02e944
fix batch execution order and texture lifetime bug
githubawn Mar 31, 2026
b40f7bd
initialize m_batchNeedsInit in constructor
githubawn Mar 31, 2026
6d17889
defer Release_Ref until after m_2DRender->Render():
githubawn Mar 31, 2026
f52030a
resolve texture leak
githubawn Mar 31, 2026
b4ddceb
move off screen clipping after the null check
githubawn Mar 31, 2026
2497ea1
fix order call in draw_image_additive
githubawn Mar 31, 2026
aaaff88
remove unneeded DRAW_IMAGE
githubawn Mar 31, 2026
6d28a51
properly initialize m_batchNeedsInit in constructor
githubawn Mar 31, 2026
8ddb66e
fix DRAW_IMAGE_GRAYSCALE to explicitly call Enable_Alpha(TRUE)
githubawn Mar 31, 2026
b280e5b
optimize m_textRendererHotKey
githubawn Mar 31, 2026
93132b4
optimize m_textRendererHotKey
githubawn Mar 31, 2026
683fb14
Merge branch 'perf/gui-batch' of https://github.com/githubawn/General…
githubawn Mar 31, 2026
0efede5
add missing curly bracket
githubawn Mar 31, 2026
53badb9
simplify onflush
githubawn Mar 31, 2026
5d9405a
Move HUD batching from GameWindowManager to W3DInGameUI::draw()
githubawn Apr 1, 2026
13fc763
replicated to generals
githubawn Apr 5, 2026
667d24d
implement review feedback
githubawn Apr 6, 2026
8bec215
fix generals replication
githubawn Apr 6, 2026
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
3 changes: 3 additions & 0 deletions Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1880,7 +1880,10 @@ void W3DView::draw()
/// @todo we might want to consider wiping this iterate out if there is nothing to post draw
//
TheGameClient->resetRenderedObjectCount();

TheDisplay->beginBatch();
TheGameClient->iterateDrawablesInRegion( &axisAlignedRegion, drawablePostDraw, this );
TheDisplay->endBatch();

TheGameClient->flushTextBearingDrawables();

Expand Down
9 changes: 9 additions & 0 deletions Generals/Code/GameEngine/Include/GameClient/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ class Display : public SubsystemInterface
virtual Bool isClippingEnabled() = 0;
virtual void enableClipping( Bool onoff ) = 0;

virtual void beginBatch();
virtual void endBatch();
virtual void flush();
virtual Bool isBatching() { return m_isBatching; }

virtual void step() {}; ///< Do one fixed time step
virtual void draw() override; ///< Redraw the entire display
virtual void setTimeOfDay( TimeOfDay tod ) = 0; ///< Set the time of day for this display
Expand Down Expand Up @@ -182,11 +187,15 @@ class Display : public SubsystemInterface
virtual Int getLastFrameDrawCalls() = 0; ///< returns the number of draw calls issued in the previous frame

protected:
virtual void onBeginBatch() { }
virtual void onEndBatch() { }
virtual void onFlush() { }

virtual void deleteViews(); ///< delete all views
UnsignedInt m_width, m_height; ///< Dimensions of the display
UnsignedInt m_bitDepth; ///< bit depth of the display
Bool m_windowed; ///< TRUE when windowed, FALSE when fullscreen
Bool m_isBatching;
View *m_viewList; ///< All of the views into the world

// Cinematic text data
Expand Down
29 changes: 29 additions & 0 deletions Generals/Code/GameEngine/Source/GameClient/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Display::Display()

m_currentlyPlayingMovie.clear();
m_letterBoxFadeStartTime = 0;
m_isBatching = FALSE;
}

/**
Expand Down Expand Up @@ -387,3 +388,31 @@ Display::DebugDisplayCallback *Display::getDebugDisplayCallback()
{
return m_debugDisplayCallback;
}

void Display::beginBatch()
{
if (m_isBatching)
{
return;
}
m_isBatching = TRUE;
onBeginBatch();
}

void Display::endBatch()
{
if (!m_isBatching)
{
return;
}
m_isBatching = FALSE;
onEndBatch();
}

void Display::flush()
{
if (m_isBatching)
{
onFlush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Render2DClass;
class RTS3DScene;
class RTS2DScene;
class RTS3DInterfaceScene;
class TextureClass;


//=============================================================================
Expand Down Expand Up @@ -160,6 +161,10 @@ class W3DDisplay : public Display
void calculateTerrainLOD(); ///< Calculate terrain LOD.
void renderLetterBox(UnsignedInt time); ///< draw letter box border
void updateAverageFPS(); ///< calculate the average fps over the last 30 frames.
void setup2DRenderState(TextureClass *tex, DrawImageMode mode, Bool grayscale);
virtual void onBeginBatch() override;
virtual void onEndBatch() override;
virtual void onFlush() override;

Byte m_initialized; ///< TRUE when system is initialized
LightClass *m_myLight[LightEnvironmentClass::MAX_LIGHTS]; ///< light hack for now
Expand All @@ -168,6 +173,12 @@ class W3DDisplay : public Display
Bool m_isClippedEnabled; ///<used by 2D drawing operations to define clip re
Real m_averageFPS; ///<average fps over the last 30 frames.
Real m_currentFPS; ///<current fps value.

TextureClass *m_batchTexture;
DrawImageMode m_batchMode;
Bool m_batchGrayscale;
Bool m_batchNeedsInit;

#if defined(RTS_DEBUG)
Int64 m_timerAtCumuFPSStart;
#endif
Expand Down
Loading
Loading