Victor Haefner
2014-09-25 19:35:50 UTC
Hi all,
I am trying to parellelize the rendering of all my Windows.
The first step towards this is to render in another thread:
Main thread:
...
// RenderActionRefPtr ract
BarrierRefPtr barrier = Barrier::get("MDW", true);
if (barrier->getNumWaiting() == 1) {
barrier->enter(2);
barrier->enter(2);
}
...
Second thread
int tries = 0;
bool state = INITIALIZING;
bool VRMultiWindow::init_win(const std::string &msg, const std::string
&server, Real32 progress) {
if (progress == 1) { state = CONNECTED; return true; }
if (tries == 3) { state = NO_CONNECTION; return false; }
tries++;
return true;
}
...
MultiDisplayWindowRefPtr win;
void initialize(RenderActionRefPtr ract) {
state = CONNECTING;
win = MultiDisplayWindow::create();
win->setSize(300, 300);
win->setHServers(1);
win->setVServers(1);
win->editMFServers()->push_back("localhost");
Thread::getCurrentChangeList()->commitChangesAndClear();
Thread::getCurrentChangeList()->fillFromCurrentState();
ClusterWindow::ConnectionCB cb = boost::bind(&VRMultiWindow::init_win,
this, _1, _2, _3);
win->initAsync(cb);
if (state == CONNECTED) win->render(ract);
}
update() {
ExternalThreadRefPtr tr = OSGThread::create("update", 0);
tr->initialize(0); // same aspect as main frame, should be fine I hope
(main thread is waiting)
do {
BarrierRefPtr barrier = Barrier::get("MDW", true);
barrier->enter(2);
//Thread::getCurrentChangeList()->fillFromCurrentState(); // using
this line works somehow, at least the scene gets distributed..
ThreadRefPtr appThread = dynamic_cast<Thread
*>(ThreadManager::getAppThread());
ChangeList* cl = Thread::getCurrentChangeList();
ChangeList* acl = appThread->getChangeList();
cl->merge(*acl);
if (state == INITIALIZING) initialize(action);
else if (state == CONNECTED) {
try { win->render(action); }
catch(exception e) { state = INITIALIZING; }
}
Thread::getCurrentChangeList()->clear();
barrier->enter(2);
osgSleep(1);
} while(control_flag);
}
start update as a boost thread
...
I see nothing on the cluster client and I get this output:
...
WARNING: New container type 'GeoPnt3fProperty' local id '6476' remote id
'1100' dies because of missing ref counts.
WARNING: New container type 'GeoVec3fProperty' local id '6477' remote id
'1101' dies because of missing ref counts.
WARNING: New container type 'GeoVec2fProperty' local id '6478' remote id
'1102' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6479' remote id
'1103' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6480' remote id
'1104' dies because of missing ref counts.
WARNING: New container type 'GeoUInt8Property' local id '6481' remote id
'1105' dies because of missing ref counts.
WARNING: New container type 'Name' local id '6484' remote id '1108' dies
because of missing ref counts.
WARNING: New container type 'Name' local id '6486' remote id '1111' dies
because of missing ref counts.
WARNING: New container type 'GeoPnt3fProperty' local id '6488' remote id
'1113' dies because of missing ref counts.
WARNING: New container type 'GeoVec3fProperty' local id '6489' remote id
'1114' dies because of missing ref counts.
WARNING: New container type 'GeoVec2fProperty' local id '6490' remote id
'1115' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6491' remote id
'1116' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6492' remote id
'1117' dies because of missing ref counts.
WARNING: New container type 'GeoUInt8Property' local id '6493' remote id
'1118' dies because of missing ref counts.
WARNING: New container type 'Name' local id '6496' remote id '1121' dies
because of missing ref counts.
WARNING: New container type 'Name' local id '6498' remote id '1124' dies
because of missing ref counts.
WARNING: New container type 'GeoPnt3fProperty' local id '6500' remote id
'1126' dies because of missing ref counts.
WARNING: New container type 'GeoVec3fProperty' local id '6501' remote id
'1127' dies because of missing ref counts.
WARNING: New container type 'GeoVec2fProperty' local id '6502' remote id
'1128' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6503' remote id
'1129' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6504' remote id
'1130' dies because of missing ref counts.
WARNING: New container type 'GeoUInt8Property' local id '6505' remote id
'1131' dies because of missing ref counts.
WARNING: New container type 'Name' local id '6508' remote id '1134' dies
because of missing ref counts.
...
I think I am doing something wrong when merging the changelists..
I also did not fully understand what committing a changelist does.
Any ideas why the refcount is 'missing' ??
Many thanks and best Regards,
Victor
I am trying to parellelize the rendering of all my Windows.
The first step towards this is to render in another thread:
Main thread:
...
// RenderActionRefPtr ract
BarrierRefPtr barrier = Barrier::get("MDW", true);
if (barrier->getNumWaiting() == 1) {
barrier->enter(2);
barrier->enter(2);
}
...
Second thread
int tries = 0;
bool state = INITIALIZING;
bool VRMultiWindow::init_win(const std::string &msg, const std::string
&server, Real32 progress) {
if (progress == 1) { state = CONNECTED; return true; }
if (tries == 3) { state = NO_CONNECTION; return false; }
tries++;
return true;
}
...
MultiDisplayWindowRefPtr win;
void initialize(RenderActionRefPtr ract) {
state = CONNECTING;
win = MultiDisplayWindow::create();
win->setSize(300, 300);
win->setHServers(1);
win->setVServers(1);
win->editMFServers()->push_back("localhost");
Thread::getCurrentChangeList()->commitChangesAndClear();
Thread::getCurrentChangeList()->fillFromCurrentState();
ClusterWindow::ConnectionCB cb = boost::bind(&VRMultiWindow::init_win,
this, _1, _2, _3);
win->initAsync(cb);
if (state == CONNECTED) win->render(ract);
}
update() {
ExternalThreadRefPtr tr = OSGThread::create("update", 0);
tr->initialize(0); // same aspect as main frame, should be fine I hope
(main thread is waiting)
do {
BarrierRefPtr barrier = Barrier::get("MDW", true);
barrier->enter(2);
//Thread::getCurrentChangeList()->fillFromCurrentState(); // using
this line works somehow, at least the scene gets distributed..
ThreadRefPtr appThread = dynamic_cast<Thread
*>(ThreadManager::getAppThread());
ChangeList* cl = Thread::getCurrentChangeList();
ChangeList* acl = appThread->getChangeList();
cl->merge(*acl);
if (state == INITIALIZING) initialize(action);
else if (state == CONNECTED) {
try { win->render(action); }
catch(exception e) { state = INITIALIZING; }
}
Thread::getCurrentChangeList()->clear();
barrier->enter(2);
osgSleep(1);
} while(control_flag);
}
start update as a boost thread
...
I see nothing on the cluster client and I get this output:
...
WARNING: New container type 'GeoPnt3fProperty' local id '6476' remote id
'1100' dies because of missing ref counts.
WARNING: New container type 'GeoVec3fProperty' local id '6477' remote id
'1101' dies because of missing ref counts.
WARNING: New container type 'GeoVec2fProperty' local id '6478' remote id
'1102' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6479' remote id
'1103' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6480' remote id
'1104' dies because of missing ref counts.
WARNING: New container type 'GeoUInt8Property' local id '6481' remote id
'1105' dies because of missing ref counts.
WARNING: New container type 'Name' local id '6484' remote id '1108' dies
because of missing ref counts.
WARNING: New container type 'Name' local id '6486' remote id '1111' dies
because of missing ref counts.
WARNING: New container type 'GeoPnt3fProperty' local id '6488' remote id
'1113' dies because of missing ref counts.
WARNING: New container type 'GeoVec3fProperty' local id '6489' remote id
'1114' dies because of missing ref counts.
WARNING: New container type 'GeoVec2fProperty' local id '6490' remote id
'1115' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6491' remote id
'1116' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6492' remote id
'1117' dies because of missing ref counts.
WARNING: New container type 'GeoUInt8Property' local id '6493' remote id
'1118' dies because of missing ref counts.
WARNING: New container type 'Name' local id '6496' remote id '1121' dies
because of missing ref counts.
WARNING: New container type 'Name' local id '6498' remote id '1124' dies
because of missing ref counts.
WARNING: New container type 'GeoPnt3fProperty' local id '6500' remote id
'1126' dies because of missing ref counts.
WARNING: New container type 'GeoVec3fProperty' local id '6501' remote id
'1127' dies because of missing ref counts.
WARNING: New container type 'GeoVec2fProperty' local id '6502' remote id
'1128' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6503' remote id
'1129' dies because of missing ref counts.
WARNING: New container type 'GeoUInt32Property' local id '6504' remote id
'1130' dies because of missing ref counts.
WARNING: New container type 'GeoUInt8Property' local id '6505' remote id
'1131' dies because of missing ref counts.
WARNING: New container type 'Name' local id '6508' remote id '1134' dies
because of missing ref counts.
...
I think I am doing something wrong when merging the changelists..
I also did not fully understand what committing a changelist does.
Any ideas why the refcount is 'missing' ??
Many thanks and best Regards,
Victor