Skip to content

Commit

Permalink
nvapi-d3d: Drop LatencyFlex support
Browse files Browse the repository at this point in the history
  • Loading branch information
jp7677 committed Feb 11, 2025
1 parent 26f54ab commit 8887803
Show file tree
Hide file tree
Showing 27 changed files with 131 additions and 549 deletions.
2 changes: 0 additions & 2 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ nvapi_src = files([
'util/util_log.cpp',
'shared/vk.cpp',
'shared/resource_factory.cpp',
'nvapi/lfx.cpp',
'nvapi/nvml.cpp',
'nvapi/nvapi_resource_factory.cpp',
'nvapi/nvapi_d3d_instance.cpp',
'nvapi/nvapi_d3d_low_latency_device.cpp',
'nvapi/nvapi_vulkan_low_latency_device.cpp',
'nvapi/nvapi_output.cpp',
Expand Down
3 changes: 0 additions & 3 deletions src/nvapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,6 @@ extern "C" {
return NvidiaDeviceNotFound(n);
}

nvapiD3dInstance = std::make_unique<NvapiD3dInstance>(*resourceFactory);
nvapiD3dInstance->Initialize();

return Ok(n);
}
}
66 changes: 0 additions & 66 deletions src/nvapi/lfx.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions src/nvapi/lfx.h

This file was deleted.

53 changes: 0 additions & 53 deletions src/nvapi/nvapi_d3d_instance.cpp

This file was deleted.

26 changes: 0 additions & 26 deletions src/nvapi/nvapi_d3d_instance.h

This file was deleted.

10 changes: 9 additions & 1 deletion src/nvapi/nvapi_d3d_low_latency_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ namespace dxvk {
if (d3dLowLatencyDevice == nullptr)
return false;

return SUCCEEDED(d3dLowLatencyDevice->SetLatencySleepMode(lowLatencyMode, lowLatencyBoost, minimumIntervalUs));
auto success = SUCCEEDED(d3dLowLatencyDevice->SetLatencySleepMode(lowLatencyMode, lowLatencyBoost, minimumIntervalUs));
if (success)
m_lowLatencyMode = lowLatencyMode;

return success;
}

bool NvapiD3dLowLatencyDevice::GetLatencyInfo(IUnknown* device, D3D_LATENCY_RESULTS* latencyResults) {
Expand Down Expand Up @@ -127,6 +131,10 @@ namespace dxvk {
frameIdGenerator->GetLowLatencyDeviceFrameId(frameID), markerType));
}

bool NvapiD3dLowLatencyDevice::GetLowLatencyMode() {
return m_lowLatencyMode;
}

