Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit d623e384 authored by schultezub's avatar schultezub
Browse files

* added singleton implementation to kisscl::CLRuntime

 * added (de)initialization of KissCL to TumVisApplication

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@243 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent d8d4738a
......@@ -38,6 +38,8 @@
#include "tgt/qt/qtcontextmanager.h"
#include "tbb/include/tbb/compat/thread"
#include "kisscl/clruntime.h"
#include "application/tumvispainter.h"
#include "application/gui/mainwindow.h"
#include "core/pipeline/abstractpipeline.h"
......@@ -48,11 +50,12 @@ namespace TUMVis {
const std::string TumVisApplication::loggerCat_ = "TUMVis.application.TumVisApplication";
TumVisApplication::TumVisApplication(int argc, char** argv)
TumVisApplication::TumVisApplication(int argc, char** argv, bool useOpenCL)
: QApplication(argc, argv)
, _localContext(0)
, _mainWindow(0)
, _initialized(false)
, _useOpenCL(useOpenCL)
, _argc(argc)
, _argv(argv)
{
......@@ -93,6 +96,7 @@ namespace TUMVis {
tgt::GLContextScopedLock lock(_localContext->getContext());
tgt::initGL(featureset);
ShdrMgr.setGlobalHeader("#version 130\n");
LGL_ERROR;
// ensure matching OpenGL specs
......@@ -103,6 +107,10 @@ namespace TUMVis {
LERROR("Your system does not support GLSL Shader Version 1.30, which is mandatory. TUMVis will probably not work as intendet.");
}
if (_useOpenCL) {
kisscl::CLRuntime::init();
}
if (_argc > 0) {
// ugly hack
std::string programPath(_argv[0]);
......@@ -131,6 +139,10 @@ namespace TUMVis {
// Deinit everything OpenGL related using the local context.
tgt::GLContextScopedLock lock(_localContext->getContext());
if (_useOpenCL) {
kisscl::CLRuntime::deinit();
}
// Deinit pipeline first
for (std::vector<AbstractPipeline*>::iterator it = _pipelines.begin(); it != _pipelines.end(); ++it) {
(*it)->deinit();
......
......@@ -63,10 +63,11 @@ namespace TUMVis {
public:
/**
* Creates a new TumVisApplication.
* \param argc number of passed arguments
* \param argv vector of arguments
* \param argc number of passed arguments
* \param argv vector of arguments
* \param useOpenCL Flag, whether to use OpenCL (inits and deinits KissCL lib at the appropriate time).
*/
TumVisApplication(int argc, char** argv);
TumVisApplication(int argc, char** argv, bool useOpenCL = true);
/**
* Destructor, make sure to call deinit() first.
......@@ -131,6 +132,9 @@ namespace TUMVis {
/// Flag, whether TumVisApplication was correctly initialized
bool _initialized;
/// Flag, whether to use OpenCL (inits and deinits KissCL lib at the appropriate time).
bool _useOpenCL;
int _argc;
char** _argv;
......
......@@ -37,9 +37,13 @@ namespace kisscl {
* Singleton class for managing the OpenCL runtime.
* Gathers all available OpenCL platforms/devices and offers methods to create OpenCL contexts on them.
*/
class CLRuntime {
class CLRuntime : public tgt::Singleton<CLRuntime> {
friend class tgt::Singleton<CLRuntime>;
public:
CLRuntime();
/**
* Destructor, cleaning up all platforms and devices.
*/
~CLRuntime();
/**
......@@ -73,10 +77,16 @@ namespace kisscl {
std::vector<Device*> _cpuDevices; ///< List of all OpenCL CPU devices (just a shortcut to the corresponding devices in _platforms)
std::vector<Device*> _gpuDevices; ///< List of all OpenCL GPU devices (just a shortcut to the corresponding devices in _platforms)
/**
* Private constructor for singleton pattern.
*/
CLRuntime();
static const std::string loggerCat_;
};
#define CLMgr tgt::Singleton<kisscl::CLRuntime>::getRef()
}
#endif // KISSCL_CLRUNTIME_H__
......@@ -67,8 +67,7 @@ namespace TUMVis {
void DVRVis::init() {
VisualizationPipeline::init();
kisscl::CLRuntime clr;
kisscl::Context* context = clr.createGlSharingContext();
kisscl::Context* context = CLMgr.createGlSharingContext();
delete context;
_camera.addSharedProperty(&_eepGenerator._camera);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment