From 5528981a7778033a5c72c83d6d4be6cb7cc95239 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 28 Oct 2018 23:32:13 +0100 Subject: [PATCH] - CreateScene, too. --- src/CMakeLists.txt | 1 - src/gl/renderer/gl_renderer.cpp | 4 +- src/gl/renderer/gl_renderer.h | 2 - src/gl/scene/gl_scene.cpp | 55 ------------------------- src/hwrenderer/scene/hw_drawinfo.cpp | 54 ++++++++++++++++++++++++ src/hwrenderer/scene/hw_drawinfo.h | 2 +- src/hwrenderer/scene/hw_spritelight.cpp | 2 +- src/v_video.h | 2 + 8 files changed, 60 insertions(+), 62 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6a945d6bb8..4973eb1c3a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -819,7 +819,6 @@ set( FASTMATH_SOURCES textures/hires/hqnx/hq4x.cpp textures/hires/xbr/xbrz.cpp textures/hires/xbr/xbrz_old.cpp - gl/scene/gl_drawinfo.cpp gl/scene/gl_scene.cpp gl_load/gl_load.c hwrenderer/postprocessing/hw_postprocess_cvars.cpp diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index 80cdc3dbc3..c5b35d8e51 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -186,7 +186,7 @@ void FGLRenderer::EndOffscreen() void FGLRenderer::UpdateShadowMap() { - if (mShadowMap.PerformUpdate()) + if (screen->mShadowMap.PerformUpdate()) { FGLDebug::PushGroup("ShadowMap"); @@ -206,7 +206,7 @@ void FGLRenderer::UpdateShadowMap() mBuffers->BindShadowMapTexture(16); FGLDebug::PopGroup(); - mShadowMap.FinishUpdate(); + screen->mShadowMap.FinishUpdate(); } } diff --git a/src/gl/renderer/gl_renderer.h b/src/gl/renderer/gl_renderer.h index fdd1a99e1f..f1a8f9003c 100644 --- a/src/gl/renderer/gl_renderer.h +++ b/src/gl/renderer/gl_renderer.h @@ -66,8 +66,6 @@ public: FShadowMapShader *mShadowMapShader = nullptr; FCustomPostProcessShaders *mCustomPostProcessShaders = nullptr; - IShadowMap mShadowMap; - //FRotator mAngles; SWSceneDrawer *swdrawer = nullptr; diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index a3bbcbdf86..6f1b561993 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -74,61 +74,6 @@ EXTERN_CVAR (Float, r_visibility) EXTERN_CVAR (Bool, r_drawvoxels) -//----------------------------------------------------------------------------- -// -// CreateScene -// -// creates the draw lists for the current scene -// -//----------------------------------------------------------------------------- - -void FDrawInfo::CreateScene() -{ - const auto &vp = Viewpoint; - angle_t a1 = FrustumAngle(); - mClipper->SafeAddClipRangeRealAngles(vp.Angles.Yaw.BAMs() + a1, vp.Angles.Yaw.BAMs() - a1); - - // reset the portal manager - screen->mPortalState->StartFrame(); - PO_LinkToSubsectors(); - - ProcessAll.Clock(); - - // clip the scene and fill the drawlists - Bsp.Clock(); - screen->mVertexData->Map(); - screen->mLights->Map(); - - // Give the DrawInfo the viewpoint in fixed point because that's what the nodes are. - viewx = FLOAT2FIXED(vp.Pos.X); - viewy = FLOAT2FIXED(vp.Pos.Y); - - validcount++; // used for processing sidedefs only once by the renderer. - - mShadowMap = &GLRenderer->mShadowMap; - - RenderBSPNode (level.HeadNode()); - PreparePlayerSprites(vp.sector, in_area); - - // Process all the sprites on the current portal's back side which touch the portal. - if (mCurrentPortal != nullptr) mCurrentPortal->RenderAttached(this); - Bsp.Unclock(); - - // And now the crappy hacks that have to be done to avoid rendering anomalies. - // These cannot be multithreaded when the time comes because all these depend - // on the global 'validcount' variable. - - HandleMissingTextures(in_area); // Missing upper/lower textures - HandleHackedSubsectors(); // open sector hacks for deep water - ProcessSectorStacks(in_area); // merge visplanes of sector stacks - PrepareUnhandledMissingTextures(); - screen->mLights->Unmap(); - screen->mVertexData->Unmap(); - - ProcessAll.Unclock(); - -} - //----------------------------------------------------------------------------- // // gl_drawscene - this function renders the scene from the current diff --git a/src/hwrenderer/scene/hw_drawinfo.cpp b/src/hwrenderer/scene/hw_drawinfo.cpp index f8d800cd87..752471d043 100644 --- a/src/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/hwrenderer/scene/hw_drawinfo.cpp @@ -34,6 +34,7 @@ #include "hw_portal.h" #include "hw_renderstate.h" #include "hw_drawinfo.h" +#include "po_man.h" #include "hwrenderer/utility/hw_clock.h" #include "hwrenderer/utility/hw_cvars.h" #include "hwrenderer/data/hw_viewpointbuffer.h" @@ -423,6 +424,59 @@ GLDecal *HWDrawInfo::AddDecal(bool onmirror) return decal; } +//----------------------------------------------------------------------------- +// +// CreateScene +// +// creates the draw lists for the current scene +// +//----------------------------------------------------------------------------- + +void HWDrawInfo::CreateScene() +{ + const auto &vp = Viewpoint; + angle_t a1 = FrustumAngle(); + mClipper->SafeAddClipRangeRealAngles(vp.Angles.Yaw.BAMs() + a1, vp.Angles.Yaw.BAMs() - a1); + + // reset the portal manager + screen->mPortalState->StartFrame(); + PO_LinkToSubsectors(); + + ProcessAll.Clock(); + + // clip the scene and fill the drawlists + Bsp.Clock(); + screen->mVertexData->Map(); + screen->mLights->Map(); + + // Give the DrawInfo the viewpoint in fixed point because that's what the nodes are. + viewx = FLOAT2FIXED(vp.Pos.X); + viewy = FLOAT2FIXED(vp.Pos.Y); + + validcount++; // used for processing sidedefs only once by the renderer. + + RenderBSPNode(level.HeadNode()); + PreparePlayerSprites(vp.sector, in_area); + + // Process all the sprites on the current portal's back side which touch the portal. + if (mCurrentPortal != nullptr) mCurrentPortal->RenderAttached(this); + Bsp.Unclock(); + + // And now the crappy hacks that have to be done to avoid rendering anomalies. + // These cannot be multithreaded when the time comes because all these depend + // on the global 'validcount' variable. + + HandleMissingTextures(in_area); // Missing upper/lower textures + HandleHackedSubsectors(); // open sector hacks for deep water + ProcessSectorStacks(in_area); // merge visplanes of sector stacks + PrepareUnhandledMissingTextures(); + screen->mLights->Unmap(); + screen->mVertexData->Unmap(); + + ProcessAll.Unclock(); + +} + //----------------------------------------------------------------------------- // // RenderScene diff --git a/src/hwrenderer/scene/hw_drawinfo.h b/src/hwrenderer/scene/hw_drawinfo.h index fcc7d3f033..10d1d28c3e 100644 --- a/src/hwrenderer/scene/hw_drawinfo.h +++ b/src/hwrenderer/scene/hw_drawinfo.h @@ -184,7 +184,6 @@ struct HWDrawInfo HWScenePortalBase *mClipPortal; HWPortal *mCurrentPortal; //FRotator mAngles; - IShadowMap *mShadowMap; Clipper *mClipper; FRenderViewpoint Viewpoint; HWViewpointUniforms VPUniforms; // per-viewpoint uniform state @@ -305,6 +304,7 @@ public: void SetViewArea(); int SetFullbrightFlags(player_t *player); + void CreateScene(); void RenderScene(FRenderState &state); void RenderTranslucent(FRenderState &state); void RenderPortal(HWPortal *p, FRenderState &state, bool usestencil); diff --git a/src/hwrenderer/scene/hw_spritelight.cpp b/src/hwrenderer/scene/hw_spritelight.cpp index 6b55f67cea..9ce11f8595 100644 --- a/src/hwrenderer/scene/hw_spritelight.cpp +++ b/src/hwrenderer/scene/hw_spritelight.cpp @@ -103,7 +103,7 @@ void HWDrawInfo::GetDynSpriteLight(AActor *self, float x, float y, float z, FLig frac *= (float)smoothstep(light->SpotOuterAngle.Cos(), light->SpotInnerAngle.Cos(), cosDir); } - if (frac > 0 && (!light->shadowmapped || mShadowMap->ShadowTest(light, { x, y, z }))) + if (frac > 0 && (!light->shadowmapped || screen->mShadowMap.ShadowTest(light, { x, y, z }))) { lr = light->GetRed() / 255.0f; lg = light->GetGreen() / 255.0f; diff --git a/src/v_video.h b/src/v_video.h index 7580aae991..fffe8c0063 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -44,6 +44,7 @@ #include "c_cvars.h" #include "v_colortables.h" #include "v_2ddrawer.h" +#include "hwrenderer/dynlights/hw_shadowmap.h" struct sector_t; class IShaderProgram; @@ -383,6 +384,7 @@ public: FFlatVertexBuffer *mVertexData = nullptr; // Global vertex data GLViewpointBuffer *mViewpoints = nullptr; // Viewpoint render data. FLightBuffer *mLights = nullptr; // Dynamic lights + IShadowMap mShadowMap; IntRect mScreenViewport; IntRect mSceneViewport;