r5sdk/r5dev/public/iengine.h
Kawe Mazidjatari 4927654da0 Bugfix: only run NVIDIA Reflex if we ran an actual engine frame
CEngine::Frame() tends to return out early if we are ahead of frame time, and therefore need to sleep. In this particular engine, CEngine::Frame() returns true if it had actually executed an engine frame, else it returns false.

Therefore, we end up calling 'NvAPI_D3D_Sleep()' multiple times a frame, and thus causing a major loss in performance. Now we check if we have actually ran a frame (incrementing reflex frame if so). If the frame was not incremented, but 'GFX_RunLowLatencyFrame()' was called, it will not call 'NvAPI_D3D_Sleep()'.

Code has been tested and appears to work on my system (never called twice or more per frame). Needs more testing on other systems to make sure its good.
2023-09-12 20:50:38 +02:00

62 lines
1.6 KiB
C++
Raw Blame History

//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
//
// $Workfile: $
// $Date: $
// $NoKeywords: $
//===========================================================================//
#if !defined( IENGINE_H )
#define IENGINE_H
#ifdef _WIN32
#pragma once
#endif
//#include "tier1/interface.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
abstract_class IEngine
{
public:
enum QuitState_t
{
QUIT_NOTQUITTING = 0,
QUIT_TODESKTOP,
QUIT_RESTART
};
// Engine State Flags
enum EngineState_t
{
DLL_INACTIVE = 0, // no dll
DLL_ACTIVE, // engine is focused
DLL_CLOSE, // closing down dll
DLL_RESTART, // engine is shutting down but will restart right away
DLL_PAUSED, // engine is paused, can become active from this state
};
virtual ~IEngine(void) { }
virtual bool Load(bool dedicated, const char* rootdir) = 0;
virtual void Unload(void) = 0;
virtual void SetNextState(EngineState_t iNextState) = 0;
virtual EngineState_t GetState(void) = 0;
virtual bool Frame(void) = 0; // Returns true if an engine frame is being ran.
virtual float GetFrameTime(void) = 0;
virtual float GetPreviousTime(void) = 0;
virtual __m128 GetCurTime(void) = 0;
virtual void SetQuitting(int quittype) = 0;
virtual int GetPlaylistCount(void) = 0;
virtual const char* sub_1401FE2B0(int a2) = 0; // Playlists KeyValues stuff.
virtual bool sub_1401FE3B0(__int64 a2) = 0; // Playlists KeyValues stuff.
};
#endif // IENGINE_H