Add DX11 and antilag class

This commit is contained in:
FakeMichau
2024-09-06 01:36:16 +02:00
parent a54910ecd8
commit 93af3c19e4
3 changed files with 49 additions and 16 deletions
+43
View File
@@ -0,0 +1,43 @@
#pragma once
#include <dxgi.h>
#if defined __MINGW64__ || defined __MINGW32__
#include "../include/d3d12.h"
#else
#include <d3d12.h>
#endif
#include "../include/ffx_antilag2_dx12.h"
#include "../include/ffx_antilag2_dx11.h"
class AntiLag {
AMD::AntiLag2DX12::Context context_dx12 = {};
AMD::AntiLag2DX11::Context context_dx11 = {};
void init_dx12(ID3D12Device *pDevice) {
auto res = AMD::AntiLag2DX12::Initialize(&context_dx12, pDevice);
}
void init_dx11() {
auto res = AMD::AntiLag2DX11::Initialize(&context_dx11);
}
public:
void init(IUnknown *pDevice) {
if (!context_dx12.m_pAntiLagAPI && !context_dx11.m_pAntiLagAPI) {
ID3D12Device* device = nullptr;
HRESULT hr = pDevice->QueryInterface(__uuidof(ID3D12Device), reinterpret_cast<void**>(&device));
if (hr == S_OK) {
init_dx12(device);
} else {
init_dx11();
}
}
}
void update() {
if (context_dx12.m_pAntiLagAPI)
AMD::AntiLag2DX12::Update(&context_dx12, true, 0);
else
AMD::AntiLag2DX11::Update(&context_dx11, true, 0);
}
};
+4 -14
View File
@@ -310,14 +310,9 @@ namespace nvd {
if (!pDev)
return Error();
#if _MSC_VER
if (!al2_context.m_pAntiLagAPI) {
ID3D12Device* device = nullptr;
HRESULT hr = pDev->QueryInterface(__uuidof(ID3D12Device), reinterpret_cast<void**>(&device));
auto res = AMD::AntiLag2DX12::Initialize(&al2_context, device);
log(std::format("AL2 Init: {}", S_OK == res));
}
antilag_ctx.init(pDev);
if (pSetLatencyMarkerParams->markerType == SIMULATION_START) {
AMD::AntiLag2DX12::Update(&al2_context, true, 0);
antilag_ctx.update();
}
#endif
return Ok();
@@ -327,13 +322,8 @@ namespace nvd {
if (!pDevice)
return Error();
#if _MSC_VER
if (!al2_context.m_pAntiLagAPI) {
ID3D12Device* device = nullptr;
HRESULT hr = pDevice->QueryInterface(__uuidof(ID3D12Device), reinterpret_cast<void**>(&device));
auto res = AMD::AntiLag2DX12::Initialize(&al2_context, device);
log(std::format("AL2 Init: {}", S_OK == res));
}
AMD::AntiLag2DX12::Update(&al2_context, true, 0);
antilag_ctx.init(pDevice);
antilag_ctx.update();
#endif
return Ok();
}
+2 -2
View File
@@ -12,7 +12,7 @@
#include <vector>
#if _MSC_VER
#include "../include/ffx_antilag2_dx12.h"
#include "antilag.h"
#endif
#include "util.h"
@@ -31,7 +31,7 @@ namespace nvd {
static UINT revisionId;
#if _MSC_VER
static AMD::AntiLag2DX12::Context al2_context = {};
static AntiLag antilag_ctx;
#endif
NvAPI_Status __cdecl NvAPI_Initialize();