- moved the light buffer pointer to globally visible state.

This commit is contained in:
Christoph Oelckers 2018-10-28 15:22:48 +01:00
parent b2776c9351
commit 926a918e0c
15 changed files with 27 additions and 27 deletions

View file

@ -102,7 +102,6 @@ void FGLRenderer::Initialize(int width, int height)
glBindVertexArray(mVAOID); glBindVertexArray(mVAOID);
FGLDebug::LabelObject(GL_VERTEX_ARRAY, mVAOID, "FGLRenderer.mVAOID"); FGLDebug::LabelObject(GL_VERTEX_ARRAY, mVAOID, "FGLRenderer.mVAOID");
mLights = new FLightBuffer();
mFBID = 0; mFBID = 0;
mOldFBID = 0; mOldFBID = 0;
@ -117,7 +116,6 @@ FGLRenderer::~FGLRenderer()
FMaterial::FlushAll(); FMaterial::FlushAll();
if (mShaderManager != nullptr) delete mShaderManager; if (mShaderManager != nullptr) delete mShaderManager;
if (mSamplerManager != nullptr) delete mSamplerManager; if (mSamplerManager != nullptr) delete mSamplerManager;
if (mLights != nullptr) delete mLights;
if (mFBID != 0) glDeleteFramebuffers(1, &mFBID); if (mFBID != 0) glDeleteFramebuffers(1, &mFBID);
if (mVAOID != 0) if (mVAOID != 0)
{ {
@ -209,7 +207,7 @@ sector_t *FGLRenderer::RenderView(player_t* player)
P_FindParticleSubsectors(); P_FindParticleSubsectors();
mLights->Clear(); screen->mLights->Clear();
screen->mViewpoints->Clear(); screen->mViewpoints->Clear();
// NoInterpolateView should have no bearing on camera textures, but needs to be preserved for the main view below. // NoInterpolateView should have no bearing on camera textures, but needs to be preserved for the main view below.
@ -311,7 +309,7 @@ void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, i
P_FindParticleSubsectors(); // make sure that all recently spawned particles have a valid subsector. P_FindParticleSubsectors(); // make sure that all recently spawned particles have a valid subsector.
screen->mVertexData->Bind(gl_RenderState); screen->mVertexData->Bind(gl_RenderState);
screen->mVertexData->Reset(); screen->mVertexData->Reset();
mLights->Clear(); screen->mLights->Clear();
screen->mViewpoints->Clear(); screen->mViewpoints->Clear();
// This shouldn't overwrite the global viewpoint even for a short time. // This shouldn't overwrite the global viewpoint even for a short time.

View file

@ -69,7 +69,6 @@ public:
//FRotator mAngles; //FRotator mAngles;
FLightBuffer *mLights = nullptr;
SWSceneDrawer *swdrawer = nullptr; SWSceneDrawer *swdrawer = nullptr;
float mSceneClearColor[3]; float mSceneClearColor[3];

View file

@ -200,7 +200,7 @@ bool FGLRenderState::ApplyShader()
matrixToGL(identityMatrix, activeShader->normalmodelmatrix_index); matrixToGL(identityMatrix, activeShader->normalmodelmatrix_index);
} }
auto index = GLRenderer->mLights->BindUBO(mLightIndex); auto index = screen->mLights->BindUBO(mLightIndex);
activeShader->muLightIndex.Set(index); activeShader->muLightIndex.Set(index);
return true; return true;

View file

