mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 04:01:31 +00:00
- converted GLFLat list to use pointers as well.
- added copy constructors and assignement operators to GLFlat and GLWall so that they can use memcpy instead of field-by-field copy. This actually increases performance slightly.
This commit is contained in:
parent
d10aa10889
commit
ee1d1a29a6
5 changed files with 42 additions and 16 deletions
|
@ -584,7 +584,8 @@ bool GLFlat::PutFlatCompat(bool fog)
|
|||
|
||||
|
||||
int list = list_indices[masked][foggy];
|
||||
gl_drawinfo->dldrawlists[list].AddFlat(this);
|
||||
auto newflat = gl_drawinfo->drawlists[list].NewFlat();
|
||||
*newflat = *this;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -285,8 +285,8 @@ SortNode * GLDrawList::FindSortWall(SortNode * head)
|
|||
//==========================================================================
|
||||
void GLDrawList::SortPlaneIntoPlane(SortNode * head,SortNode * sort)
|
||||
{
|
||||
GLFlat * fh=&flats[drawitems[head->itemindex].index];
|
||||
GLFlat * fs=&flats[drawitems[sort->itemindex].index];
|
||||
GLFlat * fh= flats[drawitems[head->itemindex].index];
|
||||
GLFlat * fs= flats[drawitems[sort->itemindex].index];
|
||||
|
||||
if (fh->z==fs->z)
|
||||
head->AddToEqual(sort);
|
||||
|
@ -304,7 +304,7 @@ void GLDrawList::SortPlaneIntoPlane(SortNode * head,SortNode * sort)
|
|||
//==========================================================================
|
||||
void GLDrawList::SortWallIntoPlane(SortNode * head, SortNode * sort)
|
||||
{
|
||||
GLFlat * fh = &flats[drawitems[head->itemindex].index];
|
||||
GLFlat * fh = flats[drawitems[head->itemindex].index];
|
||||
GLWall * ws = walls[drawitems[sort->itemindex].index];
|
||||
|
||||
bool ceiling = fh->z > r_viewpoint.Pos.Z;
|
||||
|
@ -362,7 +362,7 @@ void GLDrawList::SortWallIntoPlane(SortNode * head, SortNode * sort)
|
|||
//==========================================================================
|
||||
void GLDrawList::SortSpriteIntoPlane(SortNode * head, SortNode * sort)
|
||||
{
|
||||
GLFlat * fh = &flats[drawitems[head->itemindex].index];
|
||||
GLFlat * fh = flats[drawitems[head->itemindex].index];
|
||||
GLSprite * ss = &sprites[drawitems[sort->itemindex].index];
|
||||
|
||||
bool ceiling = fh->z > r_viewpoint.Pos.Z;
|
||||
|
@ -722,7 +722,7 @@ void GLDrawList::DoDraw(int pass, int i, bool trans)
|
|||
{
|
||||
case GLDIT_FLAT:
|
||||
{
|
||||
GLFlat * f=&flats[drawitems[i].index];
|
||||
GLFlat * f= flats[drawitems[i].index];
|
||||
RenderFlat.Clock();
|
||||
f->Draw(pass, trans);
|
||||
RenderFlat.Unclock();
|
||||
|
@ -764,7 +764,7 @@ void GLDrawList::DoDrawSorted(SortNode * head)
|
|||
|
||||
if (drawitems[head->itemindex].rendertype == GLDIT_FLAT)
|
||||
{
|
||||
z = flats[drawitems[head->itemindex].index].z;
|
||||
z = flats[drawitems[head->itemindex].index]->z;
|
||||
relation = z > r_viewpoint.Pos.Z ? 1 : -1;
|
||||
}
|
||||
|
||||
|
@ -878,7 +878,7 @@ void GLDrawList::DrawFlats(int pass)
|
|||
RenderFlat.Clock();
|
||||
for(unsigned i=0;i<drawitems.Size();i++)
|
||||
{
|
||||
flats[drawitems[i].index].Draw(pass, false);
|
||||
flats[drawitems[i].index]->Draw(pass, false);
|
||||
}
|
||||
RenderFlat.Unclock();
|
||||
}
|
||||
|
@ -924,8 +924,8 @@ void GLDrawList::SortFlats()
|
|||
{
|
||||
std::sort(drawitems.begin(), drawitems.end(), [=](const GLDrawItem &a, const GLDrawItem &b)
|
||||
{
|
||||
GLFlat * w1 = &flats[a.index];
|
||||
GLFlat* w2 = &flats[b.index];
|
||||
GLFlat * w1 = flats[a.index];
|
||||
GLFlat* w2 = flats[b.index];
|
||||
return w1->gltexture < w2->gltexture;
|
||||
});
|
||||
}
|
||||
|
@ -949,9 +949,11 @@ GLWall *GLDrawList::NewWall()
|
|||
//
|
||||
//
|
||||
//==========================================================================
|
||||
void GLDrawList::AddFlat(GLFlat * flat)
|
||||
GLFlat *GLDrawList::NewFlat()
|
||||
{
|
||||
drawitems.Push(GLDrawItem(GLDIT_FLAT,flats.Push(*flat)));
|
||||
auto flat = (GLFlat*)RenderDataAllocator.Alloc(sizeof(GLFlat));
|
||||
drawitems.Push(GLDrawItem(GLDIT_FLAT,flats.Push(flat)));
|
||||
return flat;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -107,7 +107,7 @@ struct GLDrawList
|
|||
{
|
||||
//private:
|
||||
TArray<GLWall*> walls;
|
||||
TArray<GLFlat> flats;
|
||||
TArray<GLFlat*> flats;
|
||||
TArray<GLSprite> sprites;
|
||||
TArray<GLDrawItem> drawitems;
|
||||
int SortNodeStart;
|
||||
|
@ -132,8 +132,7 @@ public:
|
|||
}
|
||||
|
||||
GLWall *NewWall();
|
||||
//void AddWall(GLWall * wall);
|
||||
void AddFlat(GLFlat * flat);
|
||||
GLFlat *NewFlat();
|
||||
void AddSprite(GLSprite * sprite);
|
||||
void Reset();
|
||||
void SortWalls();
|
||||
|
|
|
@ -489,7 +489,8 @@ inline void GLFlat::PutFlat(bool fog)
|
|||
list = masked ? GLDL_MASKEDFLATS : GLDL_PLAINFLATS;
|
||||
}
|
||||
dynlightindex = -1; // make sure this is always initialized to something proper.
|
||||
gl_drawinfo->drawlists[list].AddFlat (this);
|
||||
auto newflat = gl_drawinfo->drawlists[list].NewFlat();
|
||||
*newflat = *this;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -276,6 +276,17 @@ public:
|
|||
mDrawer = drawer;
|
||||
}
|
||||
|
||||
GLWall(const GLWall &other)
|
||||
{
|
||||
memcpy(this, &other, sizeof(GLWall));
|
||||
}
|
||||
|
||||
GLWall & operator=(const GLWall &other)
|
||||
{
|
||||
memcpy(this, &other, sizeof(GLWall));
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Process(seg_t *seg, sector_t *frontsector, sector_t *backsector);
|
||||
void ProcessLowerMiniseg(seg_t *seg, sector_t *frontsector, sector_t *backsector);
|
||||
void Draw(int pass);
|
||||
|
@ -349,6 +360,18 @@ public:
|
|||
void SetFrom3DFloor(F3DFloor *rover, bool top, bool underside);
|
||||
void ProcessSector(sector_t * frontsector);
|
||||
void Draw(int pass, bool trans);
|
||||
|
||||
GLFlat(const GLFlat &other)
|
||||
{
|
||||
memcpy(this, &other, sizeof(GLFlat));
|
||||
}
|
||||
|
||||
GLFlat & operator=(const GLFlat &other)
|
||||
{
|
||||
memcpy(this, &other, sizeof(GLFlat));
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue