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