Skip to content

Commit

Permalink
Made dynlight indices unsigned for faster iteration and to increase f…
Browse files Browse the repository at this point in the history
…ixed limits.

Re-instated numerous internal profilers activated when #ifdef DD_PROFILE.
Various other minor tweaks to improve readability of some tight loops and to remove unnecessary break/continues.
Further cleanup.
  • Loading branch information
danij committed Nov 1, 2006
1 parent c507725 commit 5fdbdac
Show file tree
Hide file tree
Showing 16 changed files with 464 additions and 286 deletions.
3 changes: 3 additions & 0 deletions doomsday/engine/api/dd_maptypes.h
Expand Up @@ -90,4 +90,7 @@
#define DMT_NODE_DX DDVT_FIXED // Partition line.
#define DMT_NODE_DY DDVT_FIXED // Partition line.

#define DMT_NODE_BBOX DDVT_FIXED
#define DMT_NODE_CHILDREN DDVT_UINT

#endif
2 changes: 1 addition & 1 deletion doomsday/engine/api/dd_share.h
Expand Up @@ -913,7 +913,7 @@ extern "C" {
short visangle; /* visual angle ("angle-servo") */ \
int selector; /* multipurpose info */ \
int validcount; /* used in iterating */ \
int light; /* index+1 of the lumobj/bias source, or 0 */ \
unsigned int light; /* index+1 of the lumobj/bias source, or 0 */ \
boolean usingBias; /* if true, "light" is the bias source index+1 */ \
byte halofactor; /* strength of halo */ \
byte translucency; /* default = 0 = opaque */ \
Expand Down
41 changes: 19 additions & 22 deletions doomsday/engine/portable/include/m_profiler.h
Expand Up @@ -4,6 +4,7 @@
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2006 Jaakko Keränen <skyjake@dengine.net>
*\author Copyright © 2005-2006 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -17,7 +18,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

Expand All @@ -28,39 +29,35 @@
#ifndef __DOOMSDAY_MISC_PROFILER_H__
#define __DOOMSDAY_MISC_PROFILER_H__

#if 0 // Disabled

#include "dd_types.h"
#include "sys_timer.h"

/*
* This header defines some handy macros for profiling.
* This header defines some handy macros for profiling.
* Define DD_PROFILE to active.
*/

typedef struct profiler_s {
uint totalTime;
uint startTime;
uint startCount;
uint totalTime;
uint startTime;
uint startCount;
} profiler_t;

#define BEGIN_PROF_TIMERS() enum {

#ifdef DD_PROFILE // Profiling is enabled.
# define END_PROF_TIMERS() ,NUM_PROFS }; static profiler_t profiler_[NUM_PROFS];
# define BEGIN_PROF(x) (profiler_[x].startCount++, profiler_[x].startTime = Sys_GetRealTime())
# define END_PROF(x) (profiler_[x].totalTime += Sys_GetRealTime() - profiler_[x].startTime)
# define PRINT_PROF(x) Con_Message(#x ": %i ms (%i starts) [%f ms]\n", \
profiler_[x].totalTime, profiler_[x].startCount, \
profiler_[x].startCount? profiler_[x].totalTime / \
(float) profiler_[x].startCount : 0)
#else // Profiling is disabled.
# define END_PROF_TIMERS() ,NUM_PROFS };
#define BEGIN_PROF_TIMERS() enum {

#ifdef DD_PROFILE // Profiling is enabled.
# define END_PROF_TIMERS() ,NUM_PROFS }; static profiler_t profiler_[NUM_PROFS];
# define BEGIN_PROF(x) (profiler_[x].startCount++, profiler_[x].startTime = Sys_GetRealTime())
# define END_PROF(x) (profiler_[x].totalTime += Sys_GetRealTime() - profiler_[x].startTime)
# define PRINT_PROF(x) Con_Message(#x ": %i ms (%i starts) [%f ms]\n", \
profiler_[x].totalTime, profiler_[x].startCount, \
profiler_[x].startCount? profiler_[x].totalTime / \
(float) profiler_[x].startCount : 0)
#else // Profiling is disabled.
# define END_PROF_TIMERS() ,NUM_PROFS };
# define BEGIN_PROF(x)
# define END_PROF(x)
# define PRINT_PROF(x)
#endif // DD_PROFILE

