Optimise lightmap updates with threaded world rendering.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5778 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2020-10-15 00:17:37 +00:00
parent 34ff2cd788
commit 697edaac76
2 changed files with 23 additions and 0 deletions

View file

@ -3035,6 +3035,7 @@ struct webostate_s
static struct webostate_s *webostates;
static struct webostate_s *webogenerating;
static int webogeneratingstate; //1 if generating, 0 if not, for waiting for sync.
int webo_blocklightmapupdates; //0 no webo, &1=using threadedworld, &2=already uploaded.
static void R_DestroyWorldEBO(struct webostate_s *es)
{
if (!es)
@ -3063,6 +3064,7 @@ void R_GeneratedWorldEBO(void *ctx, void *data, size_t a_, size_t b_)
webostates = webostate;
webogenerating = NULL;
webogeneratingstate = 0;
webo_blocklightmapupdates = 1;
mod = webostate->wmodel;
webostate->lastvalid = cls.framecount;
@ -3661,6 +3663,7 @@ void Surf_DeInit(void)
int i;
#ifdef THREADEDWORLD
webo_blocklightmapupdates = 0;
while(webogenerating)
COM_WorkerPartialSync(webogenerating, &webogeneratingstate, true);
while (webostates)
@ -3870,6 +3873,10 @@ int Surf_NewLightmaps(int count, int width, int height, uploadfmt_t fmt, qboolea
unsigned int pixbytes, pixw, pixh, pixd;
unsigned int dpixbytes, dpixw, dpixh, dpixd;
uploadfmt_t dfmt;
#ifdef THREADEDWORLD
extern int webo_blocklightmapupdates;
webo_blocklightmapupdates = 0;
#endif
if (!count)
return -1;
@ -3994,6 +4001,11 @@ int Surf_NewExternalLightmaps(int count, char *filepattern, qboolean deluxe)
char nname[MAX_QPATH];
qboolean odd = (count & 1) && deluxe;
#ifdef THREADEDWORLD
extern int webo_blocklightmapupdates;
webo_blocklightmapupdates = 0;
#endif
if (!count)
return -1;

View file

@ -5511,11 +5511,22 @@ void GLBE_SubmitMeshes (batch_t **worldbatches, int start, int stop)
}
}
#if (defined(GLQUAKE) || defined(VKQUAKE)) && defined(MULTITHREAD)
#define THREADEDWORLD
#endif
void GLBE_UpdateLightmaps(void)
{
lightmapinfo_t *lm;
int lmidx;
#ifdef THREADEDWORLD
extern int webo_blocklightmapupdates;
if (webo_blocklightmapupdates == 3)
return; //we've not had a new scene to render yet. don't bother uploading while something's still painting, its going to be redundant.
webo_blocklightmapupdates |= 2; //FIXME: round-robin it? one lightmap per frame?
#endif
for (lmidx = 0; lmidx < numlightmaps; lmidx++)
{
lm = lightmap[lmidx];