Respect high performance gpu
This commit is contained in:
parent
25a6b128eb
commit
4c74c5ca4a
@ -225,8 +225,28 @@ namespace
|
||||
}
|
||||
|
||||
const auto self = utils::nt::library::get_by_address(&trigger_high_performance_gpu_switch);
|
||||
const auto path = self.get_path().make_preferred().wstring();
|
||||
|
||||
const std::wstring data = L"GpuPreference=2;";
|
||||
/*if (RegQueryValueExW(key, path.data(), nullptr, nullptr, nullptr, nullptr) != ERROR_FILE_NOT_FOUND)
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
|
||||
auto preference = DXGI_GPU_PREFERENCE_UNSPECIFIED;
|
||||
|
||||
CComPtr<IDXGIFactory6> factory{};
|
||||
if (SUCCEEDED(CreateDXGIFactory1(__uuidof(IDXGIFactory6), reinterpret_cast<void**>(&factory))))
|
||||
{
|
||||
CComPtr<IDXGIAdapter> adapter{};
|
||||
if (SUCCEEDED(
|
||||
factory->EnumAdapterByGpuPreference(0, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, __uuidof(IDXGIAdapter),
|
||||
reinterpret_cast<void**>(&adapter))) && adapter)
|
||||
{
|
||||
preference = DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE;
|
||||
}
|
||||
}
|
||||
|
||||
const std::wstring data = L"GpuPreference=" + std::to_wstring(preference) + L";";
|
||||
RegSetValueExW(key, self.get_path().make_preferred().wstring().data(), 0, REG_SZ,
|
||||
reinterpret_cast<const BYTE*>(data.data()),
|
||||
static_cast<DWORD>((data.size() + 1u) * 2));
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include <wincrypt.h>
|
||||
#include <shellscalingapi.h>
|
||||
#include <d3d11.h>
|
||||
#include <dxgi1_6.h>
|
||||
|
||||
// min and max is required by gdi, therefore NOMINMAX won't work
|
||||
#ifdef max
|
||||
@ -103,5 +104,6 @@
|
||||
#pragma comment(lib, "iphlpapi.lib")
|
||||
#pragma comment(lib, "Crypt32.lib")
|
||||
#pragma comment(lib, "d3d11.lib")
|
||||
#pragma comment(lib, "dxgi.lib")
|
||||
|
||||
using namespace std::literals;
|
||||
|
Loading…
Reference in New Issue
Block a user