@ -158,11 +158,6 @@ void FDrawInfo::AddSubsectorToPortal(FSectorPortalGroup *ptg, subsector_t *sub)
ptl->AddSubsector(sub); ptl->AddSubsector(sub);
} }
int FDrawInfo::UploadLights(FDynLightData &data)
{
return GLRenderer->mLights->UploadLights(data);
}
bool FDrawInfo::SetDepthClamp(bool on) bool FDrawInfo::SetDepthClamp(bool on)
{ {
return gl_RenderState.SetDepthClamp(on); return gl_RenderState.SetDepthClamp(on);

View file

@ -39,8 +39,6 @@ struct FDrawInfo : public HWDrawInfo
void AddFlat(GLFlat *flat, bool fog) override; void AddFlat(GLFlat *flat, bool fog) override;
void AddSprite(GLSprite *sprite, bool translucent) override; void AddSprite(GLSprite *sprite, bool translucent) override;
int UploadLights(FDynLightData &data) override;
void Draw(EDrawType dt, FRenderState &state, int index, int count, bool apply = true) override; void Draw(EDrawType dt, FRenderState &state, int index, int count, bool apply = true) override;
void DrawIndexed(EDrawType dt, FRenderState &state, int index, int count, bool apply = true) override; void DrawIndexed(EDrawType dt, FRenderState &state, int index, int count, bool apply = true) override;
void RenderPortal(HWPortal *p, bool stencil) override; void RenderPortal(HWPortal *p, bool stencil) override;

View file

@ -105,7 +105,7 @@ void FDrawInfo::CreateScene()
// clip the scene and fill the drawlists // clip the scene and fill the drawlists
Bsp.Clock(); Bsp.Clock();
screen->mVertexData->Map(); screen->mVertexData->Map();
GLRenderer->mLights->Map(); screen->mLights->Map();
// Give the DrawInfo the viewpoint in fixed point because that's what the nodes are. // Give the DrawInfo the viewpoint in fixed point because that's what the nodes are.
viewx = FLOAT2FIXED(vp.Pos.X); viewx = FLOAT2FIXED(vp.Pos.X);
@ -130,7 +130,7 @@ void FDrawInfo::CreateScene()
HandleHackedSubsectors(); // open sector hacks for deep water HandleHackedSubsectors(); // open sector hacks for deep water
ProcessSectorStacks(in_area); // merge visplanes of sector stacks ProcessSectorStacks(in_area); // merge visplanes of sector stacks
PrepareUnhandledMissingTextures(); PrepareUnhandledMissingTextures();
GLRenderer->mLights->Unmap(); screen->mLights->Unmap();
screen->mVertexData->Unmap(); screen->mVertexData->Unmap();
ProcessAll.Unclock(); ProcessAll.Unclock();
@ -153,7 +153,7 @@ void FDrawInfo::RenderScene(int recursion)
glDepthMask(true); glDepthMask(true);
if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, this); if (!gl_no_skyclear) screen->mPortalState->RenderFirstSkyPortal(recursion, this);
GLRenderer->mLights->BindBase(gl_RenderState); // not needed for OpenGL but necessary for Vulkan command buffers to do it here! screen->mLights->BindBase(gl_RenderState); // not needed for OpenGL but necessary for Vulkan command buffers to do it here!
gl_RenderState.EnableFog(true); gl_RenderState.EnableFog(true);
gl_RenderState.SetRenderStyle(STYLE_Source); gl_RenderState.SetRenderStyle(STYLE_Source);

View file

@ -166,10 +166,10 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
// //
FString vp_comb; FString vp_comb;
assert(GLRenderer->mLights != NULL); assert(screen->mLights != NULL);
bool lightbuffertype = GLRenderer->mLights->GetBufferType(); bool lightbuffertype = screen->mLights->GetBufferType();
unsigned int lightbuffersize = GLRenderer->mLights->GetBlockSize(); unsigned int lightbuffersize = screen->mLights->GetBlockSize();
if (!lightbuffertype) if (!lightbuffertype)
{ {
vp_comb.Format("#version 330 core\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize); vp_comb.Format("#version 330 core\n#define NUM_UBO_LIGHTS %d\n", lightbuffersize);

View file

@ -41,6 +41,7 @@
#include "hwrenderer/models/hw_models.h" #include "hwrenderer/models/hw_models.h"
#include "hwrenderer/scene/hw_skydome.h" #include "hwrenderer/scene/hw_skydome.h"
#include "hwrenderer/data/hw_viewpointbuffer.h" #include "hwrenderer/data/hw_viewpointbuffer.h"
#include "hwrenderer/dynlights/hw_lightbuffer.h"
#include "gl/shaders/gl_shaderprogram.h" #include "gl/shaders/gl_shaderprogram.h"
#include "gl_debug.h" #include "gl_debug.h"
#include "r_videoscale.h" #include "r_videoscale.h"
@ -87,6 +88,7 @@ OpenGLFrameBuffer::~OpenGLFrameBuffer()
if (mVertexData != nullptr) delete mVertexData; if (mVertexData != nullptr) delete mVertexData;
if (mSkyData != nullptr) delete mSkyData; if (mSkyData != nullptr) delete mSkyData;
if (mViewpoints != nullptr) delete mViewpoints; if (mViewpoints != nullptr) delete mViewpoints;
if (mLights != nullptr) delete mLights;
if (GLRenderer) if (GLRenderer)
{ {
@ -144,13 +146,15 @@ void OpenGLFrameBuffer::InitializeState()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLRenderer = new FGLRenderer(this);
GLRenderer->Initialize(GetWidth(), GetHeight());
SetViewportRects(nullptr); SetViewportRects(nullptr);
mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight()); mVertexData = new FFlatVertexBuffer(GetWidth(), GetHeight());
mSkyData = new FSkyVertexBuffer; mSkyData = new FSkyVertexBuffer;
mViewpoints = new GLViewpointBuffer; mViewpoints = new GLViewpointBuffer;
mLights = new FLightBuffer();
GLRenderer = new FGLRenderer(this);
GLRenderer->Initialize(GetWidth(), GetHeight());
mDebug = std::make_shared<FGLDebug>(); mDebug = std::make_shared<FGLDebug>();
mDebug->Update(); mDebug->Update();

View file

@ -337,7 +337,6 @@ public:
virtual void AddFlat(GLFlat *flat, bool fog) = 0; virtual void AddFlat(GLFlat *flat, bool fog) = 0;
virtual void AddSprite(GLSprite *sprite, bool translucent) = 0; virtual void AddSprite(GLSprite *sprite, bool translucent) = 0;
virtual int UploadLights(FDynLightData &data) = 0;
virtual void ApplyVPUniforms() = 0; virtual void ApplyVPUniforms() = 0;
virtual bool SetDepthClamp(bool on) = 0; virtual bool SetDepthClamp(bool on) = 0;

View file

@ -42,6 +42,7 @@
#include "hwrenderer/textures/hw_material.h" #include "hwrenderer/textures/hw_material.h"
#include "hwrenderer/scene/hw_drawinfo.h" #include "hwrenderer/scene/hw_drawinfo.h"
#include "hwrenderer/data/flatvertices.h" #include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/dynlights/hw_lightbuffer.h"
#include "hw_drawstructs.h" #include "hw_drawstructs.h"
#include "hw_renderstate.h" #include "hw_renderstate.h"
@ -170,7 +171,7 @@ void GLFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &light
node = node->nextLight; node = node->nextLight;
} }
dynlightindex = di->UploadLights(lightdata); dynlightindex = screen->mLights->UploadLights(lightdata);
} }
//========================================================================== //==========================================================================

View file

@ -36,6 +36,7 @@
#include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/dynlights/hw_dynlightdata.h" #include "hwrenderer/dynlights/hw_dynlightdata.h"
#include "hwrenderer/data/flatvertices.h" #include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/dynlights/hw_lightbuffer.h"
sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back); sector_t * hw_FakeFlat(sector_t * sec, sector_t * dest, area_t in_area, bool back);
@ -71,7 +72,7 @@ int HWDrawInfo::SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &light
node = node->nextLight; node = node->nextLight;
} }
return UploadLights(lightdata); return screen->mLights->UploadLights(lightdata);
} }
else return -1; else return -1;
} }

