Skip to content

Commit a06ab10

Browse files
Bangalore1010Xottab-DUTY
authored andcommitted
ECO RENDER
ECO RENDER rip from KD/alpet SOC repo: https://xp-dev.com/sc/change/204486/122 Caps intro video (200 fps) and main menu (60 fps) FPS to avoid video card coil noise/overheating.
1 parent 294d821 commit a06ab10

File tree

6 files changed

+31
-4
lines changed

6 files changed

+31
-4
lines changed

src/Common/Config.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@
1111
//#define KEY_HOLD_CALLBACK // expose key hold callback to scripts (configure in bind_stalker)
1212
//#define FP_DEATH // first person death view
1313
#define DETAIL_RADIUS // detail draw radius (by K.D.)
14+
#define ECO_RENDER //ECO_RENDER adds a small delay between rendering, reduce FPS in main menu or in videos

src/Layers/xrRender/HW.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ CHW HW;
3131
IDirect3DStateBlock9* dwDebugSB = nullptr;
3232
#endif
3333

34-
CHW::CHW() : hD3D(nullptr), pD3D(nullptr), pDevice(nullptr), pBaseRT(nullptr), pBaseZB(nullptr), m_move_window(true) { ; }
35-
CHW::~CHW() { ; }
34+
CHW::CHW() : hD3D(nullptr), pD3D(nullptr), pDevice(nullptr), pBaseRT(nullptr), pBaseZB(nullptr), m_move_window(true), maxRefreshRate(200)/*ECO_RENDER*/ {}
35+
CHW::~CHW() {}
3636
void CHW::Reset(HWND hwnd)
3737
{
3838
#ifdef DEBUG
@@ -504,8 +504,10 @@ u32 CHW::selectRefresh(u32 dwWidth, u32 dwHeight, D3DFORMAT fmt)
504504
pD3D->EnumAdapterModes(DevAdapter, fmt, I, &Mode);
505505
if (Mode.Width == dwWidth && Mode.Height == dwHeight)
506506
{
507-
if (Mode.RefreshRate > selected)
508-
selected = Mode.RefreshRate;
507+
//if (Mode.RefreshRate > selected)
508+
// selected = Mode.RefreshRate;
509+
if (Mode.RefreshRate <= maxRefreshRate && Mode.RefreshRate>selected)
510+
selected = Mode.RefreshRate; //ECO_RENDER modif.
509511
}
510512
}
511513
return selected;

src/Layers/xrRender/HW.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class CHW
115115
virtual void OnAppDeactivate();
116116
#endif // USE_DX10
117117

118+
int maxRefreshRate; //ECO_RENDER add
119+
118120
private:
119121
bool m_move_window;
120122
};

src/xrEngine/IGame_Persistent.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ bool g_dedicated_server = false;
2525

2626
ENGINE_API IGame_Persistent* g_pGamePersistent = nullptr;
2727

28+
//ECO_RENDER add
29+
bool IGame_Persistent::IsMainMenuActive()
30+
{
31+
return g_pGamePersistent && g_pGamePersistent->m_pMainMenu && g_pGamePersistent->m_pMainMenu->IsActive();
32+
}
33+
2834
IGame_Persistent::IGame_Persistent()
2935
{
3036
RDEVICE.seqAppStart.Add(this);

src/xrEngine/IGame_Persistent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class ENGINE_API IGame_Persistent :
8888
void Prefetch();
8989
#endif
9090
IMainMenu* m_pMainMenu;
91+
static bool IsMainMenuActive();
9192

9293
ParticleStatistics stats;
9394

src/xrEngine/device.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "IGame_Persistent.h"
2929
#include "xrScriptEngine/ScriptExporter.hpp"
3030

31+
#include "Common/Config.hpp"
32+
3133
ENGINE_API CRenderDevice Device;
3234
ENGINE_API CLoadScreenRenderer load_screen_renderer;
3335

@@ -231,7 +233,20 @@ void CRenderDevice::on_idle()
231233
mView_saved = mView;
232234
mProject_saved = mProject;
233235
syncProcessFrame.Set(); // allow secondary thread to do its job
236+
237+
#ifdef ECO_RENDER // ECO_RENDER START
238+
static u32 time_frame = 0;
239+
u32 time_curr = timeGetTime();
240+
u32 time_diff = time_curr - time_frame;
241+
time_frame = time_curr;
242+
u32 optimal = 10;
243+
if (Device.Paused() || IGame_Persistent::IsMainMenuActive())
244+
optimal = 32;
245+
if (time_diff < optimal)
246+
Sleep(optimal - time_diff);
247+
#else
234248
Sleep(0);
249+
#endif // ECO_RENDER END
235250

236251
#ifndef DEDICATED_SERVER
237252
// all rendering is done here

0 commit comments

Comments
 (0)