mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 08:30:50 +00:00
- Improve sprite performance when there are many draw segments
This commit is contained in:
parent
44546ce16a
commit
42fedd0f4c
4 changed files with 36 additions and 11 deletions
|
@ -134,13 +134,42 @@ namespace swrenderer
|
||||||
void RenderTranslucentPass::DrawMaskedSingle(bool renew)
|
void RenderTranslucentPass::DrawMaskedSingle(bool renew)
|
||||||
{
|
{
|
||||||
RenderPortal *renderportal = Thread->Portal.get();
|
RenderPortal *renderportal = Thread->Portal.get();
|
||||||
|
DrawSegmentList *drawseglist = Thread->DrawSegments.get();
|
||||||
|
|
||||||
|
int numGroups = drawseglist->SegmentGroups.Size();
|
||||||
|
for (int j = 0; j < numGroups; j++)
|
||||||
|
drawseglist->SegmentGroups[j].GroupDrawn = false;
|
||||||
|
|
||||||
auto &sortedSprites = Thread->SpriteList->SortedSprites;
|
auto &sortedSprites = Thread->SpriteList->SortedSprites;
|
||||||
for (int i = sortedSprites.Size(); i > 0; i--)
|
for (int i = sortedSprites.Size(); i > 0; i--)
|
||||||
{
|
{
|
||||||
if (sortedSprites[i - 1]->IsCurrentPortalUniq(renderportal->CurrentPortalUniq))
|
VisibleSprite *sprite = sortedSprites[i - 1];
|
||||||
|
|
||||||
|
// Draw the draw segments known to be behind us now.
|
||||||
|
for (int j = numGroups; j > 0; j--)
|
||||||
{
|
{
|
||||||
sortedSprites[i - 1]->Render(Thread);
|
auto &group = drawseglist->SegmentGroups[j - 1];
|
||||||
|
if (!group.GroupDrawn && group.neardepth > sprite->DrawSegDepth())
|
||||||
|
{
|
||||||
|
for (unsigned int index = group.BeginIndex; index != group.EndIndex; index++)
|
||||||
|
{
|
||||||
|
DrawSegment *ds = drawseglist->Segment(index);
|
||||||
|
|
||||||
|
if (ds->CurrentPortalUniq != renderportal->CurrentPortalUniq) continue;
|
||||||
|
if (ds->fake) continue;
|
||||||
|
if (ds->maskedtexturecol != nullptr || ds->bFogBoundary)
|
||||||
|
{
|
||||||
|
RenderDrawSegment renderer(Thread);
|
||||||
|
renderer.Render(ds, ds->x1, ds->x2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
group.GroupDrawn = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sprite->IsCurrentPortalUniq(renderportal->CurrentPortalUniq))
|
||||||
|
{
|
||||||
|
sprite->Render(Thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +180,6 @@ namespace swrenderer
|
||||||
Thread->Clip3D->fake3D |= FAKE3D_REFRESHCLIP;
|
Thread->Clip3D->fake3D |= FAKE3D_REFRESHCLIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawSegmentList *drawseglist = Thread->DrawSegments.get();
|
|
||||||
for (unsigned int index = 0; index != drawseglist->SegmentsCount(); index++)
|
for (unsigned int index = 0; index != drawseglist->SegmentsCount(); index++)
|
||||||
{
|
{
|
||||||
DrawSegment *ds = drawseglist->Segment(index);
|
DrawSegment *ds = drawseglist->Segment(index);
|
||||||
|
|
|
@ -63,6 +63,7 @@ namespace swrenderer
|
||||||
short *sprbottomclip;
|
short *sprbottomclip;
|
||||||
unsigned int BeginIndex;
|
unsigned int BeginIndex;
|
||||||
unsigned int EndIndex;
|
unsigned int EndIndex;
|
||||||
|
bool GroupDrawn;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DrawSegmentList
|
class DrawSegmentList
|
||||||
|
|
|
@ -296,7 +296,7 @@ namespace swrenderer
|
||||||
for (unsigned int groupIndex = 0; groupIndex < segmentlist->SegmentGroups.Size(); groupIndex++)
|
for (unsigned int groupIndex = 0; groupIndex < segmentlist->SegmentGroups.Size(); groupIndex++)
|
||||||
{
|
{
|
||||||
auto &group = segmentlist->SegmentGroups[groupIndex];
|
auto &group = segmentlist->SegmentGroups[groupIndex];
|
||||||
if (group.x1 >= x2 || group.x2 <= x1)
|
if (group.x1 >= x2 || group.x2 <= x1 || group.neardepth > spr->depth)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (group.fardepth < spr->depth)
|
if (group.fardepth < spr->depth)
|
||||||
|
@ -335,11 +335,6 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
DrawSegment *ds = segmentlist->Segment(index);
|
DrawSegment *ds = segmentlist->Segment(index);
|
||||||
|
|
||||||
// [ZZ] portal handling here
|
|
||||||
//if (ds->CurrentPortalUniq != spr->CurrentPortalUniq)
|
|
||||||
// continue;
|
|
||||||
// [ZZ] WARNING: uncommenting the two above lines, totally breaks sprite clipping
|
|
||||||
|
|
||||||
// kg3D - no clipping on fake segs
|
// kg3D - no clipping on fake segs
|
||||||
if (ds->fake) continue;
|
if (ds->fake) continue;
|
||||||
// determine if the drawseg obscures the sprite
|
// determine if the drawseg obscures the sprite
|
||||||
|
@ -380,8 +375,7 @@ namespace swrenderer
|
||||||
RenderPortal *renderportal = thread->Portal.get();
|
RenderPortal *renderportal = thread->Portal.get();
|
||||||
|
|
||||||
// seg is behind sprite, so draw the mid texture if it has one
|
// seg is behind sprite, so draw the mid texture if it has one
|
||||||
if (ds->CurrentPortalUniq == renderportal->CurrentPortalUniq && // [ZZ] instead, portal uniq check is made here
|
if (ds->CurrentPortalUniq == renderportal->CurrentPortalUniq && (ds->maskedtexturecol != nullptr || ds->bFogBoundary))
|
||||||
(ds->maskedtexturecol != nullptr || ds->bFogBoundary))
|
|
||||||
{
|
{
|
||||||
RenderDrawSegment renderer(thread);
|
RenderDrawSegment renderer(thread);
|
||||||
renderer.Render(ds, r1, r2);
|
renderer.Render(ds, r1, r2);
|
||||||
|
|
|
@ -46,6 +46,8 @@ namespace swrenderer
|
||||||
double SortDist2D() const { return DVector2(deltax, deltay).LengthSquared(); }
|
double SortDist2D() const { return DVector2(deltax, deltay).LengthSquared(); }
|
||||||
float SortDist() const { return idepth; }
|
float SortDist() const { return idepth; }
|
||||||
|
|
||||||
|
float DrawSegDepth() const { return depth; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool IsParticle() const { return false; }
|
virtual bool IsParticle() const { return false; }
|
||||||
virtual bool IsVoxel() const { return false; }
|
virtual bool IsVoxel() const { return false; }
|
||||||
|
|
Loading…
Reference in a new issue