Stop using validcount for sprites

This commit is contained in:
Magnus Norddahl 2017-02-04 20:32:06 +01:00
parent cfe4c55973
commit beae9a3dc7
4 changed files with 29 additions and 8 deletions

View file

@ -773,6 +773,9 @@ namespace swrenderer
void RenderOpaquePass::RenderScene() void RenderOpaquePass::RenderScene()
{ {
SeenSpriteSectors.clear();
SeenActors.clear();
InSubsector = nullptr; InSubsector = nullptr;
RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output. RenderBSPNode(nodes + numnodes - 1); // The head node is the last node output.
} }
@ -824,11 +827,12 @@ namespace swrenderer
// A sector might have been split into several // A sector might have been split into several
// subsectors during BSP building. // subsectors during BSP building.
// Thus we check whether it was already added. // Thus we check whether it was already added.
if (sec->touching_renderthings == nullptr || sec->validcount == validcount) if (sec->touching_renderthings == nullptr || SeenSpriteSectors.find(sec) != SeenSpriteSectors.end()/*|| sec->validcount == validcount*/)
return; return;
// Well, now it will be done. // Well, now it will be done.
sec->validcount = validcount; //sec->validcount = validcount;
SeenSpriteSectors.insert(sec);
int spriteshade = LIGHT2SHADE(lightlevel + R_ActualExtraLight(foggy)); int spriteshade = LIGHT2SHADE(lightlevel + R_ActualExtraLight(foggy));
@ -836,8 +840,10 @@ namespace swrenderer
for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext) for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext)
{ {
auto thing = p->m_thing; auto thing = p->m_thing;
if (thing->validcount == validcount) continue; if (SeenActors.find(thing) != SeenActors.end()) continue;
thing->validcount = validcount; SeenActors.insert(thing);
//if (thing->validcount == validcount) continue;
//thing->validcount = validcount;
FIntCVar *cvar = thing->GetClass()->distancecheck; FIntCVar *cvar = thing->GetClass()->distancecheck;
if (cvar != nullptr && *cvar >= 0) if (cvar != nullptr && *cvar >= 0)

View file

@ -18,6 +18,7 @@
#include "r_defs.h" #include "r_defs.h"
#include "swrenderer/line/r_line.h" #include "swrenderer/line/r_line.h"
#include "swrenderer/scene/r_3dfloors.h" #include "swrenderer/scene/r_3dfloors.h"
#include <set>
struct FVoxelDef; struct FVoxelDef;
@ -84,5 +85,7 @@ namespace swrenderer
bool r_fakingunderwater = false; bool r_fakingunderwater = false;
SWRenderLine renderline; SWRenderLine renderline;
std::set<sector_t*> SeenSpriteSectors;
std::set<AActor*> SeenActors;
}; };
} }

View file

@ -106,10 +106,9 @@ namespace swrenderer
if (CameraLight::Instance()->ShaderColormap() && viewport->RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D)) if (CameraLight::Instance()->ShaderColormap() && viewport->RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D))
{ {
MainThread()->DrawQueue->Push<ApplySpecialColormapRGBACommand>(CameraLight::Instance()->ShaderColormap(), screen); MainThread()->DrawQueue->Push<ApplySpecialColormapRGBACommand>(CameraLight::Instance()->ShaderColormap(), screen);
}
RenderDrawQueues(); RenderDrawQueues();
} }
}
void RenderScene::RenderDrawQueues() void RenderScene::RenderDrawQueues()
{ {
@ -120,6 +119,9 @@ namespace swrenderer
queues.push_back((*it)->DrawQueue); queues.push_back((*it)->DrawQueue);
} }
DrawerThreads::Execute(queues); DrawerThreads::Execute(queues);
//using namespace std::chrono_literals;
//std::this_thread::sleep_for(0.5s);
} }
void RenderScene::RenderActorView(AActor *actor, bool dontmaplines) void RenderScene::RenderActorView(AActor *actor, bool dontmaplines)
@ -151,6 +153,7 @@ namespace swrenderer
} }
RenderThreadSlices(); RenderThreadSlices();
RenderDrawQueues();
camera->renderflags = savedflags; camera->renderflags = savedflags;
interpolator.RestoreInterpolations(); interpolator.RestoreInterpolations();
@ -165,7 +168,13 @@ namespace swrenderer
void RenderScene::RenderThreadSlices() void RenderScene::RenderThreadSlices()
{ {
int numThreads = r_scene_multithreaded ? 8 : 1; int numThreads = std::thread::hardware_concurrency();
if (numThreads == 0)
numThreads = 4;
if (!r_scene_multithreaded)
numThreads = 1;
if (numThreads != Threads.size()) if (numThreads != Threads.size())
{ {
StopThreads(); StopThreads();
@ -327,7 +336,6 @@ namespace swrenderer
viewport->SetViewport(width, height, WidescreenRatio); viewport->SetViewport(width, height, WidescreenRatio);
RenderActorView(actor, dontmaplines); RenderActorView(actor, dontmaplines);
RenderDrawQueues();
viewport->RenderTarget = screen; viewport->RenderTarget = screen;

View file

@ -77,6 +77,10 @@ namespace swrenderer
if (x1 >= x2) if (x1 >= x2)
return; return;
// Reject sprites outside the slice rendered by the thread
if (x2 < thread->X1 || x1 > thread->X2)
return;
// [RH] Sprites split behind a one-sided line can also be discarded. // [RH] Sprites split behind a one-sided line can also be discarded.
if (spr->sector == nullptr) if (spr->sector == nullptr)
return; return;