mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-01 16:41:22 +00:00
Make RenderScene the work dispatching class
This commit is contained in:
parent
5105a5d254
commit
5bae06a3c6
9 changed files with 47 additions and 43 deletions
|
@ -50,7 +50,7 @@ PolyRenderer *PolyRenderer::Instance()
|
|||
return &scene;
|
||||
}
|
||||
|
||||
PolyRenderer::PolyRenderer()
|
||||
PolyRenderer::PolyRenderer() : Thread(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -282,5 +282,5 @@ DrawerCommandQueue::DrawerCommandQueue(swrenderer::RenderThread *renderthread) :
|
|||
|
||||
void *DrawerCommandQueue::AllocMemory(size_t size)
|
||||
{
|
||||
return renderthread->FrameMemory->AllocMemory<uint8_t>(size);
|
||||
return renderthread->FrameMemory->AllocMemory<uint8_t>((int)size);
|
||||
}
|
||||
|
|
|
@ -56,8 +56,9 @@
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
RenderThread::RenderThread()
|
||||
RenderThread::RenderThread(RenderScene *scene)
|
||||
{
|
||||
Scene = scene;
|
||||
FrameMemory = std::make_unique<RenderMemory>();
|
||||
DrawQueue = std::make_shared<DrawerCommandQueue>(this);
|
||||
OpaquePass = std::make_unique<RenderOpaquePass>(this);
|
||||
|
@ -67,7 +68,6 @@ namespace swrenderer
|
|||
Clip3DFloors = std::make_unique<swrenderer::Clip3DFloors>(this);
|
||||
PlayerSprites = std::make_unique<RenderPlayerSprites>(this);
|
||||
PlaneList = std::make_unique<VisiblePlaneList>(this);
|
||||
Scene = std::make_unique<RenderScene>(this);
|
||||
DrawSegments = std::make_unique<DrawSegmentList>(this);
|
||||
ClipSegments = std::make_unique<RenderClipSegment>();
|
||||
tc_drawers = std::make_unique<SWTruecolorDrawers>(DrawQueue);
|
||||
|
|
|
@ -47,9 +47,11 @@ namespace swrenderer
|
|||
class RenderThread
|
||||
{
|
||||
public:
|
||||
RenderThread();
|
||||
RenderThread(RenderScene *scene);
|
||||
~RenderThread();
|
||||
|
||||
RenderScene *Scene;
|
||||
|
||||
std::unique_ptr<RenderMemory> FrameMemory;
|
||||
std::unique_ptr<RenderOpaquePass> OpaquePass;
|
||||
std::unique_ptr<RenderTranslucentPass> TranslucentPass;
|
||||
|
@ -58,7 +60,6 @@ namespace swrenderer
|
|||
std::unique_ptr<Clip3DFloors> Clip3DFloors;
|
||||
std::unique_ptr<RenderPlayerSprites> PlayerSprites;
|
||||
std::unique_ptr<VisiblePlaneList> PlaneList;
|
||||
std::unique_ptr<RenderScene> Scene;
|
||||
std::unique_ptr<DrawSegmentList> DrawSegments;
|
||||
std::unique_ptr<RenderClipSegment> ClipSegments;
|
||||
DrawerCommandQueuePtr DrawQueue;
|
||||
|
|
|
@ -88,7 +88,7 @@ void FSoftwareRenderer::Init()
|
|||
{
|
||||
gl_ParseDefs();
|
||||
|
||||
mMainThread.Scene->Init();
|
||||
mScene.Init();
|
||||
}
|
||||
|
||||
bool FSoftwareRenderer::UsesColormap() const
|
||||
|
@ -178,7 +178,7 @@ void FSoftwareRenderer::RenderView(player_t *player)
|
|||
if (r_polyrenderer)
|
||||
PolyRenderer::Instance()->RenderView(player);
|
||||
else
|
||||
mMainThread.Scene->RenderView(player);
|
||||
mScene.RenderView(player);
|
||||
|
||||
FCanvasTextureInfo::UpdateAll();
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi
|
|||
if (r_polyrenderer)
|
||||
PolyRenderer::Instance()->RenderViewToCanvas(player->mo, pic, 0, 0, width, height, true);
|
||||
else
|
||||
mMainThread.Scene->RenderViewToCanvas (player->mo, pic, 0, 0, width, height);
|
||||
mScene.RenderViewToCanvas (player->mo, pic, 0, 0, width, height);
|
||||
screen->GetFlashedPalette (palette);
|
||||
M_CreatePNG (file, pic->GetBuffer(), palette, SS_PAL, width, height, pic->GetPitch());
|
||||
pic->Unlock ();
|
||||
|
@ -215,7 +215,7 @@ void FSoftwareRenderer::DrawRemainingPlayerSprites()
|
|||
{
|
||||
if (!r_polyrenderer)
|
||||
{
|
||||
mMainThread.PlayerSprites->RenderRemaining();
|
||||
mScene.MainThread()->PlayerSprites->RenderRemaining();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -237,12 +237,12 @@ bool FSoftwareRenderer::RequireGLNodes()
|
|||
|
||||
void FSoftwareRenderer::OnModeSet ()
|
||||
{
|
||||
mMainThread.Scene->ScreenResized();
|
||||
mScene.ScreenResized();
|
||||
}
|
||||
|
||||
void FSoftwareRenderer::SetClearColor(int color)
|
||||
{
|
||||
mMainThread.Scene->SetClearColor(color);
|
||||
mScene.SetClearColor(color);
|
||||
}
|
||||
|
||||
void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov)
|
||||
|
@ -262,7 +262,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
|
|||
if (r_polyrenderer)
|
||||
PolyRenderer::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||
else
|
||||
mMainThread.Scene->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||
mScene.RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||
|
||||
R_SetFOV (savedfov);
|
||||
|
||||
|
@ -319,7 +319,7 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
|
|||
|
||||
sector_t *FSoftwareRenderer::FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel)
|
||||
{
|
||||
return mMainThread.OpaquePass->FakeFlat(sec, tempsec, floorlightlevel, ceilinglightlevel, nullptr, 0, 0, 0, 0);
|
||||
return mScene.MainThread()->OpaquePass->FakeFlat(sec, tempsec, floorlightlevel, ceilinglightlevel, nullptr, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
void FSoftwareRenderer::StateChanged(AActor *actor)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "r_renderer.h"
|
||||
#include "r_renderthread.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
|
||||
struct FSoftwareRenderer : public FRenderer
|
||||
{
|
||||
|
@ -43,5 +43,5 @@ struct FSoftwareRenderer : public FRenderer
|
|||
private:
|
||||
void PrecacheTexture(FTexture *tex, int cache);
|
||||
|
||||
swrenderer::RenderThread mMainThread;
|
||||
swrenderer::RenderScene mScene;
|
||||
};
|
||||
|
|
|
@ -56,9 +56,9 @@ namespace swrenderer
|
|||
{
|
||||
cycle_t WallCycles, PlaneCycles, MaskedCycles, WallScanCycles;
|
||||
|
||||
RenderScene::RenderScene(RenderThread *thread)
|
||||
RenderScene::RenderScene()
|
||||
{
|
||||
Thread = thread;
|
||||
Threads.push_back(std::make_unique<RenderThread>(this));
|
||||
}
|
||||
|
||||
void RenderScene::SetClearColor(int color)
|
||||
|
@ -98,10 +98,10 @@ namespace swrenderer
|
|||
// Apply special colormap if the target cannot do it
|
||||
if (CameraLight::Instance()->ShaderColormap() && viewport->RenderTarget->IsBgra() && !(r_shadercolormaps && screen->Accel2D))
|
||||
{
|
||||
Thread->DrawQueue->Push<ApplySpecialColormapRGBACommand>(CameraLight::Instance()->ShaderColormap(), screen);
|
||||
MainThread()->DrawQueue->Push<ApplySpecialColormapRGBACommand>(CameraLight::Instance()->ShaderColormap(), screen);
|
||||
}
|
||||
|
||||
DrawerThreads::Execute({ Thread->DrawQueue });
|
||||
DrawerThreads::Execute({ MainThread()->DrawQueue });
|
||||
}
|
||||
|
||||
void RenderScene::RenderActorView(AActor *actor, bool dontmaplines)
|
||||
|
@ -111,9 +111,9 @@ namespace swrenderer
|
|||
MaskedCycles.Reset();
|
||||
WallScanCycles.Reset();
|
||||
|
||||
Thread->FrameMemory->Clear();
|
||||
MainThread()->FrameMemory->Clear();
|
||||
|
||||
Clip3DFloors *clip3d = Thread->Clip3DFloors.get();
|
||||
Clip3DFloors *clip3d = MainThread()->Clip3DFloors.get();
|
||||
clip3d->Cleanup();
|
||||
clip3d->ResetClip(); // reset clips (floor/ceiling)
|
||||
|
||||
|
@ -121,25 +121,25 @@ namespace swrenderer
|
|||
CameraLight::Instance()->SetCamera(actor);
|
||||
RenderViewport::Instance()->SetupFreelook();
|
||||
|
||||
Thread->Portal->CopyStackedViewParameters();
|
||||
MainThread()->Portal->CopyStackedViewParameters();
|
||||
|
||||
// Clear buffers.
|
||||
Thread->ClipSegments->Clear(0, viewwidth);
|
||||
Thread->DrawSegments->Clear();
|
||||
Thread->PlaneList->Clear();
|
||||
Thread->TranslucentPass->Clear();
|
||||
MainThread()->ClipSegments->Clear(0, viewwidth);
|
||||
MainThread()->DrawSegments->Clear();
|
||||
MainThread()->PlaneList->Clear();
|
||||
MainThread()->TranslucentPass->Clear();
|
||||
|
||||
// opening / clipping determination
|
||||
Thread->OpaquePass->ClearClip();
|
||||
MainThread()->OpaquePass->ClearClip();
|
||||
|
||||
NetUpdate();
|
||||
|
||||
Thread->Portal->SetMainPortal();
|
||||
MainThread()->Portal->SetMainPortal();
|
||||
|
||||
this->dontmaplines = dontmaplines;
|
||||
|
||||
// [RH] Hack to make windows into underwater areas possible
|
||||
Thread->OpaquePass->ResetFakingUnderwater();
|
||||
MainThread()->OpaquePass->ResetFakingUnderwater();
|
||||
|
||||
// [RH] Setup particles for this frame
|
||||
P_FindParticleSubsectors();
|
||||
|
@ -153,8 +153,8 @@ namespace swrenderer
|
|||
}
|
||||
// Link the polyobjects right before drawing the scene to reduce the amounts of calls to this function
|
||||
PO_LinkToSubsectors();
|
||||
Thread->OpaquePass->RenderScene();
|
||||
Thread->Clip3DFloors->ResetClip(); // reset clips (floor/ceiling)
|
||||
MainThread()->OpaquePass->RenderScene();
|
||||
MainThread()->Clip3DFloors->ResetClip(); // reset clips (floor/ceiling)
|
||||
camera->renderflags = savedflags;
|
||||
WallCycles.Unclock();
|
||||
|
||||
|
@ -163,16 +163,16 @@ namespace swrenderer
|
|||
if (viewactive)
|
||||
{
|
||||
PlaneCycles.Clock();
|
||||
Thread->PlaneList->Render();
|
||||
Thread->Portal->RenderPlanePortals();
|
||||
MainThread()->PlaneList->Render();
|
||||
MainThread()->Portal->RenderPlanePortals();
|
||||
PlaneCycles.Unclock();
|
||||
|
||||
Thread->Portal->RenderLinePortals();
|
||||
MainThread()->Portal->RenderLinePortals();
|
||||
|
||||
NetUpdate();
|
||||
|
||||
MaskedCycles.Clock();
|
||||
Thread->TranslucentPass->Render();
|
||||
MainThread()->TranslucentPass->Render();
|
||||
MaskedCycles.Unclock();
|
||||
|
||||
NetUpdate();
|
||||
|
@ -204,7 +204,7 @@ namespace swrenderer
|
|||
|
||||
RenderActorView(actor, dontmaplines);
|
||||
|
||||
DrawerThreads::Execute({ Thread->DrawQueue });
|
||||
DrawerThreads::Execute({ MainThread()->DrawQueue });
|
||||
|
||||
viewport->RenderTarget = screen;
|
||||
|
||||
|
@ -241,8 +241,8 @@ namespace swrenderer
|
|||
|
||||
void RenderScene::Deinit()
|
||||
{
|
||||
Thread->TranslucentPass->Deinit();
|
||||
Thread->Clip3DFloors->Cleanup();
|
||||
MainThread()->TranslucentPass->Deinit();
|
||||
MainThread()->Clip3DFloors->Cleanup();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <memory>
|
||||
#include "r_defs.h"
|
||||
#include "d_player.h"
|
||||
|
||||
|
@ -28,7 +29,7 @@ namespace swrenderer
|
|||
class RenderScene
|
||||
{
|
||||
public:
|
||||
RenderScene(RenderThread *thread);
|
||||
RenderScene();
|
||||
|
||||
void Init();
|
||||
void ScreenResized();
|
||||
|
@ -41,12 +42,14 @@ namespace swrenderer
|
|||
|
||||
bool DontMapLines() const { return dontmaplines; }
|
||||
|
||||
RenderThread *Thread = nullptr;
|
||||
RenderThread *MainThread() { return Threads.front().get(); }
|
||||
|
||||
private:
|
||||
void RenderActorView(AActor *actor, bool dontmaplines = false);
|
||||
|
||||
bool dontmaplines = false;
|
||||
int clearcolor = 0;
|
||||
|
||||
std::vector<std::unique_ptr<RenderThread>> Threads;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ void DCanvas::DrawTextureParms(FTexture *img, DrawParms &parms)
|
|||
int x2_i = int(x2);
|
||||
fixed_t xiscale_i = FLOAT2FIXED(xiscale);
|
||||
|
||||
static RenderThread thread;
|
||||
static RenderThread thread(nullptr);
|
||||
thread.DrawQueue->ThreadedRender = false;
|
||||
while (x < x2_i)
|
||||
{
|
||||
|
@ -1430,7 +1430,7 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
|
|||
pt2++; if (pt2 > npoints) pt2 = 0;
|
||||
} while (pt1 != botpt);
|
||||
|
||||
static RenderThread thread;
|
||||
static RenderThread thread(nullptr);
|
||||
thread.DrawQueue->ThreadedRender = false;
|
||||
|
||||
// Travel down the left edge and fill it in.
|
||||
|
|
Loading…
Reference in a new issue