Skip to content

Commit da38b26

Browse files
abairemborgerson
authored andcommitted
ui: Force NVIDIA present method to native
Setting the NVIDIA driver Vulkan/OpenGL present method to "Prefer layerd on DXGI Swapchain" with vsync enabled within xemu causes framerate to be ~halved. This change overrides the driver setting to force the legacy/native value to be used. Resolves one identified issue with #2790
1 parent dc69fb4 commit da38b26

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

thirdparty/nvapi/nvapi.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ bool nvapi_setup_profile(NvApiProfileOpts opts)
152152
goto cleanup;
153153
}
154154

155+
NVDRS_SETTING setting_dxpresent = {
156+
.version = NVDRS_SETTING_VER,
157+
.settingId = OGL_CPL_PREFER_DXPRESENT_ID,
158+
.settingType = NVDRS_DWORD_TYPE,
159+
.u32CurrentValue = opts.present_method,
160+
};
161+
if (NvAPI_DRS_SetSetting(session, profile, &setting_dxpresent)) {
162+
LOG("NvAPI_DRS_SetSetting for settingId %x failed",
163+
setting_dxpresent.settingId);
164+
goto cleanup;
165+
}
166+
155167
if (NvAPI_DRS_SaveSettings(session)) {
156168
LOG("NvAPI_DRS_SaveSettings failed");
157169
goto cleanup;

thirdparty/nvapi/nvapi.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@
2727
#include <windows.h>
2828
#include <stdbool.h>
2929

30+
enum EValues_OGL_CPL_PREFER_DXPRESENT {
31+
OGL_CPL_PREFER_DXPRESENT_PREFER_DISABLED = 0x00000000,
32+
OGL_CPL_PREFER_DXPRESENT_PREFER_ENABLED = 0x00000001,
33+
OGL_CPL_PREFER_DXPRESENT_AUTO = 0x00000002,
34+
OGL_CPL_PREFER_DXPRESENT_NUM_VALUES = 3,
35+
OGL_CPL_PREFER_DXPRESENT_DEFAULT = OGL_CPL_PREFER_DXPRESENT_AUTO
36+
};
37+
3038
typedef struct NvApiProfileOpts {
3139
const wchar_t *profile_name;
3240
const wchar_t *executable_name;
3341
bool threaded_optimization;
42+
enum EValues_OGL_CPL_PREFER_DXPRESENT present_method;
3443
} NvApiProfileOpts;
3544

3645
bool nvapi_init(void);

thirdparty/nvapi/nvapi_defs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
enum ESetting {
3434
OGL_THREAD_CONTROL_ID = 0x20C1221E,
35+
OGL_CPL_PREFER_DXPRESENT_ID = 0x20D690F8,
3536
};
3637

3738
enum EValues_OGL_THREAD_CONTROL {

ui/xemu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,7 @@ static void setup_nvidia_profile(void)
12571257
.profile_name = L"xemu",
12581258
.executable_name = exe_name,
12591259
.threaded_optimization = false,
1260+
.present_method = OGL_CPL_PREFER_DXPRESENT_PREFER_DISABLED,
12601261
});
12611262
nvapi_finalize();
12621263
}

0 commit comments

Comments
 (0)