void Pipe::setXDisplay( Display* display ) { if( _xDisplay == display ) return; _xDisplay = display; XSetCurrentDisplay( display ); GPUInfo info; if( getGPUInfo( display, info )) { #ifndef NDEBUG // somewhat reduntant since it is a global handler XSetErrorHandler( XErrorHandler ); #endif const uint32_t port = getPipe()->getPort(); const uint32_t device = getPipe()->getDevice(); if( port != LB_UNDEFINED_UINT32 && info.port != port ) LBWARN << "Display mismatch: provided display connection uses" << " display " << info.port << ", but pipe has port " << port << std::endl; if( device != LB_UNDEFINED_UINT32 && info.device != device ) LBWARN << "Screen mismatch: provided display connection uses " << "default screen " << info.device << ", but pipe has screen " << device << std::endl; } const PixelViewport& pvp = getPipe()->getPixelViewport(); if( !pvp.isValid( )) getPipe()->setPixelViewport( info.pvp ); }
//---------------------------------------------------------------------- // configInit //---------------------------------------------------------------------- bool Window::configInit( const uint128_t& initID ) { if( !getPixelViewport().isValid( )) { sendError( ERROR_WINDOW_PVP_INVALID ); return false; } LBASSERT( !_systemWindow ); int glMajorVersion = 1; int glMinorVersion = 1; if( getPipe()->getSystemPipe()->getMaxOpenGLVersion() != AUTO ) { float maj, min; min = modff( getPipe()->getSystemPipe()->getMaxOpenGLVersion(), &maj ); glMajorVersion = static_cast< int >( maj ); glMinorVersion = static_cast< int >( min*10.f ); } if( getIAttribute( WindowSettings::IATTR_HINT_OPENGL_MAJOR ) == AUTO ) setIAttribute( WindowSettings::IATTR_HINT_OPENGL_MAJOR, glMajorVersion); if( getIAttribute( WindowSettings::IATTR_HINT_OPENGL_MINOR ) == AUTO ) setIAttribute( WindowSettings::IATTR_HINT_OPENGL_MINOR, glMinorVersion); return configInitSystemWindow( initID ) && configInitGL( initID ); }
inline Visualization::Abstract::Element* SeededIsosurfaceExtractor<DataSetWrapperParam>::startElement( const Visualization::Abstract::DataSet::Locator* seedLocator) { /* Get a pointer to the locator wrapper: */ const Locator* myLocator=dynamic_cast<const Locator*>(seedLocator); if(myLocator==0) Misc::throwStdErr("SeededIsosurfaceExtractor::createElement: Mismatching locator type"); const DSL& dsl=myLocator->getDsl(); /* Get the new isovalue and update the current value text field: */ typename SE::Scalar isovalue=dsl.calcValue(ise.getScalarExtractor()); currentValue->setValue(double(isovalue)); /* Create a new isosurface visualization element: */ if(getPipe()!=0) getPipe()->template write<typename SE::Scalar>(isovalue); currentIsosurface=new Isosurface(colorMap,isovalue,getPipe()); /* Start extracting the isosurface into the visualization element: */ ise.startSeededIsosurface(dsl,currentIsosurface->getSurface()); /* Return the result: */ return currentIsosurface.getPointer(); }
inline bool MultiStreamlineExtractor<DataSetWrapperParam>::continueSlaveElement( void) { if(getPipe()==0||getPipe()->isMaster()) Misc::throwStdErr("MultiStreamlineExtractor::continueSlaveElement: Cannot be called on master node"); return currentStreamline->getMultiPolyline().receive(); }
inline bool SeededIsosurfaceExtractor<DataSetWrapperParam>::continueSlaveElement( void) { if(getPipe()==0||getPipe()->isMaster()) Misc::throwStdErr("SeededIsosurfaceExtractor::continueSlaveElement: Cannot be called on master node"); return currentIsosurface->getSurface().receive(); }
co::Barrier* Window::joinSwapBarrier( co::Barrier* barrier ) { _swapFinish = true; if( !barrier ) { Node* node = getNode(); barrier = node->getBarrier(); barrier->increase(); _masterSwapBarriers.push_back( barrier ); _swapBarriers.push_back( barrier ); return barrier; } co::BarriersCIter i = stde::find( _swapBarriers, barrier ); if( i != _swapBarriers.end( )) // Issue #39: window already has this barrier return barrier; LBASSERT( getPipe() ); const Windows& windows = getPipe()->getWindows(); bool beforeSelf = true; // Check if another window in the same thread is using the swap barrier for( WindowsCIter j = windows.begin(); j != windows.end(); ++j ) { Window* window = *j; if( window == this ) // skip self { beforeSelf = false; continue; } co::Barriers& barriers = window->_swapBarriers; co::BarriersIter k = stde::find( barriers, barrier ); if( k == barriers.end( )) continue; if( beforeSelf ) // some earlier window will do the barrier for us return barrier; // else we will do the barrier, remove from later window barriers.erase( k ); _swapBarriers.push_back( barrier ); return barrier; } // No other window on this pipe does the barrier yet barrier->increase(); _swapBarriers.push_back( barrier ); return barrier; }
inline Visualization::Abstract::Element* MultiStreamlineExtractor<DataSetWrapperParam>::startSlaveElement( void) { if(getPipe()==0||getPipe()->isMaster()) Misc::throwStdErr("MultiStreamlineExtractor::startSlaveElement: Cannot be called on master node"); /* Create a new multi-streamline visualization element: */ currentStreamline=new MultiStreamline(msle.getNumStreamlines(),colorMap,getPipe()); return currentStreamline.getPointer(); }
inline Visualization::Abstract::Element* SeededSliceExtractor<DataSetWrapperParam>::createElement( Visualization::Abstract::Parameters* extractParameters) { /* Get proper pointer to parameter object: */ Parameters* myParameters=dynamic_cast<Parameters*>(extractParameters); if(myParameters==0) Misc::throwStdErr("SeededSliceExtractor::createElement: Mismatching parameter object type"); int svi=myParameters->scalarVariableIndex; /* Create a new slice visualization element: */ Slice* result=new Slice(myParameters,getVariableManager()->getColorMap(svi),getPipe()); /* Update the slice extractor: */ sle.update(getDs(getVariableManager()->getDataSetByScalarVariable(svi)),getSe(getVariableManager()->getScalarExtractor(svi))); /* Extract the slice into the visualization element: */ sle.startSeededSlice(myParameters->dsl,myParameters->plane,result->getSurface()); ElementSizeLimit<Slice> esl(*result,~size_t(0)); sle.continueSeededSlice(esl); sle.finishSeededSlice(); /* Return the result: */ return result; }
bool Window::_cmdConfigInit( co::Command& command ) { const WindowConfigInitPacket* packet = command.get<WindowConfigInitPacket>(); LBLOG( LOG_INIT ) << "TASK window config init " << packet << std::endl; WindowConfigInitReplyPacket reply; setError( ERROR_NONE ); if( getPipe()->isRunning( )) { _state = STATE_INITIALIZING; reply.result = configInit( packet->initID ); if( reply.result ) _state = STATE_RUNNING; } else { setError( ERROR_WINDOW_PIPE_NOTRUNNING ); reply.result = false; } LBLOG( LOG_INIT ) << "TASK window config init reply " << &reply <<std::endl; commit(); send( command.getNode(), reply ); return true; }
void Window::addTasks( const uint32_t tasks ) { Pipe* pipe = getPipe(); EQASSERT( pipe ); setTasks( getTasks() | tasks ); pipe->addTasks( tasks ); }
bool Window::_cmdConfigInit( co::Command& cmd ) { co::ObjectCommand command( cmd ); LBLOG( LOG_INIT ) << "TASK window config init " << command << std::endl; setError( ERROR_NONE ); bool result = false; if( getPipe()->isRunning( )) { _state = STATE_INITIALIZING; result = configInit( command.get< uint128_t >( )); if( result ) _state = STATE_RUNNING; } else setError( ERROR_WINDOW_PIPE_NOTRUNNING ); LBLOG( LOG_INIT ) << "TASK window config init reply " << std::endl; commit(); send( command.getNode(), fabric::CMD_WINDOW_CONFIG_INIT_REPLY ) << result; return true; }
bool Window::configInitAGLFullscreen() { AGLContext context = getAGLContext(); if( !context ) { setError( ERROR_AGLWINDOW_NO_CONTEXT ); return false; } Global::enterCarbon(); aglEnable( context, AGL_FS_CAPTURE_SINGLE ); const eq::Pipe* pipe = getPipe(); const PixelViewport& pipePVP = pipe->getPixelViewport(); const PixelViewport& windowPVP = getWindow()->getPixelViewport(); const PixelViewport& pvp = pipePVP.isValid() ? pipePVP : windowPVP; if( !aglSetFullScreen( context, pvp.w, pvp.h, 0, 0 )) LBWARN << "aglSetFullScreen to " << pvp << " failed: " << AGLERROR << std::endl; // Do focus hell ProcessSerialNumber selfProcess = { 0, kCurrentProcess }; SetFrontProcess( &selfProcess ); Global::leaveCarbon(); getWindow()->setPixelViewport( pvp ); if( getIAttribute( eq::Window::IATTR_HINT_DRAWABLE ) != OFF ) initEventHandler(); return true; }
//--------------------------------------------------------------------------- // AGL init //--------------------------------------------------------------------------- bool Pipe::configInit() { CGDirectDisplayID displayID = CGMainDisplayID(); const uint32_t device = getPipe()->getDevice(); if( device != LB_UNDEFINED_UINT32 ) { CGDirectDisplayID *displayIDs = static_cast< CGDirectDisplayID* >( alloca( (device+1) * sizeof( displayIDs ))); CGDisplayCount nDisplays; if( CGGetOnlineDisplayList( device+1, displayIDs, &nDisplays ) != kCGErrorSuccess ) { sendError( ERROR_AGLPIPE_DISPLAYS_NOTFOUND ); return false; } if( nDisplays <= device ) { sendError( ERROR_AGLPIPE_DEVICE_NOTFOUND ); return false; } displayID = displayIDs[device]; } _setCGDisplayID( displayID ); LBVERB << "Using CG displayID " << displayID << std::endl; return true; }
void Channel::_calcMVandITMV( eq::Matrix4f& modelviewM, eq::Matrix3f& modelviewITM ) const { const FrameData& frameData = _getFrameData(); const Pipe* pipe = static_cast< const Pipe* >( getPipe( )); const Renderer* renderer = pipe->getRenderer(); if( renderer ) { const VolumeScaling& volScaling = renderer->getVolumeScaling(); eq::Matrix4f scale( eq::Matrix4f::ZERO ); scale.at(0,0) = volScaling.W; scale.at(1,1) = volScaling.H; scale.at(2,2) = volScaling.D; scale.at(3,3) = 1.f; modelviewM = scale * frameData.getRotation(); } modelviewM.set_translation( frameData.getTranslation( )); modelviewM = getHeadTransform() * modelviewM; //calculate inverse transposed matrix eq::Matrix4f modelviewIM; modelviewM.inverse( modelviewIM ); eq::Matrix3f( modelviewIM ).transpose_to( modelviewITM ); }
//--------------------------------------------------------------------------- // GLX init //--------------------------------------------------------------------------- bool Pipe::configInit() { const std::string displayName = getXDisplayString(); const char* cDisplayName = ( displayName.empty() ? 0 : displayName.c_str( )); Display* xDisplay = XOpenDisplay( cDisplayName ); if( !xDisplay ) { setError( ERROR_GLXPIPE_DEVICE_NOTFOUND ); LBWARN << getError() << " " << XDisplayName( displayName.c_str( )) << ": " << lunchbox::sysError << std::endl; return false; } int major, event, error; if( !XQueryExtension( xDisplay, "GLX", &major, &event, &error )) { setError( ERROR_GLXPIPE_GLX_NOTFOUND ); XCloseDisplay( xDisplay ); return false; } setXDisplay( xDisplay ); LBVERB << "Opened X display " << XDisplayName( displayName.c_str( )) << " @" << xDisplay << ", device " << getPipe()->getDevice() << std::endl; return _configInitGLXEW(); }
HDC Pipe::createWGLDisplayDC() { uint32_t device = getPipe()->getDevice(); if( device == EQ_UNDEFINED_UINT32 ) device = 0; DISPLAY_DEVICE devInfo; devInfo.cb = sizeof( devInfo ); if( !EnumDisplayDevices( 0, device, &devInfo, 0 )) { setError( ERROR_WGLPIPE_ENUMDISPLAYS_FAILED ); EQWARN << getError() << ": " << co::base::sysError << std::endl; return 0; } const HDC displayDC = CreateDC( "DISPLAY", devInfo.DeviceName, 0, 0 ); if( !displayDC ) { setError( ERROR_WGLPIPE_CREATEDC_FAILED ); EQWARN << getError() << ": " << co::base::sysError << std::endl; return 0; } return displayDC; }
bool Window::createTransferWindow() { LBASSERT( _systemWindow ); if( _transferWindow ) return true; // create another (shared) osWindow with no drawable, restore original const int32_t drawable = getIAttribute( IATTR_HINT_DRAWABLE ); setIAttribute( IATTR_HINT_DRAWABLE, OFF ); const Pipe* pipe = getPipe(); _transferWindow = pipe->getWindowSystem().createWindow( this ); if( _transferWindow ) { if( !_transferWindow->configInit( )) { LBWARN << "Transfer window initialization failed" << std::endl; delete _transferWindow; _transferWindow = 0; } else makeCurrentTransfer(); } else LBERROR << "Window system " << pipe->getWindowSystem() << " not implemented or supported" << std::endl; setIAttribute( IATTR_HINT_DRAWABLE, drawable ); makeCurrent(); LBVERB << "Transfer window initialization finished" << std::endl; return _transferWindow != 0; }
int kpipe(int pd[2]) { OFT *read, *write; PIPE *pipe; u16 i = 0, j=0; pipe = getPipe(); if( pipe == 0) { return 0; } if ( getOFT(&read, &write) < 0 ) { printf("No open file descripters\n"); return -1; } for(i=0;i < NFD;++i) { if (running->fd[i] == 0) { printf("Putting [%d] into address %x\n", i, pd); put_word(i, running->uss, pd); pd++; if( j == 0 ) { running->fd[i] = read; }else { running->fd[i] = write; } ++j; } if (j == 2) { break; } } read->pipe_ptr = write->pipe_ptr = pipe; read->mode = READ_PIPE; read->refCount = 1; printf("READ mode[%d] count[%d]\n", read->mode, read->refCount); write->mode = WRITE_PIPE; write->refCount = 1; printf("Write mode[%d] count[%d]\n", write->mode, write->refCount); for(i=0;i< PSIZE ; ++i) { pipe->buf[i] = 0; } pipe->head = pipe->tail = pipe->data = 0; pipe->nreader = pipe->nwriter = pipe->busy = 1; pipe->room = PSIZE; }
void Window::_loadShaders() { if( _state->getShader( vertexShader_glsl ) != VertexBufferState::INVALID ) // already loaded return; // Check if functions are available if( !GLEW_VERSION_2_0 ) { LBWARN << "Shader function pointers missing, using fixed function " << "pipeline" << std::endl; return; } const GLuint vShader = _state->newShader( vertexShader_glsl, GL_VERTEX_SHADER ); LBASSERT( vShader != VertexBufferState::INVALID ); const GLchar* vShaderPtr = vertexShader_glsl; glShaderSource( vShader, 1, &vShaderPtr, 0 ); glCompileShader( vShader ); GLint status; glGetShaderiv( vShader, GL_COMPILE_STATUS, &status ); if( !status ) { LBWARN << "Failed to compile vertex shader" << std::endl; return; } const GLuint fShader = _state->newShader( fragmentShader_glsl, GL_FRAGMENT_SHADER ); LBASSERT( fShader != VertexBufferState::INVALID ); const GLchar* fShaderPtr = fragmentShader_glsl; glShaderSource( fShader, 1, &fShaderPtr, 0 ); glCompileShader( fShader ); glGetShaderiv( fShader, GL_COMPILE_STATUS, &status ); if( !status ) { LBWARN << "Failed to compile fragment shader" << std::endl; return; } const GLuint program = _state->newProgram( getPipe() ); LBASSERT( program != VertexBufferState::INVALID ); glAttachShader( program, vShader ); glAttachShader( program, fShader ); glLinkProgram( program ); glGetProgramiv( program, GL_LINK_STATUS, &status ); if( !status ) { LBWARN << "Failed to link shader program" << std::endl; return; } // turn off OpenGL lighting if we are using our own shaders glDisable( GL_LIGHTING ); LBINFO << "Shaders loaded successfully" << std::endl; }
inline Visualization::Abstract::Element* SeededIsosurfaceExtractor<DataSetWrapperParam>::startSlaveElement( void) { if(getPipe()==0||getPipe()->isMaster()) Misc::throwStdErr("SeededIsosurfaceExtractor::startSlaveElement: Cannot be called on master node"); /* Read the new isovalue and update the current value text field: */ typename SE::Scalar isovalue=getPipe()->template read<typename SE::Scalar>(); currentValue->setValue(double(isovalue)); /* Create a new isosurface visualization element: */ currentIsosurface=new Isosurface(colorMap,isovalue,getPipe()); return currentIsosurface.getPointer(); }
void Window::frameStart( const eq::uint128_t& frameID, const uint32_t frameNumber ) { const Pipe* pipe = static_cast<Pipe*>( getPipe( )); const FrameData& frameData = pipe->getFrameData(); _state->setRenderMode( frameData.getRenderMode( )); eq::Window::frameStart( frameID, frameNumber ); }
void View::notifyAttach() { eq::View::notifyAttach(); Pipe* pipe = getPipe(); if (pipe) // render client view setUserData(pipe->getRenderer()->createViewData(*this)); }
bool View::configInit() { if (!eq::View::configInit()) return false; if (!getPipe()) // application view setUserData(getConfig()->getApplication()->createViewData(*this)); return true; }
void Window::render() { Pipe *pipe = static_cast<Pipe *>(getPipe()); Ogre::Root *root = pipe->_ogre->getRoot(); root->_fireFrameStarted(); root->_fireFrameRenderingQueued(); mWindow->update(false); root->_fireFrameEnded(); }
WGLEWContext* CUDAContext::wglewGetContext() { #ifdef _WIN32 return static_cast<wgl::Pipe*>(getPipe()->getSystemPipe())->wglewGetContext(); #else return 0; #endif }
const util::BitmapFont* Window::getMediumFont() { util::BitmapFont* font = _objectManager.getEqBitmapFont( _mediumFontKey ); if( !font ) { font = _objectManager.newEqBitmapFont( _mediumFontKey ); font->init( getPipe()->getWindowSystem(), "", 20 ); } return font; }
void View::notifyAttach() { eq::View::notifyAttach(); Pipe* pipe = getPipe(); if( pipe ) // render client view setUserData( pipe->getRenderer()->createViewData( )); else // application view setUserData( getConfig()->getApplication()->createViewData( )); }
void Window::activate() { Pipe* pipe = getPipe(); EQASSERT( pipe ); ++_active; pipe->activate(); EQLOG( LOG_VIEW ) << "activate: " << _active << std::endl; }
void Window::addViewport() { Pipe *pipe = static_cast<Pipe *>(getPipe()); Ogre::Camera *cam = pipe->_ogre->getCamera(); _vp = mWindow->addViewport(cam); _vp->setBackgroundColour(Ogre::ColourValue(0,0,0)); cam->setAspectRatio( Ogre::Real(_vp->getActualWidth()) / Ogre::Real(_vp->getActualHeight())); }
bool View::configExit() { ViewData* viewData = getViewData(); if (!getPipe() && viewData) // application view { setUserData(0); getConfig()->getApplication()->destroyViewData(viewData); } return eq::View::configExit(); }