mirror of https://github.com/PCSX2/pcsx2.git
Common: Call dwmapi directly
This commit is contained in:
parent
1de3e0986e
commit
bca20c9e27
|
@ -25,34 +25,13 @@
|
||||||
|
|
||||||
static bool GetRefreshRateFromDWM(HWND hwnd, float* refresh_rate)
|
static bool GetRefreshRateFromDWM(HWND hwnd, float* refresh_rate)
|
||||||
{
|
{
|
||||||
static HMODULE dwm_module = nullptr;
|
|
||||||
static HRESULT(STDAPICALLTYPE * is_composition_enabled)(BOOL * pfEnabled) = nullptr;
|
|
||||||
static HRESULT(STDAPICALLTYPE * get_timing_info)(HWND hwnd, DWM_TIMING_INFO * pTimingInfo) = nullptr;
|
|
||||||
static bool load_tried = false;
|
|
||||||
if (!load_tried)
|
|
||||||
{
|
|
||||||
load_tried = true;
|
|
||||||
dwm_module = LoadLibraryW(L"dwmapi.dll");
|
|
||||||
if (dwm_module)
|
|
||||||
{
|
|
||||||
std::atexit([]() {
|
|
||||||
FreeLibrary(dwm_module);
|
|
||||||
dwm_module = nullptr;
|
|
||||||
});
|
|
||||||
is_composition_enabled =
|
|
||||||
reinterpret_cast<decltype(is_composition_enabled)>(GetProcAddress(dwm_module, "DwmIsCompositionEnabled"));
|
|
||||||
get_timing_info =
|
|
||||||
reinterpret_cast<decltype(get_timing_info)>(GetProcAddress(dwm_module, "DwmGetCompositionTimingInfo"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL composition_enabled;
|
BOOL composition_enabled;
|
||||||
if (!is_composition_enabled || FAILED(is_composition_enabled(&composition_enabled) || !get_timing_info))
|
if (FAILED(DwmIsCompositionEnabled(&composition_enabled)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DWM_TIMING_INFO ti = {};
|
DWM_TIMING_INFO ti = {};
|
||||||
ti.cbSize = sizeof(ti);
|
ti.cbSize = sizeof(ti);
|
||||||
HRESULT hr = get_timing_info(nullptr, &ti);
|
HRESULT hr = DwmGetCompositionTimingInfo(nullptr, &ti);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
if (ti.rateRefresh.uiNumerator == 0 || ti.rateRefresh.uiDenominator == 0)
|
if (ti.rateRefresh.uiNumerator == 0 || ti.rateRefresh.uiDenominator == 0)
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<AdditionalDependencies>comctl32.lib;ws2_32.lib;shlwapi.lib;winmm.lib;rpcrt4.lib;iphlpapi.lib;dsound.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>comctl32.lib;ws2_32.lib;shlwapi.lib;winmm.lib;rpcrt4.lib;iphlpapi.lib;dsound.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<AdditionalDependencies>dxguid.lib;dinput8.lib;hid.lib;PowrProf.lib;d3dcompiler.lib;d3d11.lib;d3d12.lib;dxgi.lib;strmiids.lib;opengl32.lib;comsuppw.lib;OneCore.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>dxguid.lib;dinput8.lib;hid.lib;PowrProf.lib;d3dcompiler.lib;d3d11.lib;d3d12.lib;dxgi.lib;strmiids.lib;opengl32.lib;comsuppw.lib;OneCore.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
|
@ -1210,6 +1210,7 @@ if(WIN32)
|
||||||
strmiids.lib
|
strmiids.lib
|
||||||
opengl32.lib
|
opengl32.lib
|
||||||
comsuppw.lib
|
comsuppw.lib
|
||||||
|
dwmapi.lib
|
||||||
OneCore.lib
|
OneCore.lib
|
||||||
)
|
)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
|
|
Loading…
Reference in New Issue