Merge remote-tracking branch 'gz/master' into thereisnospoon

This commit is contained in:
ZZYZX 2017-01-28 05:23:16 +02:00
commit 2c314f3f3f
19 changed files with 628 additions and 386 deletions

View file

@ -2522,6 +2522,9 @@ void D_DoomMain (void)
// Create replacements for dehacked pickups // Create replacements for dehacked pickups
FinishDehPatch(); FinishDehPatch();
// clean up the compiler symbols which are not needed any longer.
RemoveUnusedSymbols();
InitActorNumsFromMapinfo(); InitActorNumsFromMapinfo();
InitSpawnablesFromMapinfo(); InitSpawnablesFromMapinfo();
PClassActor::StaticSetActorNums(); PClassActor::StaticSetActorNums();

View file

@ -3898,3 +3898,45 @@ void FNamespaceManager::ReleaseSymbols()
GlobalNamespace = nullptr; GlobalNamespace = nullptr;
AllNamespaces.Clear(); AllNamespaces.Clear();
} }
// removes all symbols from the symbol tables.
// After running the compiler these are not needed anymore.
// Only the namespaces themselves are kept because the type table references them.
int FNamespaceManager::RemoveSymbols()
{
int count = 0;
for (auto ns : AllNamespaces)
{
count += ns->Symbols.Symbols.CountUsed();
ns->Symbols.ReleaseSymbols();
}
return count;
}
void RemoveUnusedSymbols()
{
// Global symbols are not needed anymore after running the compiler.
int count = Namespaces.RemoveSymbols();
// We do not need any non-field and non-function symbols in structs and classes anymore.
for (size_t i = 0; i < countof(TypeTable.TypeHash); ++i)
{
for (PType *ty = TypeTable.TypeHash[i]; ty != NULL; ty = ty->HashNext)
{
if (ty->IsKindOf(RUNTIME_CLASS(PStruct)))
{
auto it = ty->Symbols.GetIterator();
PSymbolTable::MapType::Pair *pair;
while (it.NextPair(pair))
{
if (!pair->Value->IsKindOf(RUNTIME_CLASS(PField)) && !pair->Value->IsKindOf(RUNTIME_CLASS(PFunction)))
{
ty->Symbols.RemoveSymbol(pair->Value);
count++;
}
}
}
}
}
DPrintf(DMSG_SPAMMY, "%d symbols removed after compilation\n", count);
}

View file

@ -76,6 +76,7 @@ class VMFrameStack;
struct VMValue; struct VMValue;
struct VMReturn; struct VMReturn;
class VMFunction; class VMFunction;
struct FNamespaceManager;
// A VM function ------------------------------------------------------------ // A VM function ------------------------------------------------------------
@ -157,6 +158,7 @@ private:
MapType Symbols; MapType Symbols;
friend class DObject; friend class DObject;
friend struct FNamespaceManager;
}; };
// A symbol for a compiler tree node ---------------------------------------- // A symbol for a compiler tree node ----------------------------------------
@ -1010,6 +1012,7 @@ struct FNamespaceManager
PNamespace *NewNamespace(int filenum); PNamespace *NewNamespace(int filenum);
size_t MarkSymbols(); size_t MarkSymbols();
void ReleaseSymbols(); void ReleaseSymbols();
int RemoveSymbols();
}; };
extern FNamespaceManager Namespaces; extern FNamespaceManager Namespaces;
@ -1047,4 +1050,7 @@ inline T *&DObject::PointerVar(FName field)
{ {
return *(T**)ScriptVar(field, nullptr); // pointer check is more tricky and for the handful of uses in the DECORATE parser not worth the hassle. return *(T**)ScriptVar(field, nullptr); // pointer check is more tricky and for the handful of uses in the DECORATE parser not worth the hassle.
} }
void RemoveUnusedSymbols();
#endif #endif

View file

