fix corrupt d3d batches (on large maps)

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5117 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2017-06-22 10:29:06 +00:00
parent 272e3f978c
commit 705067928a
8 changed files with 31 additions and 28 deletions

View file

@ -5822,9 +5822,8 @@ void CL_ExecInitialConfigs(char *resetcommand)
int def;
Cbuf_Execute (); //make sure any pending console commands are done with. mostly, anyway...
SCR_ShowPic_ClearAll(true);
Cbuf_AddText("unbindall\n", RESTRICT_LOCAL);
Cbuf_AddText("unbindall\nshowpic_removeall\n", RESTRICT_LOCAL);
Cbuf_AddText("bind volup \"inc volume 0.1\"\n", RESTRICT_LOCAL);
Cbuf_AddText("bind voldown \"inc volume -0.1\"\n", RESTRICT_LOCAL);
Cbuf_AddText("alias restart_ents \"changelevel . .\"\n",RESTRICT_LOCAL);

View file

@ -265,14 +265,14 @@ static char *svc_nqstrings[] =
"NEW PROTOCOL(75)", //75
"NEW PROTOCOL(76)", //76
"NEW PROTOCOL(77)", //77
"NEW PROTOCOL(78)", //78
"NEW PROTOCOL(79)", //79
"nqsvcfte_updatestatstring(78)", //78
"nqsvcfte_updatestatfloat(79)", //79
"NEW PROTOCOL(80)", //80
"NEW PROTOCOL(81)", //81
"NEW PROTOCOL(82)", //82
"nqsvcfte_cgamepacket(83)", //83
"nqsvcfte_voicechat", //84
"NEW PROTOCOL(85)", //85
"nqsvcfte_setangledelta(85)", //85
"nqsvcfte_updateentities", //86
"NEW PROTOCOL(87)", //87
"NEW PROTOCOL(88)" //88

View file

