Example #1
0
void LoadEqualizer::_updateLeaf( Node* node )
{
    const Compound* compound = node->compound;
    const Channel* channel = compound->getChannel();
    LBASSERT( channel );
    const PixelViewport& pvp = channel->getPixelViewport();
    node->resources = compound->isActive() ? compound->getUsage() : 0.f;
    LBLOG( LOG_LB2 ) << channel->getName() << " active " << compound->isActive()
                     << " using " << node->resources << std::endl;
    LBASSERT( node->resources >= 0.f );

    node->maxSize.x() = pvp.w;
    node->maxSize.y() = pvp.h;
    node->boundaryf = getBoundaryf();
    node->boundary2i = getBoundary2i();
    node->resistancef = getResistancef();
    node->resistance2i = getResistance2i();
    if( !compound->hasDestinationChannel( ))
        return;

    const float nResources = _getTotalResources();
    if( getAssembleOnlyLimit() <= nResources - node->resources )
    {
        node->resources = 0.f;
        return; // OPT
    }

    const float time = float( _getTotalTime( ));
    const float assembleTime = float( _getAssembleTime( ));
    if( assembleTime == 0.f || node->resources == 0.f )
        return;

    const float timePerResource = time / ( nResources - node->resources );
    const float renderTime = timePerResource * node->resources ;

    const float clampedAssembleTime = LB_MIN( assembleTime, renderTime );
    const float newTimePerResource = (time + clampedAssembleTime) / nResources;
    node->resources -= ( clampedAssembleTime / newTimePerResource );
    if( node->resources < 0.f ) // may happen due to fp rounding
        node->resources = 0.f;
}
Example #2
0
void LoadEqualizer::_updateLeaf( Node* node )
{
    const Compound* compound = node->compound;
    const Channel* channel = compound->getChannel();
    EQASSERT( channel );
    const PixelViewport& pvp = channel->getPixelViewport();
    node->resources = compound->isRunning() ? compound->getUsage() : 0.f;
    EQASSERT( node->resources >= 0.f );

    node->maxSize.x() = pvp.w; 
    node->maxSize.y() = pvp.h; 
    node->boundaryf = _boundaryf;
    node->boundary2i = _boundary2i;
    if( !compound->hasDestinationChannel( ))
        return;

    const float nResources = _getTotalResources();
    if( _assembleOnlyLimit <= nResources - node->resources )
    {
        node->resources = 0.f;
        return; // OPT
    }

    const float time = float( _getTotalTime( ));
    const float assembleTime = float( _getAssembleTime( ));
    if( assembleTime == 0 || node->resources == 0.f )
        return; 

    const float timePerResource = time / ( nResources - node->resources );
    const float renderTime = timePerResource * node->resources ;

    const float clampedAssembleTime = EQ_MIN( assembleTime, renderTime );
    const float newTimePerResource = (time + clampedAssembleTime) / nResources;
    node->resources -= ( clampedAssembleTime / newTimePerResource );
    if( node->resources < 0.f ) // may happen due to fp rounding
        node->resources = 0.f;
}