Compositor: initialize OpenCL only when the option is enabled. This eliminates
error prints or even crashes for poor OpenCL implementations when not using it.
This commit is contained in:
@@ -36,24 +36,29 @@ extern "C" {
|
||||
|
||||
static ThreadMutex s_compositorMutex;
|
||||
static char is_compositorMutex_init = FALSE;
|
||||
|
||||
void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
|
||||
{
|
||||
if (is_compositorMutex_init == FALSE) { /// TODO: move to blender startup phase
|
||||
memset(&s_compositorMutex, 0, sizeof(s_compositorMutex));
|
||||
/* initialize mutex, TODO this mutex init is actually not thread safe and
|
||||
* should be done somewhere as part of blender startup, all the other
|
||||
* initializations can be done lazily */
|
||||
if (is_compositorMutex_init == FALSE) {
|
||||
BLI_mutex_init(&s_compositorMutex);
|
||||
OCL_init();
|
||||
WorkScheduler::initialize(); ///TODO: call workscheduler.deinitialize somewhere
|
||||
is_compositorMutex_init = TRUE;
|
||||
}
|
||||
|
||||
BLI_mutex_lock(&s_compositorMutex);
|
||||
|
||||
if (editingtree->test_break(editingtree->tbh)) {
|
||||
// during editing multiple calls to this method can be triggered.
|
||||
// make sure one the last one will be doing the work.
|
||||
BLI_mutex_unlock(&s_compositorMutex);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/* initialize workscheduler, will check if already done. TODO deinitialize somewhere */
|
||||
bool use_opencl = (editingtree->flag & NTREE_COM_OPENCL);
|
||||
WorkScheduler::initialize(use_opencl);
|
||||
|
||||
/* set progress bar to 0% and status to init compositing */
|
||||
editingtree->progress(editingtree->prh, 0.0);
|
||||
@@ -83,11 +88,12 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering)
|
||||
|
||||
void COM_deinitialize()
|
||||
{
|
||||
if (is_compositorMutex_init)
|
||||
{
|
||||
if (is_compositorMutex_init) {
|
||||
BLI_mutex_lock(&s_compositorMutex);
|
||||
|
||||
deintializeDistortionCache();
|
||||
WorkScheduler::deinitialize();
|
||||
|
||||
is_compositorMutex_init = FALSE;
|
||||
BLI_mutex_unlock(&s_compositorMutex);
|
||||
BLI_mutex_end(&s_compositorMutex);
|
||||
|
Reference in New Issue
Block a user