#endif
#endif // DD_PROFILE

#endif
5 changes: 5 additions & 0 deletions doomsday/engine/portable/include/mapdata.hs
Expand Up @@ -176,3 +176,8 @@ struct node
- fixed_t[2][4] bbox // Bounding box for each child.
- uint[2] children // If NF_SUBSECTOR it's a subsector.
end

public
#define DMT_NODE_BBOX DDVT_FIXED
#define DMT_NODE_CHILDREN DDVT_UINT
end
10 changes: 6 additions & 4 deletions doomsday/engine/portable/include/r_data.h
Expand Up @@ -164,12 +164,14 @@ typedef struct {
float dist; // Distance to the vertex.
} rendpoly_vertex_t;

typedef struct walldiv_s {
unsigned int num;
float pos[RL_MAX_DIVS];
} walldiv_t;

typedef struct rendpoly_wall_s {
float length;
struct div_t {
byte num;
float pos[RL_MAX_DIVS];
} divs[2]; // For wall segments (two vertices).
walldiv_t divs[2]; // For wall segments (two vertices).
} rendpoly_wall_t;

// rendpoly_t is only for convenience; the data written in the rendering
Expand Down
29 changes: 13 additions & 16 deletions doomsday/engine/portable/include/rend_dyn.h
Expand Up @@ -4,6 +4,7 @@
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2006 Jaakko Keränen <skyjake@dengine.net>
*\author Copyright © 2006 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -46,6 +47,7 @@ typedef struct lumobj_s // For dynamic lighting.
{
struct lumobj_s *next; // Next in the same DL block, or NULL.
struct lumobj_s *ssNext; // Next in the same subsector, or NULL.

int flags;
mobj_t *thing;
float center; // Offset to center from mobj Z.
Expand All @@ -69,6 +71,7 @@ typedef struct lumobj_s // For dynamic lighting.
*/
typedef struct dynlight_s {
struct dynlight_s *next, *nextUsed;

int flags;
float s[2], t[2];
byte color[3];
Expand All @@ -79,10 +82,8 @@ typedef struct dynlight_s {
#define DYNF_PREGEN_DECOR 0x1 // Pregen RGB lightmap for a light decoration.

extern boolean dlInited;
extern lumobj_t *luminousList;
extern int numLuminous;
extern int useDynLights;
extern int maxDynLights, dlBlend, dlMaxRad;
extern int dlBlend, dlMaxRad;
extern float dlRadFactor, dlFactor;
extern int useWallGlow, glowHeightMax;
extern float glowHeightFactor;
Expand All @@ -94,27 +95,23 @@ extern int dlMinRadForBias;
void DL_Register(void);

// Setup.
void DL_InitLinks();
void DL_Clear(); // 'Physically' destroy the tables.
void DL_InitForMap(void);
void DL_Clear(void); // 'Physically' destroy the tables.

// Action.
void DL_ClearForFrame();
void DL_InitForNewFrame();
int DL_NewLuminous(void);
lumobj_t *DL_GetLuminous(int index);
void DL_ClearForFrame(void);
void DL_InitForNewFrame(void);
unsigned int DL_NewLuminous(void);
lumobj_t* DL_GetLuminous(unsigned int index);
unsigned int DL_GetNumLuminous(void);
void DL_ProcessSubsector(subsector_t *ssec);
dynlight_t *DL_GetSegLightLinks(int seg, int whichpart);
dynlight_t *DL_GetSubSecLightLinks(int ssec, int plane);
dynlight_t* DL_GetSegSectionLightLinks(int segidx, int section);
dynlight_t* DL_GetSubSecPlaneLightLinks(int ssecidx, int plane);

// Helpers.
boolean DL_RadiusIterator(subsector_t *subsector, fixed_t x, fixed_t y,
fixed_t radius, void *data,
boolean (*func) (lumobj_t *, fixed_t, void *data));
boolean DL_BoxIterator(fixed_t box[4], void *ptr,
boolean (*func) (lumobj_t *, void *));

int Rend_SubsectorClipper(fvertex_t * out, subsector_t *sub,
float x, float y, float radius);

void DL_ClipInSubsector(int ssecidx);
void DL_ClipBySight(int ssecidx);
Expand Down
3 changes: 2 additions & 1 deletion doomsday/engine/portable/include/rend_fakeradio.h
Expand Up @@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

Expand All @@ -29,6 +29,7 @@
#define __DOOMSDAY_RENDER_FAKERADIO_H__

void Rend_RadioRegister(void);
void Rend_RadioInitForFrame(void);
void Rend_RadioInitForSector(sector_t *sector);
void Rend_RadioWallSection(const seg_t *seg, rendpoly_t *origQuad);
void Rend_RadioSubsectorEdges(subsector_t *subsector);
Expand Down
46 changes: 23 additions & 23 deletions doomsday/engine/portable/src/cl_world.c
Expand Up @@ -81,7 +81,7 @@ short *xlat_lump;

// CODE --------------------------------------------------------------------

/*
/**
* Allocates and inits the lump translation array. Clients use this
* to make sure lump (e.g. flats) references are correct (in case the
* server and the client are using different WAD configurations and
Expand All @@ -96,7 +96,7 @@ void Cl_InitTranslations(void)

xlat_lump = Z_Malloc(sizeof(short) * MAX_TRANSLATIONS, PU_REFRESHTEX, 0);
memset(xlat_lump, 0, sizeof(short) * MAX_TRANSLATIONS);
for(i = 0; i < numlumps; i++)
for(i = 0; i < numlumps; ++i)
xlat_lump[i] = i; // Identity translation.
}

Expand All @@ -113,7 +113,7 @@ void Cl_SetLumpTranslation(short lumpnum, char *name)
}
}

/*
/**
* This is a fail-safe operation.
*/
short Cl_TranslateLump(short lump)
Expand All @@ -123,7 +123,7 @@ short Cl_TranslateLump(short lump)
return xlat_lump[lump];
}

/*
/**
* Clears the arrays that track active plane and polyobj mover thinkers.
*/
void Cl_InitMovers(void)
Expand All @@ -132,11 +132,11 @@ void Cl_InitMovers(void)
memset(activepolys, 0, sizeof(activepolys));
}

void Cl_RemoveActiveMover(mover_t * mover)
void Cl_RemoveActiveMover(mover_t *mover)
{
int i;

for(i = 0; i < MAX_MOVERS; i++)
for(i = 0; i < MAX_MOVERS; ++i)
if(activemovers[i] == mover)
{
P_RemoveThinker(&mover->thinker);
Expand All @@ -145,14 +145,14 @@ void Cl_RemoveActiveMover(mover_t * mover)
}
}

/*
/**
* Removes the given polymover from the active polys array.
*/
void Cl_RemoveActivePoly(polymover_t * mover)
void Cl_RemoveActivePoly(polymover_t *mover)
{
int i;

for(i = 0; i < MAX_MOVERS; i++)
for(i = 0; i < MAX_MOVERS; ++i)
if(activepolys[i] == mover)
{
P_RemoveThinker(&mover->thinker);
Expand All @@ -161,10 +161,10 @@ void Cl_RemoveActivePoly(polymover_t * mover)
}
}

/*
/**
* Plane mover.
*/
void Cl_MoverThinker(mover_t * mover)
void Cl_MoverThinker(mover_t *mover)
{
fixed_t *current = mover->current, original = *current;
boolean remove = false;
Expand Down Expand Up @@ -224,7 +224,7 @@ void Cl_AddMover(int sectornum, clmovertype_t type, fixed_t dest, fixed_t speed)
sector = SECTOR_PTR(sectornum);

// Remove any existing movers for the same plane.
for(i = 0; i < MAX_MOVERS; i++)
for(i = 0; i < MAX_MOVERS; ++i)
if(activemovers[i] && activemovers[i]->sector == sector &&
activemovers[i]->type == type)
{
Expand All @@ -242,7 +242,7 @@ void Cl_AddMover(int sectornum, clmovertype_t type, fixed_t dest, fixed_t speed)
} */

// Add a new mover.
for(i = 0; i < MAX_MOVERS; i++)
for(i = 0; i < MAX_MOVERS; ++i)
if(activemovers[i] == NULL)
{
// Allocate a new mover_t thinker.
Expand All @@ -267,7 +267,7 @@ void Cl_AddMover(int sectornum, clmovertype_t type, fixed_t dest, fixed_t speed)
}
}

void Cl_PolyMoverThinker(polymover_t * mover)
void Cl_PolyMoverThinker(polymover_t *mover)
{
polyobj_t *poly = mover->poly;
int dx, dy, dist;
Expand Down Expand Up @@ -320,7 +320,7 @@ polymover_t *Cl_FindActivePoly(int number)
{
int i;

for(i = 0; i < MAX_MOVERS; i++)
for(i = 0; i < MAX_MOVERS; ++i)
if(activepolys[i] && activepolys[i]->number == number)
return activepolys[i];
return NULL;
Expand Down Expand Up @@ -355,14 +355,14 @@ void Cl_SetPolyMover(int number, int move, int rotate)
mover->rotate = true;
}

/*
/**
* Removes all the active movers.
*/
void Cl_RemoveMovers(void)
{
int i;

for(i = 0; i < MAX_MOVERS; i++)
for(i = 0; i < MAX_MOVERS; ++i)
{
if(activemovers[i])
{
Expand All @@ -381,7 +381,7 @@ mover_t *Cl_GetActiveMover(int sectornum, clmovertype_t type)
{
int i;

for(i = 0; i < MAX_MOVERS; i++)
for(i = 0; i < MAX_MOVERS; ++i)
if(activemovers[i] && activemovers[i]->sectornum == sectornum &&
activemovers[i]->type == type)
{
Expand All @@ -390,8 +390,8 @@ mover_t *Cl_GetActiveMover(int sectornum, clmovertype_t type)
return NULL;
}

/*
* Returns false iff the end marker is found (lump index zero).
/**
* Returns false if the end marker is found (lump index zero).
*/
int Cl_ReadLumpDelta(void)
{
Expand All @@ -412,7 +412,7 @@ int Cl_ReadLumpDelta(void)
return true;
}

/*
/**
* Reads a sector delta from the PSV_FRAME2 message buffer and applies it
* to the world.
*/
Expand Down Expand Up @@ -616,7 +616,7 @@ void Cl_ReadSectorDelta2(int deltaType, boolean skip)
}
}

/*
/**
* Reads a side delta from the message buffer and applies it to the world.
*/
void Cl_ReadSideDelta2(int deltaType, boolean skip)
Expand Down Expand Up @@ -757,7 +757,7 @@ void Cl_ReadSideDelta2(int deltaType, boolean skip)
}
}

/*
/**
* Reads a poly delta from the message buffer and applies it to
* the world.
*/
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/r_main.c
Expand Up @@ -672,7 +672,7 @@ void R_RenderPlayerView(ddplayer_t *player)
}
if(rendInfoLums)
{
Con_Printf("LumObjs: %-4i\n", numLuminous);
Con_Printf("LumObjs: %-4i\n", DL_GetNumLuminous());
}

R_InfoRendPolys();
Expand Down

0 comments on commit 5fdbdac

Please sign in to comment.