I am the CEO of renderers

This commit is contained in:
Jaime Passos 2019-09-09 16:20:17 -03:00
parent dc93cafda9
commit da93e0f1f5
11 changed files with 61 additions and 60 deletions

View file

@ -1267,7 +1267,7 @@ void CONS_Printf(const char *fmt, ...)
con_scrollup = 0; con_scrollup = 0;
// if not in display loop, force screen update // if not in display loop, force screen update
if (con_startup) if (con_startup && (!setrenderneeded))
{ {
#if (defined (_WINDOWS)) || (defined (__OS2__) && !defined (HAVE_SDL)) #if (defined (_WINDOWS)) || (defined (__OS2__) && !defined (HAVE_SDL))
patch_t *con_backpic = W_CachePatchName("CONSBACK", PU_PATCH); patch_t *con_backpic = W_CachePatchName("CONSBACK", PU_PATCH);
@ -1584,13 +1584,11 @@ void CON_Drawer(void)
if (!con_started || !graphics_started) if (!con_started || !graphics_started)
return; return;
if (needpatchrecache)
R_ReloadHUDGraphics();
if (con_recalc) if (con_recalc)
{ {
CON_RecalcSize(); CON_RecalcSize();
CON_ClearHUD(); if (con_curlines <= 0)
CON_ClearHUD();
} }
if (con_curlines > 0) if (con_curlines > 0)

View file

@ -117,6 +117,8 @@ boolean devparm = false; // started game with -devparm
boolean singletics = false; // timedemo boolean singletics = false; // timedemo
boolean lastdraw = false; boolean lastdraw = false;
static void D_CheckRendererState(void);
postimg_t postimgtype = postimg_none; postimg_t postimgtype = postimg_none;
INT32 postimgparam; INT32 postimgparam;
postimg_t postimgtype2 = postimg_none; postimg_t postimgtype2 = postimg_none;
@ -227,7 +229,7 @@ gamestate_t wipegamestate = GS_LEVEL;
static void D_Display(void) static void D_Display(void)
{ {
INT32 setrenderstillneeded = setrenderneeded; INT32 setrenderstillneeded = 0;
boolean forcerefresh = false; boolean forcerefresh = false;
static boolean wipe = false; static boolean wipe = false;
INT32 wipedefindex = 0; INT32 wipedefindex = 0;
@ -242,9 +244,16 @@ static void D_Display(void)
if (setrenderneeded && (moviemode != MM_OFF)) if (setrenderneeded && (moviemode != MM_OFF))
M_StopMovie(); M_StopMovie();
// check for change of screen size (video mode) // check for change of renderer or screen size (video mode)
if ((setmodeneeded || setrenderneeded) && !wipe) if ((setrenderneeded || setmodeneeded) && !wipe)
{
if (setrenderneeded)
{
CONS_Debug(DBG_RENDER, "setrenderneeded set (%d)\n", setrenderneeded);
setrenderstillneeded = setrenderneeded;
}
SCR_SetMode(); // change video mode SCR_SetMode(); // change video mode
}
if (vid.recalc || setrenderstillneeded) if (vid.recalc || setrenderstillneeded)
SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc() SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc()
@ -256,6 +265,8 @@ static void D_Display(void)
forcerefresh = true; // force background redraw forcerefresh = true; // force background redraw
} }
D_CheckRendererState();
// draw buffered stuff to screen // draw buffered stuff to screen
// Used only by linux GGI version // Used only by linux GGI version
I_UpdateNoBlit(); I_UpdateNoBlit();
@ -495,16 +506,24 @@ static void D_Display(void)
I_FinishUpdate(); // page flip or blit buffer I_FinishUpdate(); // page flip or blit buffer
} }
// in the occasion no functions
// that require patches to be cached
// have been called.
if (needpatchrecache)
R_ReloadHUDGraphics();
needpatchflush = false; needpatchflush = false;
needpatchrecache = false; needpatchrecache = false;
} }
void D_CheckRendererState(void)
{
// flush all patches from memory
// (also frees memory tagged with PU_CACHE)
// (which are not necessarily patches but I don't care)
if (needpatchflush)
Z_FlushCachedPatches();
// some patches have been freed,
// so cache them again
if (needpatchrecache)
R_ReloadHUDGraphics();
}
// ========================================================================= // =========================================================================
// D_SRB2Loop // D_SRB2Loop
// ========================================================================= // =========================================================================
@ -1201,6 +1220,21 @@ void D_SRB2Main(void)
// set user default mode or mode set at cmdline // set user default mode or mode set at cmdline
SCR_CheckDefaultMode(); SCR_CheckDefaultMode();
// renderer needs to change?
// ok cool please just change it
// exactly right now please.
if ((setrenderneeded != 0) && (setrenderneeded != rendermode))
{
needpatchflush = true;
needpatchrecache = true;
VID_CheckRenderer();
// set cv_renderer back
if (setrenderneeded == render_soft)
CV_StealthSetValue(&cv_renderer, 1);
else if (setrenderneeded == render_opengl)
CV_StealthSetValue(&cv_renderer, 2);
}
D_CheckRendererState();
wipegamestate = gamestate; wipegamestate = gamestate;

