-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The intent of this commit is to enable Reflex for all D3D11, and D3D12 titles using dxvk-nvapi. It does this through a new device interface called ID3DLowLatencyDevice. This interface will be implemented by ID3D12Device in vkd3d-proton, and ID3D11Device in dxvk. To provide compatibility with LatencyFleX this change will only use the ID3DLowLatencyDevice interface when LatencyFleX is not detected.
- Loading branch information
1 parent
42ec75b
commit 5ca994f
Showing
19 changed files
with
752 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include "nvapi_d3d_low_latency_device.h" | ||
|
||
namespace dxvk { | ||
bool NvapiD3dLowLatencyDevice::SupportsLowLatency(IUnknown* device) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(device); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return d3dLowLatencyDevice->SupportsLowLatency(); | ||
} | ||
|
||
bool NvapiD3dLowLatencyDevice::LatencySleep(IUnknown* device) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(device); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return SUCCEEDED(d3dLowLatencyDevice->LatencySleep()); | ||
} | ||
|
||
bool NvapiD3dLowLatencyDevice::SetLatencySleepMode(IUnknown* device, bool lowLatencyMode, bool lowLatencyBoost, uint32_t minimumIntervalUs) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(device); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return SUCCEEDED(d3dLowLatencyDevice->SetLatencySleepMode(lowLatencyMode, lowLatencyBoost, minimumIntervalUs)); | ||
} | ||
|
||
bool NvapiD3dLowLatencyDevice::GetLatencyInfo(IUnknown* device, D3D_LATENCY_RESULTS* latencyResults) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(device); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return SUCCEEDED(d3dLowLatencyDevice->GetLatencyInfo(latencyResults)); | ||
} | ||
|
||
bool NvapiD3dLowLatencyDevice::SetLatencyMarker(IUnknown* device, uint64_t frameID, uint32_t markerType) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(device); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return SUCCEEDED(d3dLowLatencyDevice->SetLatencyMarker(frameID, markerType)); | ||
} | ||
|
||
void NvapiD3dLowLatencyDevice::ClearCacheMaps() { | ||
std::scoped_lock lock(m_LowLatencyDeviceMutex); | ||
|
||
m_lowLatencyDeviceMap.clear(); | ||
} | ||
|
||
Com<ID3DLowLatencyDevice> NvapiD3dLowLatencyDevice::GetLowLatencyDevice(IUnknown* device) { | ||
std::scoped_lock lock(m_LowLatencyDeviceMutex); | ||
auto it = m_lowLatencyDeviceMap.find(device); | ||
if (it != m_lowLatencyDeviceMap.end()) | ||
return it->second; | ||
|
||
Com<ID3DLowLatencyDevice> d3dLowLatencyDevice; | ||
if (FAILED(device->QueryInterface(IID_PPV_ARGS(&d3dLowLatencyDevice)))) | ||
return nullptr; | ||
|
||
m_lowLatencyDeviceMap.emplace(device, d3dLowLatencyDevice.ptr()); | ||
|
||
return d3dLowLatencyDevice; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "../nvapi_private.h" | ||
#include "../shared/shared_interfaces.h" | ||
#include "../util/com_pointer.h" | ||
|
||
namespace dxvk { | ||
class NvapiD3dLowLatencyDevice { | ||
public: | ||
static bool SupportsLowLatency(IUnknown* device); | ||
static bool LatencySleep(IUnknown* device); | ||
static bool SetLatencySleepMode(IUnknown* device, bool lowLatencyMode, bool lowLatencyBoost, uint32_t minimumIntervalUs); | ||
static bool GetLatencyInfo(IUnknown* device, D3D_LATENCY_RESULTS* latencyResults); | ||
static bool SetLatencyMarker(IUnknown* device, uint64_t frameID, uint32_t markerType); | ||
|
||
static void ClearCacheMaps(); | ||
|
||
private: | ||
inline static std::unordered_map<IUnknown*, ID3DLowLatencyDevice*> m_lowLatencyDeviceMap; | ||
|
||
inline static std::mutex m_LowLatencyDeviceMutex; | ||
|
||
[[nodiscard]] static Com<ID3DLowLatencyDevice> GetLowLatencyDevice(IUnknown* device); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.