diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index bb2036108..321d6d026 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -56,6 +56,13 @@ #include #endif +#ifdef __LINUX__ +#include +#include +#include +#endif + + /* Available video drivers */ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_COCOA @@ -2640,6 +2647,15 @@ SDL_CreateWindowFramebuffer(SDL_Window * window) attempt_texture_framebuffer = SDL_FALSE; } +#if defined(__LINUX__) + /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ + else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "x11") == 0)) { + struct stat sb; + if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */ + attempt_texture_framebuffer = SDL_FALSE; + } + } +#endif #if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "windows") == 0)) { attempt_texture_framebuffer = SDL_FALSE;