Skip to content

Commit

Permalink
[opencl] Initialize opencl path from cmd line and env
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Aug 8, 2018
1 parent 82fdb56 commit 9ed9cbd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
35 changes: 35 additions & 0 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ typedef SInt32 SRefCon;
#include "qgsuserprofilemanager.h"
#include "qgsuserprofile.h"

#ifdef HAVE_OPENCL
#include "qgsopenclutils.h"
#endif

/**
* Print usage text
*/
Expand Down Expand Up @@ -141,6 +145,9 @@ void usage( const QString &appName )
<< QStringLiteral( "\t[--profile name]\tload a named profile from the users profiles folder.\n" )
<< QStringLiteral( "\t[--profiles-path path]\tpath to store user profile folders. Will create profiles inside a {path}\\profiles folder \n" )
<< QStringLiteral( "\t[--version-migration]\tforce the settings migration from older version if found\n" )
#ifdef HAVE_OPENCL
<< QStringLiteral( "\t[--openclprogramfolder]\t\tpath to the folder containing the sources for OpenCL programs.\n" )
#endif
<< QStringLiteral( "\t[--help]\t\tthis text\n" )
<< QStringLiteral( "\t[--]\t\ttreat all following arguments as FILEs\n\n" )
<< QStringLiteral( " FILE:\n" )
Expand Down Expand Up @@ -543,6 +550,10 @@ int main( int argc, char *argv[] )
QString customizationfile;
QString globalsettingsfile;

#ifdef HAVE_OPENCL
QString openClProgramFolder;
#endif

// TODO Fix android
#if defined(ANDROID)
QgsDebugMsg( QString( "Android: All params stripped" ) );// Param %1" ).arg( argv[0] ) );
Expand Down Expand Up @@ -726,6 +737,12 @@ int main( int argc, char *argv[] )
{
dxfMapTheme = args[++i];
}
#ifdef HAVE_OPENCL
else if ( arg == QLatin1String( "--openclprogramfolder" ) )
{
openClProgramFolder = args[++i];
}
#endif
else if ( arg == QLatin1String( "--" ) )
{
for ( i++; i < args.size(); ++i )
Expand Down Expand Up @@ -1444,6 +1461,24 @@ int main( int argc, char *argv[] )
// make sure we don't have a dirty blank project after launch
QgsProject::instance()->setDirty( false );

#ifdef HAVE_OPENCL

// Overrides the OpenCL path to the folder containing the programs
// - use the path specified with --openclprogramfolder,
// - use the environment QGIS_OPENCL_PROGRAM_FOLDER if not found
// - use a default location as a fallback (this is set in QgsApplication initialization)
if ( openClProgramFolder.isEmpty() )
{
openClProgramFolder = getenv( "QGIS_OPENCL_PROGRAM_FOLDER" );
}

if ( ! openClProgramFolder.isEmpty() )
{
QgsOpenClUtils::setSourcePath( openClProgramFolder );
}

#endif

/////////////////////////////////////////////////////////////////////
// Continue on to interactive gui...
/////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 1 addition & 2 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,8 +1118,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh


#ifdef HAVE_OPENCL
// Setup OpenCL source path
// TODO: cmd line switch and env var
// Setup the default OpenCL programs source path, this my be overriden later by main.cpp startup
QgsOpenClUtils::setSourcePath( QDir( QgsApplication::pkgDataPath() ).absoluteFilePath( QStringLiteral( "resources/opencl_programs" ) ) );
#endif

Expand Down

0 comments on commit 9ed9cbd

Please sign in to comment.