mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 16:14:38 +00:00
Changes on ShaderGen for generate GLSL shaders.
This commit is contained in:
parent
c354f59b72
commit
61d3e52ad1
4 changed files with 20 additions and 18 deletions
|
|
@ -203,7 +203,7 @@ void ShaderConnectorHLSL::reset()
|
||||||
mCurTexElem = 0;
|
mCurTexElem = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderConnectorHLSL::print( Stream &stream )
|
void ShaderConnectorHLSL::print( Stream &stream, bool isVertexShader )
|
||||||
{
|
{
|
||||||
const char * header = "struct ";
|
const char * header = "struct ";
|
||||||
const char * header2 = "\r\n{\r\n";
|
const char * header2 = "\r\n{\r\n";
|
||||||
|
|
@ -269,7 +269,7 @@ void ParamsDefHLSL::assignConstantNumbers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexParamsDefHLSL::print( Stream &stream )
|
void VertexParamsDefHLSL::print( Stream &stream, bool isVerterShader )
|
||||||
{
|
{
|
||||||
assignConstantNumbers();
|
assignConstantNumbers();
|
||||||
|
|
||||||
|
|
@ -305,7 +305,7 @@ void VertexParamsDefHLSL::print( Stream &stream )
|
||||||
stream.write( dStrlen(closer), closer );
|
stream.write( dStrlen(closer), closer );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelParamsDefHLSL::print( Stream &stream )
|
void PixelParamsDefHLSL::print( Stream &stream, bool isVerterShader )
|
||||||
{
|
{
|
||||||
assignConstantNumbers();
|
assignConstantNumbers();
|
||||||
|
|
||||||
|
|
@ -326,18 +326,18 @@ void PixelParamsDefHLSL::print( Stream &stream )
|
||||||
|
|
||||||
if( var->sampler )
|
if( var->sampler )
|
||||||
{
|
{
|
||||||
dSprintf( (char*)varNum, sizeof(varNum), "register(S%d)", var->constNum );
|
dSprintf( (char*)varNum, sizeof(varNum), ": register(S%d)", var->constNum );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dSprintf( (char*)varNum, sizeof(varNum), "register(C%d)", var->constNum );
|
dSprintf( (char*)varNum, sizeof(varNum), ": register(C%d)", var->constNum );
|
||||||
}
|
}
|
||||||
|
|
||||||
U8 output[256];
|
U8 output[256];
|
||||||
if (var->arraySize <= 1)
|
if (var->arraySize <= 1)
|
||||||
dSprintf( (char*)output, sizeof(output), "uniform %-9s %-15s : %s", var->type, var->name, varNum );
|
dSprintf( (char*)output, sizeof(output), "uniform %-9s %-15s %s", var->type, var->name, varNum );
|
||||||
else
|
else
|
||||||
dSprintf( (char*)output, sizeof(output), "uniform %-9s %s[%d] : %s", var->type, var->name, var->arraySize, varNum );
|
dSprintf( (char*)output, sizeof(output), "uniform %-9s %s[%d] %s", var->type, var->name, var->arraySize, varNum );
|
||||||
|
|
||||||
WRITESTR( (char*) output );
|
WRITESTR( (char*) output );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public:
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
virtual void sortVars();
|
virtual void sortVars();
|
||||||
|
|
||||||
virtual void print( Stream &stream );
|
virtual void print( Stream &stream, bool isVertexShader );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -59,14 +59,14 @@ protected:
|
||||||
class VertexParamsDefHLSL : public ParamsDefHLSL
|
class VertexParamsDefHLSL : public ParamsDefHLSL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void print( Stream &stream );
|
virtual void print( Stream &stream, bool isVerterShader );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PixelParamsDefHLSL : public ParamsDefHLSL
|
class PixelParamsDefHLSL : public ParamsDefHLSL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void print( Stream &stream );
|
virtual void print( Stream &stream, bool isVerterShader );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SHADERCOMP_HLSL_H_
|
#endif // _SHADERCOMP_HLSL_H_
|
||||||
|
|
@ -43,7 +43,8 @@ class ShaderComponent
|
||||||
public:
|
public:
|
||||||
virtual ~ShaderComponent() {}
|
virtual ~ShaderComponent() {}
|
||||||
|
|
||||||
virtual void print( Stream &stream ){};
|
virtual void print( Stream &stream, bool isVerterShader ){};
|
||||||
|
virtual void printOnMain( Stream &stream, bool isVerterShader ){};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,7 +87,7 @@ public:
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
virtual void sortVars() = 0;
|
virtual void sortVars() = 0;
|
||||||
|
|
||||||
virtual void print( Stream &stream ) = 0;
|
virtual void print( Stream &stream, bool isVerterShader ) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This is to provide common functionalty needed by vertex and pixel main defs
|
/// This is to provide common functionalty needed by vertex and pixel main defs
|
||||||
|
|
|
||||||
|
|
@ -409,13 +409,13 @@ void ShaderGen::_printVertShader( Stream &stream )
|
||||||
_printFeatureList(stream);
|
_printFeatureList(stream);
|
||||||
|
|
||||||
// print out structures
|
// print out structures
|
||||||
mComponents[C_VERT_STRUCT]->print( stream );
|
mComponents[C_VERT_STRUCT]->print( stream, true );
|
||||||
mComponents[C_CONNECTOR]->print( stream );
|
mComponents[C_CONNECTOR]->print( stream, true );
|
||||||
|
|
||||||
mPrinter->printMainComment(stream);
|
mPrinter->printMainComment(stream);
|
||||||
|
|
||||||
mComponents[C_VERT_MAIN]->print( stream );
|
mComponents[C_VERT_MAIN]->print( stream, true );
|
||||||
|
mComponents[C_VERT_STRUCT]->printOnMain( stream, true );
|
||||||
|
|
||||||
// print out the function
|
// print out the function
|
||||||
_printFeatures( stream );
|
_printFeatures( stream );
|
||||||
|
|
@ -430,12 +430,13 @@ void ShaderGen::_printPixShader( Stream &stream )
|
||||||
_printDependencies(stream); // TODO: Split into vert and pix dependencies?
|
_printDependencies(stream); // TODO: Split into vert and pix dependencies?
|
||||||
_printFeatureList(stream);
|
_printFeatureList(stream);
|
||||||
|
|
||||||
mComponents[C_CONNECTOR]->print( stream );
|
mComponents[C_CONNECTOR]->print( stream, false );
|
||||||
|
|
||||||
mPrinter->printPixelShaderOutputStruct(stream, mFeatureData);
|
mPrinter->printPixelShaderOutputStruct(stream, mFeatureData);
|
||||||
mPrinter->printMainComment(stream);
|
mPrinter->printMainComment(stream);
|
||||||
|
|
||||||
mComponents[C_PIX_MAIN]->print( stream );
|
mComponents[C_PIX_MAIN]->print( stream, false );
|
||||||
|
mComponents[C_CONNECTOR]->printOnMain( stream, false );
|
||||||
|
|
||||||
// print out the function
|
// print out the function
|
||||||
_printFeatures( stream );
|
_printFeatures( stream );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue