From 51cc3f8900780c9c1a6ebab421fa57823fa2a803 Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Fri, 17 Feb 2017 12:06:27 +0100 Subject: [PATCH 1/4] Fix NPR on unloaded plugins (#618) --- eq/compressor/compressor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/eq/compressor/compressor.cpp b/eq/compressor/compressor.cpp index bdc93fecca..fc40cdd75b 100644 --- a/eq/compressor/compressor.cpp +++ b/eq/compressor/compressor.cpp @@ -80,6 +80,8 @@ void Compressor::registerEngine( const Compressor::Functions& functions ) size_t EqCompressorGetNumCompressors() { + if( !eq::plugin::_functions ) + return 0; return eq::plugin::_functions->size(); } From eee7aa40b6a887e8319161a50c264fb947a6408d Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Fri, 17 Feb 2017 14:07:32 +0100 Subject: [PATCH 2/4] Fix static initializer fiasco (#618) --- doc/Changelog.md | 2 ++ eq/init.cpp | 40 +--------------------------------------- eq/windowSystem.cpp | 29 +++++++++++++++++------------ eq/windowSystem.h | 1 - 4 files changed, 20 insertions(+), 52 deletions(-) diff --git a/doc/Changelog.md b/doc/Changelog.md index 589fca1ab7..865c083cc2 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -3,6 +3,8 @@ Changelog {#Changelog} # git master +* [619](https://github.com/Eyescale/Equalizer/pull/619) + Fix running from an installed version * [611](https://github.com/Eyescale/Equalizer/pull/611) Add eq::getHelp(), eq::Client::getHelp() and seq::Application::getHelp(), improve help for all applications diff --git a/eq/init.cpp b/eq/init.cpp index df765b1e37..55186588b1 100644 --- a/eq/init.cpp +++ b/eq/init.cpp @@ -81,7 +81,6 @@ const char EQ_CONFIG_PREFIXES[] = "eq-config-prefixes"; const char EQ_RENDER_CLIENT[] = "eq-render-client"; static bool _parseArguments( const int argc, char** argv ); -static void _initPlugins(); bool _init( const int argc, char** argv, NodeFactory* nodeFactory ) { @@ -130,7 +129,6 @@ bool _init( const int argc, char** argv, NodeFactory* nodeFactory ) if( workDir.empty( )) Global::setWorkDir( lunchbox::getWorkDir( )); - _initPlugins(); return fabric::init( argc, argv ); } @@ -144,7 +142,7 @@ bool exit() if( --_initialized > 0 ) // not last return true; - BOOST_FOREACH( WindowSystemIF* windowSystem, _windowSystems ) + for( WindowSystemIF* windowSystem : _windowSystems ) delete windowSystem; _windowSystems.clear(); @@ -281,42 +279,6 @@ bool _parseArguments( const int argc, char** argv ) return true; } -void _initPlugins() -{ - pression::PluginRegistry& plugins = pression::PluginRegistry::getInstance(); - - plugins.loadDirectory( lunchbox::getRootPath() + - "/share/Equalizer/plugins" ); // install dir - plugins.loadDirectory( "/usr/share/Equalizer/plugins" ); - plugins.loadDirectory( "/usr/local/share/Equalizer/plugins" ); - plugins.loadDirectory( ".eqPlugins" ); - plugins.loadDirectory( "/opt/local/lib" ); // MacPorts - plugins.loadDirectory( "/usr/local/lib" ); // Homebrew - - const char* home = getenv( "HOME" ); - if( home ) - plugins.loadDirectory( std::string( home ) + "/.eqPlugins" ); - -#ifdef EQUALIZER_DSO_NAME - plugins.loadFile( EQUALIZER_DSO_NAME ); - std::string absDSO = std::string( EQ_BUILD_DIR ) + "lib/" + - EQUALIZER_DSO_NAME; - plugins.loadFile( absDSO ); - -# ifdef NDEBUG - absDSO = std::string( EQ_BUILD_DIR ) + "lib/Release/" + EQUALIZER_DSO_NAME; -# else - absDSO = std::string( EQ_BUILD_DIR ) + "lib/Debug/" + EQUALIZER_DSO_NAME; -# endif - - plugins.loadFile( absDSO ); -#else -# ifndef NDEBUG -# error "EQUALIZER_DSO_NAME not defined" -# endif -#endif -} - Config* getConfig( const int argc, char** argv ) { // 1. initialization of a local client node diff --git a/eq/windowSystem.cpp b/eq/windowSystem.cpp index 0895a06005..b5ceb49d25 100644 --- a/eq/windowSystem.cpp +++ b/eq/windowSystem.cpp @@ -1,5 +1,5 @@ -/* Copyright (c) 2007-2015, Stefan Eilemann +/* Copyright (c) 2007-2017, Stefan Eilemann * Daniel Pfeifer * Daniel Nachbaur * @@ -28,12 +28,18 @@ namespace eq { -static WindowSystemIF* _stack = 0; +namespace +{ + std::vector< WindowSystemIF* >& _getRegistry() + { + static std::vector< WindowSystemIF* > registry; + return registry; + } +} WindowSystemIF::WindowSystemIF() - : _next( _stack ) { - _stack = this; + _getRegistry().push_back( this ); } uint32_t WindowSystemIF::_setupLists( util::ObjectManager& gl, const void* key, @@ -60,9 +66,9 @@ WindowSystem::WindowSystem( const std::string& type ) void WindowSystem::_chooseImpl( const std::string& name ) { - LBASSERTINFO( _stack, "no window system available" ); + LBASSERTINFO( !_getRegistry().empty(), "no window system available" ); - for( WindowSystemIF* ws = _stack; ws; ws = ws->_next ) + for( auto ws : _getRegistry() ) { if( ws->getName() == name ) { @@ -71,11 +77,10 @@ void WindowSystem::_chooseImpl( const std::string& name ) } } - for( WindowSystemIF* ws = _stack; ws; ws = ws->_next ) + for( auto ws : _getRegistry() ) if( !ws->getName().empty( )) _impl = ws; - if( !_impl ) - _impl = _stack; + _impl = _getRegistry().back(); LBWARN << "Window system '" << name << "' not supported, " << "using " << _impl->getName() << " instead." << std::endl; @@ -83,7 +88,7 @@ void WindowSystem::_chooseImpl( const std::string& name ) bool WindowSystem::supports( std::string const& type ) { - for( WindowSystemIF* ws = _stack; ws; ws = ws->_next ) + for( auto ws : _getRegistry() ) { if( ws->getName() == type ) return true; @@ -94,13 +99,13 @@ bool WindowSystem::supports( std::string const& type ) void WindowSystem::configInit( Node* node ) { - for( WindowSystemIF* ws = _stack; ws; ws = ws->_next ) + for( auto ws : _getRegistry() ) ws->configInit( node ); } void WindowSystem::configExit( Node* node ) { - for( WindowSystemIF* ws = _stack; ws; ws = ws->_next ) + for( auto ws : _getRegistry() ) ws->configExit(node ); } diff --git a/eq/windowSystem.h b/eq/windowSystem.h index 9861eff217..e8904a483d 100644 --- a/eq/windowSystem.h +++ b/eq/windowSystem.h @@ -95,7 +95,6 @@ class WindowSystemIF virtual bool hasMainThreadEvents() const { return false; } private: - WindowSystemIF* _next; friend class WindowSystem; }; From 022077899a4574a07e513749a150a0a4b6dfd505 Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Fri, 17 Feb 2017 17:02:57 +0100 Subject: [PATCH 3/4] Fix weird interaction crash between window systems and plugins by moving plugins into separate library (#618) --- eq/CMakeLists.txt | 14 +++----------- eq/compressor/CMakeLists.txt | 21 +++++++++++++++++++++ eq/init.cpp | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 eq/compressor/CMakeLists.txt diff --git a/eq/CMakeLists.txt b/eq/CMakeLists.txt index 417ee466a1..da76a4c281 100644 --- a/eq/CMakeLists.txt +++ b/eq/CMakeLists.txt @@ -2,11 +2,9 @@ include_directories(SYSTEM ${OPENGL_INCLUDE_DIR} ${GLEW_MX_INCLUDE_DIRS}) -install(FILES DESTINATION include/eq COMPONENT dev) +list(APPEND CPPCHECK_EXTRA_ARGS -DEQ_API=) -list(APPEND CPPCHECK_EXTRA_ARGS -DEQUALIZER_DSO_NAME=foo -DEQ_API=) - -add_definitions(-DEQ_PLUGIN_BUILD -DBOOST_PROGRAM_OPTIONS_DYN_LINK) +add_definitions(-DBOOST_PROGRAM_OPTIONS_DYN_LINK) set(EQUALIZER_PUBLIC_HEADERS agl/eventHandler.h @@ -21,9 +19,6 @@ set(EQUALIZER_PUBLIC_HEADERS client.h commandQueue.h compositor.h - compressor/compressor.h - compressor/compressorReadDrawPixels.h - compressor/compressorYUV.h config.h configStatistics.h eq.h @@ -151,9 +146,6 @@ set(EQUALIZER_SOURCES windowStatistics.cpp windowSystem.cpp worker.cpp - compressor/compressor.cpp - compressor/compressorReadDrawPixels.cpp - compressor/compressorYUV.cpp ) set(EQUALIZER_LINK_LIBRARIES @@ -275,8 +267,8 @@ target_compile_definitions(Equalizer PRIVATE EQUALIZERFABRIC_SHARED_INL) if(CMAKE_COMPILER_IS_CLANG) target_compile_options(Equalizer PUBLIC -Wno-overloaded-virtual) endif() -add_dependencies(Equalizer EqualizerServer) # dlopen'ed +add_subdirectory(compressor) add_subdirectory(fabric) add_subdirectory(server) add_subdirectory(admin) diff --git a/eq/compressor/CMakeLists.txt b/eq/compressor/CMakeLists.txt new file mode 100644 index 0000000000..aacfaaa546 --- /dev/null +++ b/eq/compressor/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright (c) 2017 Stefan.Eilemann@epfl.ch + +include_directories(SYSTEM ${OPENGL_INCLUDE_DIR} ${GLEW_MX_INCLUDE_DIRS}) + +add_definitions(-DEQ_PLUGIN_BUILD) + +set(EQUALIZERCOMPRESSOR_HEADERS + compressor.h + compressorReadDrawPixels.h + compressorYUV.h + ) + +set(EQUALIZERCOMPRESSOR_SOURCES + compressor.cpp + compressorReadDrawPixels.cpp + compressorYUV.cpp + ) + +set(EQUALIZERCOMPRESSOR_LINK_LIBRARIES PRIVATE Equalizer Pression) + +common_library(EqualizerCompressor) diff --git a/eq/init.cpp b/eq/init.cpp index 55186588b1..009276e18f 100644 --- a/eq/init.cpp +++ b/eq/init.cpp @@ -81,6 +81,7 @@ const char EQ_CONFIG_PREFIXES[] = "eq-config-prefixes"; const char EQ_RENDER_CLIENT[] = "eq-render-client"; static bool _parseArguments( const int argc, char** argv ); +static void _initPlugins(); bool _init( const int argc, char** argv, NodeFactory* nodeFactory ) { @@ -129,6 +130,7 @@ bool _init( const int argc, char** argv, NodeFactory* nodeFactory ) if( workDir.empty( )) Global::setWorkDir( lunchbox::getWorkDir( )); + _initPlugins(); return fabric::init( argc, argv ); } @@ -279,6 +281,23 @@ bool _parseArguments( const int argc, char** argv ) return true; } +void _initPlugins() +{ + pression::PluginRegistry& plugins = pression::PluginRegistry::getInstance(); + + plugins.loadDirectory( lunchbox::getRootPath() + + "/share/Equalizer/plugins" ); // install dir + plugins.loadDirectory( "/usr/share/Equalizer/plugins" ); + plugins.loadDirectory( "/usr/local/share/Equalizer/plugins" ); + plugins.loadDirectory( ".eqPlugins" ); + plugins.loadDirectory( "/opt/local/lib" ); // MacPorts + plugins.loadDirectory( "/usr/local/lib" ); // Homebrew + + const char* home = getenv( "HOME" ); + if( home ) + plugins.loadDirectory( std::string( home ) + "/.eqPlugins" ); +} + Config* getConfig( const int argc, char** argv ) { // 1. initialization of a local client node From 030cf768fb8b8dea09dc5fd0cdea60d9cf8d30fc Mon Sep 17 00:00:00 2001 From: Stefan Eilemann Date: Fri, 17 Feb 2017 17:18:06 +0100 Subject: [PATCH 4/4] Fix YUV downloader --- eq/compressor/compressorYUV.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/eq/compressor/compressorYUV.cpp b/eq/compressor/compressorYUV.cpp index 7bcb67f2ac..c309fb1f99 100644 --- a/eq/compressor/compressorYUV.cpp +++ b/eq/compressor/compressorYUV.cpp @@ -138,13 +138,23 @@ void CompressorYUV::_compress( const GLEWContext* glewContext, if ( _fbo ) { - LBCHECK( _fbo->resize( outDims[1], outDims[3] )); + const auto error = _fbo->resize( outDims[1], outDims[3] ); + if( error != ERROR_NONE ) + { + LBERROR << "FBO resize failed: " << error << std::endl; + return; + } _fbo->bind(); } else { _fbo = new util::FrameBufferObject( glewContext ); - LBCHECK( _fbo->init( outDims[1], outDims[3], GL_RGBA, 0, 0 )); + const auto error = _fbo->init( outDims[1], outDims[3], GL_RGBA, 0, 0 ); + if( error != ERROR_NONE ) + { + LBERROR << "FBO init failed: " << error << std::endl; + return; + } } _texture->bind();