mirror of
https://github.com/diasurgical/DevilutionX.git
synced 2026-05-21 05:40:35 +00:00
Prefer DX11 renderer if running on windows with vsync active
This works around a bug in DX9 on Win11.
This commit is contained in:
@@ -269,11 +269,25 @@ void ReinitializeRenderer()
|
||||
rendererFlags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// On Windows 11 the directx9 VSYNC timer doesn't get recreated properly, see https://github.com/libsdl-org/SDL/issues/5099
|
||||
// Attempt to use the directx11 driver instead if we have vsync active.
|
||||
const char *const renderHint = SDL_GetHint(SDL_HINT_RENDER_DRIVER);
|
||||
if ((rendererFlags & SDL_RENDERER_PRESENTVSYNC) != 0 && SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d11") != SDL_TRUE) {
|
||||
Log("Error when trying to set hint for direct3d11, using default render driver");
|
||||
}
|
||||
#endif
|
||||
|
||||
renderer = SDL_CreateRenderer(ghMainWnd, -1, rendererFlags);
|
||||
if (renderer == nullptr) {
|
||||
ErrSdl();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
// Restore any system/user defined hint just in case they turn off upscale/vsync.
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, renderHint);
|
||||
#endif
|
||||
|
||||
auto quality = fmt::format("{}", static_cast<int>(*sgOptions.Graphics.scaleQuality));
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, quality.c_str());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user