View file

@ -712,9 +712,6 @@ void HWR_GetFlat(lumpnum_t flatlumpnum)
{ {
GLMipmap_t *grmip; GLMipmap_t *grmip;
if (needpatchflush)
Z_FlushCachedPatches();
grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap; grmip = &HWR_GetCachedGLPatch(flatlumpnum)->mipmap;
if (!grmip->downloaded && !grmip->grInfo.data) if (!grmip->downloaded && !grmip->grInfo.data)
@ -751,9 +748,6 @@ static void HWR_LoadMappedPatch(GLMipmap_t *grmip, GLPatch_t *gpatch)
// -----------------+ // -----------------+
void HWR_GetPatch(GLPatch_t *gpatch) void HWR_GetPatch(GLPatch_t *gpatch)
{ {
if (needpatchflush)
Z_FlushCachedPatches();
// is it in hardware cache // is it in hardware cache
if (!gpatch->mipmap.downloaded && !gpatch->mipmap.grInfo.data) if (!gpatch->mipmap.downloaded && !gpatch->mipmap.grInfo.data)
{ {
@ -781,9 +775,6 @@ void HWR_GetMappedPatch(GLPatch_t *gpatch, const UINT8 *colormap)
{ {
GLMipmap_t *grmip, *newmip; GLMipmap_t *grmip, *newmip;
if (needpatchflush)
Z_FlushCachedPatches();
if (colormap == colormaps || colormap == NULL) if (colormap == colormaps || colormap == NULL)
{ {
// Load the default (green) color in doom cache (temporary?) AND hardware cache // Load the default (green) color in doom cache (temporary?) AND hardware cache
@ -909,9 +900,6 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum)
{ {
GLPatch_t *grpatch; GLPatch_t *grpatch;
if (needpatchflush)
Z_FlushCachedPatches();
grpatch = HWR_GetCachedGLPatch(lumpnum); grpatch = HWR_GetCachedGLPatch(lumpnum);
if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data) if (!grpatch->mipmap.downloaded && !grpatch->mipmap.grInfo.data)
@ -1109,9 +1097,6 @@ void HWR_GetFadeMask(lumpnum_t fademasklumpnum)
{ {
GLMipmap_t *grmip; GLMipmap_t *grmip;
if (needpatchflush)
Z_FlushCachedPatches();
grmip = &HWR_GetCachedGLPatch(fademasklumpnum)->mipmap; grmip = &HWR_GetCachedGLPatch(fademasklumpnum)->mipmap;
if (!grmip->downloaded && !grmip->grInfo.data) if (!grmip->downloaded && !grmip->grInfo.data)

View file

@ -1993,9 +1993,6 @@ static void HU_DrawDemoInfo(void)
// //
void HU_Drawer(void) void HU_Drawer(void)
{ {
if (needpatchrecache)
R_ReloadHUDGraphics();
#ifndef NONET #ifndef NONET
// draw chat string plus cursor // draw chat string plus cursor
if (chat_on) if (chat_on)

View file

@ -2481,9 +2481,6 @@ void M_Drawer(void)
if (currentMenu == &MessageDef) if (currentMenu == &MessageDef)
menuactive = true; menuactive = true;
if (needpatchrecache)
R_ReloadHUDGraphics();
if (menuactive) if (menuactive)
{ {
// now that's more readable with a faded background (yeah like Quake...) // now that's more readable with a faded background (yeah like Quake...)

View file

@ -3098,10 +3098,7 @@ boolean P_SetupLevel(boolean skipprecip)
// preload graphics // preload graphics
#ifdef HWRENDER // not win32 only 19990829 by Kin #ifdef HWRENDER // not win32 only 19990829 by Kin
if (rendermode == render_opengl) if (rendermode == render_opengl)
{
HWR_PrepLevelCache(numtextures); HWR_PrepLevelCache(numtextures);
//HWR_FreeColormaps();
}
#endif #endif
P_MapEnd(); P_MapEnd();

View file

@ -1353,7 +1353,7 @@ void R_InitHardwareMode(void)
void R_ReloadHUDGraphics(void) void R_ReloadHUDGraphics(void)
{ {
Z_FlushCachedPatches(); CONS_Debug(DBG_RENDER, "R_ReloadHUDGraphics()...\n");
ST_LoadGraphics(); ST_LoadGraphics();
HU_LoadGraphics(); HU_LoadGraphics();
ST_ReloadSkinFaceGraphics(); ST_ReloadSkinFaceGraphics();

View file

@ -1909,9 +1909,6 @@ static void ST_overlayDrawer(void)
void ST_Drawer(void) void ST_Drawer(void)
{ {
if (needpatchrecache)
R_ReloadHUDGraphics();
#ifdef SEENAMES #ifdef SEENAMES
if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo) if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo)
{ {

View file

@ -830,10 +830,10 @@ void W_UnloadWadFile(UINT16 num)
lumpcache = delwad->lumpcache; lumpcache = delwad->lumpcache;
numwadfiles--; numwadfiles--;
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode != render_soft && rendermode != render_none) if (rendermode == render_opengl)
{ {
HWR_FreeTextureCache();
HWR_FreeColormaps(); HWR_FreeColormaps();
HWR_FreeTextureCache();
} }
M_AATreeFree(delwad->hwrcache); M_AATreeFree(delwad->hwrcache);
#endif #endif
@ -1512,9 +1512,6 @@ static inline void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag)
{ {
GLPatch_t *grPatch; GLPatch_t *grPatch;
if (needpatchflush)
Z_FlushCachedPatches();
if (rendermode == render_soft || rendermode == render_none) if (rendermode == render_soft || rendermode == render_none)
return W_CacheLumpNumPwad(wad, lump, tag); return W_CacheLumpNumPwad(wad, lump, tag);

View file

@ -192,7 +192,6 @@ void Y_IntermissionDrawer(void)
if (needpatchrecache) if (needpatchrecache)
{ {
Y_CleanupData(); Y_CleanupData();
R_ReloadHUDGraphics();
safetorender = false; safetorender = false;
} }

View file

@ -415,20 +415,20 @@ void Z_FreeTags(INT32 lowtag, INT32 hightag)
boolean needpatchflush = false; boolean needpatchflush = false;
boolean needpatchrecache = false; boolean needpatchrecache = false;
// flush all patches from memory
// (also frees memory tagged with PU_CACHE)
// (which are not necessarily patches but I don't care)
void Z_FlushCachedPatches(void) void Z_FlushCachedPatches(void)
{ {
if (needpatchflush) CONS_Debug(DBG_RENDER, "Z_FlushCachedPatches()...\n");
{ Z_FreeTag(PU_CACHE);
Z_FreeTag(PU_CACHE); Z_FreeTag(PU_PATCH);
Z_FreeTag(PU_PATCH); Z_FreeTag(PU_HUDGFX);
Z_FreeTag(PU_HUDGFX); Z_FreeTag(PU_HWRPATCHINFO);
Z_FreeTag(PU_HWRPATCHINFO); Z_FreeTag(PU_HWRPATCHCOLMIPMAP);
Z_FreeTag(PU_HWRPATCHCOLMIPMAP); Z_FreeTag(PU_HWRCACHE);
Z_FreeTag(PU_HWRCACHE); Z_FreeTag(PU_HWRCACHE_UNLOCKED);
Z_FreeTag(PU_HWRCACHE_UNLOCKED); Z_FreeTag(PU_HWRPATCHINFO_UNLOCKED);
Z_FreeTag(PU_HWRPATCHINFO_UNLOCKED);
}
needpatchflush = false;
} }
// //