- /* context now valid to work in while we hold up main thread */
- SDL_AtomicLock( &vg.sl_context );
- vg.context_ownership_refcount ++;
- SDL_AtomicUnlock( &vg.sl_context );
+ SDL_AtomicLock( &vg.sl_context );
+ if( vg.context_ownership_depth == 0 )
+ {
+ vg.context_ownership_depth ++;
+ vg.exec_context = 1;
+ SDL_AtomicUnlock( &vg.sl_context );
+
+ /* wait until told we can go */
+ VG_SYNC_LOG( "[%d] Waiting to acuire sync.\n" );
+ SDL_SemWait( vg.sem_allow_exec );
+
+ _vg_ensure_engine_running();