mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-13 00:24:44 +00:00
add auto reallocate
This commit is contained in:
parent
25cb7acda8
commit
e1a9e7e4e2
3 changed files with 32 additions and 21 deletions
2
Makefile
2
Makefile
|
@ -173,7 +173,7 @@ CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
|
||||||
-Wall -pipe -g -fwrapv
|
-Wall -pipe -g -fwrapv
|
||||||
CFLAGS += $(OSX_ARCH)
|
CFLAGS += $(OSX_ARCH)
|
||||||
else
|
else
|
||||||
CFLAGS := -std=gnu99 -fno-strict-aliasing \
|
CFLAGS := -std=gnu99 -O2 -fno-strict-aliasing \
|
||||||
-Wall -pipe -g -ggdb -MMD -fwrapv
|
-Wall -pipe -g -ggdb -MMD -fwrapv
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -158,10 +158,6 @@ extern oldrefdef_t r_refdef;
|
||||||
|
|
||||||
#define DS_SPAN_LIST_END -128
|
#define DS_SPAN_LIST_END -128
|
||||||
|
|
||||||
#define NUMSTACKEDGES 3072
|
|
||||||
#define NUMSTACKSURFACES 2048
|
|
||||||
#define MAXALIASVERTS 2048 // TODO: tune this
|
|
||||||
|
|
||||||
// flags in finalvert_t.flags
|
// flags in finalvert_t.flags
|
||||||
#define ALIAS_LEFT_CLIP 0x0001
|
#define ALIAS_LEFT_CLIP 0x0001
|
||||||
#define ALIAS_TOP_CLIP 0x0002
|
#define ALIAS_TOP_CLIP 0x0002
|
||||||
|
@ -569,7 +565,6 @@ extern void *colormap;
|
||||||
//====================================================================
|
//====================================================================
|
||||||
|
|
||||||
void R_NewMap (void);
|
void R_NewMap (void);
|
||||||
void R_ReallocateMapBuffers (void);
|
|
||||||
void Draw_InitLocal(void);
|
void Draw_InitLocal(void);
|
||||||
void R_InitCaches(void);
|
void R_InitCaches(void);
|
||||||
void D_FlushCaches(void);
|
void D_FlushCaches(void);
|
||||||
|
|
|
@ -31,6 +31,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "header/local.h"
|
#include "header/local.h"
|
||||||
|
|
||||||
|
#define NUMSTACKEDGES 2048
|
||||||
|
#define NUMSTACKSURFACES 1024
|
||||||
|
#define MAXALIASVERTS 2048
|
||||||
|
|
||||||
viddef_t vid;
|
viddef_t vid;
|
||||||
pixel_t *vid_buffer = NULL;
|
pixel_t *vid_buffer = NULL;
|
||||||
espan_t *vid_polygon_spans = NULL;
|
espan_t *vid_polygon_spans = NULL;
|
||||||
|
@ -403,24 +407,30 @@ void R_NewMap (void)
|
||||||
r_viewcluster = -1;
|
r_viewcluster = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
surf_t *lsurfs;
|
static surf_t *lsurfs;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
R_ReallocateMapBuffers
|
R_ReallocateMapBuffers
|
||||||
===============
|
===============
|
||||||
*/
|
*/
|
||||||
void
|
static void
|
||||||
R_ReallocateMapBuffers (void)
|
R_ReallocateMapBuffers (void)
|
||||||
{
|
{
|
||||||
if (!r_cnumsurfs)
|
if (!r_cnumsurfs || r_outofsurfaces)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(lsurfs)
|
if(lsurfs)
|
||||||
{
|
{
|
||||||
free(lsurfs);
|
free(lsurfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r_outofsurfaces)
|
||||||
|
{
|
||||||
|
R_Printf(PRINT_ALL, "%s: not enough %d(+%d) surfaces\n",
|
||||||
|
__func__, r_cnumsurfs, r_outofsurfaces);
|
||||||
|
r_cnumsurfs *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (r_cnumsurfs < NUMSTACKSURFACES)
|
if (r_cnumsurfs < NUMSTACKSURFACES)
|
||||||
r_cnumsurfs = NUMSTACKSURFACES;
|
r_cnumsurfs = NUMSTACKSURFACES;
|
||||||
|
|
||||||
|
@ -446,13 +456,20 @@ R_ReallocateMapBuffers (void)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!r_numallocatededges)
|
if (!r_numallocatededges || r_outofedges)
|
||||||
{
|
{
|
||||||
if (!r_edges)
|
if (!r_edges)
|
||||||
{
|
{
|
||||||
free(r_edges);
|
free(r_edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r_outofedges)
|
||||||
|
{
|
||||||
|
R_Printf(PRINT_ALL, "%s: not enough %d(+%d) edges\n",
|
||||||
|
__func__, r_numallocatededges, r_outofedges * 2 / 3);
|
||||||
|
r_numallocatededges *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (r_numallocatededges < NUMSTACKEDGES)
|
if (r_numallocatededges < NUMSTACKEDGES)
|
||||||
r_numallocatededges = NUMSTACKEDGES;
|
r_numallocatededges = NUMSTACKEDGES;
|
||||||
|
|
||||||
|
@ -471,13 +488,20 @@ R_ReallocateMapBuffers (void)
|
||||||
__func__, r_numallocatededges);
|
__func__, r_numallocatededges);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!r_numallocatedverts)
|
if (!r_numallocatedverts || r_outofverts)
|
||||||
{
|
{
|
||||||
if (finalverts)
|
if (finalverts)
|
||||||
{
|
{
|
||||||
free(finalverts);
|
free(finalverts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r_outofverts)
|
||||||
|
{
|
||||||
|
R_Printf(PRINT_ALL, "%s: not enough %d(+%d) finalverts\n",
|
||||||
|
__func__, r_numallocatedverts, r_outofverts);
|
||||||
|
r_numallocatedverts *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (r_numallocatedverts < MAXALIASVERTS)
|
if (r_numallocatedverts < MAXALIASVERTS)
|
||||||
r_numallocatedverts = MAXALIASVERTS;
|
r_numallocatedverts = MAXALIASVERTS;
|
||||||
|
|
||||||
|
@ -1118,19 +1142,11 @@ RE_RenderFrame (refdef_t *fd)
|
||||||
|
|
||||||
if (sw_reportsurfout->value && r_outofsurfaces)
|
if (sw_reportsurfout->value && r_outofsurfaces)
|
||||||
R_Printf(PRINT_ALL,"Short %d surfaces\n", r_outofsurfaces);
|
R_Printf(PRINT_ALL,"Short %d surfaces\n", r_outofsurfaces);
|
||||||
else if (r_outofsurfaces)
|
|
||||||
R_Printf(PRINT_ALL, "%s: not enough %d(+%d) surfaces\n",
|
|
||||||
__func__, r_cnumsurfs, r_outofsurfaces);
|
|
||||||
|
|
||||||
if (sw_reportedgeout->value && r_outofedges)
|
if (sw_reportedgeout->value && r_outofedges)
|
||||||
R_Printf(PRINT_ALL,"Short roughly %d edges\n", r_outofedges * 2 / 3);
|
R_Printf(PRINT_ALL,"Short roughly %d edges\n", r_outofedges * 2 / 3);
|
||||||
else if (r_outofedges)
|
|
||||||
R_Printf(PRINT_ALL, "%s: not enough %d(+%d) edges\n",
|
|
||||||
__func__, r_numallocatededges, r_outofedges * 2 / 3);
|
|
||||||
|
|
||||||
if (r_outofverts)
|
R_ReallocateMapBuffers();
|
||||||
R_Printf(PRINT_ALL, "%s: not enough %d(+%d) finalverts\n",
|
|
||||||
__func__, r_numallocatedverts, r_outofverts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue