-
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
ed4338f
commit 0bc516f
Showing
14 changed files
with
313 additions
and
29 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,58 @@ | ||
#include "nvapi_d3d_low_latency_device.h" | ||
|
||
namespace dxvk { | ||
bool NvapiD3dLowLatencyDevice::SupportsLowLatency(IUnknown* pDevice) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(pDevice); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return d3dLowLatencyDevice->SupportsLowLatency(); | ||
} | ||
|
||
bool NvapiD3dLowLatencyDevice::LatencySleep(IUnknown* pDevice) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(pDevice); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return d3dLowLatencyDevice->LatencySleep(); | ||
} | ||
|
||
bool NvapiD3dLowLatencyDevice::SetLatencySleepMode(IUnknown* pDevice, bool lowLatencyMode, bool lowLatencyBoost, uint32_t minimumIntervalUs) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(pDevice); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return d3dLowLatencyDevice->SetLatencySleepMode(lowLatencyMode, lowLatencyBoost, minimumIntervalUs); | ||
} | ||
|
||
bool NvapiD3dLowLatencyDevice::GetLatencyInfo(IUnknown* pDevice, D3D_LATENCY_RESULTS* latency_results) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(pDevice); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return d3dLowLatencyDevice->GetLatencyInfo(latency_results); | ||
} | ||
|
||
bool NvapiD3dLowLatencyDevice::SetLatencyMarker(IUnknown* pDevice, uint64_t frameID, uint32_t markerType) { | ||
auto d3dLowLatencyDevice = GetLowLatencyDevice(pDevice); | ||
if (d3dLowLatencyDevice == nullptr) | ||
return false; | ||
|
||
return d3dLowLatencyDevice->SetLatencyMarker(frameID, markerType); | ||
} | ||
|
||
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,23 @@ | ||
#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* pDevice); | ||
static bool LatencySleep(IUnknown* pDevice); | ||
static bool SetLatencySleepMode(IUnknown* pDevice, bool lowLatencyMode, bool lowLatencyBoost, uint32_t minimumIntervalUs); | ||
static bool GetLatencyInfo(IUnknown* pDevice, D3D_LATENCY_RESULTS* latency_results); | ||
static bool SetLatencyMarker(IUnknown* pDevice, uint64_t frameID, uint32_t markerType); | ||
|
||
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.