mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 08:34:40 +00:00
Update shaderGen.cpp
vertex shaders need to regen on run again to get the vertex format setup
This commit is contained in:
parent
ae785f0e5e
commit
21534473c9
1 changed files with 18 additions and 9 deletions
|
|
@ -93,6 +93,8 @@ ShaderGen::~ShaderGen()
|
||||||
{
|
{
|
||||||
GFXDevice::getDeviceEventSignal().remove(this, &ShaderGen::_handleGFXEvent);
|
GFXDevice::getDeviceEventSignal().remove(this, &ShaderGen::_handleGFXEvent);
|
||||||
_uninit();
|
_uninit();
|
||||||
|
|
||||||
|
mFileCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderGen::registerInitDelegate(GFXAdapterType adapterType, ShaderGenInitDelegate& initDelegate)
|
void ShaderGen::registerInitDelegate(GFXAdapterType adapterType, ShaderGenInitDelegate& initDelegate)
|
||||||
|
|
@ -190,7 +192,7 @@ void ShaderGen::generateShader( const MaterialFeatureData& featureData,
|
||||||
_uninit();
|
_uninit();
|
||||||
_init();
|
_init();
|
||||||
|
|
||||||
const bool skipRegen = !Con::getBoolVariable("ShaderGen::GenNewShaders", true);
|
bool skipRegen = !Con::getBoolVariable("ShaderGen::GenNewShaders", true);
|
||||||
const FeatureSet& features = mFeatureData.features;
|
const FeatureSet& features = mFeatureData.features;
|
||||||
U32 stages = 0;
|
U32 stages = 0;
|
||||||
|
|
||||||
|
|
@ -240,7 +242,12 @@ void ShaderGen::generateShader( const MaterialFeatureData& featureData,
|
||||||
// set the shaderdata file for this stage, shaderdata ptr needs to be passed in here.
|
// set the shaderdata file for this stage, shaderdata ptr needs to be passed in here.
|
||||||
dSprintf(fileName, sizeof(fileName), "shadergen:/%s.%s", stageName.c_str(), mFileEnding.c_str());
|
dSprintf(fileName, sizeof(fileName), "shadergen:/%s.%s", stageName.c_str(), mFileEnding.c_str());
|
||||||
shaderData->setShaderStageFile(curStage, fileName);
|
shaderData->setShaderStageFile(curStage, fileName);
|
||||||
continue;
|
if (!(curStage & GFXShaderStage::VERTEX_SHADER))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
skipRegen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mFileCache[stageName] = true;
|
mFileCache[stageName] = true;
|
||||||
|
|
@ -251,10 +258,13 @@ void ShaderGen::generateShader( const MaterialFeatureData& featureData,
|
||||||
|
|
||||||
mOutput = new MultiLine;
|
mOutput = new MultiLine;
|
||||||
FileStream* stream = new FileStream();
|
FileStream* stream = new FileStream();
|
||||||
if (!stream->open(fileName, Torque::FS::File::Write))
|
if (!skipRegen)
|
||||||
{
|
{
|
||||||
AssertFatal(false, "Failed to open Shader Stream");
|
if (!stream->open(fileName, Torque::FS::File::Write))
|
||||||
return;
|
{
|
||||||
|
AssertFatal(false, "Failed to open Shader Stream");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (curStage)
|
switch (curStage)
|
||||||
|
|
@ -350,15 +360,15 @@ void ShaderGen::_processVertFeatures( Vector<GFXShaderMacro> ¯os, bool macro
|
||||||
|
|
||||||
feature->processVertMacros( macros, mFeatureData );
|
feature->processVertMacros( macros, mFeatureData );
|
||||||
|
|
||||||
if ( macrosOnly )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
feature->setInstancingFormat( &mInstancingFormat );
|
feature->setInstancingFormat( &mInstancingFormat );
|
||||||
|
|
||||||
feature->mVertexFormat = mVertexFormat;
|
feature->mVertexFormat = mVertexFormat;
|
||||||
|
|
||||||
feature->processVert( mComponents, mFeatureData );
|
feature->processVert( mComponents, mFeatureData );
|
||||||
|
|
||||||
|
if (macrosOnly)
|
||||||
|
continue;
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
if ( index > -1 )
|
if ( index > -1 )
|
||||||
line = String::ToString( " // %s %d\r\n", feature->getName().c_str(), index );
|
line = String::ToString( " // %s %d\r\n", feature->getName().c_str(), index );
|
||||||
|
|
@ -601,5 +611,4 @@ void ShaderGen::flushProceduralShaders()
|
||||||
}
|
}
|
||||||
|
|
||||||
mProcShaderData.clear();
|
mProcShaderData.clear();
|
||||||
mFileCache.clear();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue