mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Move NVIDIA Reflex implementation to library function
Improve code, there will be more NVIDIA GeForce related stuff soon.
This commit is contained in:
parent
85de096f98
commit
804f96625b
@ -15,6 +15,7 @@ add_subdirectory( vstdlib )
|
||||
add_subdirectory( vphysics )
|
||||
add_subdirectory( ebisusdk )
|
||||
add_subdirectory( codecs )
|
||||
add_subdirectory( geforce )
|
||||
|
||||
set( FOLDER_CONTEXT "Protocols" )
|
||||
add_subdirectory( protoc )
|
||||
|
@ -76,6 +76,7 @@ target_link_libraries( ${PROJECT_NAME} PRIVATE
|
||||
"filesystem"
|
||||
"datacache"
|
||||
"EbisuSDK"
|
||||
"GFSDK"
|
||||
|
||||
"localize"
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "engine/sys_mainwind.h"
|
||||
#include "windows/id3dx.h"
|
||||
#include "client/vengineclient_impl.h"
|
||||
#include "geforce/reflex.h"
|
||||
#endif // !DEDICATED
|
||||
#include "rtech/rtech_utils.h"
|
||||
#include "filesystem/filesystem.h"
|
||||
@ -191,22 +192,7 @@ bool CEngineAPI::MainLoop()
|
||||
fpsMax = 0.0f; // Don't let NVIDIA limit the frame rate.
|
||||
}
|
||||
|
||||
NV_SET_SLEEP_MODE_PARAMS_V1 params = {};
|
||||
params.version = NV_SET_SLEEP_MODE_PARAMS_VER1;
|
||||
|
||||
params.bLowLatencyMode = bUseLowLatencyMode;
|
||||
params.bLowLatencyBoost = bUseLowLatencyMode && bUseLowLatencyBoost;
|
||||
params.minimumIntervalUs = fpsMax > 0 ? (NvU32)((1000.0f / fpsMax) * 1000.0f) : 0;
|
||||
params.bUseMarkersToOptimize = false;
|
||||
|
||||
ID3D11Device* pGameDevice = D3D11Device();
|
||||
Assert(pGameDevice);
|
||||
|
||||
NvAPI_Status status = NvAPI_D3D_SetSleepMode(pGameDevice, ¶ms);
|
||||
|
||||
if (status == NVAPI_OK)
|
||||
NvAPI_D3D_Sleep(pGameDevice);
|
||||
|
||||
GFX_RunLowLatencySDK(D3D11Device(), bUseLowLatencyMode, bUseLowLatencyBoost, fpsMax);
|
||||
CEngineAPI_PumpMessages();
|
||||
#endif // !DEDICATED
|
||||
|
||||
|
13
r5dev/geforce/CMakeLists.txt
Normal file
13
r5dev/geforce/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
cmake_minimum_required( VERSION 3.16 )
|
||||
add_module( "lib" "GFSDK" "vpc" ${FOLDER_CONTEXT} TRUE TRUE )
|
||||
|
||||
start_sources()
|
||||
|
||||
add_sources( SOURCE_GROUP "Runtime"
|
||||
"reflex.cpp"
|
||||
"reflex.h"
|
||||
)
|
||||
|
||||
end_sources()
|
||||
|
||||
target_include_directories( ${PROJECT_NAME} PRIVATE "${ENGINE_SOURCE_DIR}/tier0/" "${ENGINE_SOURCE_DIR}/tier1/" )
|
37
r5dev/geforce/reflex.cpp
Normal file
37
r5dev/geforce/reflex.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
//===========================================================================//
|
||||
//
|
||||
// Purpose: NVIDIA Reflex utilities
|
||||
//
|
||||
//===========================================================================//
|
||||
#include "reflex.h"
|
||||
#include "mathlib/mathlib.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: runs the low latency sdk
|
||||
// Input : device -
|
||||
// useLowLatencyMode -
|
||||
// useLowLatencyBoost -
|
||||
// maxFramesPerSecond -
|
||||
//-----------------------------------------------------------------------------
|
||||
void GFX_RunLowLatencySDK(IUnknown* device, const bool useLowLatencyMode,
|
||||
const bool useLowLatencyBoost, const float maxFramesPerSecond)
|
||||
{
|
||||
Assert(device);
|
||||
Assert(IsFinite(maxFramesPerSecond));
|
||||
|
||||
NV_SET_SLEEP_MODE_PARAMS params = {};
|
||||
params.version = NV_SET_SLEEP_MODE_PARAMS_VER1;
|
||||
|
||||
params.bLowLatencyMode = useLowLatencyMode;
|
||||
params.bLowLatencyBoost = useLowLatencyMode && useLowLatencyBoost;
|
||||
params.minimumIntervalUs = maxFramesPerSecond > 0
|
||||
? (NvU32)((1000.0f / maxFramesPerSecond) * 1000.0f)
|
||||
: 0;
|
||||
params.bUseMarkersToOptimize = false;
|
||||
|
||||
NvAPI_Status status = NvAPI_D3D_SetSleepMode(device, ¶ms);
|
||||
|
||||
if (status == NVAPI_OK)
|
||||
NvAPI_D3D_Sleep(device);
|
||||
}
|
7
r5dev/geforce/reflex.h
Normal file
7
r5dev/geforce/reflex.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef GFSDK_REFLEX_H
|
||||
#define GFSDK_REFLEX_H
|
||||
|
||||
void GFX_RunLowLatencySDK(IUnknown* device, const bool useLowLatencyMode,
|
||||
const bool useLowLatencyBoost, const float maxFramesPerSecond);
|
||||
|
||||
#endif // GFSDK_REFLEX_H
|
Loading…
x
Reference in New Issue
Block a user