sdl2: potential huge perf. boost to software

SDL_UpdateTexture is apparently not good for streaming textures.
So instead, I did SDL_LockTexture/Unlock.
This commit is contained in:
Ronald Kinard 2014-07-24 19:13:06 -05:00
parent 005b502756
commit 8b0f374bfe
1 changed files with 18 additions and 1 deletions

View File

@ -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);