diff --git a/engine/client/r_surf.c b/engine/client/r_surf.c index 1e0f24482..0e9d0087e 100644 --- a/engine/client/r_surf.c +++ b/engine/client/r_surf.c @@ -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; diff --git a/engine/gl/gl_backend.c b/engine/gl/gl_backend.c index 641407a94..a546579eb 100644 --- a/engine/gl/gl_backend.c +++ b/engine/gl/gl_backend.c @@ -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];