mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-11-22 13:47:11 +00:00
Fix fake nvapi contracts and Reflex FPS cap restore
This commit is contained in:
1 parent
9da75d8c8a
commit
95519efccd
5 files changed
+39
-9
No files matched your search
@@ -613,7 +613,10 @@ void ReflexHooks::setFPSLimit(float fps)
|
||||
{
|
||||
NV_SET_SLEEP_MODE_PARAMS temp {};
|
||||
memcpy(&temp, &_lastSleepParams, sizeof(NV_SET_SLEEP_MODE_PARAMS));
|
||||
temp.minimumIntervalUs = _minimumIntervalUs;
|
||||
|
||||
// Without OptiScaler's limit the game's own cap applies
|
||||
if (_minimumIntervalUs != 0)
|
||||
temp.minimumIntervalUs = _minimumIntervalUs;
|
||||
|
||||
o_NvAPI_D3D_SetSleepMode(device, &temp);
|
||||
}
|
||||
@@ -622,7 +625,9 @@ void ReflexHooks::setFPSLimit(float fps)
|
||||
{
|
||||
NV_VULKAN_SET_SLEEP_MODE_PARAMS temp {};
|
||||
memcpy(&temp, &_lastVkSleepParams, sizeof(NV_VULKAN_SET_SLEEP_MODE_PARAMS));
|
||||
temp.minimumIntervalUs = _minimumIntervalUs;
|
||||
|
||||
if (_minimumIntervalUs != 0)
|
||||
temp.minimumIntervalUs = _minimumIntervalUs;
|
||||
o_NvAPI_Vulkan_SetSleepMode(vkDevice, &temp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +145,12 @@ NvAPI_Status InputReflex::D3D_GetLatency(IUnknown* pDev, NV_LATENCY_RESULT_PARAM
|
||||
return driver(pDev, pGetLatencyParams);
|
||||
}
|
||||
|
||||
if (pGetLatencyParams->version != NV_LATENCY_RESULT_PARAMS_VER1)
|
||||
{
|
||||
LOG_ERROR("Unsupported version {}", pGetLatencyParams->version);
|
||||
return NVAPI_INCOMPATIBLE_STRUCT_VERSION;
|
||||
}
|
||||
|
||||
return ToNvApi(InputCommon::get_latency(own ? optiScalerContext : inputContext, pDev, pGetLatencyParams),
|
||||
"get_latency");
|
||||
}
|
||||
|
||||
@@ -191,9 +191,9 @@ void AntiLag2::set_async_marker(IUnknown* pCommandQueue, const MarkerParams& mar
|
||||
{
|
||||
if (marker_params.marker_type == MarkerType::OUT_OF_BAND_PRESENT_START)
|
||||
{
|
||||
static uint64_t previous_frame_id = marker_params.frame_id;
|
||||
set_fg_type(marker_params.interpolated.value_or(previous_frame_id == marker_params.frame_id),
|
||||
// A present with the previous one's frame id is a generated frame
|
||||
set_fg_type(marker_params.interpolated.value_or(previous_oob_frame_id == marker_params.frame_id),
|
||||
marker_params.frame_id);
|
||||
previous_frame_id = marker_params.frame_id;
|
||||
previous_oob_frame_id = marker_params.frame_id;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ class AntiLag2 : public LowLatencyTech
|
||||
uint64_t simulation_framecount = 0;
|
||||
const uint64_t call_spot_switch_threshold = 20;
|
||||
|
||||
uint64_t previous_oob_frame_id = INVALID_ID;
|
||||
|
||||
HRESULT al2_sleep();
|
||||
|
||||
public:
|
||||
|
||||
@@ -220,12 +220,22 @@ NvAPI_Status __cdecl NvAPI_GPU_GetPstates20(NvPhysicalGpuHandle hPhysicalGpu, NV
|
||||
if (!pPstatesInfo)
|
||||
return ERROR();
|
||||
|
||||
const auto version = pPstatesInfo->version;
|
||||
|
||||
if (version != NV_GPU_PERF_PSTATES20_INFO_VER1 && version != NV_GPU_PERF_PSTATES20_INFO_VER2 &&
|
||||
version != NV_GPU_PERF_PSTATES20_INFO_VER3)
|
||||
{
|
||||
return ERROR_VALUE(NVAPI_INCOMPATIBLE_STRUCT_VERSION);
|
||||
}
|
||||
|
||||
// Initialize the structure with mock data
|
||||
pPstatesInfo->version = NV_GPU_PERF_PSTATES20_INFO_VER;
|
||||
pPstatesInfo->numPstates = 2; // Example: 2 P-states
|
||||
pPstatesInfo->numClocks = 3;
|
||||
pPstatesInfo->numBaseVoltages = 1;
|
||||
pPstatesInfo->ov.numVoltages = 0;
|
||||
|
||||
// V1 is V2 without ov, the caller's struct ends before it
|
||||
if (version != NV_GPU_PERF_PSTATES20_INFO_VER1)
|
||||
pPstatesInfo->ov.numVoltages = 0;
|
||||
|
||||
// Fill mock data for P-state 0
|
||||
pPstatesInfo->pstates[0].pstateId = NVAPI_GPU_PERF_PSTATE_P0;
|
||||
@@ -302,13 +312,19 @@ NvAPI_Status __cdecl NvAPI_Mosaic_GetDisplayViewportsByResolution(NvU32 displayI
|
||||
|
||||
NvAPI_Status __cdecl NvAPI_SYS_GetDisplayDriverInfo(NV_DISPLAY_DRIVER_INFO* driverInfo)
|
||||
{
|
||||
if (!driverInfo)
|
||||
return ERROR_VALUE(NVAPI_INVALID_ARGUMENT);
|
||||
|
||||
if (driverInfo->version != NV_DISPLAY_DRIVER_INFO_VER1 && driverInfo->version != NV_DISPLAY_DRIVER_INFO_VER2)
|
||||
return ERROR_VALUE(NVAPI_INCOMPATIBLE_STRUCT_VERSION);
|
||||
|
||||
driverInfo->driverVersion = 99999;
|
||||
tonvss(driverInfo->szBuildBranch, "buildBranch");
|
||||
driverInfo->bIsDCHDriver = 1;
|
||||
driverInfo->bIsNVIDIAStudioPackage = 1;
|
||||
driverInfo->bIsNVIDIARTXProductionBranchPackage = 1;
|
||||
driverInfo->bIsNVIDIARTXNewFeatureBranchPackage = 1;
|
||||
if (driverInfo->version == 2)
|
||||
if (driverInfo->version == NV_DISPLAY_DRIVER_INFO_VER2)
|
||||
tonvss(driverInfo->szBuildBaseBranch, "buildBaseBranch");
|
||||
return OK();
|
||||
}
|
||||
@@ -582,8 +598,9 @@ NvAPI_Status __cdecl NvAPI_DRS_GetBaseProfile(NvDRSSessionHandle session, NvDRSP
|
||||
NvAPI_Status __cdecl NvAPI_DRS_GetSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile, NvU32 settingId,
|
||||
NVDRS_SETTING* pSetting)
|
||||
{
|
||||
// No settings are stored, the caller must not read pSetting
|
||||
LOG_DEBUG("Missing get setting: {:X}", settingId);
|
||||
return OK();
|
||||
return ERROR_VALUE(NVAPI_SETTING_NOT_FOUND);
|
||||
}
|
||||
|
||||
NvAPI_Status __cdecl NvAPI_DRS_SetSetting(NvDRSSessionHandle hSession, NvDRSProfileHandle hProfile,
|
||||
|
||||
Reference in new issue
Block a user