mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 00:20:38 +00:00
- moved the global 'no dynamic lights' variable to FLevelLocals so that it is outside renderer specific data.
This commit is contained in:
parent
583da7f6cf
commit
43b491ea33
11 changed files with 25 additions and 27 deletions
|
@ -79,6 +79,7 @@
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "v_text.h"
|
#include "v_text.h"
|
||||||
#include "gi.h"
|
#include "gi.h"
|
||||||
|
#include "a_dynlight.h"
|
||||||
#include "gameconfigfile.h"
|
#include "gameconfigfile.h"
|
||||||
#include "sbar.h"
|
#include "sbar.h"
|
||||||
#include "decallib.h"
|
#include "decallib.h"
|
||||||
|
@ -776,6 +777,15 @@ void D_Display ()
|
||||||
// [ZZ] execute event hook that we just started the frame
|
// [ZZ] execute event hook that we just started the frame
|
||||||
//E_RenderFrame();
|
//E_RenderFrame();
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// Check for the presence of dynamic lights at the start of the frame once.
|
||||||
|
if (gl_lights)
|
||||||
|
{
|
||||||
|
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
||||||
|
level.HasDynamicLights = !!it.Next();
|
||||||
|
}
|
||||||
|
else level.HasDynamicLights = false; // lights are off so effectively we have none.
|
||||||
|
|
||||||
screen->RenderView(&players[consoleplayer]);
|
screen->RenderView(&players[consoleplayer]);
|
||||||
screen->Begin2D(false);
|
screen->Begin2D(false);
|
||||||
// returns with 2S mode set.
|
// returns with 2S mode set.
|
||||||
|
|
|
@ -152,6 +152,7 @@ struct FLevelLocals
|
||||||
|
|
||||||
bool FromSnapshot; // The current map was restored from a snapshot
|
bool FromSnapshot; // The current map was restored from a snapshot
|
||||||
bool HasHeightSecs; // true if some Transfer_Heights effects are present in the map. If this is false, some checks in the renderer can be shortcut.
|
bool HasHeightSecs; // true if some Transfer_Heights effects are present in the map. If this is false, some checks in the renderer can be shortcut.
|
||||||
|
bool HasDynamicLights; // Another render optimization for maps with no lights at all.
|
||||||
|
|
||||||
double teamdamage;
|
double teamdamage;
|
||||||
|
|
||||||
|
|
|
@ -881,7 +881,7 @@ void GLSceneDrawer::RenderMultipassStuff()
|
||||||
|
|
||||||
// second pass: draw lights
|
// second pass: draw lights
|
||||||
glDepthMask(false);
|
glDepthMask(false);
|
||||||
if (GLRenderer->mLightCount && !FixedColormap)
|
if (level.HasDynamicLights && !FixedColormap)
|
||||||
{
|
{
|
||||||
if (gl_SetupLightTexture())
|
if (gl_SetupLightTexture())
|
||||||
{
|
{
|
||||||
|
|
|
@ -90,7 +90,6 @@ FGLRenderer::FGLRenderer(OpenGLFrameBuffer *fb)
|
||||||
mCurrentPortal = nullptr;
|
mCurrentPortal = nullptr;
|
||||||
mMirrorCount = 0;
|
mMirrorCount = 0;
|
||||||
mPlaneMirrorCount = 0;
|
mPlaneMirrorCount = 0;
|
||||||
mLightCount = 0;
|
|
||||||
mAngles = FRotator(0.f, 0.f, 0.f);
|
mAngles = FRotator(0.f, 0.f, 0.f);
|
||||||
mViewVector = FVector2(0,0);
|
mViewVector = FVector2(0,0);
|
||||||
mVBO = nullptr;
|
mVBO = nullptr;
|
||||||
|
@ -446,9 +445,6 @@ void FGLRenderer::RenderView(player_t* player)
|
||||||
{
|
{
|
||||||
fovratio = ratio;
|
fovratio = ratio;
|
||||||
}
|
}
|
||||||
// Check if there's some lights. If not some code can be skipped.
|
|
||||||
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
|
||||||
mLightCount = ((it.Next()) != NULL);
|
|
||||||
|
|
||||||
GLSceneDrawer drawer;
|
GLSceneDrawer drawer;
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,6 @@ public:
|
||||||
GLPortal *mCurrentPortal;
|
GLPortal *mCurrentPortal;
|
||||||
int mMirrorCount;
|
int mMirrorCount;
|
||||||
int mPlaneMirrorCount;
|
int mPlaneMirrorCount;
|
||||||
int mLightCount;
|
|
||||||
float mCurrentFoV;
|
float mCurrentFoV;
|
||||||
AActor *mViewActor;
|
AActor *mViewActor;
|
||||||
FShaderManager *mShaderManager;
|
FShaderManager *mShaderManager;
|
||||||
|
|
|
@ -311,8 +311,7 @@ void GLSceneDrawer::RenderScene(int recursion)
|
||||||
|
|
||||||
// if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front,
|
// if we don't have a persistently mapped buffer, we have to process all the dynamic lights up front,
|
||||||
// so that we don't have to do repeated map/unmap calls on the buffer.
|
// so that we don't have to do repeated map/unmap calls on the buffer.
|
||||||
bool haslights = GLRenderer->mLightCount > 0 && FixedColormap == CM_DEFAULT && gl_lights;
|
if (gl.lightmethod == LM_DEFERRED && level.HasDynamicLights && FixedColormap == CM_DEFAULT)
|
||||||
if (gl.lightmethod == LM_DEFERRED && haslights)
|
|
||||||
{
|
{
|
||||||
GLRenderer->mLights->Begin();
|
GLRenderer->mLights->Begin();
|
||||||
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(gl_drawinfo, GLPASS_LIGHTSONLY);
|
gl_drawinfo->drawlists[GLDL_PLAINFLATS].DrawFlats(gl_drawinfo, GLPASS_LIGHTSONLY);
|
||||||
|
@ -329,21 +328,17 @@ void GLSceneDrawer::RenderScene(int recursion)
|
||||||
|
|
||||||
int pass;
|
int pass;
|
||||||
|
|
||||||
if (!haslights || gl.lightmethod == LM_DEFERRED)
|
if (!level.HasDynamicLights || !gl.legacyMode)
|
||||||
{
|
|
||||||
pass = GLPASS_PLAIN;
|
|
||||||
}
|
|
||||||
else if (gl.lightmethod == LM_DIRECT)
|
|
||||||
{
|
{
|
||||||
pass = GLPASS_ALL;
|
pass = GLPASS_ALL;
|
||||||
}
|
}
|
||||||
else // GL 2.x legacy mode
|
else // GL 2.x legacy mode
|
||||||
{
|
{
|
||||||
// process everything that needs to handle textured dynamic lights.
|
// process everything that needs to handle textured dynamic lights.
|
||||||
if (haslights) RenderMultipassStuff();
|
if (level.HasDynamicLights) RenderMultipassStuff();
|
||||||
|
|
||||||
// The remaining lists which are unaffected by dynamic lights are just processed as normal.
|
// The remaining lists which are unaffected by dynamic lights are just processed as normal.
|
||||||
pass = GLPASS_PLAIN;
|
pass = GLPASS_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_RenderState.EnableTexture(gl_texture);
|
gl_RenderState.EnableTexture(gl_texture);
|
||||||
|
@ -773,10 +768,6 @@ void GLSceneDrawer::WriteSavePic (player_t *player, FileWriter *file, int width,
|
||||||
GLRenderer->mVBO->Reset();
|
GLRenderer->mVBO->Reset();
|
||||||
if (!gl.legacyMode) GLRenderer->mLights->Clear();
|
if (!gl.legacyMode) GLRenderer->mLights->Clear();
|
||||||
|
|
||||||
// Check if there's some lights. If not some code can be skipped.
|
|
||||||
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
|
||||||
GLRenderer->mLightCount = ((it.Next()) != NULL);
|
|
||||||
|
|
||||||
sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds,
|
sector_t *viewsector = RenderViewpoint(players[consoleplayer].camera, &bounds,
|
||||||
r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
r_viewpoint.FieldOfView.Degrees, 1.6f, 1.6f, true, false);
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
|
|
|
@ -144,7 +144,7 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
||||||
}
|
}
|
||||||
if (RenderStyle.BlendOp != STYLEOP_Shadow)
|
if (RenderStyle.BlendOp != STYLEOP_Shadow)
|
||||||
{
|
{
|
||||||
if (gl_lights && GLRenderer->mLightCount && mDrawer->FixedColormap == CM_DEFAULT && !sprite->fullbright)
|
if (level.HasDynamicLights && mDrawer->FixedColormap == CM_DEFAULT && !sprite->fullbright)
|
||||||
{
|
{
|
||||||
if ( sprite->dynlightindex == -1) // only set if we got no light buffer index. This covers all cases where sprite lighting is used.
|
if ( sprite->dynlightindex == -1) // only set if we got no light buffer index. This covers all cases where sprite lighting is used.
|
||||||
{
|
{
|
||||||
|
@ -328,7 +328,7 @@ void FDrawInfo::AddSprite(GLSprite *sprite, bool translucent)
|
||||||
}
|
}
|
||||||
|
|
||||||
// That's a lot of checks...
|
// That's a lot of checks...
|
||||||
if (sprite->modelframe && sprite->RenderStyle.BlendOp != STYLEOP_Shadow && gl_lights && gl_light_sprites && GLRenderer->mLightCount && mDrawer->FixedColormap == CM_DEFAULT && !sprite->fullbright && !gl.legacyMode)
|
if (sprite->modelframe && sprite->RenderStyle.BlendOp != STYLEOP_Shadow && level.HasDynamicLights && gl_light_sprites && mDrawer->FixedColormap == CM_DEFAULT && !sprite->fullbright && !gl.legacyMode)
|
||||||
{
|
{
|
||||||
hw_GetDynModelLight(sprite->actor, lightdata);
|
hw_GetDynModelLight(sprite->actor, lightdata);
|
||||||
sprite->dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
sprite->dynlightindex = GLRenderer->mLights->UploadLights(lightdata);
|
||||||
|
|
|
@ -42,9 +42,6 @@
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, gl_seamless)
|
EXTERN_CVAR(Bool, gl_seamless)
|
||||||
|
|
||||||
// If we want to share the array to avoid constant allocations it needs to be thread local unless it'd be littered with expensive synchronization.
|
|
||||||
thread_local FDynLightData lightdata;
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// General purpose wall rendering function
|
// General purpose wall rendering function
|
||||||
|
@ -473,7 +470,7 @@ void FDrawInfo::DrawDecal(GLDecal *gldecal)
|
||||||
auto &seg = wall->seg;
|
auto &seg = wall->seg;
|
||||||
|
|
||||||
// calculate dynamic light effect.
|
// calculate dynamic light effect.
|
||||||
if (gl_lights && GLRenderer->mLightCount && !mDrawer->FixedColormap && gl_light_sprites)
|
if (level.HasDynamicLights && !mDrawer->FixedColormap && gl_light_sprites)
|
||||||
{
|
{
|
||||||
// Note: This should be replaced with proper shader based lighting.
|
// Note: This should be replaced with proper shader based lighting.
|
||||||
double x, y;
|
double x, y;
|
||||||
|
|
|
@ -99,7 +99,7 @@ void GLSceneDrawer::SetupWeaponLight()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Check if lighting can be used on this item.
|
// Check if lighting can be used on this item.
|
||||||
if (camera->RenderStyle.BlendOp == STYLEOP_Shadow || !gl_lights || !gl_light_sprites || !GLRenderer->mLightCount || FixedColormap != CM_DEFAULT || gl.legacyMode)
|
if (camera->RenderStyle.BlendOp == STYLEOP_Shadow || !level.HasDynamicLights || !gl_light_sprites || FixedColormap != CM_DEFAULT || gl.legacyMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
|
for (DPSprite *psp = player->psprites; psp != nullptr && psp->GetID() < PSP_TARGETCENTER; psp = psp->GetNext())
|
||||||
|
@ -179,7 +179,7 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gl_lights && GLRenderer->mLightCount && FixedColormap == CM_DEFAULT && gl_light_sprites)
|
if (level.HasDynamicLights && FixedColormap == CM_DEFAULT && gl_light_sprites)
|
||||||
{
|
{
|
||||||
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false) : nullptr;
|
FSpriteModelFrame *smf = playermo->player->ReadyWeapon ? gl_FindModelFrame(playermo->player->ReadyWeapon->GetClass(), psp->GetState()->sprite, psp->GetState()->GetFrame(), false) : nullptr;
|
||||||
if (!smf || gl.legacyMode) // For models with per-pixel lighting this was done in a previous pass.
|
if (!smf || gl.legacyMode) // For models with per-pixel lighting this was done in a previous pass.
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
#include "hw_dynlightdata.h"
|
#include "hw_dynlightdata.h"
|
||||||
|
|
||||||
|
// If we want to share the array to avoid constant allocations it needs to be thread local unless it'd be littered with expensive synchronization.
|
||||||
|
thread_local FDynLightData lightdata;
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
|
|
|
@ -58,5 +58,7 @@ struct FDynLightData
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern thread_local FDynLightData lightdata;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue