mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-17 01:31:25 +00:00
- Improve softpoly culling performance
This commit is contained in:
parent
432afd9edf
commit
4d671fb618
3 changed files with 32 additions and 17 deletions
|
@ -33,11 +33,21 @@ void PolyCull::CullScene(const TriMatrix &worldToClip, const PolyClipPlane &port
|
||||||
ClearSolidSegments();
|
ClearSolidSegments();
|
||||||
MarkViewFrustum();
|
MarkViewFrustum();
|
||||||
|
|
||||||
|
for (const auto &sub : PvsSectors)
|
||||||
|
SubsectorDepths[sub->Index()] = 0xffffffff;
|
||||||
|
SubsectorDepths.resize(level.subsectors.Size(), 0xffffffff);
|
||||||
|
|
||||||
|
for (const auto §or : SeenSectors)
|
||||||
|
SectorSeen[sector->Index()] = false;
|
||||||
|
SectorSeen.resize(level.sectors.Size());
|
||||||
|
|
||||||
PvsSectors.clear();
|
PvsSectors.clear();
|
||||||
PvsLineStart.clear();
|
|
||||||
PvsLineVisible.clear();
|
|
||||||
SeenSectors.clear();
|
SeenSectors.clear();
|
||||||
SubsectorDepths.clear();
|
|
||||||
|
NextPvsLineStart = 0;
|
||||||
|
PvsLineStart.clear();
|
||||||
|
PvsLineVisible.resize(level.segs.Size());
|
||||||
|
|
||||||
PortalClipPlane = portalClipPlane;
|
PortalClipPlane = portalClipPlane;
|
||||||
|
|
||||||
// Cull front to back
|
// Cull front to back
|
||||||
|
@ -108,7 +118,7 @@ void PolyCull::CullSubsector(subsector_t *sub)
|
||||||
|
|
||||||
// Mark that we need to render this
|
// Mark that we need to render this
|
||||||
PvsSectors.push_back(sub);
|
PvsSectors.push_back(sub);
|
||||||
PvsLineStart.push_back((uint32_t)PvsLineVisible.size());
|
PvsLineStart.push_back(NextPvsLineStart);
|
||||||
|
|
||||||
DVector3 viewpos = PolyRenderer::Instance()->Viewpoint.Pos;
|
DVector3 viewpos = PolyRenderer::Instance()->Viewpoint.Pos;
|
||||||
|
|
||||||
|
@ -122,7 +132,7 @@ void PolyCull::CullSubsector(subsector_t *sub)
|
||||||
DVector2 pt2 = line->v2->fPos() - viewpos;
|
DVector2 pt2 = line->v2->fPos() - viewpos;
|
||||||
if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0)
|
if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0)
|
||||||
{
|
{
|
||||||
PvsLineVisible.push_back(false);
|
PvsLineVisible[NextPvsLineStart++] = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +140,7 @@ void PolyCull::CullSubsector(subsector_t *sub)
|
||||||
if ((PortalClipPlane.A * line->v1->fX() + PortalClipPlane.B * line->v1->fY() + PortalClipPlane.D <= 0.0) ||
|
if ((PortalClipPlane.A * line->v1->fX() + PortalClipPlane.B * line->v1->fY() + PortalClipPlane.D <= 0.0) ||
|
||||||
(PortalClipPlane.A * line->v2->fX() + PortalClipPlane.B * line->v2->fY() + PortalClipPlane.D <= 0.0))
|
(PortalClipPlane.A * line->v2->fX() + PortalClipPlane.B * line->v2->fY() + PortalClipPlane.D <= 0.0))
|
||||||
{
|
{
|
||||||
PvsLineVisible.push_back(false);
|
PvsLineVisible[NextPvsLineStart++] = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,11 +152,16 @@ void PolyCull::CullSubsector(subsector_t *sub)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark if this line was visible
|
// Mark if this line was visible
|
||||||
PvsLineVisible.push_back(lineVisible);
|
PvsLineVisible[NextPvsLineStart++] = lineVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
SeenSectors.insert(sub->sector);
|
if (!SectorSeen[sub->sector->Index()])
|
||||||
SubsectorDepths[sub] = subsectorDepth;
|
{
|
||||||
|
SectorSeen[sub->sector->Index()] = true;
|
||||||
|
SeenSectors.push_back(sub->sector);
|
||||||
|
}
|
||||||
|
|
||||||
|
SubsectorDepths[sub->Index()] = subsectorDepth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyCull::ClearSolidSegments()
|
void PolyCull::ClearSolidSegments()
|
||||||
|
|
|
@ -40,8 +40,9 @@ public:
|
||||||
double MaxCeilingHeight = 0.0;
|
double MaxCeilingHeight = 0.0;
|
||||||
double MinFloorHeight = 0.0;
|
double MinFloorHeight = 0.0;
|
||||||
|
|
||||||
std::set<sector_t *> SeenSectors;
|
std::vector<sector_t *> SeenSectors;
|
||||||
std::unordered_map<subsector_t *, uint32_t> SubsectorDepths;
|
std::vector<bool> SectorSeen;
|
||||||
|
std::vector<uint32_t> SubsectorDepths;
|
||||||
|
|
||||||
static angle_t PointToPseudoAngle(double x, double y);
|
static angle_t PointToPseudoAngle(double x, double y);
|
||||||
|
|
||||||
|
@ -78,6 +79,7 @@ private:
|
||||||
|
|
||||||
std::vector<uint32_t> PvsLineStart;
|
std::vector<uint32_t> PvsLineStart;
|
||||||
std::vector<bool> PvsLineVisible;
|
std::vector<bool> PvsLineVisible;
|
||||||
|
uint32_t NextPvsLineStart = 0;
|
||||||
|
|
||||||
static angle_t AngleToPseudo(angle_t ang);
|
static angle_t AngleToPseudo(angle_t ang);
|
||||||
};
|
};
|
||||||
|
|
|
@ -213,9 +213,8 @@ void RenderPolyScene::RenderSprite(PolyRenderThread *thread, AActor *thing, doub
|
||||||
if (level.nodes.Size() == 0)
|
if (level.nodes.Size() == 0)
|
||||||
{
|
{
|
||||||
subsector_t *sub = &level.subsectors[0];
|
subsector_t *sub = &level.subsectors[0];
|
||||||
auto it = Cull.SubsectorDepths.find(sub);
|
if (Cull.SubsectorDepths[sub->Index()] != 0xffffffff)
|
||||||
if (it != Cull.SubsectorDepths.end())
|
TranslucentObjects[thread->ThreadIndex].push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, Cull.SubsectorDepths[sub->Index()], sortDistance, 0.0f, 1.0f, StencilValue));
|
||||||
TranslucentObjects[thread->ThreadIndex].push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, it->second, sortDistance, 0.0f, 1.0f, StencilValue));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -254,9 +253,8 @@ void RenderPolyScene::RenderSprite(PolyRenderThread *thread, AActor *thing, doub
|
||||||
|
|
||||||
subsector_t *sub = (subsector_t *)((uint8_t *)node - 1);
|
subsector_t *sub = (subsector_t *)((uint8_t *)node - 1);
|
||||||
|
|
||||||
auto it = Cull.SubsectorDepths.find(sub);
|
if (Cull.SubsectorDepths[sub->Index()] != 0xffffffff)
|
||||||
if (it != Cull.SubsectorDepths.end())
|
TranslucentObjects[thread->ThreadIndex].push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, Cull.SubsectorDepths[sub->Index()], sortDistance, (float)t1, (float)t2, StencilValue));
|
||||||
TranslucentObjects[thread->ThreadIndex].push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, it->second, sortDistance, (float)t1, (float)t2, StencilValue));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPolyScene::RenderLine(PolyRenderThread *thread, subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth)
|
void RenderPolyScene::RenderLine(PolyRenderThread *thread, subsector_t *sub, seg_t *line, sector_t *frontsector, uint32_t subsectorDepth)
|
||||||
|
|
Loading…
Reference in a new issue