- CreateScene, too.

This commit is contained in:
Christoph Oelckers 2018-10-28 23:32:13 +01:00
parent 70f9507f16
commit 5528981a77
8 changed files with 60 additions and 62 deletions

View file

@ -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

View file

@ -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();
}
}

View file

@ -66,8 +66,6 @@ public:
FShadowMapShader *mShadowMapShader = nullptr;
FCustomPostProcessShaders *mCustomPostProcessShaders = nullptr;
IShadowMap mShadowMap;
//FRotator mAngles;
SWSceneDrawer *swdrawer = nullptr;

View file

@ -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

View file

@ -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

View file

@ -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);

View file

@ -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;

View file

@ -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;