Three-in-one commit:
- Compositor now is threaded
Enable it with the Scene buttons "Threads". This will handle over nodes to
individual threads to be calculated. However, if nodes depend on others
they have to wait. The current system only threads per entire node, not for
calculating results in parts.
I've reshuffled the node execution code to evaluate 'changed' events, and
prepare the entire tree to become simply parsed for open jobs with a call
to node = getExecutableNode()
By default, even without 'thread' option active, all node execution is
done within a separate thread.
Also fixed issues in yesterdays commit for 'event based' calculations, it
didn't do animated images, or execute (on rendering) the correct nodes
when you don't have Render-Result nodes included.
- Added generic Thread support in blenlib/ module
The renderer and the node system now both use same code for controlling the
threads. This has been moved to a new C file in blenlib/intern/threads.c.
Check this c file for an extensive doc and example how to use it.
The current implementation for Compositing allows unlimited amount of
threads. For rendering it is still tied to two threads, although it is
pretty easy to extend to 4 already. People with giant amounts of cpus can
poke me once for tests. :)
- Bugfix in creating group nodes
Group node definitions demand a clear separation of 'internal sockets' and
'external sockets'. The first are sockets being linked internally, the latter
are sockets exposed as sockets for the group itself.
When sockets were linked both internal and external, Blender crashed. It is
solved now by removing the external link(s).
2006-01-29 11:36:33 +00:00
|
|
|
/*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Three-in-one commit:
- Compositor now is threaded
Enable it with the Scene buttons "Threads". This will handle over nodes to
individual threads to be calculated. However, if nodes depend on others
they have to wait. The current system only threads per entire node, not for
calculating results in parts.
I've reshuffled the node execution code to evaluate 'changed' events, and
prepare the entire tree to become simply parsed for open jobs with a call
to node = getExecutableNode()
By default, even without 'thread' option active, all node execution is
done within a separate thread.
Also fixed issues in yesterdays commit for 'event based' calculations, it
didn't do animated images, or execute (on rendering) the correct nodes
when you don't have Render-Result nodes included.
- Added generic Thread support in blenlib/ module
The renderer and the node system now both use same code for controlling the
threads. This has been moved to a new C file in blenlib/intern/threads.c.
Check this c file for an extensive doc and example how to use it.
The current implementation for Compositing allows unlimited amount of
threads. For rendering it is still tied to two threads, although it is
pretty easy to extend to 4 already. People with giant amounts of cpus can
poke me once for tests. :)
- Bugfix in creating group nodes
Group node definitions demand a clear separation of 'internal sockets' and
'external sockets'. The first are sockets being linked internally, the latter
are sockets exposed as sockets for the group itself.
When sockets were linked both internal and external, Blender crashed. It is
solved now by removing the external link(s).
2006-01-29 11:36:33 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2006 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BLI_THREADS_H__
|
|
|
|
#define __BLI_THREADS_H__
|
Three-in-one commit:
- Compositor now is threaded
Enable it with the Scene buttons "Threads". This will handle over nodes to
individual threads to be calculated. However, if nodes depend on others
they have to wait. The current system only threads per entire node, not for
calculating results in parts.
I've reshuffled the node execution code to evaluate 'changed' events, and
prepare the entire tree to become simply parsed for open jobs with a call
to node = getExecutableNode()
By default, even without 'thread' option active, all node execution is
done within a separate thread.
Also fixed issues in yesterdays commit for 'event based' calculations, it
didn't do animated images, or execute (on rendering) the correct nodes
when you don't have Render-Result nodes included.
- Added generic Thread support in blenlib/ module
The renderer and the node system now both use same code for controlling the
threads. This has been moved to a new C file in blenlib/intern/threads.c.
Check this c file for an extensive doc and example how to use it.
The current implementation for Compositing allows unlimited amount of
threads. For rendering it is still tied to two threads, although it is
pretty easy to extend to 4 already. People with giant amounts of cpus can
poke me once for tests. :)
- Bugfix in creating group nodes
Group node definitions demand a clear separation of 'internal sockets' and
'external sockets'. The first are sockets being linked internally, the latter
are sockets exposed as sockets for the group itself.
When sockets were linked both internal and external, Blender crashed. It is
solved now by removing the external link(s).
2006-01-29 11:36:33 +00:00
|
|
|
|
2011-02-18 13:58:08 +00:00
|
|
|
/** \file BLI_threads.h
|
|
|
|
* \ingroup bli
|
|
|
|
*/
|
2012-07-10 06:31:16 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2011-02-18 13:58:08 +00:00
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
#include <pthread.h>
|
2006-03-13 11:01:17 +00:00
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
#include <libkern/OSAtomic.h>
|
|
|
|
#endif
|
|
|
|
|
2006-11-29 17:01:09 +00:00
|
|
|
/* for tables, button in UI, etc */
|
2015-06-07 22:48:51 +02:00
|
|
|
#define BLENDER_MAX_THREADS 1024
|
2006-11-29 17:01:09 +00:00
|
|
|
|
|
|
|
struct ListBase;
|
2013-10-12 14:08:59 +00:00
|
|
|
struct TaskScheduler;
|
2009-09-30 18:18:32 +00:00
|
|
|
|
|
|
|
/* Threading API */
|
|
|
|
|
2010-04-13 12:51:03 +00:00
|
|
|
/*this is run once at startup*/
|
|
|
|
void BLI_threadapi_init(void);
|
2013-08-19 10:51:40 +00:00
|
|
|
void BLI_threadapi_exit(void);
|
2010-04-13 12:51:03 +00:00
|
|
|
|
2013-10-12 14:08:59 +00:00
|
|
|
struct TaskScheduler *BLI_task_scheduler_get(void);
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
void BLI_init_threads(struct ListBase *threadbase, void *(*do_thread)(void *), int tot);
|
|
|
|
int BLI_available_threads(struct ListBase *threadbase);
|
|
|
|
int BLI_available_thread_index(struct ListBase *threadbase);
|
|
|
|
void BLI_insert_thread(struct ListBase *threadbase, void *callerdata);
|
|
|
|
void BLI_remove_thread(struct ListBase *threadbase, void *callerdata);
|
|
|
|
void BLI_remove_thread_index(struct ListBase *threadbase, int index);
|
|
|
|
void BLI_remove_threads(struct ListBase *threadbase);
|
|
|
|
void BLI_end_threads(struct ListBase *threadbase);
|
|
|
|
int BLI_thread_is_main(void);
|
2006-02-11 15:55:00 +00:00
|
|
|
|
2011-10-22 16:16:14 +00:00
|
|
|
|
|
|
|
void BLI_begin_threaded_malloc(void);
|
|
|
|
void BLI_end_threaded_malloc(void);
|
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
/* System Information */
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
int BLI_system_thread_count(void); /* gets the number of threads the system can make use of */
|
2013-05-08 13:23:17 +00:00
|
|
|
void BLI_system_num_threads_override_set(int num);
|
|
|
|
int BLI_system_num_threads_override_get(void);
|
2014-03-31 13:51:40 +02:00
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
/* Global Mutex Locks
|
|
|
|
*
|
|
|
|
* One custom lock available now. can be extended. */
|
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
#define LOCK_IMAGE 0
|
2012-07-13 13:47:13 +00:00
|
|
|
#define LOCK_DRAW_IMAGE 1
|
2012-05-12 20:39:39 +00:00
|
|
|
#define LOCK_VIEWER 2
|
|
|
|
#define LOCK_CUSTOM1 3
|
|
|
|
#define LOCK_RCACHE 4
|
|
|
|
#define LOCK_OPENGL 5
|
|
|
|
#define LOCK_NODES 6
|
|
|
|
#define LOCK_MOVIECLIP 7
|
Color Management, Stage 2: Switch color pipeline to use OpenColorIO
Replace old color pipeline which was supporting linear/sRGB color spaces
only with OpenColorIO-based pipeline.
This introduces two configurable color spaces:
- Input color space for images and movie clips. This space is used to convert
images/movies from color space in which file is saved to Blender's linear
space (for float images, byte images are not internally converted, only input
space is stored for such images and used later).
This setting could be found in image/clip data block settings.
- Display color space which defines space in which particular display is working.
This settings could be found in scene's Color Management panel.
When render result is being displayed on the screen, apart from converting image
to display space, some additional conversions could happen.
This conversions are:
- View, which defines tone curve applying before display transformation.
These are different ways to view the image on the same display device.
For example it could be used to emulate film view on sRGB display.
- Exposure affects on image exposure before tone map is applied.
- Gamma is post-display gamma correction, could be used to match particular
display gamma.
- RGB curves are user-defined curves which are applying before display
transformation, could be used for different purposes.
All this settings by default are only applying on render result and does not
affect on other images. If some particular image needs to be affected by this
transformation, "View as Render" setting of image data block should be set to
truth. Movie clips are always affected by all display transformations.
This commit also introduces configurable color space in which sequencer is
working. This setting could be found in scene's Color Management panel and
it should be used if such stuff as grading needs to be done in color space
different from sRGB (i.e. when Film view on sRGB display is use, using VD16
space as sequencer's internal space would make grading working in space
which is close to the space using for display).
Some technical notes:
- Image buffer's float buffer is now always in linear space, even if it was
created from 16bit byte images.
- Space of byte buffer is stored in image buffer's rect_colorspace property.
- Profile of image buffer was removed since it's not longer meaningful.
- OpenGL and GLSL is supposed to always work in sRGB space. It is possible
to support other spaces, but it's quite large project which isn't so
much important.
- Legacy Color Management option disabled is emulated by using None display.
It could have some regressions, but there's no clear way to avoid them.
- If OpenColorIO is disabled on build time, it should make blender behaving
in the same way as previous release with color management enabled.
More details could be found at this page (more details would be added soon):
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Color_Management
--
Thanks to Xavier Thomas, Lukas Toene for initial work on OpenColorIO
integration and to Brecht van Lommel for some further development and code/
usecase review!
2012-09-15 10:05:07 +00:00
|
|
|
#define LOCK_COLORMANAGE 8
|
2014-03-01 20:46:58 +01:00
|
|
|
#define LOCK_FFTW 9
|
2015-04-06 10:40:12 -03:00
|
|
|
#define LOCK_VIEW3D 10
|
2009-09-30 18:18:32 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
void BLI_lock_thread(int type);
|
|
|
|
void BLI_unlock_thread(int type);
|
2009-09-30 18:18:32 +00:00
|
|
|
|
|
|
|
/* Mutex Lock */
|
|
|
|
|
|
|
|
typedef pthread_mutex_t ThreadMutex;
|
2012-05-12 20:39:39 +00:00
|
|
|
#define BLI_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
2009-09-30 18:18:32 +00:00
|
|
|
|
|
|
|
void BLI_mutex_init(ThreadMutex *mutex);
|
2013-04-24 17:31:09 +00:00
|
|
|
void BLI_mutex_end(ThreadMutex *mutex);
|
|
|
|
|
|
|
|
ThreadMutex *BLI_mutex_alloc(void);
|
|
|
|
void BLI_mutex_free(ThreadMutex *mutex);
|
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
void BLI_mutex_lock(ThreadMutex *mutex);
|
2013-10-12 14:08:59 +00:00
|
|
|
bool BLI_mutex_trylock(ThreadMutex *mutex);
|
2009-09-30 18:18:32 +00:00
|
|
|
void BLI_mutex_unlock(ThreadMutex *mutex);
|
2006-02-11 15:55:00 +00:00
|
|
|
|
2012-11-15 15:59:58 +00:00
|
|
|
/* Spin Lock */
|
|
|
|
|
2017-11-14 12:21:15 +01:00
|
|
|
#if defined(__APPLE__)
|
2017-11-14 16:51:34 +02:00
|
|
|
typedef OSSpinLock SpinLock;
|
2017-11-14 12:21:15 +01:00
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
typedef volatile int SpinLock;
|
2012-11-15 15:59:58 +00:00
|
|
|
#else
|
|
|
|
typedef pthread_spinlock_t SpinLock;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void BLI_spin_init(SpinLock *spin);
|
|
|
|
void BLI_spin_lock(SpinLock *spin);
|
|
|
|
void BLI_spin_unlock(SpinLock *spin);
|
|
|
|
void BLI_spin_end(SpinLock *spin);
|
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
/* Read/Write Mutex Lock */
|
2008-08-16 22:47:33 +00:00
|
|
|
|
2012-05-12 20:39:39 +00:00
|
|
|
#define THREAD_LOCK_READ 1
|
|
|
|
#define THREAD_LOCK_WRITE 2
|
2009-06-08 10:00:14 +00:00
|
|
|
|
2013-12-29 16:40:34 +06:00
|
|
|
#define BLI_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER
|
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
typedef pthread_rwlock_t ThreadRWMutex;
|
|
|
|
|
|
|
|
void BLI_rw_mutex_init(ThreadRWMutex *mutex);
|
2013-04-24 17:31:09 +00:00
|
|
|
void BLI_rw_mutex_end(ThreadRWMutex *mutex);
|
|
|
|
|
|
|
|
ThreadRWMutex *BLI_rw_mutex_alloc(void);
|
|
|
|
void BLI_rw_mutex_free(ThreadRWMutex *mutex);
|
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
void BLI_rw_mutex_lock(ThreadRWMutex *mutex, int mode);
|
|
|
|
void BLI_rw_mutex_unlock(ThreadRWMutex *mutex);
|
|
|
|
|
2013-07-08 17:56:51 +00:00
|
|
|
/* Ticket Mutex Lock
|
|
|
|
*
|
|
|
|
* This is a 'fair' mutex in that it will grant the lock to the first thread
|
|
|
|
* that requests it. */
|
|
|
|
|
|
|
|
typedef struct TicketMutex TicketMutex;
|
|
|
|
|
|
|
|
TicketMutex *BLI_ticket_mutex_alloc(void);
|
|
|
|
void BLI_ticket_mutex_free(TicketMutex *ticket);
|
|
|
|
void BLI_ticket_mutex_lock(TicketMutex *ticket);
|
|
|
|
void BLI_ticket_mutex_unlock(TicketMutex *ticket);
|
|
|
|
|
2013-10-12 14:08:59 +00:00
|
|
|
/* Condition */
|
|
|
|
|
|
|
|
typedef pthread_cond_t ThreadCondition;
|
2008-08-16 22:47:33 +00:00
|
|
|
|
2013-10-12 14:08:59 +00:00
|
|
|
void BLI_condition_init(ThreadCondition *cond);
|
|
|
|
void BLI_condition_wait(ThreadCondition *cond, ThreadMutex *mutex);
|
2015-08-10 15:03:31 +02:00
|
|
|
void BLI_condition_wait_global_mutex(ThreadCondition *cond, const int type);
|
2013-10-12 14:08:59 +00:00
|
|
|
void BLI_condition_notify_one(ThreadCondition *cond);
|
|
|
|
void BLI_condition_notify_all(ThreadCondition *cond);
|
|
|
|
void BLI_condition_end(ThreadCondition *cond);
|
2008-08-16 22:47:33 +00:00
|
|
|
|
2010-01-22 11:06:57 +00:00
|
|
|
/* ThreadWorkQueue
|
|
|
|
*
|
|
|
|
* Thread-safe work queue to push work/pointers between threads. */
|
|
|
|
|
|
|
|
typedef struct ThreadQueue ThreadQueue;
|
|
|
|
|
2010-12-03 12:30:59 +00:00
|
|
|
ThreadQueue *BLI_thread_queue_init(void);
|
2010-01-22 11:06:57 +00:00
|
|
|
void BLI_thread_queue_free(ThreadQueue *queue);
|
|
|
|
|
|
|
|
void BLI_thread_queue_push(ThreadQueue *queue, void *work);
|
|
|
|
void *BLI_thread_queue_pop(ThreadQueue *queue);
|
|
|
|
void *BLI_thread_queue_pop_timeout(ThreadQueue *queue, int ms);
|
|
|
|
int BLI_thread_queue_size(ThreadQueue *queue);
|
2015-06-19 12:30:21 +02:00
|
|
|
bool BLI_thread_queue_is_empty(ThreadQueue *queue);
|
2010-01-22 11:06:57 +00:00
|
|
|
|
2012-06-10 12:26:33 +00:00
|
|
|
void BLI_thread_queue_wait_finish(ThreadQueue *queue);
|
2010-01-22 11:06:57 +00:00
|
|
|
void BLI_thread_queue_nowait(ThreadQueue *queue);
|
2008-08-16 22:47:33 +00:00
|
|
|
|
2016-03-03 15:53:42 +05:00
|
|
|
|
|
|
|
/* Thread local storage */
|
|
|
|
|
|
|
|
#if defined(__APPLE__)
|
|
|
|
# define ThreadLocal(type) pthread_key_t
|
|
|
|
# define BLI_thread_local_create(name) pthread_key_create(&name, NULL)
|
|
|
|
# define BLI_thread_local_delete(name) pthread_key_delete(name)
|
|
|
|
# define BLI_thread_local_get(name) pthread_getspecific(name)
|
|
|
|
# define BLI_thread_local_set(name, value) pthread_setspecific(name, value)
|
|
|
|
#else /* defined(__APPLE__) */
|
|
|
|
# ifdef _MSC_VER
|
|
|
|
# define ThreadLocal(type) __declspec(thread) type
|
|
|
|
# else
|
|
|
|
# define ThreadLocal(type) __thread type
|
|
|
|
# endif
|
|
|
|
# define BLI_thread_local_create(name)
|
|
|
|
# define BLI_thread_local_delete(name)
|
|
|
|
# define BLI_thread_local_get(name) name
|
|
|
|
# define BLI_thread_local_set(name, value) name = value
|
|
|
|
#endif /* defined(__APPLE__) */
|
|
|
|
|
2012-07-10 06:31:16 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
Three-in-one commit:
- Compositor now is threaded
Enable it with the Scene buttons "Threads". This will handle over nodes to
individual threads to be calculated. However, if nodes depend on others
they have to wait. The current system only threads per entire node, not for
calculating results in parts.
I've reshuffled the node execution code to evaluate 'changed' events, and
prepare the entire tree to become simply parsed for open jobs with a call
to node = getExecutableNode()
By default, even without 'thread' option active, all node execution is
done within a separate thread.
Also fixed issues in yesterdays commit for 'event based' calculations, it
didn't do animated images, or execute (on rendering) the correct nodes
when you don't have Render-Result nodes included.
- Added generic Thread support in blenlib/ module
The renderer and the node system now both use same code for controlling the
threads. This has been moved to a new C file in blenlib/intern/threads.c.
Check this c file for an extensive doc and example how to use it.
The current implementation for Compositing allows unlimited amount of
threads. For rendering it is still tied to two threads, although it is
pretty easy to extend to 4 already. People with giant amounts of cpus can
poke me once for tests. :)
- Bugfix in creating group nodes
Group node definitions demand a clear separation of 'internal sockets' and
'external sockets'. The first are sockets being linked internally, the latter
are sockets exposed as sockets for the group itself.
When sockets were linked both internal and external, Blender crashed. It is
solved now by removing the external link(s).
2006-01-29 11:36:33 +00:00
|
|
|
#endif
|
|
|
|
|