From 8b0f374bfe3b5ee41ce8e1295d86d731a4300c97 Mon Sep 17 00:00:00 2001 From: Ronald Kinard Date: Thu, 24 Jul 2014 19:13:06 -0500 Subject: [PATCH] sdl2: potential huge perf. boost to software SDL_UpdateTexture is apparently not good for streaming textures. So instead, I did SDL_LockTexture/Unlock. --- src/sdl2/i_video.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/sdl2/i_video.c b/src/sdl2/i_video.c index 3a23d5f0d..8faff69bc 100644 --- a/src/sdl2/i_video.c +++ b/src/sdl2/i_video.c @@ -1381,8 +1381,25 @@ void I_FinishUpdate(void) } if (bufSurface) //Alam: New Way to send video data { + void *pixels; + int pitch; + SDL_BlitSurface(bufSurface, NULL, vidSurface, &rect); - SDL_UpdateTexture(texture, NULL, vidSurface->pixels, realwidth * 4); + // Fury -- streaming textures are bad on UpdateTexture + SDL_LockSurface(vidSurface); + SDL_LockTexture(texture, &rect, &pixels, &pitch); + if (pitch == vidSurface->pitch) + { + M_Memcpy(pixels, vidSurface->pixels, (pitch * vid.height)); + } + else + { + SDL_UnlockTexture(texture); + SDL_UnlockSurface(vidSurface); + I_Error("The intermediate buffer and final texture types are not the same.\n"); + } + SDL_UnlockTexture(texture); + SDL_UnlockSurface(vidSurface); } // Blit buffer to texture SDL_RenderCopy(renderer, texture, NULL, NULL);