- lock cvar shader uniforms behind a command line parameter for now

This commit is contained in:
Rachael Alexanderson 2022-04-16 12:12:40 -04:00
parent 1ba4dfbfa8
commit 43a419b318

View file

@ -49,6 +49,7 @@
#include "hw_material.h" #include "hw_material.h"
#include "texturemanager.h" #include "texturemanager.h"
#include "gameconfigfile.h" #include "gameconfigfile.h"
#include "m_argv.h"
void AddLightDefaults(FLightDefaults *defaults, double attnFactor); void AddLightDefaults(FLightDefaults *defaults, double attnFactor);
void AddLightAssociation(const char *actor, const char *frame, const char *light); void AddLightAssociation(const char *actor, const char *frame, const char *light);
@ -1562,46 +1563,54 @@ class GLDefsParser
val.Float = oldval.Float = (float)sc.Float; val.Float = oldval.Float = (float)sc.Float;
if (!cvar) if (!Args->CheckParm ("-shaderuniformtest"))
{ {
cvar = C_CreateCVar(cvarname, cvartype, cvarflags); // these aren't really release-ready, so lock them behind a command-line argument for now.
sc.ScriptMessage("Warning - Use -shaderuniformtest to enable shader uniforms!");
} }
else if (cvar && (((cvar->GetFlags()) & CVAR_MOD) == CVAR_MOD)) else
{ {
// this value may have been previously loaded if (!cvar)
oldval.Float = cvar->GetGenericRep(CVAR_Float).Float; {
oldextra = (ExtraUniformCVARData*)cvar->GetExtraDataPointer(); cvar = C_CreateCVar(cvarname, cvartype, cvarflags);
} }
else if (cvar && (((cvar->GetFlags()) & CVAR_MOD) == CVAR_MOD))
{
// this value may have been previously loaded
oldval.Float = cvar->GetGenericRep(CVAR_Float).Float;
oldextra = (ExtraUniformCVARData*)cvar->GetExtraDataPointer();
}
if (!(cvar->GetFlags() & CVAR_MOD)) if (!(cvar->GetFlags() & CVAR_MOD))
{ {
if (!((cvar->GetFlags() & (CVAR_AUTO | CVAR_UNSETTABLE)) == (CVAR_AUTO | CVAR_UNSETTABLE))) if (!((cvar->GetFlags() & (CVAR_AUTO | CVAR_UNSETTABLE)) == (CVAR_AUTO | CVAR_UNSETTABLE)))
sc.ScriptError("CVAR '%s' already in use!", cvarname.GetChars()); sc.ScriptError("CVAR '%s' already in use!", cvarname.GetChars());
} }
// must've picked this up from an autoexec.cfg, handle accordingly // must've picked this up from an autoexec.cfg, handle accordingly
if (cvar && ((cvar->GetFlags() & (CVAR_MOD|CVAR_AUTO|CVAR_UNSETTABLE)) == (CVAR_AUTO | CVAR_UNSETTABLE))) if (cvar && ((cvar->GetFlags() & (CVAR_MOD|CVAR_AUTO|CVAR_UNSETTABLE)) == (CVAR_AUTO | CVAR_UNSETTABLE)))
{ {
oldval.Float = cvar->GetGenericRep(CVAR_Float).Float; oldval.Float = cvar->GetGenericRep(CVAR_Float).Float;
delete cvar; delete cvar;
cvar = C_CreateCVar(cvarname, cvartype, cvarflags); cvar = C_CreateCVar(cvarname, cvartype, cvarflags);
oldextra = (ExtraUniformCVARData*)cvar->GetExtraDataPointer(); oldextra = (ExtraUniformCVARData*)cvar->GetExtraDataPointer();
} }
shaderdesc.Uniforms[uniformName].Values[0] = oldval.Float; shaderdesc.Uniforms[uniformName].Values[0] = oldval.Float;
cvar->SetGenericRepDefault(val, CVAR_Float); cvar->SetGenericRepDefault(val, CVAR_Float);
if (val.Float != oldval.Float) // it's not default anymore if (val.Float != oldval.Float) // it's not default anymore
cvar->SetGenericRep(oldval.Float, CVAR_Float); cvar->SetGenericRep(oldval.Float, CVAR_Float);
if (callback) if (callback)
cvar->SetCallback(callback); cvar->SetCallback(callback);
ExtraUniformCVARData* extra = new ExtraUniformCVARData; ExtraUniformCVARData* extra = new ExtraUniformCVARData;
extra->Shader = shaderdesc.Name.GetChars(); extra->Shader = shaderdesc.Name.GetChars();
extra->Uniform = uniformName.GetChars(); extra->Uniform = uniformName.GetChars();
extra->Next = oldextra; extra->Next = oldextra;
cvar->SetExtraDataPointer(extra); cvar->SetExtraDataPointer(extra);
}
} }
} }
else if (sc.Compare("texture")) else if (sc.Compare("texture"))