@ -142,21 +142,25 @@ void DCorpsePointer::OnDestroy ()
TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER); TThinkerIterator<DCorpsePointer> iterator (STAT_CORPSEPOINTER);
DCorpsePointer *first = iterator.Next (); DCorpsePointer *first = iterator.Next ();
int prevCount = first->Count; // During a serialization unwind the thinker list won't be available.
if (first != nullptr)
if (first == this)
{ {
first = iterator.Next (); int prevCount = first->Count;
}
if (first != NULL) if (first == this)
{ {
first->Count = prevCount - 1; first = iterator.Next();
} }
if (first != NULL)
{
first->Count = prevCount - 1;
}
}
if (Corpse != NULL) if (Corpse != NULL)
{ {
Corpse->Destroy (); Corpse->Destroy();
} }
Super::OnDestroy(); Super::OnDestroy();
} }

View file

@ -133,6 +133,17 @@ CUSTOM_CVAR(Float, gl_ssao_exponent, 1.8f, 0)
if (self < 0.1f) self = 0.1f; if (self < 0.1f) self = 0.1f;
} }
CUSTOM_CVAR(Float, gl_paltonemap_powtable, 2.0f, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
GLRenderer->ClearTonemapPalette();
}
CUSTOM_CVAR(Bool, gl_paltonemap_reverselookup, true, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
GLRenderer->ClearTonemapPalette();
}
EXTERN_CVAR(Float, vid_brightness) EXTERN_CVAR(Float, vid_brightness)
EXTERN_CVAR(Float, vid_contrast) EXTERN_CVAR(Float, vid_contrast)
@ -533,8 +544,11 @@ void FGLRenderer::CreateTonemapPalette()
void FGLRenderer::ClearTonemapPalette() void FGLRenderer::ClearTonemapPalette()
{ {
delete mTonemapPalette; if (mTonemapPalette)
mTonemapPalette = nullptr; {
delete mTonemapPalette;
mTonemapPalette = nullptr;
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -821,14 +835,16 @@ int FGLRenderer::PTM_BestColor (const uint32 *pal_in, int r, int g, int b, int f
const PalEntry *pal = (const PalEntry *)pal_in; const PalEntry *pal = (const PalEntry *)pal_in;
static double powtable[256]; static double powtable[256];
static bool firstTime = true; static bool firstTime = true;
static float trackpowtable = 0.;
double fbestdist, fdist; double fbestdist, fdist;
int bestcolor; int bestcolor;
if (firstTime) if (firstTime || trackpowtable != gl_paltonemap_powtable)
{ {
trackpowtable = gl_paltonemap_powtable;
firstTime = false; firstTime = false;
for (int x = 0; x < 256; x++) powtable[x] = pow((double)x/255,1.2); for (int x = 0; x < 256; x++) powtable[x] = pow((double)x/255, (double)gl_paltonemap_powtable);
} }
for (int color = first; color < num; color++) for (int color = first; color < num; color++)
@ -837,9 +853,9 @@ int FGLRenderer::PTM_BestColor (const uint32 *pal_in, int r, int g, int b, int f
double y = powtable[abs(g-pal[color].g)]; double y = powtable[abs(g-pal[color].g)];
double z = powtable[abs(b-pal[color].b)]; double z = powtable[abs(b-pal[color].b)];
fdist = x + y + z; fdist = x + y + z;
if (color == first || fdist < fbestdist) if (color == first || ((gl_paltonemap_reverselookup)?(fdist <= fbestdist):(fdist < fbestdist)))
{ {
if (fdist == 0) if (fdist == 0 && !gl_paltonemap_reverselookup)
return color; return color;
fbestdist = fdist; fbestdist = fdist;

View file

@ -43,6 +43,7 @@ void gl_SetTextureMode(int type);
FRenderState gl_RenderState; FRenderState gl_RenderState;
CVAR(Bool, gl_direct_state_change, true, 0) CVAR(Bool, gl_direct_state_change, true, 0)
CVAR(Bool, gl_bandedswlight, false, CVAR_ARCHIVE)
static VSMatrix identityMatrix(1); static VSMatrix identityMatrix(1);
@ -146,6 +147,7 @@ bool FRenderState::ApplyShader()
activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muDesaturation.Set(mDesaturation / 255.f);
activeShader->muFogEnabled.Set(fogset); activeShader->muFogEnabled.Set(fogset);
activeShader->muPalLightLevels.Set(gl_bandedswlight);
activeShader->muTextureMode.Set(mTextureMode); activeShader->muTextureMode.Set(mTextureMode);
activeShader->muCameraPos.Set(mCameraPos.vec); activeShader->muCameraPos.Set(mCameraPos.vec);
activeShader->muLightParms.Set(mLightParms); activeShader->muLightParms.Set(mLightParms);

View file

@ -214,6 +214,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
muDesaturation.Init(hShader, "uDesaturationFactor"); muDesaturation.Init(hShader, "uDesaturationFactor");
muFogEnabled.Init(hShader, "uFogEnabled"); muFogEnabled.Init(hShader, "uFogEnabled");
muPalLightLevels.Init(hShader, "uPalLightLevels");
muTextureMode.Init(hShader, "uTextureMode"); muTextureMode.Init(hShader, "uTextureMode");
muCameraPos.Init(hShader, "uCameraPos"); muCameraPos.Init(hShader, "uCameraPos");
muLightParms.Init(hShader, "uLightAttr"); muLightParms.Init(hShader, "uLightAttr");

View file

@ -259,6 +259,7 @@ class FShader
FBufferedUniform1f muDesaturation; FBufferedUniform1f muDesaturation;
FBufferedUniform1i muFogEnabled; FBufferedUniform1i muFogEnabled;
FBufferedUniform1i muPalLightLevels;
FBufferedUniform1i muTextureMode; FBufferedUniform1i muTextureMode;
FBufferedUniform4f muCameraPos; FBufferedUniform4f muCameraPos;
FBufferedUniform4f muLightParms; FBufferedUniform4f muLightParms;

View file

@ -156,6 +156,7 @@ FRandom::FRandom ()
#endif #endif
Next = RNGList; Next = RNGList;
RNGList = this; RNGList = this;
Init(0);
} }
//========================================================================== //==========================================================================
@ -199,6 +200,7 @@ FRandom::FRandom (const char *name)
Next = probe; Next = probe;
*prev = this; *prev = this;
Init(0);
} }
//========================================================================== //==========================================================================

View file

@ -9716,7 +9716,16 @@ scriptwait:
if (runaway != 0 && InModuleScriptNumber >= 0) if (runaway != 0 && InModuleScriptNumber >= 0)
{ {
activeBehavior->GetScriptPtr(InModuleScriptNumber)->ProfileData.AddRun(runaway); auto scriptptr = activeBehavior->GetScriptPtr(InModuleScriptNumber);
if (scriptptr != nullptr)
{
scriptptr->ProfileData.AddRun(runaway);
}
else
{
// It is pointless to continue execution. The script is broken and needs to be aborted.
I_Error("Bad script definition encountered. Script %d is reported running but not present.\nThe most likely cause for this message is using 'delay' inside a function which is not supported.\nPlease check the ACS compiler used for compiling the script!", InModuleScriptNumber);
}
} }
if (state == SCRIPT_DivideBy0) if (state == SCRIPT_DivideBy0)

View file

@ -3532,7 +3532,14 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
|| ((mo->flags6 & MF6_NOBOSSRIP) && (BlockingMobj->flags2 & MF2_BOSS))) && (BlockingMobj->flags2 & MF2_REFLECTIVE)) || ((mo->flags6 & MF6_NOBOSSRIP) && (BlockingMobj->flags2 & MF2_BOSS))) && (BlockingMobj->flags2 & MF2_REFLECTIVE))
|| ((BlockingMobj->player == NULL) && (!(BlockingMobj->flags3 & MF3_ISMONSTER))))) || ((BlockingMobj->player == NULL) && (!(BlockingMobj->flags3 & MF3_ISMONSTER)))))
{ {
if (mo->bouncecount > 0 && --mo->bouncecount == 0) return false; if (mo->bouncecount>0 && --mo->bouncecount == 0)
{
if (mo->flags & MF_MISSILE)
P_ExplodeMissile(mo, nullptr, BlockingMobj);
else
mo->CallDie(BlockingMobj, nullptr);
return true;
}
if (mo->flags7 & MF7_HITTARGET) mo->target = BlockingMobj; if (mo->flags7 & MF7_HITTARGET) mo->target = BlockingMobj;
if (mo->flags7 & MF7_HITMASTER) mo->master = BlockingMobj; if (mo->flags7 & MF7_HITMASTER) mo->master = BlockingMobj;

View file

@ -1814,15 +1814,18 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target)
mo->effects = 0; // [RH] mo->effects = 0; // [RH]
mo->flags &= ~MF_SHOOTABLE; mo->flags &= ~MF_SHOOTABLE;
FState *nextstate=NULL; FState *nextstate = nullptr;
if (target != NULL && ((target->flags & (MF_SHOOTABLE|MF_CORPSE)) || (target->flags6 & MF6_KILLED)) ) if (target != nullptr)
{ {
if (mo->flags7 & MF7_HITTARGET) mo->target = target; if (mo->flags7 & MF7_HITTARGET) mo->target = target;
if (mo->flags7 & MF7_HITMASTER) mo->master = target; if (mo->flags7 & MF7_HITMASTER) mo->master = target;
if (mo->flags7 & MF7_HITTRACER) mo->tracer = target; if (mo->flags7 & MF7_HITTRACER) mo->tracer = target;
if (target->flags & MF_NOBLOOD) nextstate = mo->FindState(NAME_Crash); if ((target->flags & (MF_SHOOTABLE | MF_CORPSE)) || (target->flags6 & MF6_KILLED))
if (nextstate == NULL) nextstate = mo->FindState(NAME_Death, NAME_Extreme); {
if (target->flags & MF_NOBLOOD) nextstate = mo->FindState(NAME_Crash);
if (nextstate == NULL) nextstate = mo->FindState(NAME_Death, NAME_Extreme);
}
} }
if (nextstate == NULL) nextstate = mo->FindState(NAME_Death); if (nextstate == NULL) nextstate = mo->FindState(NAME_Death);

View file

@ -63,7 +63,7 @@ static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool
if (frame >= MAX_SPRITE_FRAMES || rotation > 16) if (frame >= MAX_SPRITE_FRAMES || rotation > 16)
{ {
Printf (TEXTCOLOR_RED"R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan[lump]->Name.GetChars()); Printf (TEXTCOLOR_RED "R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan[lump]->Name.GetChars());
return false; return false;
} }

View file

@ -1217,9 +1217,8 @@ static void ParseDamageDefinition(FScanner &sc)
// //
//========================================================================== //==========================================================================
void ParseDecorate (FScanner &sc) void ParseDecorate (FScanner &sc, PNamespace *ns)
{ {
auto ns = Namespaces.NewNamespace(sc.LumpNum);
// Get actor class name. // Get actor class name.
for(;;) for(;;)
{ {
@ -1245,7 +1244,7 @@ void ParseDecorate (FScanner &sc)
} }
FScanner newscanner; FScanner newscanner;
newscanner.Open(sc.String); newscanner.Open(sc.String);
ParseDecorate(newscanner); ParseDecorate(newscanner, ns);
break; break;
} }
@ -1308,6 +1307,7 @@ void ParseAllDecorate()
while ((lump = Wads.FindLump("DECORATE", &lastlump)) != -1) while ((lump = Wads.FindLump("DECORATE", &lastlump)) != -1)
{ {
FScanner sc(lump); FScanner sc(lump);
ParseDecorate(sc); auto ns = Namespaces.NewNamespace(sc.LumpNum);
ParseDecorate(sc, ns);
} }
} }

