mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
SDL layer: in 8-bit mode, defer setting the palette until showing the next frame.
CON code sometimes uses 'setgamepalette' from withing actors, which is a bit too frequent. Deferring the actual palette updating means that multiple requests in between two screen redraws are coalesced into one, which is desirable for performance reasons and for the reduction of 'tearing' artefacts (but not prevention, since the drawing isn't synced to the screen refresh rate with vsync off). (Did-not-)update issues might be introduced. Windows isn't touched because - I expect it to be more brittle, especially in light of the ATI HW gamma problems. - I haven't tested whether the particular performance penalty that lead to this change ('gas' in AMC TC) exists there too git-svn-id: https://svn.eduke32.com/eduke32@2221 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
9e1399ec14
commit
4ae50ef22a
1 changed files with 17 additions and 7 deletions
|
@ -1397,6 +1397,8 @@ void enddrawing(void)
|
|||
if (SDL_MUSTLOCK(sdl_surface)) SDL_UnlockSurface(sdl_surface);
|
||||
}
|
||||
|
||||
static int32_t needpalupdate;
|
||||
static SDL_Color sdlayer_pal[256];
|
||||
|
||||
//
|
||||
// showframe() -- update the display
|
||||
|
@ -1451,6 +1453,15 @@ void showframe(int32_t w)
|
|||
while (lockcount) enddrawing();
|
||||
}
|
||||
|
||||
// deferred palette updating
|
||||
if (needpalupdate)
|
||||
{
|
||||
SDL_SetColors(sdl_surface, sdlayer_pal, 0, 256);
|
||||
// same as:
|
||||
//SDL_SetPalette(sdl_surface, SDL_LOGPAL|SDL_PHYSPAL, pal, 0, 256);
|
||||
needpalupdate = 0;
|
||||
}
|
||||
|
||||
SDL_Flip(sdl_surface);
|
||||
}
|
||||
|
||||
|
@ -1460,25 +1471,24 @@ void showframe(int32_t w)
|
|||
//
|
||||
int32_t setpalette(int32_t start, int32_t num)
|
||||
{
|
||||
SDL_Color pal[256];
|
||||
int32_t i,n;
|
||||
|
||||
if (bpp > 8) return 0; // no palette in opengl
|
||||
|
||||
copybuf(curpalettefaded, pal, 256);
|
||||
Bmemcpy(sdlayer_pal, curpalettefaded, 256*4);
|
||||
|
||||
for (i=start, n=num; n>0; i++, n--)
|
||||
curpalettefaded[i].f = pal[i].unused = 0;
|
||||
curpalettefaded[i].f = sdlayer_pal[i].unused = 0;
|
||||
|
||||
//return SDL_SetPalette(sdl_surface, SDL_LOGPAL|SDL_PHYSPAL, pal, 0, 256);
|
||||
needpalupdate = 1;
|
||||
|
||||
return sdl_surface ? SDL_SetColors(sdl_surface, pal, 0, 256) : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// getpalette() -- get palette values
|
||||
//
|
||||
/*
|
||||
#if 0
|
||||
int32_t getpalette(int32_t start, int32_t num, char *dapal)
|
||||
{
|
||||
int32_t i;
|
||||
|
@ -1496,7 +1506,7 @@ int32_t getpalette(int32_t start, int32_t num, char *dapal)
|
|||
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
//
|
||||
// setgamma
|
||||
|
|
Loading…
Reference in a new issue