@ -565,7 +565,7 @@ void VARGS Stats_Message(char *msg, ...)
p->time_start = cl.time;
}
#define MAX_CPRINT_LINES 256
#define MAX_CPRINT_LINES 512
void SCR_DrawCenterString (vrect_t *rect, cprint_t *p, struct font_s *font)
{
int l;
@ -688,15 +688,11 @@ void SCR_DrawCenterString (vrect_t *rect, cprint_t *p, struct font_s *font)
if (y >= bottom)
break;
if (p->flags & CPRINT_RALIGN)
{
x = right - Font_LineWidth(line_start[l], line_end[l]);
}
else if (p->flags & CPRINT_LALIGN)
x = left;
else
{
x = left + (right - left - Font_LineWidth(line_start[l], line_end[l]))/2;
}
remaining -= line_end[l]-line_start[l];
if (remaining <= 0)

View file

@ -4582,7 +4582,7 @@ static int PScript_RunParticleEffectState (vec3_t org, vec3_t dir, float count,
while(ptype)
{
if (r_part_contentswitch.ival && (ptype->flags & (PT_TRUNDERWATER | PT_TROVERWATER)) && cl.worldmodel)
if (r_part_contentswitch.ival && (ptype->flags & (PT_TRUNDERWATER | PT_TROVERWATER)) && cl.worldmodel && cl.worldmodel->loadstate==MLS_LOADED)
{
int cont;
cont = cl.worldmodel->funcs.PointContents(cl.worldmodel, NULL, org);

View file

@ -293,7 +293,7 @@ extern D3D_FEATURE_LEVEL d3dfeaturelevel;
#define VERTEXSTREAMSIZE (1024*1024*2) //2mb = 1 PAE jumbo page
#define DYNVBUFFSIZE 65536
#define DYNIBUFFSIZE 65536
#define DYNIBUFFSIZE 65536*3
static vecV_t tmpbuf[65536]; //max verts per mesh
@ -2605,7 +2605,7 @@ void D3D11BE_GenBatchVBOs(vbo_t **vbochain, batch_t *firstbatch, batch_t *stopba
void D3D11BE_GenBrushModelVBO(model_t *mod)
{
unsigned int vcount;
unsigned int vcount, cvcount;
batch_t *batch, *fbatch;
@ -2621,16 +2621,17 @@ void D3D11BE_GenBrushModelVBO(model_t *mod)
for (fbatch = batch = mod->batches[sortid]; batch != NULL; batch = batch->next)
{
for (i = 0, cvcount = 0; i < batch->maxmeshes; i++)
cvcount += batch->mesh[i]->numvertexes;
//firstmesh got reused as the number of verticies in each batch
if (vcount + batch->firstmesh > MAX_INDICIES)
if (vcount + cvcount > MAX_INDICIES)
{
D3D11BE_GenBatchVBOs(&mod->vbos, fbatch, batch);
fbatch = batch;
vcount = 0;
}
for (i = 0; i < batch->maxmeshes; i++)
vcount += batch->mesh[i]->numvertexes;
vcount += cvcount;
}
D3D11BE_GenBatchVBOs(&mod->vbos, fbatch, batch);

View file

@ -226,8 +226,8 @@ typedef struct
byte_vec4_t colorsb;
} vbovdata_t;
#define DYNVBUFFSIZE 65536
#define DYNIBUFFSIZE 65536
#define DYNVBUFFSIZE 65536*8
#define DYNIBUFFSIZE 65536*24
static d3dbackend_t shaderstate;
@ -698,7 +698,7 @@ static unsigned int allocindexbuffer(void **dest, unsigned int entries)
unsigned int bytes = entries*sizeof(index_t);
unsigned int offset;
if (shaderstate.dynidx_offs + bytes > DYNIBUFFSIZE)
if (shaderstate.dynidx_offs + bytes > shaderstate.dynidx_size)
{
offset = 0;
shaderstate.dynidx_offs = 0;
@ -2487,6 +2487,9 @@ static void D3D9BE_GenBatchVBOs(vbo_t **vbochain, batch_t *firstbatch, batch_t *
maxvboverts += m->numvertexes;
}
}
if (maxvboverts > MAX_INDICIES)
Sys_Error("Building a vbo with too many verticies\n");
IDirect3DDevice9_CreateIndexBuffer(pD3DDev9, sizeof(index_t) * maxvboelements, 0, D3DFMT_QINDEX, D3DPOOL_MANAGED, &ebuff, NULL);
IDirect3DDevice9_CreateVertexBuffer(pD3DDev9, sizeof(*vbovdata) * maxvboverts, D3DUSAGE_WRITEONLY, 0, D3DPOOL_MANAGED, &vbuff, NULL);
@ -2556,7 +2559,7 @@ static void D3D9BE_GenBatchVBOs(vbo_t **vbochain, batch_t *firstbatch, batch_t *
void D3D9BE_GenBrushModelVBO(model_t *mod)
{
unsigned int vcount;
unsigned int vcount, cvcount;
batch_t *batch, *fbatch;
@ -2572,16 +2575,18 @@ void D3D9BE_GenBrushModelVBO(model_t *mod)
for (fbatch = batch = mod->batches[sortid]; batch != NULL; batch = batch->next)
{
for (i = 0, cvcount = 0; i < batch->maxmeshes; i++)
cvcount += batch->mesh[i]->numvertexes;
//firstmesh got reused as the number of verticies in each batch
if (vcount + batch->firstmesh > MAX_INDICIES)
if (vcount + cvcount > MAX_INDICIES)
{
D3D9BE_GenBatchVBOs(&mod->vbos, fbatch, batch);
fbatch = batch;
vcount = 0;
}
for (i = 0; i < batch->maxmeshes; i++)
vcount += batch->mesh[i]->numvertexes;
vcount += cvcount;
}
D3D9BE_GenBatchVBOs(&mod->vbos, fbatch, batch);

View file

@ -153,7 +153,7 @@ static void Mod_BatchList_f(void)
if (batch->lmlightstyle[0] != 255)
Con_Printf(" %s lm=(%i:%i) surfs=%u\n", batch->texture->shader->name, batch->lightmap[0], batch->lmlightstyle[0], batch->maxmeshes);
else
Con_Printf(" %s lm=%i surfs=%u\n", batch->texture->shader->name, batch->lightmap[0], batch->maxmeshes);
Con_Printf(" %s lm=%i surfs=%u verts=%i indexes=%i\n", batch->texture->shader->name, batch->lightmap[0], batch->maxmeshes, batch->vbo->vertcount, batch->vbo->indexcount);
count++;
}
}
@ -2662,13 +2662,13 @@ static int Mod_Batches_Generate(model_t *mod)
lbatch->shader == shader &&
lbatch->lightmap[0] == lmmerge(surf->lightmaptexturenums[0]) &&
Vector4Compare(plane, lbatch->plane) &&
lbatch->firstmesh + surf->mesh->numvertexes <= MAX_INDICIES) &&
lbatch->firstmesh + surf->mesh->numvertexes <= MAX_INDICIES &&
#if MAXRLIGHTMAPS > 1
lbatch->lightmap[1] == lmmerge(surf->lightmaptexturenums[1]) &&
lbatch->lightmap[2] == lmmerge(surf->lightmaptexturenums[2]) &&
lbatch->lightmap[3] == lmmerge(surf->lightmaptexturenums[3]) &&
#endif
lbatch->fog == surf->fog)
lbatch->fog == surf->fog))
batch = lbatch;
else
{

View file

@ -1588,6 +1588,8 @@ void QCC_PR_LexString (void)
c = '\n';
else if (c == 'r')
c = '\r';
else if (c == '#') //avoid preqcc expansion in strings.
c = '#';
else if (c == '"')
c = '"';
else if (c == 't')