View file

@ -53,6 +53,7 @@
#include "hwrenderer/utility/hw_lighting.h" #include "hwrenderer/utility/hw_lighting.h"
#include "hwrenderer/textures/hw_material.h" #include "hwrenderer/textures/hw_material.h"
#include "hwrenderer/dynlights/hw_dynlightdata.h" #include "hwrenderer/dynlights/hw_dynlightdata.h"
#include "hwrenderer/dynlights/hw_lightbuffer.h"
#include "hw_renderstate.h" #include "hw_renderstate.h"
extern TArray<spritedef_t> sprites; extern TArray<spritedef_t> sprites;
@ -460,7 +461,7 @@ inline void GLSprite::PutSprite(HWDrawInfo *di, bool translucent)
if (modelframe && RenderStyle.BlendOp != STYLEOP_Shadow && gl_light_sprites && level.HasDynamicLights && !di->isFullbrightScene() && !fullbright) if (modelframe && RenderStyle.BlendOp != STYLEOP_Shadow && gl_light_sprites && level.HasDynamicLights && !di->isFullbrightScene() && !fullbright)
{ {
hw_GetDynModelLight(actor, lightdata); hw_GetDynModelLight(actor, lightdata);
dynlightindex = di->UploadLights(lightdata); dynlightindex = screen->mLights->UploadLights(lightdata);
} }
else else
dynlightindex = -1; dynlightindex = -1;

