added high performance adapter selection

This commit is contained in:
cdozdil
2024-12-21 15:23:59 +03:00
parent bec612770d
commit f4bba7e22e
6 changed files with 103 additions and 4 deletions
+4
View File
@@ -473,6 +473,9 @@ bool Config::Reload(std::filesystem::path iniPath)
if (!RestoreGraphicSignature.has_value())
RestoreGraphicSignature = readBool("Hotfix", "RestoreGraphicSignature");
if (!PreferDedicatedGpu.has_value())
PreferDedicatedGpu = readBool("Hotfix", "PreferDedicatedGpu");
if (!SkipFirstFrames.has_value())
SkipFirstFrames = readInt("Hotfix", "SkipFirstFrames");
@@ -866,6 +869,7 @@ bool Config::SaveIni()
ini.SetValue("Hotfix", "SkipFirstFrames", GetIntValue(Instance()->SkipFirstFrames).c_str());
ini.SetValue("Hotfix", "UsePrecompiledShaders", GetBoolValue(Instance()->UsePrecompiledShaders).c_str());
ini.SetValue("Hotfix", "PreferDedicatedGpu", GetBoolValue(Instance()->PreferDedicatedGpu).c_str());
ini.SetValue("Hotfix", "UseGenericAppIdWithDlss", GetBoolValue(Instance()->UseGenericAppIdWithDlss).c_str());
+1
View File
@@ -110,6 +110,7 @@ public:
std::optional<bool> UsePrecompiledShaders;
std::optional<bool> UseGenericAppIdWithDlss;
std::optional<bool> PreferDedicatedGpu;
std::optional<int32_t> ColorResourceBarrier;
std::optional<int32_t> MVResourceBarrier;
+1 -1
View File
@@ -82,7 +82,7 @@
<IncludePath>$(SolutionDir)external\vulkan\include;$(SolutionDir)external\nvngx_dlss_sdk;$(SolutionDir)external\xess\inc\xess;$(SolutionDir)external\FidelityFX-SDK\ffx-api\include\ffx_api;$(SolutionDir)external\simpleini;$(SolutionDir)external\unordered_dense\include;$(SolutionDir)external\spdlog\include;$(SolutionDir)external\freetype;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)fsr2\lib;$(ProjectDir)fsr2_212\lib;$(ProjectDir)fsr31\lib;$(ProjectDir)vulkan;$(ProjectDir)d3dx;$(ProjectDir)detours;$(SolutionDir)external\xess\lib;$(SolutionDir)external\freetype;$(LibraryPath)</LibraryPath>
<TargetName>dxgi</TargetName>
<OutDir>F:\source\optiscaler\external\FidelityFX-SDK\bin\</OutDir>
<OutDir>D:\Folders\Games\Deep Rock Galactic\FSD\Binaries\Win64\</OutDir>
<IntDir>.\x64\Debug</IntDir>
<TargetExt>.dll</TargetExt>
</PropertyGroup>
+92 -2
View File
@@ -1585,7 +1585,52 @@ HRESULT WINAPI detEnumAdapters1(IDXGIFactory1* This, UINT Adapter, IDXGIAdapter1
{
AttachToFactory(This);
auto result = ptrEnumAdapters1(This, Adapter, ppAdapter);
HRESULT result = S_OK;
if (Config::Instance()->PreferDedicatedGpu.value_or(true))
{
if (Adapter != 0)
{
LOG_DEBUG("{}, returning not found", Adapter);
return DXGI_ERROR_NOT_FOUND;
}
IDXGIFactory6* factory6 = nullptr;
if (This->QueryInterface(IID_PPV_ARGS(&factory6)) == S_OK && factory6 != nullptr)
{
LOG_DEBUG("Trying to select high performance adapter ({})", Adapter);
result = factory6->EnumAdapterByGpuPreference(Adapter, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, IID_PPV_ARGS(ppAdapter));
if (result != S_OK)
{
LOG_ERROR("Can't get high performance adapter: {:X}, fallback to standard method", Adapter);
result = ptrEnumAdapters1(This, Adapter, ppAdapter);
}
if (result == S_OK)
{
DXGI_ADAPTER_DESC desc;
if ((*ppAdapter)->GetDesc(&desc) == S_OK)
{
std::wstring name(desc.Description);
LOG_DEBUG("High performance adapter ({}) will be used", wstring_to_string(name));
}
else
{
LOG_DEBUG("High performance adapter (Can't get description!) will be used");
}
}
factory6->Release();
}
}
else
{
result = ptrEnumAdapters1(This, Adapter, ppAdapter);
}
if (result == S_OK)
AttachToAdapter(*ppAdapter);
@@ -1597,7 +1642,52 @@ HRESULT WINAPI detEnumAdapters(IDXGIFactory* This, UINT Adapter, IDXGIAdapter**
{
AttachToFactory(This);
auto result = ptrEnumAdapters(This, Adapter, ppAdapter);
HRESULT result = S_OK;
if (Config::Instance()->PreferDedicatedGpu.value_or(true))
{
if (Adapter > 0)
{
LOG_DEBUG("{}, returning not found", Adapter);
return DXGI_ERROR_NOT_FOUND;
}
IDXGIFactory6* factory6 = nullptr;
if (This->QueryInterface(IID_PPV_ARGS(&factory6)) == S_OK && factory6 != nullptr)
{
LOG_DEBUG("Trying to select high performance adapter ({})", Adapter);
result = factory6->EnumAdapterByGpuPreference(Adapter, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, IID_PPV_ARGS(ppAdapter));
if (result != S_OK)
{
LOG_ERROR("Can't get high performance adapter: {:X}, fallback to standard method", Adapter);
result = ptrEnumAdapters(This, Adapter, ppAdapter);
}
if (result == S_OK)
{
DXGI_ADAPTER_DESC desc;
if ((*ppAdapter)->GetDesc(&desc) == S_OK)
{
std::wstring name(desc.Description);
LOG_DEBUG("High performance adapter ({}) will be used", wstring_to_string(name));
}
else
{
LOG_DEBUG("High performance adapter (Can't get description!) will be used");
}
}
factory6->Release();
}
}
else
{
result = ptrEnumAdapters(This, Adapter, ppAdapter);
}
if (result == S_OK)
AttachToAdapter(*ppAdapter);
+1 -1
View File
@@ -21,7 +21,7 @@
#define VER_MAJOR_VERSION 0
#define VER_MINOR_VERSION 7
#define VER_HOTFIX_VERSION 0
#define VER_BUILD_NUMBER 84
#define VER_BUILD_NUMBER 85
#define VER_PRE_RELEASE
+4
View File
@@ -561,6 +561,10 @@ UseHDR10=auto
; -------------------------------------------------------
[Hotfix]
; -------------------------------------------------------
; OptiScaler will try to force high performance GPU
; true or false - Default (auto) is true
PreferDedicatedGpu=auto
; Override value for mipmap lod bias
; -15.0 - 15.0 - Default (auto) is disabled
MipmapBiasOverride=auto