[2.1] Multithreading cNumTransforms Topic is solved

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

[2.1] Multithreading cNumTransforms

Post by Rahzym » Tue Jan 09, 2018 5:19 pm

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) ?
0 x

User avatar
OGRE Team Member
OGRE Team Member
Posts: 3526
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 78

Re: [2.1] Multithreading cNumTransforms

Post by dark_sylinc » Wed Jan 10, 2018 10:52 pm


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.
0 x

Post Reply