mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 07:34:50 +00:00
Move openings to r_memory
This commit is contained in:
parent
74e1955afa
commit
60c0dcc3c7
10 changed files with 67 additions and 38 deletions
|
@ -808,6 +808,7 @@ set( NOT_COMPILED_SOURCE_FILES
|
|||
set( FASTMATH_PCH_SOURCES
|
||||
swrenderer/r_swrenderer.cpp
|
||||
swrenderer/r_main.cpp
|
||||
swrenderer/r_memory.cpp
|
||||
swrenderer/drawers/r_draw.cpp
|
||||
swrenderer/drawers/r_draw_pal.cpp
|
||||
swrenderer/drawers/r_draw_rgba.cpp
|
||||
|
|
52
src/swrenderer/r_memory.cpp
Normal file
52
src/swrenderer/r_memory.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "templates.h"
|
||||
#include "doomdef.h"
|
||||
#include "m_bbox.h"
|
||||
#include "i_system.h"
|
||||
#include "p_lnspec.h"
|
||||
#include "p_setup.h"
|
||||
#include "swrenderer/r_main.h"
|
||||
#include "swrenderer/drawers/r_draw.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "g_level.h"
|
||||
#include "p_effect.h"
|
||||
#include "doomstat.h"
|
||||
#include "r_state.h"
|
||||
#include "v_palette.h"
|
||||
#include "r_sky.h"
|
||||
#include "po_man.h"
|
||||
#include "r_data/colormaps.h"
|
||||
#include "r_memory.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
short *openings;
|
||||
|
||||
namespace
|
||||
{
|
||||
size_t maxopenings;
|
||||
ptrdiff_t lastopening;
|
||||
}
|
||||
|
||||
ptrdiff_t R_NewOpening(ptrdiff_t len)
|
||||
{
|
||||
ptrdiff_t res = lastopening;
|
||||
len = (len + 1) & ~1; // only return DWORD aligned addresses because some code stores fixed_t's and floats in openings...
|
||||
lastopening += len;
|
||||
if ((size_t)lastopening > maxopenings)
|
||||
{
|
||||
do
|
||||
maxopenings = maxopenings ? maxopenings * 2 : 16384;
|
||||
while ((size_t)lastopening > maxopenings);
|
||||
openings = (short *)M_Realloc(openings, maxopenings * sizeof(*openings));
|
||||
DPrintf(DMSG_NOTIFY, "MaxOpenings increased to %zu\n", maxopenings);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void R_FreeOpenings()
|
||||
{
|
||||
lastopening = 0;
|
||||
}
|
||||
}
|
10
src/swrenderer/r_memory.h
Normal file
10
src/swrenderer/r_memory.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
extern short *openings;
|
||||
|
||||
ptrdiff_t R_NewOpening(ptrdiff_t len);
|
||||
void R_FreeOpenings();
|
||||
}
|
|
@ -74,20 +74,4 @@ namespace swrenderer
|
|||
|
||||
return ds_p++;
|
||||
}
|
||||
|
||||
ptrdiff_t R_NewOpening(ptrdiff_t len)
|
||||
{
|
||||
ptrdiff_t res = lastopening;
|
||||
len = (len + 1) & ~1; // only return DWORD aligned addresses because some code stores fixed_t's and floats in openings...
|
||||
lastopening += len;
|
||||
if ((size_t)lastopening > maxopenings)
|
||||
{
|
||||
do
|
||||
maxopenings = maxopenings ? maxopenings * 2 : 16384;
|
||||
while ((size_t)lastopening > maxopenings);
|
||||
openings = (short *)M_Realloc(openings, maxopenings * sizeof(*openings));
|
||||
DPrintf(DMSG_NOTIFY, "MaxOpenings increased to %zu\n", maxopenings);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,5 +43,4 @@ namespace swrenderer
|
|||
void R_FreeDrawSegs();
|
||||
|
||||
drawseg_t *R_AddDrawSegment();
|
||||
ptrdiff_t R_NewOpening(ptrdiff_t len);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@
|
|||
#include "r_clip_segment.h"
|
||||
#include "r_draw_segment.h"
|
||||
#include "r_portal_segment.h"
|
||||
#include "swrenderer\r_memory.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4244)
|
||||
|
@ -118,15 +119,6 @@ double stacked_visibility;
|
|||
DVector3 stacked_viewpos;
|
||||
DAngle stacked_angle;
|
||||
|
||||
|
||||
//
|
||||
// opening
|
||||
//
|
||||
|
||||
size_t maxopenings;
|
||||
short *openings;
|
||||
ptrdiff_t lastopening;
|
||||
|
||||
//
|
||||
// Clip values are the solid pixel bounding the range.
|
||||
// floorclip starts out SCREENHEIGHT and is just outside the range
|
||||
|
@ -546,7 +538,7 @@ void R_ClearPlanes (bool fullclear)
|
|||
!screen->Accel2D && ConBottom > viewwindowy && !bRenderingToCanvas
|
||||
? (ConBottom - viewwindowy) : 0);
|
||||
|
||||
lastopening = 0;
|
||||
R_FreeOpenings();
|
||||
|
||||
next_plane_light = 0;
|
||||
}
|
||||
|
@ -1351,7 +1343,6 @@ void R_DrawPortals ()
|
|||
DAngle savedangle = ViewAngle;
|
||||
ptrdiff_t savedvissprite_p = vissprite_p - vissprites;
|
||||
ptrdiff_t savedds_p = ds_p - drawsegs;
|
||||
ptrdiff_t savedlastopening = lastopening;
|
||||
size_t savedinteresting = FirstInterestingDrawseg;
|
||||
double savedvisibility = R_GetVisibility();
|
||||
AActor *savedcamera = camera;
|
||||
|
@ -1520,8 +1511,6 @@ void R_DrawPortals ()
|
|||
InterestingDrawsegs.Resize ((unsigned int)FirstInterestingDrawseg);
|
||||
FirstInterestingDrawseg = savedinteresting;
|
||||
|
||||
lastopening = savedlastopening;
|
||||
|
||||
camera = savedcamera;
|
||||
viewsector = savedsector;
|
||||
ViewPos = savedpos;
|
||||
|
|
|
@ -80,10 +80,6 @@ typedef struct visplane_s visplane_t;
|
|||
|
||||
|
||||
|
||||
// Visplane related.
|
||||
extern ptrdiff_t lastopening; // type short
|
||||
|
||||
|
||||
typedef void (*planefunction_t) (int top, int bottom);
|
||||
|
||||
extern planefunction_t floorfunc;
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "r_walldraw.h"
|
||||
#include "r_draw_segment.h"
|
||||
#include "r_portal_segment.h"
|
||||
#include "swrenderer\r_memory.h"
|
||||
|
||||
#define WALLYREPEAT 8
|
||||
|
||||
|
|
|
@ -31,10 +31,6 @@ struct drawseg_t;
|
|||
bool R_StoreWallRange(int start, int stop);
|
||||
void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2);
|
||||
|
||||
extern short *openings;
|
||||
extern ptrdiff_t lastopening;
|
||||
extern size_t maxopenings;
|
||||
|
||||
int R_CreateWallSegmentY (short *outbuf, double z1, double z2, const FWallCoords *wallc);
|
||||
int R_CreateWallSegmentYSloped (short *outbuf, const secplane_t &plane, const FWallCoords *wallc);
|
||||
inline int R_CreateWallSegmentY(short *outbuf, double z, const FWallCoords *wallc)
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
#include "r_voxel.h"
|
||||
#include "r_draw_segment.h"
|
||||
#include "r_portal_segment.h"
|
||||
#include "swrenderer\r_memory.h"
|
||||
|
||||
EXTERN_CVAR(Bool, st_scale)
|
||||
EXTERN_CVAR(Bool, r_shadercolormaps)
|
||||
|
|
Loading…
Reference in a new issue