View file

@ -2645,6 +2645,9 @@ GLPREFMNU_LENS = "Lens distortion effect";
GLPREFMNU_SSAO = "Ambient occlusion quality"; GLPREFMNU_SSAO = "Ambient occlusion quality";
GLPREFMNU_SSAO_PORTALS = "Portals with AO"; GLPREFMNU_SSAO_PORTALS = "Portals with AO";
GLPREFMNU_FXAA = "FXAA Quality"; GLPREFMNU_FXAA = "FXAA Quality";
GLPREFMNU_PALTONEMAPORDER = "Tonemap Palette Order";
GLPREFMNU_PALTONEMAPPOWER = "Tonemap Palette Exponent";
GLPREFMNU_SWLMBANDED = "Banded SW Lightmode";
// Option Values // Option Values
OPTVAL_SMART = "Smart"; OPTVAL_SMART = "Smart";
@ -2728,3 +2731,5 @@ OPTVAL_LOW = "Low";
OPTVAL_MEDIUM = "Medium"; OPTVAL_MEDIUM = "Medium";
OPTVAL_HIGH = "High"; OPTVAL_HIGH = "High";
OPTVAL_EXTREME = "Extreme"; OPTVAL_EXTREME = "Extreme";
OPTVAL_OBVERSEFIRST = "Obverse";
OPTVAL_REVERSEFIRST = "Reverse";

