gzdoom-gles/src/swrenderer/r_renderthread.h
Christoph Oelckers f261ec7d53 - rewrote dynamic lights to not use actors for the internal representation and made DynamicLight a purely scripted class.
This should be less of a drag on the playsim than having each light a separate actor. A quick check with ZDCMP2 showed that the light processing time was reduced to 1/3rd from 0.5 ms to 0.17 ms per tic.
It's also one native actor class less.

# Conflicts:
#	src/g_shared/a_dynlight.cpp
#	src/g_shared/a_dynlight.h
#	src/hwrenderer/dynlights/hw_dynlightdata.cpp
#	src/hwrenderer/dynlights/hw_dynlightdata.h
#	src/hwrenderer/scene/hw_renderhacks.cpp
#	src/namedef.h
#	src/scripting/thingdef_data.cpp
#	src/swrenderer/line/r_walldraw.cpp

# Conflicts:
#	src/d_main.cpp
#	src/g_levellocals.h
#	src/g_shared/a_dynlight.cpp
#	src/g_shared/a_dynlight.h
#	src/gl/dynlights/gl_dynlight.h
#	src/gl/dynlights/gl_dynlight1.cpp
#	src/gl/scene/gl_spritelight.cpp
#	src/gl/scene/gl_walls.cpp
#	src/hwrenderer/dynlights/hw_shadowmap.cpp
#	src/hwrenderer/dynlights/hw_shadowmap.h
#	src/hwrenderer/scene/hw_flats.cpp
#	src/p_setup.cpp
2019-04-26 00:19:03 +02:00

100 lines
2.9 KiB
C++

/*
** Renderer multithreading framework
** Copyright (c) 2016 Magnus Norddahl
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any damages
** arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose,
** including commercial applications, and to alter it and redistribute it
** freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not
** claim that you wrote the original software. If you use this software
** in a product, an acknowledgment in the product documentation would be
** appreciated but is not required.
** 2. Altered source versions must be plainly marked as such, and must not be
** misrepresented as being the original software.
** 3. This notice may not be removed or altered from any source distribution.
**
*/
#pragma once
#include <memory>
#include <thread>
class DrawerCommandQueue;
typedef std::shared_ptr<DrawerCommandQueue> DrawerCommandQueuePtr;
class RenderMemory;
struct FDynamicLight;
EXTERN_CVAR(Bool, r_models);
extern bool r_modelscene;
namespace swrenderer
{
class VisibleSpriteList;
class RenderPortal;
class RenderOpaquePass;
class RenderTranslucentPass;
class RenderPlayerSprites;
class RenderScene;
class RenderViewport;
class Clip3DFloors;
class VisiblePlaneList;
class DrawSegmentList;
class RenderClipSegment;
class RenderViewport;
class LightVisibility;
class SWPixelFormatDrawers;
class SWTruecolorDrawers;
class SWPalDrawers;
class RenderThread
{
public:
RenderThread(RenderScene *scene, bool mainThread = true);
~RenderThread();
RenderScene *Scene;
int X1 = 0;
int X2 = MAXWIDTH;
bool MainThread = false;
std::unique_ptr<RenderMemory> FrameMemory;
std::unique_ptr<RenderOpaquePass> OpaquePass;
std::unique_ptr<RenderTranslucentPass> TranslucentPass;
std::unique_ptr<VisibleSpriteList> SpriteList;
std::unique_ptr<RenderPortal> Portal;
std::unique_ptr<Clip3DFloors> Clip3D;
std::unique_ptr<RenderPlayerSprites> PlayerSprites;
std::unique_ptr<VisiblePlaneList> PlaneList;
std::unique_ptr<DrawSegmentList> DrawSegments;
std::unique_ptr<RenderClipSegment> ClipSegments;
std::unique_ptr<RenderViewport> Viewport;
std::unique_ptr<LightVisibility> Light;
DrawerCommandQueuePtr DrawQueue;
TArray<FDynamicLight*> AddedLightsArray;
std::thread thread;
// VisibleSprite working buffers
short clipbot[MAXWIDTH];
short cliptop[MAXWIDTH];
SWPixelFormatDrawers *Drawers(RenderViewport *viewport);
// Make sure texture can accessed safely
void PrepareTexture(FTexture *texture, FRenderStyle style);
// Setup poly object in a threadsafe manner
void PreparePolyObject(subsector_t *sub);
private:
std::unique_ptr<SWTruecolorDrawers> tc_drawers;
std::unique_ptr<SWPalDrawers> pal_drawers;
};
}