- remove the GLWallLightEntry type. Everything it contains can be retrieved from the existing lightlist just as easily, and this approach avoids a lot of memory allocations.

- removed the SplitWall profiling timer because all it measures now is an almost empty function.
This commit is contained in:
Christoph Oelckers 2016-02-01 01:03:34 +01:00
parent 71da7406bd
commit 9305cd86a0
7 changed files with 20 additions and 44 deletions

View file

@ -413,7 +413,6 @@ static void InitVertexData()
TArray<int> * vt_sectorlists; TArray<int> * vt_sectorlists;
int i,j,k; int i,j,k;
unsigned int l;
vt_sectorlists = new TArray<int>[numvertexes]; vt_sectorlists = new TArray<int>[numvertexes];

View file

@ -838,7 +838,6 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
angle_t a1 = FrustumAngle(); angle_t a1 = FrustumAngle();
clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1); clipper.SafeAddClipRangeRealAngles(viewangle + a1, viewangle - a1);
GLWallLightEntryArena.FreeAll();
ProcessScene(toscreen); ProcessScene(toscreen);
if (mainview) EndDrawScene(retval); // do not call this for camera textures. if (mainview) EndDrawScene(retval); // do not call this for camera textures.
eye->TearDown(); eye->TearDown();

View file

@ -85,16 +85,6 @@ struct GLSectorPlane
}; };
struct GLWallLightEntry
{
secplane_t *cliptop;
secplane_t *clipbottom;
int lightlevel;
FColormap colormap;
};
extern FMemArena GLWallLightEntryArena;
class GLWall class GLWall
{ {
public: public:
@ -134,8 +124,7 @@ public:
fixed_t viewdistance; fixed_t viewdistance;
GLWallLightEntry *lights; TArray<lightlist_t> *lightlist;
unsigned int lightsize;
int lightlevel; int lightlevel;
BYTE type; BYTE type;
BYTE flags; BYTE flags;

View file

@ -62,8 +62,6 @@
#include "gl/shaders/gl_shader.h" #include "gl/shaders/gl_shader.h"
FMemArena GLWallLightEntryArena;
//========================================================================== //==========================================================================
// //
// Checks whether a wall should glow // Checks whether a wall should glow
@ -228,28 +226,14 @@ void GLWall::PutWall(bool translucent)
void GLWall::SplitWall(sector_t * frontsector, bool translucent) void GLWall::SplitWall(sector_t * frontsector, bool translucent)
{ {
TArray<lightlist_t> & lightlist=frontsector->e->XFloor.lightlist;
if (glseg.x1==glseg.x2 && glseg.y1==glseg.y2) if (glseg.x1==glseg.x2 && glseg.y1==glseg.y2)
{ {
return; return;
} }
::SplitWall.Clock(); lightlist=&frontsector->e->XFloor.lightlist;
lightsize = lightlist.Size();
lights = (GLWallLightEntry*)GLWallLightEntryArena.Alloc(sizeof(GLWallLightEntry)*lightsize);
secplane_t *upperplane = &topplane;
for (unsigned i = 0; i < lightlist.Size(); i++)
{
lights[i].cliptop = &lightlist[i].plane;
lights[i].clipbottom = i == lightlist.Size() - 1 ? (secplane_t*)NULL : &lightlist[i + 1].plane;
lights[i].lightlevel = lightlist[i].caster != NULL? gl_ClampLight(*lightlist[i].p_lightlevel) : lightlevel;
lights[i].colormap.FadeColor = Colormap.FadeColor;
lights[i].colormap.CopyFrom3DLight(&lightlist[i]);
}
PutWall(translucent); PutWall(translucent);
lights = NULL; lightlist = NULL;
lightsize = 0;
} }
@ -1296,7 +1280,7 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector)
Colormap = frontsector->ColorMap; Colormap = frontsector->ColorMap;
flags = 0; flags = 0;
dynlightindex = UINT_MAX; dynlightindex = UINT_MAX;
lights = NULL; lightlist = NULL;
int rel = 0; int rel = 0;
int orglightlevel = gl_ClampLight(frontsector->lightlevel); int orglightlevel = gl_ClampLight(frontsector->lightlevel);

View file

@ -330,7 +330,7 @@ void GLWall::RenderTextured(int rflags)
} }
float absalpha = fabsf(alpha); float absalpha = fabsf(alpha);
if (lights == NULL) if (lightlist == NULL)
{ {
gl_SetColor(lightlevel, rel, Colormap, absalpha); gl_SetColor(lightlevel, rel, Colormap, absalpha);
if (type != RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, RenderStyle == STYLE_Add); if (type != RENDERWALL_M2SNF) gl_SetFog(lightlevel, rel, &Colormap, RenderStyle == STYLE_Add);
@ -341,13 +341,19 @@ void GLWall::RenderTextured(int rflags)
gl_RenderState.EnableSplit(true); gl_RenderState.EnableSplit(true);
glEnable(GL_CLIP_DISTANCE3); glEnable(GL_CLIP_DISTANCE3);
glEnable(GL_CLIP_DISTANCE4); glEnable(GL_CLIP_DISTANCE4);
for (unsigned i = 0; i <lightsize; i++)
for (unsigned i = 0; i < lightlist->Size(); i++)
{ {
gl_SetColor(lights[i].lightlevel, rel, lights[i].colormap, absalpha); int thisll = (*lightlist)[i].caster != NULL? gl_ClampLight(*(*lightlist)[i].p_lightlevel) : lightlevel;
if (type != RENDERWALL_M2SNF) gl_SetFog(lights[i].lightlevel, rel, &lights[i].colormap, RenderStyle == STYLE_Add); FColormap thiscm;
gl_RenderState.SetSplitPlanes(*lights[i].cliptop, lights[i].clipbottom? *lights[i].clipbottom : bottomplane); thiscm.FadeColor = Colormap.FadeColor;
thiscm.CopyFrom3DLight(&(*lightlist)[i]);
gl_SetColor(thisll, rel, thiscm, absalpha);
if (type != RENDERWALL_M2SNF) gl_SetFog(thisll, rel, &thiscm, RenderStyle == STYLE_Add);
gl_RenderState.SetSplitPlanes((*lightlist)[i].plane, i == (*lightlist).Size() - 1 ? bottomplane : (*lightlist)[i + 1].plane);
RenderWall(rflags); RenderWall(rflags);
} }
glDisable(GL_CLIP_DISTANCE3); glDisable(GL_CLIP_DISTANCE3);
glDisable(GL_CLIP_DISTANCE4); glDisable(GL_CLIP_DISTANCE4);
gl_RenderState.EnableSplit(false); gl_RenderState.EnableSplit(false);

View file

@ -16,7 +16,7 @@
#include "gl/utility/gl_convert.h" #include "gl/utility/gl_convert.h"
glcycle_t RenderWall,SetupWall,ClipWall,SplitWall; glcycle_t RenderWall,SetupWall,ClipWall;
glcycle_t RenderFlat,SetupFlat; glcycle_t RenderFlat,SetupFlat;
glcycle_t RenderSprite,SetupSprite; glcycle_t RenderSprite,SetupSprite;
glcycle_t All, Finish, PortalAll, Bsp; glcycle_t All, Finish, PortalAll, Bsp;
@ -91,7 +91,6 @@ void ResetProfilingData()
ProcessAll.Reset(); ProcessAll.Reset();
RenderWall.Reset(); RenderWall.Reset();
SetupWall.Reset(); SetupWall.Reset();
SplitWall.Reset();
ClipWall.Reset(); ClipWall.Reset();
RenderFlat.Reset(); RenderFlat.Reset();
SetupFlat.Reset(); SetupFlat.Reset();
@ -111,15 +110,15 @@ void ResetProfilingData()
static void AppendRenderTimes(FString &str) static void AppendRenderTimes(FString &str)
{ {
double setupwall = SetupWall.TimeMS() - SplitWall.TimeMS(); double setupwall = SetupWall.TimeMS();
double clipwall = ClipWall.TimeMS() - SetupWall.TimeMS(); double clipwall = ClipWall.TimeMS() - SetupWall.TimeMS();
double bsp = Bsp.TimeMS() - ClipWall.TimeMS() - SetupFlat.TimeMS() - SetupSprite.TimeMS(); double bsp = Bsp.TimeMS() - ClipWall.TimeMS() - SetupFlat.TimeMS() - SetupSprite.TimeMS();
str.AppendFormat("W: Render=%2.3f, Split = %2.3f, Setup=%2.3f, Clip=%2.3f\n" str.AppendFormat("W: Render=%2.3f, Setup=%2.3f, Clip=%2.3f\n"
"F: Render=%2.3f, Setup=%2.3f\n" "F: Render=%2.3f, Setup=%2.3f\n"
"S: Render=%2.3f, Setup=%2.3f\n" "S: Render=%2.3f, Setup=%2.3f\n"
"All=%2.3f, Render=%2.3f, Setup=%2.3f, BSP = %2.3f, Portal=%2.3f, Drawcalls=%2.3f, Finish=%2.3f\n", "All=%2.3f, Render=%2.3f, Setup=%2.3f, BSP = %2.3f, Portal=%2.3f, Drawcalls=%2.3f, Finish=%2.3f\n",
RenderWall.TimeMS(), SplitWall.TimeMS(), setupwall, clipwall, RenderFlat.TimeMS(), SetupFlat.TimeMS(), RenderWall.TimeMS(), setupwall, clipwall, RenderFlat.TimeMS(), SetupFlat.TimeMS(),
RenderSprite.TimeMS(), SetupSprite.TimeMS(), All.TimeMS() + Finish.TimeMS(), RenderAll.TimeMS(), RenderSprite.TimeMS(), SetupSprite.TimeMS(), All.TimeMS() + Finish.TimeMS(), RenderAll.TimeMS(),
ProcessAll.TimeMS(), bsp, PortalAll.TimeMS(), drawcalls.TimeMS(), Finish.TimeMS()); ProcessAll.TimeMS(), bsp, PortalAll.TimeMS(), drawcalls.TimeMS(), Finish.TimeMS());
} }

View file

@ -102,7 +102,7 @@ private:
#endif // __APPLE__ #endif // __APPLE__
extern glcycle_t RenderWall,SetupWall,ClipWall,SplitWall; extern glcycle_t RenderWall,SetupWall,ClipWall;
extern glcycle_t RenderFlat,SetupFlat; extern glcycle_t RenderFlat,SetupFlat;
extern glcycle_t RenderSprite,SetupSprite; extern glcycle_t RenderSprite,SetupSprite;
extern glcycle_t All, Finish, PortalAll, Bsp; extern glcycle_t All, Finish, PortalAll, Bsp;