View file

@ -38,6 +38,7 @@
#include "hwrenderer/scene/hw_drawinfo.h" #include "hwrenderer/scene/hw_drawinfo.h"
#include "hwrenderer/scene/hw_drawstructs.h" #include "hwrenderer/scene/hw_drawstructs.h"
#include "hwrenderer/scene/hw_portal.h" #include "hwrenderer/scene/hw_portal.h"
#include "hwrenderer/dynlights/hw_lightbuffer.h"
#include "hw_renderstate.h" #include "hw_renderstate.h"
#include "hw_skydome.h" #include "hw_skydome.h"
@ -359,7 +360,7 @@ void GLWall::SetupLights(HWDrawInfo *di, FDynLightData &lightdata)
} }
node = node->nextLight; node = node->nextLight;
} }
dynlightindex = di->UploadLights(lightdata); dynlightindex = screen->mLights->UploadLights(lightdata);
} }

View file

@ -43,6 +43,7 @@
#include "hwrenderer/scene/hw_drawinfo.h" #include "hwrenderer/scene/hw_drawinfo.h"
#include "hwrenderer/scene/hw_drawstructs.h" #include "hwrenderer/scene/hw_drawstructs.h"
#include "hwrenderer/data/flatvertices.h" #include "hwrenderer/data/flatvertices.h"
#include "hwrenderer/dynlights/hw_lightbuffer.h"
#include "hw_renderstate.h" #include "hw_renderstate.h"
EXTERN_CVAR(Float, transsouls) EXTERN_CVAR(Float, transsouls)
@ -544,7 +545,7 @@ void HWDrawInfo::PreparePlayerSprites(sector_t * viewsector, area_t in_area)
else else
{ {
hw_GetDynModelLight(playermo, lightdata); hw_GetDynModelLight(playermo, lightdata);
hudsprite.lightindex = UploadLights(lightdata); hudsprite.lightindex = screen->mLights->UploadLights(lightdata);
} }
} }

View file

@ -55,6 +55,7 @@ class IVertexBuffer;
class IDataBuffer; class IDataBuffer;
class FFlatVertexBuffer; class FFlatVertexBuffer;
class GLViewpointBuffer; class GLViewpointBuffer;
class FLightBuffer;
enum EHWCaps enum EHWCaps
{ {
@ -380,6 +381,7 @@ public:
FSkyVertexBuffer *mSkyData = nullptr; // the sky vertex buffer FSkyVertexBuffer *mSkyData = nullptr; // the sky vertex buffer
FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data
GLViewpointBuffer *mViewpoints = nullptr; // Viewpoint render data. GLViewpointBuffer *mViewpoints = nullptr; // Viewpoint render data.
FLightBuffer *mLights = nullptr; // Dynamic lights
IntRect mScreenViewport; IntRect mScreenViewport;
IntRect mSceneViewport; IntRect mSceneViewport;