fix some other issues that exhibited themselves in aqueous.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4835 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2015-02-03 09:44:27 +00:00
parent 670a5d5992
commit 23971df104
8 changed files with 59 additions and 32 deletions

View File

@ -308,7 +308,7 @@ static void CSQC_FindGlobals(void)
if (!csqc_world.g.physics_mode)
{
csphysicsmode = csqc_isdarkplaces?1:0;
csphysicsmode = 0; /*note: dp handles think functions as part of addentity rather than elsewhere. if we're in a compat mode, we don't want to have to duplicate work*/
csqc_world.g.physics_mode = &csphysicsmode;
}

View File

@ -1216,6 +1216,11 @@ void Surf_RenderDynamicLightmaps (msurface_t *fa)
dynamic:
RSpeedRemark();
#ifdef _DEBUG
if ((unsigned)fa->lightmaptexturenums[0] >= numlightmaps)
Sys_Error("Invalid lightmap index\n");
#endif
lm = lightmap[fa->lightmaptexturenums[0]];
lm->modified = true;
@ -2644,7 +2649,7 @@ void Surf_BuildModelLightmaps (model_t *m)
#ifdef TERRAIN
//easiest way to deal with heightmap lightmaps is to just purge the entire thing.
if (m->terrain)
Terr_PurgeTerrainModel(m, true, false);
Terr_PurgeTerrainModel(m, false, false); //FIXME: cop out. middle arg should be 'true'.
#endif
if (m->type != mod_brush)
@ -2858,22 +2863,14 @@ void Surf_BuildLightmaps (void)
r_oldviewcluster2 = -1;
numlightmaps = 0;
for (j=1 ; j<MAX_PRECACHE_MODELS ; j++)
//FIXME: unload stuff that's no longer relevant somehow.
for (i = 0; i < mod_numknown; i++)
{
m = cl.model_precache[j];
if (!m)
break;
m = &mod_known[i];
if (m->loadstate != MLS_LOADED)
continue;
Surf_BuildModelLightmaps(m);
}
for (j=1 ; j<MAX_CSMODELS ; j++)
{
m = cl.model_csqcprecache[j];
if (!m)
break;
Surf_BuildModelLightmaps(m);
}
BE_UploadAllLightmaps();
}

View File

@ -37,6 +37,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <process.h>
#endif
//exports that 3rd-party drivers can see in order to use descrete graphics cards over integrated ones, FOR MORE POWAH!
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; //13.35+
wchar_t *widen(wchar_t *out, size_t outlen, const char *utf8);
char *narrowen(char *out, size_t outlen, wchar_t *wide);

View File

@ -2234,6 +2234,12 @@ void Terr_FreeModel(model_t *mod)
if (hm)
{
Terr_PurgeTerrainModel(mod, false, false);
while(hm->entities)
{
struct hmentity_s *n = hm->entities->next;
Z_Free(hm->entities);
hm->entities = n;
}
Z_Free(hm);
mod->terrain = NULL;
}

View File

@ -1247,7 +1247,7 @@ void R_Clear (qboolean fbo)
//for performance, we clear the depth at the same time we clear colour, so we can skip clearing depth here the first time around each frame.
//but for multiple scenes, we do need to clear depth still.
//fbos always get cleared depth, just in case (colour fbos may contain junk, but hey).
qglClear (GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
qglClear (GL_DEPTH_BUFFER_BIT);
}
if (!fbo)
depthcleared = false;

View File

@ -416,19 +416,24 @@ static void SH_CalcShadowBatches(model_t *mod)
}
}
l = NULL;
sb = 0;
mod->shadowbatches = BZ_Malloc(sizeof(*mod->shadowbatches)*mod->numshadowbatches);
for (s = 0; s < SHADER_SORT_COUNT; s++)
if (!mod->numshadowbatches)
mod->shadowbatches = NULL;
else
{
for (b = mod->batches[s]; b; b = b->next)
l = NULL;
sb = 0;
mod->shadowbatches = BZ_Malloc(sizeof(*mod->shadowbatches)*mod->numshadowbatches);
for (s = 0; s < SHADER_SORT_COUNT; s++)
{
if (!l || l->vbo != b->vbo || l->texture != b->texture)
for (b = mod->batches[s]; b; b = b->next)
{
mod->shadowbatches[sb].tex = b->texture;
mod->shadowbatches[sb].vbo = b->vbo;
sb++;
l = b;
if (!l || l->vbo != b->vbo || l->texture != b->texture)
{
mod->shadowbatches[sb].tex = b->texture;
mod->shadowbatches[sb].vbo = b->vbo;
sb++;
l = b;
}
}
}
}

View File

@ -1037,7 +1037,7 @@ pbool PR_RunGC (progfuncs_t *progfuncs)
unsigned int p;
char *marked;
unsigned int *str;
// unsigned int r_l, r_d;
unsigned int r_l, r_d;
// unsigned long long starttime, markedtime, endtime;
//only run the GC when we've itterated each string at least once.
@ -1066,13 +1066,13 @@ pbool PR_RunGC (progfuncs_t *progfuncs)
//sweep
// markedtime = Sys_GetClock();
// r_l = 0;
// r_d = 0;
r_l = 0;
r_d = 0;
for (p = 0; p < prinst.numtempstrings; p++)
{
if (marked[p])
{
// r_l++;
r_l++;
}
else
break;
@ -1082,11 +1082,11 @@ pbool PR_RunGC (progfuncs_t *progfuncs)
{
if (marked[p])
{
// r_l++;
r_l++;
}
else if (prinst.tempstrings[p])
{
// r_d++;
r_d++;
externs->memfree(prinst.tempstrings[p]);
prinst.tempstrings[p] = NULL;
}
@ -1097,6 +1097,20 @@ pbool PR_RunGC (progfuncs_t *progfuncs)
free(marked);
//if over half the (max)strings are still live, just increase the max so we are not spamming collections
r_d += prinst.maxtempstrings - prinst.numtempstrings;
if (r_l > r_d)
{
unsigned int newmax = prinst.maxtempstrings * 2;
char **ntable = progfuncs->funcs.parms->memalloc(sizeof(char*) * newmax);
memcpy(ntable, prinst.tempstrings, sizeof(char*) * prinst.maxtempstrings);
memset(ntable+prinst.maxtempstrings, 0, sizeof(char*) * (newmax-prinst.maxtempstrings));
prinst.maxtempstrings = newmax;
if (prinst.tempstrings)
progfuncs->funcs.parms->memfree(prinst.tempstrings);
prinst.tempstrings = ntable;
}
// endtime = Sys_GetClock();
// printf("live: %u, dead: %u, time: mark=%f, sweep=%f\n", r_l, r_d, (double)(markedtime - starttime) / Sys_GetClockRate(), (double)(endtime - markedtime) / Sys_GetClockRate());
@ -1121,7 +1135,7 @@ void PR_FreeTemps (progfuncs_t *progfuncs, int depth)
#endif
void PR_FreeAllTemps (progfuncs_t *progfuncs)
{
int i;
unsigned int i;
for (i = 0; i < prinst.numtempstrings; i++)
{
externs->memfree(prinst.tempstrings[i]);

View File

@ -1588,7 +1588,7 @@ void PDECL PR_ExecuteProgram (pubprogfuncs_t *ppf, func_t fnum)
PR_FreeTemps(progfuncs, tempdepth);
prinst.numtempstringsstack = tempdepth;
#else
if (!oldexitdepth)
if (!pr_depth)
PR_RunGC(progfuncs);
#endif