std::optional<uint32_t> NvapiD3dLowLatencyDevice::ToMarkerType(NV_LATENCY_MARKER_TYPE markerType) {
static_assert(static_cast<int>(SIMULATION_START) == static_cast<int>(VK_LATENCY_MARKER_SIMULATION_START_NV));
static_assert(static_cast<int>(SIMULATION_END) == static_cast<int>(VK_LATENCY_MARKER_SIMULATION_END_NV));
Expand Down
3 changes: 3 additions & 0 deletions src/nvapi/nvapi_d3d_low_latency_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace dxvk {
static bool GetLatencyInfo(IUnknown* device, D3D_LATENCY_RESULTS* latencyResults);
static bool SetLatencyMarker(IUnknown* device, uint64_t frameID, uint32_t markerType);
static bool SetLatencyMarker(ID3D12CommandQueue* commandQueue, uint64_t frameID, uint32_t markerType);
[[nodiscard]] static bool GetLowLatencyMode();

[[nodiscard]] static std::optional<uint32_t> ToMarkerType(NV_LATENCY_MARKER_TYPE markerType);

Expand All @@ -47,6 +48,8 @@ namespace dxvk {
inline static std::mutex m_lowLatencyDeviceMutex;
inline static std::mutex m_lowLatencyFrameIdGeneratorMutex;

inline static bool m_lowLatencyMode;

[[nodiscard]] static Com<ID3DLowLatencyDevice> GetLowLatencyDevice(IUnknown* device);
[[nodiscard]] static Com<ID3DLowLatencyDevice> GetLowLatencyDevice(ID3D12CommandQueue* commandQueue);
[[nodiscard]] static LowLatencyFrameIdGenerator* GetFrameIdGenerator(ID3DLowLatencyDevice* device);
Expand Down
4 changes: 0 additions & 4 deletions src/nvapi/nvapi_resource_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@ namespace dxvk {
std::unique_ptr<Nvml> NvapiResourceFactory::CreateNvml() {
return std::make_unique<Nvml>();
}

std::unique_ptr<Lfx> NvapiResourceFactory::CreateLfx() {
return std::make_unique<Lfx>();
}
}
2 changes: 0 additions & 2 deletions src/nvapi/nvapi_resource_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "../shared/resource_factory.h"
#include "../shared/vk.h"
#include "nvml.h"
#include "lfx.h"

namespace dxvk {
class NvapiResourceFactory : ResourceFactory {
Expand All @@ -15,6 +14,5 @@ namespace dxvk {
virtual std::unique_ptr<Vk> CreateVulkan(Com<IDXGIFactory1>& dxgiFactory);
virtual Com<IDXGIFactory1> CreateDXGIFactory1();
virtual std::unique_ptr<Nvml> CreateNvml();
virtual std::unique_ptr<Lfx> CreateLfx();
};
}
16 changes: 8 additions & 8 deletions src/nvapi_d3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ extern "C" {
if (!pDevice)
return InvalidArgument(n);

if (!nvapiD3dInstance->IsReflexAvailable(pDevice))
if (!NvapiD3dLowLatencyDevice::SupportsLowLatency(pDevice))
return NoImplementation(n, alreadyLoggedNoReflex);

if (!nvapiD3dInstance->Sleep(pDevice))
if (!NvapiD3dLowLatencyDevice::LatencySleep(pDevice))
return Error(n, alreadyLoggedError);

return Ok(n, alreadyLoggedOk);
Expand All @@ -195,10 +195,10 @@ extern "C" {
if (pSetSleepModeParams->version != NV_SET_SLEEP_MODE_PARAMS_VER1)
return IncompatibleStructVersion(n, pSetSleepModeParams->version);

if (!nvapiD3dInstance->IsReflexAvailable(pDevice))
if (!NvapiD3dLowLatencyDevice::SupportsLowLatency(pDevice))
return NoImplementation(n, alreadyLoggedNoReflex);

if (!nvapiD3dInstance->SetReflexMode(pDevice, pSetSleepModeParams->bLowLatencyMode, pSetSleepModeParams->bLowLatencyBoost, pSetSleepModeParams->minimumIntervalUs))
if (!NvapiD3dLowLatencyDevice::SetLatencySleepMode(pDevice, pSetSleepModeParams->bLowLatencyMode, pSetSleepModeParams->bLowLatencyBoost, pSetSleepModeParams->minimumIntervalUs))
return Error(n, alreadyLoggedError);

if (lastLowLatencyMode != pSetSleepModeParams->bLowLatencyMode || lastMinimumIntervalUs != pSetSleepModeParams->minimumIntervalUs) {
Expand Down Expand Up @@ -226,10 +226,10 @@ extern "C" {
if (pGetSleepStatusParams->version != NV_GET_SLEEP_STATUS_PARAMS_VER1)
return IncompatibleStructVersion(n, pGetSleepStatusParams->version);

if (!nvapiD3dInstance->IsReflexAvailable(pDevice))
if (!NvapiD3dLowLatencyDevice::SupportsLowLatency(pDevice))
return NoImplementation(n, alreadyLoggedNoReflex);

pGetSleepStatusParams->bLowLatencyMode = nvapiD3dInstance->IsLowLatencyEnabled();
pGetSleepStatusParams->bLowLatencyMode = NvapiD3dLowLatencyDevice::GetLowLatencyMode();

return Ok(n, alreadyLoggedOk);
}
Expand All @@ -252,7 +252,7 @@ extern "C" {
if (pGetLatencyParams->version != NV_LATENCY_RESULT_PARAMS_VER1)
return IncompatibleStructVersion(n, pGetLatencyParams->version);

if (nvapiD3dInstance->IsUsingLfx() || !NvapiD3dLowLatencyDevice::SupportsLowLatency(pDev))
if (!NvapiD3dLowLatencyDevice::SupportsLowLatency(pDev))
return NoImplementation(n, alreadyLoggedNoImpl);

if (!NvapiD3dLowLatencyDevice::GetLatencyInfo(pDev, reinterpret_cast<D3D_LATENCY_RESULTS*>(pGetLatencyParams)))
Expand Down Expand Up @@ -280,7 +280,7 @@ extern "C" {
if (pSetLatencyMarkerParams->version != NV_LATENCY_MARKER_PARAMS_VER1)
return IncompatibleStructVersion(n, pSetLatencyMarkerParams->version);

if (nvapiD3dInstance->IsUsingLfx() || !NvapiD3dLowLatencyDevice::SupportsLowLatency(pDev))
if (!NvapiD3dLowLatencyDevice::SupportsLowLatency(pDev))
return NoImplementation(n, alreadyLoggedNoImpl);

auto markerType = NvapiD3dLowLatencyDevice::ToMarkerType(pSetLatencyMarkerParams->markerType);
Expand Down
4 changes: 2 additions & 2 deletions src/nvapi_d3d12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ extern "C" {
if (!pCommandQueue)
return InvalidPointer(n);

if (nvapiD3dInstance->IsUsingLfx() || !NvapiD3dLowLatencyDevice::SupportsLowLatency(pCommandQueue))
if (!NvapiD3dLowLatencyDevice::SupportsLowLatency(pCommandQueue))
return NoImplementation(n);

if (cqType == OUT_OF_BAND_IGNORE && !std::exchange(alreadyLoggedTypeIgnore, true))
Expand Down Expand Up @@ -486,7 +486,7 @@ extern "C" {
if (pSetAsyncFrameMarkerParams->version != NV_LATENCY_MARKER_PARAMS_VER1)
return IncompatibleStructVersion(n, pSetAsyncFrameMarkerParams->version);

if (nvapiD3dInstance->IsUsingLfx() || !NvapiD3dLowLatencyDevice::SupportsLowLatency(pCommandQueue))
if (!NvapiD3dLowLatencyDevice::SupportsLowLatency(pCommandQueue))
return NoImplementation(n);

auto markerType = NvapiD3dLowLatencyDevice::ToMarkerType(pSetAsyncFrameMarkerParams->markerType);
Expand Down
1 change: 0 additions & 1 deletion src/nvapi_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
uint64_t initializationCount = 0ULL;
std::unique_ptr<dxvk::NvapiResourceFactory> resourceFactory;
std::unique_ptr<dxvk::NvapiAdapterRegistry> nvapiAdapterRegistry;
std::unique_ptr<dxvk::NvapiD3dInstance> nvapiD3dInstance;
2 changes: 0 additions & 2 deletions src/nvapi_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#include "nvapi_private.h"
#include "nvapi/nvapi_resource_factory.h"
#include "nvapi/nvapi_adapter_registry.h"
#include "nvapi/nvapi_d3d_instance.h"

extern uint64_t initializationCount;
extern std::unique_ptr<dxvk::NvapiResourceFactory> resourceFactory;
extern std::unique_ptr<dxvk::NvapiAdapterRegistry> nvapiAdapterRegistry;
extern std::unique_ptr<dxvk::NvapiD3dInstance> nvapiD3dInstance;
2 changes: 0 additions & 2 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ nvapi_src = files([
'../src/util/util_log.cpp',
'../src/shared/vk.cpp',
'../src/shared/resource_factory.cpp',
'../src/nvapi/lfx.cpp',
'../src/nvapi/nvml.cpp',
'../src/nvapi/nvapi_resource_factory.cpp',
'../src/nvapi/nvapi_d3d_instance.cpp',
'../src/nvapi/nvapi_d3d_low_latency_device.cpp',
'../src/nvapi/nvapi_vulkan_low_latency_device.cpp',
'../src/nvapi/nvapi_output.cpp',
Expand Down
10 changes: 0 additions & 10 deletions tests/mocks/lfx_mocks.h

This file was deleted.

Loading

0 comments on commit 8887803

Please sign in to comment.