mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
Merge pull request #1467 from Azaezel/alpha41/PostfxProdding
postfx throttling
This commit is contained in:
commit
cfdb8fe959
2 changed files with 33 additions and 21 deletions
|
|
@ -458,6 +458,7 @@ PostEffect::PostEffect()
|
||||||
mStateBlockData( NULL ),
|
mStateBlockData( NULL ),
|
||||||
mUpdateShader( true ),
|
mUpdateShader( true ),
|
||||||
mSkip( false ),
|
mSkip( false ),
|
||||||
|
mPreProcessed(false),
|
||||||
mAllowReflectPass( false ),
|
mAllowReflectPass( false ),
|
||||||
mTargetClear( PFXTargetClear_None ),
|
mTargetClear( PFXTargetClear_None ),
|
||||||
mTargetScale( Point2F::One ),
|
mTargetScale( Point2F::One ),
|
||||||
|
|
@ -508,6 +509,7 @@ PostEffect::PostEffect()
|
||||||
dMemset( mTexSizeSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
dMemset( mTexSizeSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
||||||
dMemset( mRenderTargetParamsSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
dMemset( mRenderTargetParamsSC, 0, sizeof( GFXShaderConstHandle* ) * NumTextures );
|
||||||
|
|
||||||
|
mConstUpdateTimer = PlatformTimer::create();
|
||||||
}
|
}
|
||||||
|
|
||||||
PostEffect::~PostEffect()
|
PostEffect::~PostEffect()
|
||||||
|
|
@ -1109,28 +1111,32 @@ void PostEffect::_setupConstants( const SceneRenderState *state )
|
||||||
dSscanf( buffer.c_str(), "%g %g", texSizeScriptConst.x, texSizeScriptConst.y );
|
dSscanf( buffer.c_str(), "%g %g", texSizeScriptConst.x, texSizeScriptConst.y );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
|
||||||
PROFILE_SCOPE( PostEffect_SetShaderConsts );
|
|
||||||
|
|
||||||
// Pass some data about the current render state to script.
|
if (mConstUpdateTimer->getElapsedMs() > TickMs)
|
||||||
//
|
{
|
||||||
// TODO: This is pretty messy... it should go away. This info
|
mConstUpdateTimer->reset();
|
||||||
// should be available from some other script accessible method
|
|
||||||
// or field which isn't PostEffect specific.
|
|
||||||
//
|
|
||||||
if ( state )
|
|
||||||
{
|
{
|
||||||
Con::setFloatVariable( "$Param::NearDist", state->getNearPlane() );
|
PROFILE_SCOPE(PostEffect_SetShaderConsts);
|
||||||
Con::setFloatVariable( "$Param::FarDist", state->getFarPlane() );
|
|
||||||
|
// Pass some data about the current render state to script.
|
||||||
|
//
|
||||||
|
// TODO: This is pretty messy... it should go away. This info
|
||||||
|
// should be available from some other script accessible method
|
||||||
|
// or field which isn't PostEffect specific.
|
||||||
|
//
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
Con::setFloatVariable("$Param::NearDist", state->getNearPlane());
|
||||||
|
Con::setFloatVariable("$Param::FarDist", state->getFarPlane());
|
||||||
|
}
|
||||||
|
|
||||||
|
setShaderConsts_callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
setShaderConsts_callback();
|
EffectConstTable::Iterator iter = mEffectConsts.begin();
|
||||||
}
|
for (; iter != mEffectConsts.end(); iter++)
|
||||||
|
iter->value->setToBuffer(mShaderConsts);
|
||||||
EffectConstTable::Iterator iter = mEffectConsts.begin();
|
}
|
||||||
for ( ; iter != mEffectConsts.end(); iter++ )
|
|
||||||
iter->value->setToBuffer( mShaderConsts );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *inTexViewport )
|
void PostEffect::_setupTexture( U32 stage, GFXTexHandle &inputTex, const RectI *inTexViewport )
|
||||||
|
|
@ -1423,9 +1429,11 @@ void PostEffect::process( const SceneRenderState *state,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GFXDEBUGEVENT_SCOPE_EX( PostEffect_Process, ColorI::GREEN, avar("PostEffect: %s", getName()) );
|
GFXDEBUGEVENT_SCOPE_EX( PostEffect_Process, ColorI::GREEN, avar("PostEffect: %s", getName()) );
|
||||||
|
if (!mPreProcessed || mShader->getReloadKey() != mShaderReloadKey)
|
||||||
preProcess_callback();
|
{
|
||||||
|
mPreProcessed = true;
|
||||||
|
preProcess_callback();
|
||||||
|
}
|
||||||
GFXTransformSaver saver;
|
GFXTransformSaver saver;
|
||||||
|
|
||||||
// Set the textures.
|
// Set the textures.
|
||||||
|
|
@ -1578,6 +1586,7 @@ bool PostEffect::_setIsEnabled( void *object, const char *index, const char *dat
|
||||||
|
|
||||||
void PostEffect::enable()
|
void PostEffect::enable()
|
||||||
{
|
{
|
||||||
|
mPreProcessed = false;
|
||||||
// Don't add TexGen PostEffects to the PostEffectManager!
|
// Don't add TexGen PostEffects to the PostEffectManager!
|
||||||
if ( mRenderTime == PFXTexGenOnDemand )
|
if ( mRenderTime == PFXTexGenOnDemand )
|
||||||
return;
|
return;
|
||||||
|
|
@ -1621,6 +1630,7 @@ void PostEffect::disable()
|
||||||
|
|
||||||
void PostEffect::reload()
|
void PostEffect::reload()
|
||||||
{
|
{
|
||||||
|
mPreProcessed = false;
|
||||||
// Reload the shader if we have one or mark it
|
// Reload the shader if we have one or mark it
|
||||||
// for updating when its processed next.
|
// for updating when its processed next.
|
||||||
if ( mShader )
|
if ( mShader )
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,7 @@ protected:
|
||||||
/// Parent and sibling PostEffects in the chain are still processed.
|
/// Parent and sibling PostEffects in the chain are still processed.
|
||||||
/// This is intended for debugging purposes.
|
/// This is intended for debugging purposes.
|
||||||
bool mSkip;
|
bool mSkip;
|
||||||
|
bool mPreProcessed;
|
||||||
|
|
||||||
bool mOneFrameOnly;
|
bool mOneFrameOnly;
|
||||||
bool mOnThisFrame;
|
bool mOnThisFrame;
|
||||||
|
|
@ -323,6 +324,7 @@ protected:
|
||||||
|
|
||||||
EffectConstTable mEffectConsts;
|
EffectConstTable mEffectConsts;
|
||||||
|
|
||||||
|
PlatformTimer* mConstUpdateTimer;
|
||||||
///
|
///
|
||||||
virtual void _updateScreenGeometry( const Frustum &frustum,
|
virtual void _updateScreenGeometry( const Frustum &frustum,
|
||||||
GFXVertexBufferHandle<PFXVertex> *outVB );
|
GFXVertexBufferHandle<PFXVertex> *outVB );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue