From fc075e4c81b67ad515b19cecf396393798caa328 Mon Sep 17 00:00:00 2001 From: Ronald Kinard Date: Wed, 23 Jul 2014 23:02:21 -0500 Subject: [PATCH 1/3] sdl2: use ABGR8888 texture on little endian system This is a massive performance boost on slow processors, because before, the intermediary buffer had to be swizzled to ABGR8888 before being uploaded -- for large resolutions this was an enormous performance penalty. --- src/sdl2/i_video.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sdl2/i_video.c b/src/sdl2/i_video.c index 669825428..da5632e48 100644 --- a/src/sdl2/i_video.c +++ b/src/sdl2/i_video.c @@ -174,6 +174,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) int gmask; int bmask; int amask; + int sw_texture_format = SDL_PIXELFORMAT_ABGR8888; realwidth = vid.width; realheight = vid.height; @@ -229,7 +230,12 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) { SDL_DestroyTexture(texture); } - texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, width, height); +#ifdef SDL_BIG_ENDIAN + sw_texture_format = SDL_PIXELFORMAT_RGBA8888; +#else + sw_texture_format = SDL_PIXELFORMAT_ABGR8888; +#endif + texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height); // Set up SW surface if (vidSurface != NULL) From 73e99fa96c730bf7c0bf9cf502d0af887470b9d4 Mon Sep 17 00:00:00 2001 From: Ronald Kinard Date: Wed, 23 Jul 2014 23:15:31 -0500 Subject: [PATCH 2/3] sdl2: I_Error if we can't create gl context --- src/sdl2/i_video.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/sdl2/i_video.c b/src/sdl2/i_video.c index da5632e48..32788093d 100644 --- a/src/sdl2/i_video.c +++ b/src/sdl2/i_video.c @@ -83,7 +83,7 @@ #endif // maximum number of windowed modes (see windowedModes[][]) -#define MAXWINMODES (16) +#define MAXWINMODES (17) /** \brief */ @@ -147,6 +147,7 @@ static INT32 windowedModes[MAXWINMODES][2] = {1920,1080}, // 1.66 {1680,1050}, // 1.60,5.25 {1600, 900}, // 1.66 + {1366, 768}, // 1.66 {1440, 900}, // 1.60,4.50 {1280,1024}, // 1.33? {1280, 960}, // 1.33,4.00 @@ -1684,7 +1685,15 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) if (window != NULL) { sdlglcontext = SDL_GL_CreateContext(window); - SDL_GL_MakeCurrent(window, sdlglcontext); + if (sdlglcontext == NULL) + { + SDL_DestroyWindow(window); + I_Error("Failed to create a GL context: %s\n", SDL_GetError()); + } + else + { + SDL_GL_MakeCurrent(window, sdlglcontext); + } } else return SDL_FALSE; } From 4433be194f8a412ef3def5c0113f4d37a33da7c8 Mon Sep 17 00:00:00 2001 From: Ronald Kinard Date: Wed, 23 Jul 2014 23:21:19 -0500 Subject: [PATCH 3/3] sdl2: software: clear window on mode change --- src/sdl2/i_video.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sdl2/i_video.c b/src/sdl2/i_video.c index 32788093d..53fc95495 100644 --- a/src/sdl2/i_video.c +++ b/src/sdl2/i_video.c @@ -224,6 +224,7 @@ static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) if (rendermode == render_soft) { SDL_RenderSetLogicalSize(renderer, width, height); + SDL_RenderClear(renderer); // Set up Texture realwidth = width; realheight = height;