[2.1] Multithreading cNumTransforms Topic is solved

Problems building or running the engine, queries about how to use features etc.
Post Reply
Rahzym
Gnoblar
Posts: 12
Joined: Tue Jun 21, 2011 7:14 pm

[2.1] Multithreading cNumTransforms

Post by Rahzym »

Hello and sorry about my english. I'm working on the tutorial 06 multithreading sample. I don't understand what is cNumTransforms in GameEntityManager.cpp

Code: Select all

namespace Demo
{
    const size_t cNumTransforms = 250;

    GameEntityManager::GameEntityManager( Mq::MessageQueueSystem *graphicsSystem,
                                          LogicSystem *logicSystem ) :
Especially here :

Code: Select all

void GameEntityManager::aquireTransformSlot( size_t &outSlot, size_t &outBufferIdx )
{
    if( mAvailableTransforms.empty() )
    {
        GameEntityTransform *buffer = reinterpret_cast<GameEntityTransform*>( OGRE_MALLOC_SIMD(
                    sizeof(GameEntityTransform) * cNumTransforms * NUM_GAME_ENTITY_BUFFERS,
                    Ogre::MEMCATEGORY_SCENE_OBJECTS ) );
        mTransformBuffers.push_back( buffer );
        mAvailableTransforms.push_back( Region( 0, cNumTransforms, mTransformBuffers.size() - 1 ) );
    }
Is the value of cNumTransforms arbitrary ? or related to sizeof(GameEntityTransform) ?
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: [2.1] Multithreading cNumTransforms

Post by dark_sylinc »

Hi.

The value of cNumTransforms is arbitrary. The system works with pools of memory to reduce fragmentation and improve cache coherency, and each pool holds up to cNumTransforms entities. Large values of cNumTransforms will require more contiguous memory per pool (which makes the OS harder to fulfill because of virtual address space fragmentation, particularly relevant for 32 bit applications) small values of cNumTransforms will trash the cache more.
Post Reply