From acb95056066e1277014acbc19a9b4e73ec69d566 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 20 Oct 2018 10:33:26 +0200 Subject: [PATCH] - fixed cherry-picked commit so that modern OpenGL can still do the light setup in the render pass. --- src/gl/scene/gl_flats.cpp | 13 ++++++++++--- src/hwrenderer/scene/hw_flats.cpp | 9 ++++++--- src/v_video.h | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index ca18a589ad..1d878bc64c 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -112,7 +112,14 @@ void FDrawInfo::DrawSubsectors(GLFlat *flat, int pass, bool processlights, bool gl_RenderState.Apply(); auto iboindex = flat->iboindex; - if (processlights) gl_RenderState.ApplyLightIndex(flat->dynlightindex); + if (processlights) + { + if (screen->hwcaps & RFL_BUFFER_STORAGE) + { + flat->SetupLights(this, flat->sector->lighthead, lightdata, flat->sector->PortalGroup); + } + gl_RenderState.ApplyLightIndex(flat->dynlightindex); + } if (iboindex >= 0) { @@ -215,13 +222,13 @@ void FDrawInfo::DrawFlat(GLFlat *flat, int pass, bool trans) // trans only has m { gl_RenderState.SetMaterial(flat->gltexture, CLAMP_NONE, 0, -1, false); gl_RenderState.SetPlaneTextureRotation(&plane, flat->gltexture); - DrawSubsectors(flat, pass, processLights && (gl.lightmethod == LM_DIRECT || flat->dynlightindex > -1), false); + DrawSubsectors(flat, pass, processLights, false); gl_RenderState.EnableTextureMatrix(false); } else { gl_RenderState.SetMaterial(flat->gltexture, CLAMP_XY, 0, -1, false); - DrawSkyboxSector(flat, pass, processLights && (gl.lightmethod == LM_DIRECT || flat->dynlightindex > -1)); + DrawSkyboxSector(flat, pass, processLights); } gl_RenderState.SetObjectColor(0xffffffff); break; diff --git a/src/hwrenderer/scene/hw_flats.cpp b/src/hwrenderer/scene/hw_flats.cpp index 33937f3909..0973b03146 100644 --- a/src/hwrenderer/scene/hw_flats.cpp +++ b/src/hwrenderer/scene/hw_flats.cpp @@ -139,6 +139,7 @@ void GLFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &light { Plane p; + lightdata.Clear(); if (renderstyle == STYLE_Add && !level.lightadditivesurfaces) { dynlightindex = -1; @@ -182,14 +183,16 @@ void GLFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &light inline void GLFlat::PutFlat(HWDrawInfo *di, bool fog) { - if (di->isFullbrightScene()) { Colormap.Clear(); } - else if (level.HasDynamicLights && gltexture != nullptr) + else if (!(screen->hwcaps & RFL_BUFFER_STORAGE)) { - SetupLights(di, sector->lighthead, lightdata, sector->PortalGroup); + if (level.HasDynamicLights && gltexture != nullptr) + { + SetupLights(di, sector->lighthead, lightdata, sector->PortalGroup); + } } di->AddFlat(this, fog); } diff --git a/src/v_video.h b/src/v_video.h index 72ae6e0a5c..6908dfd575 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -57,6 +57,7 @@ enum EHWCaps RFL_SHADER_STORAGE_BUFFER = 4, RFL_BUFFER_STORAGE = 8, + RFL_NO_LIGHT_PREGENERATE = 16, // delays dynamic light creation until the render pass. With modern OpenGL this is faster because it can make use of the CPU while the GPU is rendering. RFL_NO_CLIP_PLANES = 32,