Prevent a crash in Windows AMD drivers
Usually, when window is being created without SDL_WINDOW_OPENGL flag, SDL2 internally re-creates it to support OpenGL during SDL_CreateRenderer if needed. This leads to crash in AMD OpenGL drivers (Windows only), which happens for drivers: "opengl", "opengles", "opengles2". When the window is created with correct flag from the get-go, the crash does not happen. On Linux, the code does not crash either way (at least not when using Mesa and AMDGPU open source driver), so there's no point in propagating the hack. Also, remove a comment that is no longer relevant to the code below.
This commit is contained in:
parent
bb43294f68
commit
8d5bc9537a
2 changed files with 16 additions and 8 deletions
|
@ -122,4 +122,9 @@ void upcase(std::string &str);
|
|||
void lowcase(std::string &str);
|
||||
void strip_punctuation(std::string &str);
|
||||
|
||||
template<size_t N>
|
||||
bool starts_with(const char (& pfx)[N], const std::string &str) noexcept {
|
||||
return (strncmp(pfx, str.c_str(), N) == 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -546,13 +546,16 @@ static SDL_Window * GFX_SetSDLWindowMode(Bit16u width, Bit16u height, bool fulls
|
|||
SDL_DestroyWindow(sdl.window);
|
||||
}
|
||||
|
||||
/* Don't create a fullscreen immediately. Reasons:
|
||||
* 1. This theoretically allows us to set window resolution and
|
||||
* then let SDL2 remember it for later (even if not actually done).
|
||||
* 2. It's a bit less glitchy to set a custom display mode for a
|
||||
* full screen, albeit it's still not perfect (at least on X11).
|
||||
*/
|
||||
const uint32_t flags = (screenType == SCREEN_OPENGL) ? SDL_WINDOW_OPENGL : 0;
|
||||
uint32_t flags = 0;
|
||||
if (screenType == SCREEN_OPENGL)
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
#if defined (WIN32)
|
||||
// This is a hack for Windows 10 to prevent a crash in AMD OpenGL
|
||||
// driver when window is being re-created by SDL2 internally to
|
||||
// support OpenGL.
|
||||
else if (screenType == SCREEN_TEXTURE && starts_with("opengl", sdl.render_driver))
|
||||
flags |= SDL_WINDOW_OPENGL;
|
||||
#endif
|
||||
|
||||
// Using undefined position will take care of placing and restoring the
|
||||
// window by WM.
|
||||
|
@ -1915,6 +1918,7 @@ static void GUI_StartUp(Section * sec) {
|
|||
sdl.texture.texture = 0;
|
||||
sdl.texture.pixelFormat = 0;
|
||||
sdl.render_driver = section->Get_string("texture_renderer");
|
||||
lowcase(sdl.render_driver);
|
||||
|
||||
#if C_OPENGL
|
||||
if (sdl.desktop.want_type == SCREEN_OPENGL) { /* OPENGL is requested */
|
||||
|
@ -1983,7 +1987,6 @@ static void GUI_StartUp(Section * sec) {
|
|||
LOG_MSG("OpenGL extension: pixel_bufer_object %d",sdl.opengl.pixel_buffer_object);
|
||||
}
|
||||
} /* OPENGL is requested end */
|
||||
|
||||
#endif //OPENGL
|
||||
|
||||
if (!SetDefaultWindowMode())
|
||||
|
|
Loading…
Add table
Reference in a new issue