View file

@ -1,3 +1,9 @@
OptionValue "LookupOrder"
{
0, "$OPTVAL_OBVERSEFIRST"
1, "$OPTVAL_REVERSEFIRST"
}
OptionValue "SpriteclipModes" OptionValue "SpriteclipModes"
{ {
0, "$OPTVAL_NEVER" 0, "$OPTVAL_NEVER"
@ -226,6 +232,7 @@ OptionMenu "GLPrefOptions"
{ {
Title "$GLPREFMNU_TITLE" Title "$GLPREFMNU_TITLE"
Option "$GLPREFMNU_SECLIGHTMODE", gl_lightmode, "LightingModes" Option "$GLPREFMNU_SECLIGHTMODE", gl_lightmode, "LightingModes"
Option "$GLPREFMNU_SWLMBANDED", gl_bandedswlight, "OnOff"
Option "$GLPREFMNU_FOGMODE", gl_fogmode, "FogMode" Option "$GLPREFMNU_FOGMODE", gl_fogmode, "FogMode"
Option "$GLPREFMNU_FOGFORCEFULLBRIGHT", gl_brightfog, "YesNo" Option "$GLPREFMNU_FOGFORCEFULLBRIGHT", gl_brightfog, "YesNo"
Slider "$GLPREFMNU_WPNLIGHTSTR", gl_weaponlight, 0,32, 2 Slider "$GLPREFMNU_WPNLIGHTSTR", gl_weaponlight, 0,32, 2
@ -249,4 +256,7 @@ OptionMenu "GLPrefOptions"
Option "$GLPREFMNU_SSAO", gl_ssao, "SSAOModes" Option "$GLPREFMNU_SSAO", gl_ssao, "SSAOModes"
Slider "$GLPREFMNU_SSAO_PORTALS", gl_ssao_portals, 0.0, 4.0, 1.0, 0 Slider "$GLPREFMNU_SSAO_PORTALS", gl_ssao_portals, 0.0, 4.0, 1.0, 0
Option "$GLPREFMNU_FXAA", gl_fxaa, "FXAAQuality" Option "$GLPREFMNU_FXAA", gl_fxaa, "FXAAQuality"
StaticText " "
Slider "$GLPREFMNU_PALTONEMAPPOWER", gl_paltonemap_powtable, 0.2, 3.0, 0.1, 1
Option "$GLPREFMNU_PALTONEMAPORDER", gl_paltonemap_reverselookup, "LookupOrder"
} }

View file

@ -121,7 +121,11 @@ float R_DoomLightingEquation(float light)
/* The zdoom light equation */ /* The zdoom light equation */
float vis = globVis / z; float vis = globVis / z;
float shade = 64.0 - (L + 12.0) * 32.0/128.0; float shade = 64.0 - (L + 12.0) * 32.0/128.0;
float lightscale = clamp((shade - min(24.0, vis)) / 32.0, 0.0, 31.0/32.0); float lightscale;
if (uPalLightLevels != 0)
lightscale = clamp(float(int(shade - min(24.0, vis))) / 32.0, 0.0, 31.0/32.0);
else
lightscale = clamp((shade - min(24.0, vis)) / 32.0, 0.0, 31.0/32.0);
// Result is the normalized colormap index (0 bright .. 1 dark) // Result is the normalized colormap index (0 bright .. 1 dark)
return lightscale; return lightscale;

View file

@ -41,6 +41,7 @@ uniform vec4 uLightAttr;
#define uLightFactor uLightAttr.g #define uLightFactor uLightAttr.g
#define uLightDist uLightAttr.r #define uLightDist uLightAttr.r
uniform int uFogEnabled; uniform int uFogEnabled;
uniform int uPalLightLevels;
// dynamic lights // dynamic lights
uniform int uLightIndex; uniform int uLightIndex;

File diff suppressed because it is too large Load diff