Cleanup: rename BLI_thread.h API
- Use BLI_threadpool_ prefix for (deprecated) thread/listbase API. - Use BLI_thread as prefix for other functions. See P614 to apply instead of manually resolving conflicts.
This commit is contained in:
parent
ccdacf1c9b
commit
2aef87bfae
|
@ -4557,7 +4557,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
|
|||
}
|
||||
|
||||
/* begin thread safe malloc */
|
||||
BLI_begin_threaded_malloc();
|
||||
BLI_threaded_malloc_begin();
|
||||
|
||||
/* only continue if particle bb is close enough to canvas bb */
|
||||
if (boundsIntersectDist(&grid->grid_bounds, &part_bb, range)) {
|
||||
|
@ -4592,7 +4592,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
|
|||
&settings);
|
||||
}
|
||||
}
|
||||
BLI_end_threaded_malloc();
|
||||
BLI_threaded_malloc_end();
|
||||
BLI_kdtree_free(tree);
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -2547,7 +2547,7 @@ void BKE_image_verify_viewer_views(const RenderData *rd, Image *ima, ImageUser *
|
|||
bool do_reset;
|
||||
const bool is_multiview = (rd->scemode & R_MULTIVIEW) != 0;
|
||||
|
||||
BLI_lock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_lock(LOCK_DRAW_IMAGE);
|
||||
|
||||
if (!BKE_scene_multiview_is_stereo3d(rd))
|
||||
iuser->flag &= ~IMA_SHOW_STEREO;
|
||||
|
@ -2581,7 +2581,7 @@ void BKE_image_verify_viewer_views(const RenderData *rd, Image *ima, ImageUser *
|
|||
BLI_spin_unlock(&image_spin);
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||
}
|
||||
|
||||
void BKE_image_walk_all_users(const Main *mainp, void *customdata,
|
||||
|
@ -3662,7 +3662,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
|
|||
|
||||
/* release is done in BKE_image_release_ibuf using r_lock */
|
||||
if (from_render) {
|
||||
BLI_lock_thread(LOCK_VIEWER);
|
||||
BLI_thread_lock(LOCK_VIEWER);
|
||||
*r_lock = re;
|
||||
rv = NULL;
|
||||
}
|
||||
|
@ -3755,7 +3755,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
|
|||
}
|
||||
|
||||
/* invalidate color managed buffers if render result changed */
|
||||
BLI_lock_thread(LOCK_COLORMANAGE);
|
||||
BLI_thread_lock(LOCK_COLORMANAGE);
|
||||
if (ibuf->x != rres.rectx || ibuf->y != rres.recty || ibuf->rect_float != rectf) {
|
||||
ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID;
|
||||
}
|
||||
|
@ -3796,7 +3796,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **r_loc
|
|||
ibuf->flags &= ~IB_zbuffloat;
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
BLI_thread_unlock(LOCK_COLORMANAGE);
|
||||
|
||||
ibuf->dither = dither;
|
||||
|
||||
|
@ -3998,7 +3998,7 @@ static ImBuf *image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
|
|||
/* requires lock/unlock, otherwise don't return image */
|
||||
if (r_lock) {
|
||||
/* unlock in BKE_image_release_ibuf */
|
||||
BLI_lock_thread(LOCK_VIEWER);
|
||||
BLI_thread_lock(LOCK_VIEWER);
|
||||
*r_lock = ima;
|
||||
|
||||
/* XXX anim play for viewer nodes not yet supported */
|
||||
|
@ -4051,11 +4051,11 @@ void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
|
|||
if (lock) {
|
||||
/* for getting image during threaded render / compositing, need to release */
|
||||
if (lock == ima) {
|
||||
BLI_unlock_thread(LOCK_VIEWER); /* viewer image */
|
||||
BLI_thread_unlock(LOCK_VIEWER); /* viewer image */
|
||||
}
|
||||
else if (lock) {
|
||||
RE_ReleaseResultImage(lock); /* render result */
|
||||
BLI_unlock_thread(LOCK_VIEWER); /* view image imbuf */
|
||||
BLI_thread_unlock(LOCK_VIEWER); /* view image imbuf */
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -926,7 +926,7 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip,
|
|||
|
||||
/* cache isn't threadsafe itself and also loading of movies
|
||||
* can't happen from concurrent threads that's why we use lock here */
|
||||
BLI_lock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_lock(LOCK_MOVIECLIP);
|
||||
|
||||
/* try to obtain cached postprocessed frame first */
|
||||
if (need_postprocessed_frame(user, postprocess_flag)) {
|
||||
|
@ -976,7 +976,7 @@ static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip,
|
|||
}
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_unlock(LOCK_MOVIECLIP);
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
@ -1410,13 +1410,13 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i
|
|||
* could be solved in a way that thread only prepares memory
|
||||
* buffer and write to disk happens separately
|
||||
*/
|
||||
BLI_lock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_lock(LOCK_MOVIECLIP);
|
||||
|
||||
BLI_make_existing_file(name);
|
||||
if (IMB_saveiff(scaleibuf, name, IB_rect) == 0)
|
||||
perror(name);
|
||||
|
||||
BLI_unlock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_unlock(LOCK_MOVIECLIP);
|
||||
|
||||
IMB_freeImBuf(scaleibuf);
|
||||
}
|
||||
|
@ -1560,9 +1560,9 @@ ImBuf *BKE_movieclip_anim_ibuf_for_frame(MovieClip *clip, MovieClipUser *user)
|
|||
ImBuf *ibuf = NULL;
|
||||
|
||||
if (clip->source == MCLIP_SRC_MOVIE) {
|
||||
BLI_lock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_lock(LOCK_MOVIECLIP);
|
||||
ibuf = movieclip_load_movie_file(clip, user, user->framenr, clip->flag);
|
||||
BLI_unlock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_unlock(LOCK_MOVIECLIP);
|
||||
}
|
||||
|
||||
return ibuf;
|
||||
|
@ -1572,9 +1572,9 @@ bool BKE_movieclip_has_cached_frame(MovieClip *clip, MovieClipUser *user)
|
|||
{
|
||||
bool has_frame = false;
|
||||
|
||||
BLI_lock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_lock(LOCK_MOVIECLIP);
|
||||
has_frame = has_imbuf_cache(clip, user, clip->flag);
|
||||
BLI_unlock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_unlock(LOCK_MOVIECLIP);
|
||||
|
||||
return has_frame;
|
||||
}
|
||||
|
@ -1585,9 +1585,9 @@ bool BKE_movieclip_put_frame_if_possible(MovieClip *clip,
|
|||
{
|
||||
bool result;
|
||||
|
||||
BLI_lock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_lock(LOCK_MOVIECLIP);
|
||||
result = put_imbuf_cache(clip, user, ibuf, clip->flag, false);
|
||||
BLI_unlock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_unlock(LOCK_MOVIECLIP);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -917,7 +917,7 @@ void BKE_ocean_init(struct Ocean *o, int M, int N, float Lx, float Lz, float V,
|
|||
o->_fft_in = (fftw_complex *)MEM_mallocN(o->_M * (1 + o->_N / 2) * sizeof(fftw_complex), "ocean_fft_in");
|
||||
o->_htilda = (fftw_complex *)MEM_mallocN(o->_M * (1 + o->_N / 2) * sizeof(fftw_complex), "ocean_htilda");
|
||||
|
||||
BLI_lock_thread(LOCK_FFTW);
|
||||
BLI_thread_lock(LOCK_FFTW);
|
||||
|
||||
if (o->_do_disp_y) {
|
||||
o->_disp_y = (double *)MEM_mallocN(o->_M * o->_N * sizeof(double), "ocean_disp_y");
|
||||
|
@ -963,7 +963,7 @@ void BKE_ocean_init(struct Ocean *o, int M, int N, float Lx, float Lz, float V,
|
|||
o->_Jxz_plan = fftw_plan_dft_c2r_2d(o->_M, o->_N, o->_fft_in_jxz, o->_Jxz, FFTW_ESTIMATE);
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_FFTW);
|
||||
BLI_thread_unlock(LOCK_FFTW);
|
||||
|
||||
BLI_rw_mutex_unlock(&o->oceanmutex);
|
||||
|
||||
|
@ -978,7 +978,7 @@ void BKE_ocean_free_data(struct Ocean *oc)
|
|||
|
||||
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_WRITE);
|
||||
|
||||
BLI_lock_thread(LOCK_FFTW);
|
||||
BLI_thread_lock(LOCK_FFTW);
|
||||
|
||||
if (oc->_do_disp_y) {
|
||||
fftw_destroy_plan(oc->_disp_y_plan);
|
||||
|
@ -1016,7 +1016,7 @@ void BKE_ocean_free_data(struct Ocean *oc)
|
|||
MEM_freeN(oc->_Jxz);
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_FFTW);
|
||||
BLI_thread_unlock(LOCK_FFTW);
|
||||
|
||||
if (oc->_fft_in)
|
||||
MEM_freeN(oc->_fft_in);
|
||||
|
|
|
@ -168,11 +168,11 @@ void smoke_reallocate_highres_fluid(SmokeDomainSettings *sds, float dx, int res[
|
|||
}
|
||||
|
||||
/* smoke_turbulence_init uses non-threadsafe functions from fftw3 lib (like fftw_plan & co). */
|
||||
BLI_lock_thread(LOCK_FFTW);
|
||||
BLI_thread_lock(LOCK_FFTW);
|
||||
|
||||
sds->wt = smoke_turbulence_init(res, sds->amplify + 1, sds->noise, BKE_tempdir_session(), use_fire, use_colors);
|
||||
|
||||
BLI_unlock_thread(LOCK_FFTW);
|
||||
BLI_thread_unlock(LOCK_FFTW);
|
||||
|
||||
sds->res_wt[0] = res[0] * (sds->amplify + 1);
|
||||
sds->res_wt[1] = res[1] * (sds->amplify + 1);
|
||||
|
|
|
@ -1602,12 +1602,12 @@ static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,
|
|||
sb_threads[i].tot= totthread;
|
||||
}
|
||||
if (totthread > 1) {
|
||||
BLI_init_threads(&threads, exec_scan_for_ext_spring_forces, totthread);
|
||||
BLI_threadpool_init(&threads, exec_scan_for_ext_spring_forces, totthread);
|
||||
|
||||
for (i=0; i<totthread; i++)
|
||||
BLI_insert_thread(&threads, &sb_threads[i]);
|
||||
BLI_threadpool_insert(&threads, &sb_threads[i]);
|
||||
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
}
|
||||
else
|
||||
exec_scan_for_ext_spring_forces(&sb_threads[0]);
|
||||
|
@ -2214,12 +2214,12 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t
|
|||
|
||||
|
||||
if (totthread > 1) {
|
||||
BLI_init_threads(&threads, exec_softbody_calc_forces, totthread);
|
||||
BLI_threadpool_init(&threads, exec_softbody_calc_forces, totthread);
|
||||
|
||||
for (i=0; i<totthread; i++)
|
||||
BLI_insert_thread(&threads, &sb_threads[i]);
|
||||
BLI_threadpool_insert(&threads, &sb_threads[i]);
|
||||
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
}
|
||||
else
|
||||
exec_softbody_calc_forces(&sb_threads[0]);
|
||||
|
|
|
@ -787,9 +787,9 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
|
|||
* in the cache which is nice on the one hand (faster re-use of the
|
||||
* frames) but on the other hand it bumps the memory usage up.
|
||||
*/
|
||||
BLI_lock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_lock(LOCK_MOVIECLIP);
|
||||
IMB_float_from_rect(orig_ibuf);
|
||||
BLI_unlock_thread(LOCK_MOVIECLIP);
|
||||
BLI_thread_unlock(LOCK_MOVIECLIP);
|
||||
final_ibuf = orig_ibuf;
|
||||
}
|
||||
/* Downscale if needed. */
|
||||
|
|
|
@ -55,19 +55,19 @@ void BLI_threadapi_exit(void);
|
|||
|
||||
struct TaskScheduler *BLI_task_scheduler_get(void);
|
||||
|
||||
void BLI_init_threads(struct ListBase *threadbase, void *(*do_thread)(void *), int tot);
|
||||
void BLI_threadpool_init(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_threadpool_available_thread_index(struct ListBase *threadbase);
|
||||
void BLI_threadpool_insert(struct ListBase *threadbase, void *callerdata);
|
||||
void BLI_threadpool_remove(struct ListBase *threadbase, void *callerdata);
|
||||
void BLI_threadpool_remove_index(struct ListBase *threadbase, int index);
|
||||
void BLI_threadpool_clear(struct ListBase *threadbase);
|
||||
void BLI_threadpool_end(struct ListBase *threadbase);
|
||||
int BLI_thread_is_main(void);
|
||||
|
||||
|
||||
void BLI_begin_threaded_malloc(void);
|
||||
void BLI_end_threaded_malloc(void);
|
||||
void BLI_threaded_malloc_begin(void);
|
||||
void BLI_threaded_malloc_end(void);
|
||||
|
||||
/* System Information */
|
||||
|
||||
|
@ -91,8 +91,8 @@ int BLI_system_num_threads_override_get(void);
|
|||
#define LOCK_FFTW 9
|
||||
#define LOCK_VIEW3D 10
|
||||
|
||||
void BLI_lock_thread(int type);
|
||||
void BLI_unlock_thread(int type);
|
||||
void BLI_thread_lock(int type);
|
||||
void BLI_thread_unlock(int type);
|
||||
|
||||
/* Mutex Lock */
|
||||
|
||||
|
|
|
@ -696,7 +696,7 @@ static TaskPool *task_pool_create_ex(TaskScheduler *scheduler,
|
|||
* and malloc could be non-thread safe at this point because
|
||||
* no other jobs are running.
|
||||
*/
|
||||
BLI_begin_threaded_malloc();
|
||||
BLI_threaded_malloc_begin();
|
||||
|
||||
return pool;
|
||||
}
|
||||
|
@ -763,7 +763,7 @@ void BLI_task_pool_free(TaskPool *pool)
|
|||
|
||||
MEM_freeN(pool);
|
||||
|
||||
BLI_end_threaded_malloc();
|
||||
BLI_threaded_malloc_end();
|
||||
}
|
||||
|
||||
BLI_INLINE bool task_can_use_local_queues(TaskPool *pool, int thread_id)
|
||||
|
|
|
@ -83,13 +83,13 @@ static TaskScheduler *task_scheduler = NULL;
|
|||
* int maxthreads = 2;
|
||||
* int cont = 1;
|
||||
*
|
||||
* BLI_init_threads(&lb, do_something_func, maxthreads);
|
||||
* BLI_threadpool_init(&lb, do_something_func, maxthreads);
|
||||
*
|
||||
* while (cont) {
|
||||
* if (BLI_available_threads(&lb) && !(escape loop event)) {
|
||||
* // get new job (data pointer)
|
||||
* // tag job 'processed
|
||||
* BLI_insert_thread(&lb, job);
|
||||
* BLI_threadpool_insert(&lb, job);
|
||||
* }
|
||||
* else PIL_sleep_ms(50);
|
||||
*
|
||||
|
@ -98,7 +98,7 @@ static TaskScheduler *task_scheduler = NULL;
|
|||
* for (go over all jobs)
|
||||
* if (job is ready) {
|
||||
* if (job was not removed) {
|
||||
* BLI_remove_thread(&lb, job);
|
||||
* BLI_threadpool_remove(&lb, job);
|
||||
* }
|
||||
* }
|
||||
* else cont = 1;
|
||||
|
@ -110,7 +110,7 @@ static TaskScheduler *task_scheduler = NULL;
|
|||
* }
|
||||
* }
|
||||
*
|
||||
* BLI_end_threads(&lb);
|
||||
* BLI_threadpool_end(&lb);
|
||||
*
|
||||
************************************************ */
|
||||
static SpinLock _malloc_lock;
|
||||
|
@ -183,7 +183,7 @@ TaskScheduler *BLI_task_scheduler_get(void)
|
|||
* problem otherwise: scene render will kill of the mutex!
|
||||
*/
|
||||
|
||||
void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot)
|
||||
void BLI_threadpool_init(ListBase *threadbase, void *(*do_thread)(void *), int tot)
|
||||
{
|
||||
int a;
|
||||
|
||||
|
@ -228,7 +228,7 @@ int BLI_available_threads(ListBase *threadbase)
|
|||
}
|
||||
|
||||
/* returns thread number, for sample patterns or threadsafe tables */
|
||||
int BLI_available_thread_index(ListBase *threadbase)
|
||||
int BLI_threadpool_available_thread_index(ListBase *threadbase)
|
||||
{
|
||||
ThreadSlot *tslot;
|
||||
int counter = 0;
|
||||
|
@ -258,7 +258,7 @@ int BLI_thread_is_main(void)
|
|||
return pthread_equal(pthread_self(), mainid);
|
||||
}
|
||||
|
||||
void BLI_insert_thread(ListBase *threadbase, void *callerdata)
|
||||
void BLI_threadpool_insert(ListBase *threadbase, void *callerdata)
|
||||
{
|
||||
ThreadSlot *tslot;
|
||||
|
||||
|
@ -273,7 +273,7 @@ void BLI_insert_thread(ListBase *threadbase, void *callerdata)
|
|||
printf("ERROR: could not insert thread slot\n");
|
||||
}
|
||||
|
||||
void BLI_remove_thread(ListBase *threadbase, void *callerdata)
|
||||
void BLI_threadpool_remove(ListBase *threadbase, void *callerdata)
|
||||
{
|
||||
ThreadSlot *tslot;
|
||||
|
||||
|
@ -286,7 +286,7 @@ void BLI_remove_thread(ListBase *threadbase, void *callerdata)
|
|||
}
|
||||
}
|
||||
|
||||
void BLI_remove_thread_index(ListBase *threadbase, int index)
|
||||
void BLI_threadpool_remove_index(ListBase *threadbase, int index)
|
||||
{
|
||||
ThreadSlot *tslot;
|
||||
int counter = 0;
|
||||
|
@ -301,7 +301,7 @@ void BLI_remove_thread_index(ListBase *threadbase, int index)
|
|||
}
|
||||
}
|
||||
|
||||
void BLI_remove_threads(ListBase *threadbase)
|
||||
void BLI_threadpool_clear(ListBase *threadbase)
|
||||
{
|
||||
ThreadSlot *tslot;
|
||||
|
||||
|
@ -314,7 +314,7 @@ void BLI_remove_threads(ListBase *threadbase)
|
|||
}
|
||||
}
|
||||
|
||||
void BLI_end_threads(ListBase *threadbase)
|
||||
void BLI_threadpool_end(ListBase *threadbase)
|
||||
{
|
||||
ThreadSlot *tslot;
|
||||
|
||||
|
@ -418,12 +418,12 @@ static ThreadMutex *global_mutex_from_type(const int type)
|
|||
}
|
||||
}
|
||||
|
||||
void BLI_lock_thread(int type)
|
||||
void BLI_thread_lock(int type)
|
||||
{
|
||||
pthread_mutex_lock(global_mutex_from_type(type));
|
||||
}
|
||||
|
||||
void BLI_unlock_thread(int type)
|
||||
void BLI_thread_unlock(int type)
|
||||
{
|
||||
pthread_mutex_unlock(global_mutex_from_type(type));
|
||||
}
|
||||
|
@ -819,7 +819,7 @@ void BLI_thread_queue_wait_finish(ThreadQueue *queue)
|
|||
|
||||
/* ************************************************ */
|
||||
|
||||
void BLI_begin_threaded_malloc(void)
|
||||
void BLI_threaded_malloc_begin(void)
|
||||
{
|
||||
unsigned int level = atomic_fetch_and_add_u(&thread_levels, 1);
|
||||
if (level == 0) {
|
||||
|
@ -832,7 +832,7 @@ void BLI_begin_threaded_malloc(void)
|
|||
}
|
||||
}
|
||||
|
||||
void BLI_end_threaded_malloc(void)
|
||||
void BLI_threaded_malloc_end(void)
|
||||
{
|
||||
unsigned int level = atomic_sub_and_fetch_u(&thread_levels, 1);
|
||||
if (level == 0) {
|
||||
|
|
|
@ -131,18 +131,18 @@ void WorkScheduler::start(CompositorContext &context)
|
|||
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
|
||||
unsigned int index;
|
||||
g_cpuqueue = BLI_thread_queue_init();
|
||||
BLI_init_threads(&g_cputhreads, thread_execute_cpu, g_cpudevices.size());
|
||||
BLI_threadpool_init(&g_cputhreads, thread_execute_cpu, g_cpudevices.size());
|
||||
for (index = 0; index < g_cpudevices.size(); index++) {
|
||||
Device *device = g_cpudevices[index];
|
||||
BLI_insert_thread(&g_cputhreads, device);
|
||||
BLI_threadpool_insert(&g_cputhreads, device);
|
||||
}
|
||||
#ifdef COM_OPENCL_ENABLED
|
||||
if (context.getHasActiveOpenCLDevices()) {
|
||||
g_gpuqueue = BLI_thread_queue_init();
|
||||
BLI_init_threads(&g_gputhreads, thread_execute_gpu, g_gpudevices.size());
|
||||
BLI_threadpool_init(&g_gputhreads, thread_execute_gpu, g_gpudevices.size());
|
||||
for (index = 0; index < g_gpudevices.size(); index++) {
|
||||
Device *device = g_gpudevices[index];
|
||||
BLI_insert_thread(&g_gputhreads, device);
|
||||
BLI_threadpool_insert(&g_gputhreads, device);
|
||||
}
|
||||
g_openclActive = true;
|
||||
}
|
||||
|
@ -172,13 +172,13 @@ void WorkScheduler::stop()
|
|||
{
|
||||
#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
|
||||
BLI_thread_queue_nowait(g_cpuqueue);
|
||||
BLI_end_threads(&g_cputhreads);
|
||||
BLI_threadpool_end(&g_cputhreads);
|
||||
BLI_thread_queue_free(g_cpuqueue);
|
||||
g_cpuqueue = NULL;
|
||||
#ifdef COM_OPENCL_ENABLED
|
||||
if (g_openclActive) {
|
||||
BLI_thread_queue_nowait(g_gpuqueue);
|
||||
BLI_end_threads(&g_gputhreads);
|
||||
BLI_threadpool_end(&g_gputhreads);
|
||||
BLI_thread_queue_free(g_gpuqueue);
|
||||
g_gpuqueue = NULL;
|
||||
}
|
||||
|
|
|
@ -108,9 +108,9 @@ void CompositorOperation::deinitExecution()
|
|||
re = NULL;
|
||||
}
|
||||
|
||||
BLI_lock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_lock(LOCK_DRAW_IMAGE);
|
||||
BKE_image_signal(BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"), NULL, IMA_SIGNAL_FREE);
|
||||
BLI_unlock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||
}
|
||||
else {
|
||||
if (this->m_outputBuffer) {
|
||||
|
|
|
@ -135,14 +135,14 @@ void ViewerOperation::initImage()
|
|||
BKE_image_verify_viewer_views(this->m_rd, ima, this->m_imageUser);
|
||||
}
|
||||
|
||||
BLI_lock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_lock(LOCK_DRAW_IMAGE);
|
||||
|
||||
/* local changes to the original ImageUser */
|
||||
iuser.multi_index = BKE_scene_multiview_view_id_get(this->m_rd, this->m_viewName);
|
||||
ibuf = BKE_image_acquire_ibuf(ima, &iuser, &lock);
|
||||
|
||||
if (!ibuf) {
|
||||
BLI_unlock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||
return;
|
||||
}
|
||||
if (ibuf->x != (int)getWidth() || ibuf->y != (int)getHeight()) {
|
||||
|
@ -176,7 +176,7 @@ void ViewerOperation::initImage()
|
|||
|
||||
BKE_image_release_ibuf(this->m_image, this->m_ibuf, lock);
|
||||
|
||||
BLI_unlock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||
}
|
||||
|
||||
void ViewerOperation::updateImage(rcti *rect)
|
||||
|
|
|
@ -832,9 +832,9 @@ static int bake_image_exec(bContext *C, wmOperator *op)
|
|||
RE_Database_Baking(bkr.re, bmain, scene, scene->lay, scene->r.bake_mode, (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL);
|
||||
|
||||
/* baking itself is threaded, cannot use test_break in threads */
|
||||
BLI_init_threads(&threads, do_bake_render, 1);
|
||||
BLI_threadpool_init(&threads, do_bake_render, 1);
|
||||
bkr.ready = 0;
|
||||
BLI_insert_thread(&threads, &bkr);
|
||||
BLI_threadpool_insert(&threads, &bkr);
|
||||
|
||||
while (bkr.ready == 0) {
|
||||
PIL_sleep_ms(50);
|
||||
|
@ -845,7 +845,7 @@ static int bake_image_exec(bContext *C, wmOperator *op)
|
|||
if (!G.background)
|
||||
BKE_blender_test_break();
|
||||
}
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
|
||||
if (bkr.result == BAKE_RESULT_NO_OBJECTS)
|
||||
BKE_report(op->reports, RPT_ERROR, "No valid images found to bake to");
|
||||
|
|
|
@ -323,12 +323,12 @@ static int screen_render_exec(bContext *C, wmOperator *op)
|
|||
|
||||
RE_SetReports(re, op->reports);
|
||||
|
||||
BLI_begin_threaded_malloc();
|
||||
BLI_threaded_malloc_begin();
|
||||
if (is_animation)
|
||||
RE_BlenderAnim(re, mainp, scene, camera_override, lay_override, scene->r.sfra, scene->r.efra, scene->r.frame_step);
|
||||
else
|
||||
RE_BlenderFrame(re, mainp, scene, srl, camera_override, lay_override, scene->r.cfra, is_write_still);
|
||||
BLI_end_threaded_malloc();
|
||||
BLI_threaded_malloc_end();
|
||||
|
||||
RE_SetReports(re, NULL);
|
||||
|
||||
|
|
|
@ -2692,7 +2692,7 @@ static void project_paint_face_init(
|
|||
int face_seam_flag;
|
||||
|
||||
if (threaded)
|
||||
BLI_lock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
|
||||
BLI_thread_lock(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
|
||||
|
||||
face_seam_flag = ps->faceSeamFlags[tri_index];
|
||||
|
||||
|
@ -2709,7 +2709,7 @@ static void project_paint_face_init(
|
|||
if ((face_seam_flag & (PROJ_FACE_SEAM1 | PROJ_FACE_SEAM2 | PROJ_FACE_SEAM3)) == 0) {
|
||||
|
||||
if (threaded)
|
||||
BLI_unlock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
|
||||
BLI_thread_unlock(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
|
||||
|
||||
}
|
||||
else {
|
||||
|
@ -2735,7 +2735,7 @@ static void project_paint_face_init(
|
|||
|
||||
/* ps->faceSeamUVs cant be modified when threading, now this is done we can unlock */
|
||||
if (threaded)
|
||||
BLI_unlock_thread(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
|
||||
BLI_thread_unlock(LOCK_CUSTOM1); /* Other threads could be modifying these vars */
|
||||
|
||||
vCoSS[0] = ps->screenCoords[lt_vtri[0]];
|
||||
vCoSS[1] = ps->screenCoords[lt_vtri[1]];
|
||||
|
@ -4133,7 +4133,7 @@ static bool project_bucket_iter_next(
|
|||
const int diameter = 2 * ps->brush_size;
|
||||
|
||||
if (ps->thread_tot > 1)
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
|
||||
//printf("%d %d\n", ps->context_bucket_x, ps->context_bucket_y);
|
||||
|
||||
|
@ -4150,7 +4150,7 @@ static bool project_bucket_iter_next(
|
|||
ps->context_bucket_x++;
|
||||
|
||||
if (ps->thread_tot > 1)
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -4159,7 +4159,7 @@ static bool project_bucket_iter_next(
|
|||
}
|
||||
|
||||
if (ps->thread_tot > 1)
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -4878,7 +4878,7 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
|
|||
}
|
||||
|
||||
if (ps->thread_tot > 1)
|
||||
BLI_init_threads(&threads, do_projectpaint_thread, ps->thread_tot);
|
||||
BLI_threadpool_init(&threads, do_projectpaint_thread, ps->thread_tot);
|
||||
|
||||
pool = BKE_image_pool_new();
|
||||
|
||||
|
@ -4908,11 +4908,11 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
|
|||
handles[a].pool = pool;
|
||||
|
||||
if (ps->thread_tot > 1)
|
||||
BLI_insert_thread(&threads, &handles[a]);
|
||||
BLI_threadpool_insert(&threads, &handles[a]);
|
||||
}
|
||||
|
||||
if (ps->thread_tot > 1) /* wait for everything to be done */
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
else
|
||||
do_projectpaint_thread(&handles[0]);
|
||||
|
||||
|
|
|
@ -890,7 +890,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
|
|||
SculptUndoNode *unode;
|
||||
|
||||
/* list is manipulated by multiple threads, so we lock */
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
|
||||
if (ss->bm ||
|
||||
ELEM(type,
|
||||
|
@ -900,17 +900,17 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node,
|
|||
/* Dynamic topology stores only one undo node per stroke,
|
||||
* regardless of the number of PBVH nodes modified */
|
||||
unode = sculpt_undo_bmesh_push(ob, node, type);
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
return unode;
|
||||
}
|
||||
else if ((unode = sculpt_undo_get_node(node))) {
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
return unode;
|
||||
}
|
||||
|
||||
unode = sculpt_undo_alloc_node(ob, node, type);
|
||||
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
|
||||
/* copy threaded, hopefully this is the performance critical part */
|
||||
|
||||
|
|
|
@ -881,7 +881,7 @@ void draw_image_main(const bContext *C, ARegion *ar)
|
|||
* other images are not modifying in such a way so they does not require
|
||||
* lock (sergey)
|
||||
*/
|
||||
BLI_lock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_lock(LOCK_DRAW_IMAGE);
|
||||
}
|
||||
|
||||
if (show_stereo3d) {
|
||||
|
@ -942,7 +942,7 @@ void draw_image_main(const bContext *C, ARegion *ar)
|
|||
#endif
|
||||
|
||||
if (show_viewer) {
|
||||
BLI_unlock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||
}
|
||||
|
||||
/* render info */
|
||||
|
|
|
@ -765,14 +765,14 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
|
|||
/* ED_space_image_get* will acquire image buffer which requires
|
||||
* lock here by the same reason why lock is needed in draw_image_main
|
||||
*/
|
||||
BLI_lock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_lock(LOCK_DRAW_IMAGE);
|
||||
}
|
||||
|
||||
ED_space_image_get_size(sima, &width, &height);
|
||||
ED_space_image_get_aspect(sima, &aspx, &aspy);
|
||||
|
||||
if (show_viewer)
|
||||
BLI_unlock_thread(LOCK_DRAW_IMAGE);
|
||||
BLI_thread_unlock(LOCK_DRAW_IMAGE);
|
||||
|
||||
ED_mask_draw_region(mask, ar,
|
||||
sima->mask_info.draw_flag,
|
||||
|
|
|
@ -3793,28 +3793,28 @@ static void view3d_stereo3d_setup(Scene *scene, View3D *v3d, ARegion *ar, const
|
|||
data = (Camera *)v3d->camera->data;
|
||||
shiftx = data->shiftx;
|
||||
|
||||
BLI_lock_thread(LOCK_VIEW3D);
|
||||
BLI_thread_lock(LOCK_VIEW3D);
|
||||
data->shiftx = BKE_camera_multiview_shift_x(&scene->r, v3d->camera, viewname);
|
||||
|
||||
BKE_camera_multiview_view_matrix(&scene->r, v3d->camera, is_left, viewmat);
|
||||
view3d_main_region_setup_view(scene, v3d, ar, viewmat, NULL, rect);
|
||||
|
||||
data->shiftx = shiftx;
|
||||
BLI_unlock_thread(LOCK_VIEW3D);
|
||||
BLI_thread_unlock(LOCK_VIEW3D);
|
||||
}
|
||||
else { /* SCE_VIEWS_FORMAT_MULTIVIEW */
|
||||
float viewmat[4][4];
|
||||
Object *view_ob = v3d->camera;
|
||||
Object *camera = BKE_camera_multiview_render(scene, v3d->camera, viewname);
|
||||
|
||||
BLI_lock_thread(LOCK_VIEW3D);
|
||||
BLI_thread_lock(LOCK_VIEW3D);
|
||||
v3d->camera = camera;
|
||||
|
||||
BKE_camera_multiview_view_matrix(&scene->r, camera, false, viewmat);
|
||||
view3d_main_region_setup_view(scene, v3d, ar, viewmat, NULL, rect);
|
||||
|
||||
v3d->camera = view_ob;
|
||||
BLI_unlock_thread(LOCK_VIEW3D);
|
||||
BLI_thread_unlock(LOCK_VIEW3D);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1475,9 +1475,9 @@ static LinkNode *image_free_queue = NULL;
|
|||
|
||||
static void gpu_queue_image_for_free(Image *ima)
|
||||
{
|
||||
BLI_lock_thread(LOCK_OPENGL);
|
||||
BLI_thread_lock(LOCK_OPENGL);
|
||||
BLI_linklist_prepend(&image_free_queue, ima);
|
||||
BLI_unlock_thread(LOCK_OPENGL);
|
||||
BLI_thread_unlock(LOCK_OPENGL);
|
||||
}
|
||||
|
||||
void GPU_free_unused_buffers(void)
|
||||
|
@ -1485,7 +1485,7 @@ void GPU_free_unused_buffers(void)
|
|||
if (!BLI_thread_is_main())
|
||||
return;
|
||||
|
||||
BLI_lock_thread(LOCK_OPENGL);
|
||||
BLI_thread_lock(LOCK_OPENGL);
|
||||
|
||||
/* images */
|
||||
for (LinkNode *node = image_free_queue; node; node = node->next) {
|
||||
|
@ -1502,7 +1502,7 @@ void GPU_free_unused_buffers(void)
|
|||
/* vbo buffers */
|
||||
GPU_global_buffer_pool_free_unused();
|
||||
|
||||
BLI_unlock_thread(LOCK_OPENGL);
|
||||
BLI_thread_unlock(LOCK_OPENGL);
|
||||
}
|
||||
|
||||
void GPU_free_image(Image *ima)
|
||||
|
|
|
@ -2176,7 +2176,7 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
|
|||
BLI_rcti_init(&ibuf->invalid_rect, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
BLI_lock_thread(LOCK_COLORMANAGE);
|
||||
BLI_thread_lock(LOCK_COLORMANAGE);
|
||||
|
||||
/* ensure color management bit fields exists */
|
||||
if (!ibuf->display_buffer_flags) {
|
||||
|
@ -2194,7 +2194,7 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
|
|||
display_buffer = colormanage_cache_get(ibuf, &cache_view_settings, &cache_display_settings, cache_handle);
|
||||
|
||||
if (display_buffer) {
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
BLI_thread_unlock(LOCK_COLORMANAGE);
|
||||
return display_buffer;
|
||||
}
|
||||
|
||||
|
@ -2205,7 +2205,7 @@ unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSet
|
|||
|
||||
colormanage_cache_put(ibuf, &cache_view_settings, &cache_display_settings, display_buffer, cache_handle);
|
||||
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
BLI_thread_unlock(LOCK_COLORMANAGE);
|
||||
|
||||
return display_buffer;
|
||||
}
|
||||
|
@ -2244,11 +2244,11 @@ void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *li
|
|||
void IMB_display_buffer_release(void *cache_handle)
|
||||
{
|
||||
if (cache_handle) {
|
||||
BLI_lock_thread(LOCK_COLORMANAGE);
|
||||
BLI_thread_lock(LOCK_COLORMANAGE);
|
||||
|
||||
colormanage_cache_handle_release(cache_handle);
|
||||
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
BLI_thread_unlock(LOCK_COLORMANAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2964,7 +2964,7 @@ static void imb_partial_display_buffer_update_ex(ImBuf *ibuf,
|
|||
view_flag = 1 << (cache_view_settings.view - 1);
|
||||
display_index = cache_display_settings.display - 1;
|
||||
|
||||
BLI_lock_thread(LOCK_COLORMANAGE);
|
||||
BLI_thread_lock(LOCK_COLORMANAGE);
|
||||
|
||||
if ((ibuf->userflags & IB_DISPLAY_BUFFER_INVALID) == 0) {
|
||||
display_buffer = colormanage_cache_get(ibuf,
|
||||
|
@ -2983,7 +2983,7 @@ static void imb_partial_display_buffer_update_ex(ImBuf *ibuf,
|
|||
memset(ibuf->display_buffer_flags, 0, global_tot_display * sizeof(unsigned int));
|
||||
ibuf->display_buffer_flags[display_index] |= view_flag;
|
||||
|
||||
BLI_unlock_thread(LOCK_COLORMANAGE);
|
||||
BLI_thread_unlock(LOCK_COLORMANAGE);
|
||||
}
|
||||
|
||||
if (display_buffer == NULL) {
|
||||
|
|
|
@ -652,7 +652,7 @@ static struct IMBThumbLocks {
|
|||
|
||||
void IMB_thumb_locks_acquire(void)
|
||||
{
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
|
||||
if (thumb_locks.lock_counter == 0) {
|
||||
BLI_assert(thumb_locks.locked_paths == NULL);
|
||||
|
@ -663,12 +663,12 @@ void IMB_thumb_locks_acquire(void)
|
|||
|
||||
BLI_assert(thumb_locks.locked_paths != NULL);
|
||||
BLI_assert(thumb_locks.lock_counter > 0);
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
|
||||
void IMB_thumb_locks_release(void)
|
||||
{
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
BLI_assert((thumb_locks.locked_paths != NULL) && (thumb_locks.lock_counter > 0));
|
||||
|
||||
thumb_locks.lock_counter--;
|
||||
|
@ -678,14 +678,14 @@ void IMB_thumb_locks_release(void)
|
|||
BLI_condition_end(&thumb_locks.cond);
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
|
||||
void IMB_thumb_path_lock(const char *path)
|
||||
{
|
||||
void *key = BLI_strdup(path);
|
||||
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
BLI_assert((thumb_locks.locked_paths != NULL) && (thumb_locks.lock_counter > 0));
|
||||
|
||||
if (thumb_locks.locked_paths) {
|
||||
|
@ -694,14 +694,14 @@ void IMB_thumb_path_lock(const char *path)
|
|||
}
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
|
||||
void IMB_thumb_path_unlock(const char *path)
|
||||
{
|
||||
const void *key = path;
|
||||
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
BLI_assert((thumb_locks.locked_paths != NULL) && (thumb_locks.lock_counter > 0));
|
||||
|
||||
if (thumb_locks.locked_paths) {
|
||||
|
@ -711,5 +711,5 @@ void IMB_thumb_path_unlock(const char *path)
|
|||
BLI_condition_notify_all(&thumb_locks.cond);
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
|
|
|
@ -616,10 +616,10 @@ bool ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
|
|||
|
||||
/* ensure execdata is only initialized once */
|
||||
if (!exec) {
|
||||
BLI_lock_thread(LOCK_NODES);
|
||||
BLI_thread_lock(LOCK_NODES);
|
||||
if (!ntree->execdata)
|
||||
ntree->execdata = ntreeShaderBeginExecTree(ntree);
|
||||
BLI_unlock_thread(LOCK_NODES);
|
||||
BLI_thread_unlock(LOCK_NODES);
|
||||
|
||||
exec = ntree->execdata;
|
||||
}
|
||||
|
|
|
@ -345,10 +345,10 @@ int ntreeTexExecTree(
|
|||
|
||||
/* ensure execdata is only initialized once */
|
||||
if (!exec) {
|
||||
BLI_lock_thread(LOCK_NODES);
|
||||
BLI_thread_lock(LOCK_NODES);
|
||||
if (!nodes->execdata)
|
||||
ntreeTexBeginExecTree(nodes);
|
||||
BLI_unlock_thread(LOCK_NODES);
|
||||
BLI_thread_unlock(LOCK_NODES);
|
||||
|
||||
exec = nodes->execdata;
|
||||
}
|
||||
|
|
|
@ -64,10 +64,10 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i
|
|||
if ( (!xsize) || (!ysize) ) return;
|
||||
|
||||
if (!ibuf->rect_float) {
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
if (!ibuf->rect_float)
|
||||
IMB_float_from_rect(ibuf);
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
|
||||
while (px < 0) px += ibuf->x;
|
||||
|
|
|
@ -609,7 +609,7 @@ static int get_next_bake_face(BakeShade *bs)
|
|||
return 0;
|
||||
}
|
||||
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
|
||||
for (; obi; obi = obi->next, v = 0) {
|
||||
obr = obi->obr;
|
||||
|
@ -724,13 +724,13 @@ static int get_next_bake_face(BakeShade *bs)
|
|||
bs->vlr = vlr;
|
||||
bs->vdone++; /* only for error message if nothing was rendered */
|
||||
v++;
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -845,7 +845,7 @@ static void shade_tface(BakeShade *bs)
|
|||
if (bs->use_mask || bs->use_displacement_buffer) {
|
||||
BakeImBufuserData *userdata = bs->ibuf->userdata;
|
||||
if (userdata == NULL) {
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
userdata = bs->ibuf->userdata;
|
||||
if (userdata == NULL) /* since the thread was locked, its possible another thread alloced the value */
|
||||
userdata = MEM_callocN(sizeof(BakeImBufuserData), "BakeImBufuserData");
|
||||
|
@ -864,7 +864,7 @@ static void shade_tface(BakeShade *bs)
|
|||
|
||||
bs->ibuf->userdata = userdata;
|
||||
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
}
|
||||
|
||||
bs->rect_mask = userdata->mask_buffer;
|
||||
|
@ -1040,7 +1040,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
|
|||
BKE_main_id_tag_listbase(&G.main->mesh, LIB_TAG_DOIT, false);
|
||||
}
|
||||
|
||||
BLI_init_threads(&threads, do_bake_thread, re->r.threads);
|
||||
BLI_threadpool_init(&threads, do_bake_thread, re->r.threads);
|
||||
|
||||
handles = MEM_callocN(sizeof(BakeShade) * re->r.threads, "BakeShade");
|
||||
|
||||
|
@ -1077,7 +1077,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
|
|||
handles[a].displacement_min = FLT_MAX;
|
||||
handles[a].displacement_max = -FLT_MAX;
|
||||
|
||||
BLI_insert_thread(&threads, &handles[a]);
|
||||
BLI_threadpool_insert(&threads, &handles[a]);
|
||||
}
|
||||
|
||||
/* wait for everything to be done */
|
||||
|
@ -1151,7 +1151,7 @@ int RE_bake_shade_all_selected(Render *re, int type, Object *actob, short *do_up
|
|||
|
||||
MEM_freeN(handles);
|
||||
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
|
||||
if (vdone == 0) {
|
||||
result = BAKE_RESULT_NO_OBJECTS;
|
||||
|
|
|
@ -70,7 +70,7 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf)
|
|||
int dx, part;
|
||||
|
||||
/* after lock we test cube[1], if set the other thread has done it fine */
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
if (env->cube[1] == NULL) {
|
||||
|
||||
BKE_texture_envmap_free_data(env);
|
||||
|
@ -118,7 +118,7 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf)
|
|||
}
|
||||
}
|
||||
}
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
|
|
@ -144,7 +144,7 @@ RenderEngine *RE_engine_create_ex(RenderEngineType *type, bool use_for_viewport)
|
|||
if (use_for_viewport) {
|
||||
engine->flag |= RE_ENGINE_USED_FOR_VIEWPORT;
|
||||
|
||||
BLI_begin_threaded_malloc();
|
||||
BLI_threaded_malloc_begin();
|
||||
}
|
||||
|
||||
return engine;
|
||||
|
@ -159,7 +159,7 @@ void RE_engine_free(RenderEngine *engine)
|
|||
#endif
|
||||
|
||||
if (engine->flag & RE_ENGINE_USED_FOR_VIEWPORT) {
|
||||
BLI_end_threaded_malloc();
|
||||
BLI_threaded_malloc_end();
|
||||
}
|
||||
|
||||
MEM_freeN(engine);
|
||||
|
|
|
@ -890,18 +890,18 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf)
|
|||
if ((ibuf->flags & IB_fields) == 0) {
|
||||
|
||||
if (ibuf->mipmap[0] && (ibuf->userflags & IB_MIPMAP_INVALID)) {
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
if (ibuf->userflags & IB_MIPMAP_INVALID) {
|
||||
IMB_remakemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
|
||||
ibuf->userflags &= ~IB_MIPMAP_INVALID;
|
||||
}
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
if (ibuf->mipmap[0] == NULL) {
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
if (ibuf->mipmap[0] == NULL)
|
||||
IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
/* if no mipmap could be made, fall back on non-mipmap render */
|
||||
if (ibuf->mipmap[0] == NULL) {
|
||||
|
|
|
@ -466,7 +466,7 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, bool require_t
|
|||
bake_data = initBakeData(bkr, ima);
|
||||
|
||||
if (tot_thread > 1)
|
||||
BLI_init_threads(&threads, do_multires_bake_thread, tot_thread);
|
||||
BLI_threadpool_init(&threads, do_multires_bake_thread, tot_thread);
|
||||
|
||||
handles = MEM_callocN(tot_thread * sizeof(MultiresBakeThread), "do_multires_bake handles");
|
||||
|
||||
|
@ -509,12 +509,12 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image *ima, bool require_t
|
|||
init_bake_rast(&handle->bake_rast, ibuf, &handle->data, flush_pixel, bkr->do_update);
|
||||
|
||||
if (tot_thread > 1)
|
||||
BLI_insert_thread(&threads, handle);
|
||||
BLI_threadpool_insert(&threads, handle);
|
||||
}
|
||||
|
||||
/* run threads */
|
||||
if (tot_thread > 1)
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
else
|
||||
do_multires_bake_thread(&handles[0]);
|
||||
|
||||
|
|
|
@ -553,7 +553,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i
|
|||
occ_build_8_split(tree, begin, end, offset, count);
|
||||
|
||||
if (depth == 1 && tree->dothreadedbuild)
|
||||
BLI_init_threads(&threads, exec_occ_build, tree->totbuildthread);
|
||||
BLI_threadpool_init(&threads, exec_occ_build, tree->totbuildthread);
|
||||
|
||||
for (b = 0; b < TOTCHILD; b++) {
|
||||
if (count[b] == 0) {
|
||||
|
@ -566,7 +566,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i
|
|||
}
|
||||
else {
|
||||
if (tree->dothreadedbuild)
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
|
||||
child = BLI_memarena_alloc(tree->arena, sizeof(OccNode));
|
||||
node->child[b].node = child;
|
||||
|
@ -576,7 +576,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i
|
|||
tree->maxdepth = depth + 1;
|
||||
|
||||
if (tree->dothreadedbuild)
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
|
||||
if (depth == 1 && tree->dothreadedbuild) {
|
||||
othreads[totthread].tree = tree;
|
||||
|
@ -584,7 +584,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i
|
|||
othreads[totthread].begin = offset[b];
|
||||
othreads[totthread].end = offset[b] + count[b];
|
||||
othreads[totthread].depth = depth + 1;
|
||||
BLI_insert_thread(&threads, &othreads[totthread]);
|
||||
BLI_threadpool_insert(&threads, &othreads[totthread]);
|
||||
totthread++;
|
||||
}
|
||||
else
|
||||
|
@ -593,7 +593,7 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i
|
|||
}
|
||||
|
||||
if (depth == 1 && tree->dothreadedbuild)
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
}
|
||||
|
||||
/* combine area, position and sh */
|
||||
|
@ -1313,12 +1313,12 @@ void make_occ_tree(Render *re)
|
|||
exec_strandsurface_sample(&othreads[0]);
|
||||
}
|
||||
else {
|
||||
BLI_init_threads(&threads, exec_strandsurface_sample, totthread);
|
||||
BLI_threadpool_init(&threads, exec_strandsurface_sample, totthread);
|
||||
|
||||
for (a = 0; a < totthread; a++)
|
||||
BLI_insert_thread(&threads, &othreads[a]);
|
||||
BLI_threadpool_insert(&threads, &othreads[a]);
|
||||
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
}
|
||||
|
||||
for (a = 0; a < mesh->totface; a++) {
|
||||
|
|
|
@ -1407,7 +1407,7 @@ static void threaded_tile_processor(Render *re)
|
|||
BLI_thread_queue_nowait(workqueue);
|
||||
|
||||
/* start all threads */
|
||||
BLI_init_threads(&threads, do_render_thread, re->r.threads);
|
||||
BLI_threadpool_init(&threads, do_render_thread, re->r.threads);
|
||||
|
||||
for (a = 0; a < re->r.threads; a++) {
|
||||
thread[a].workqueue = workqueue;
|
||||
|
@ -1423,7 +1423,7 @@ static void threaded_tile_processor(Render *re)
|
|||
thread[a].duh = NULL;
|
||||
}
|
||||
|
||||
BLI_insert_thread(&threads, &thread[a]);
|
||||
BLI_threadpool_insert(&threads, &thread[a]);
|
||||
}
|
||||
|
||||
/* wait for results to come back */
|
||||
|
@ -1467,7 +1467,7 @@ static void threaded_tile_processor(Render *re)
|
|||
}
|
||||
}
|
||||
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
|
||||
if ((g_break=re->test_break(re->tbh)))
|
||||
break;
|
||||
|
|
|
@ -1041,7 +1041,7 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart, cons
|
|||
RenderPass *rpassp;
|
||||
int offs, partx, party;
|
||||
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
|
||||
for (rlp = rrpart->layers.first; rlp; rlp = rlp->next) {
|
||||
rl = RE_GetRenderLayer(rr, rlp->name);
|
||||
|
@ -1090,7 +1090,7 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart, cons
|
|||
IMB_exrtile_write_channels(rl->exrhandle, partx, party, 0, viewname, false);
|
||||
}
|
||||
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
|
||||
void render_result_save_empty_result_tiles(Render *re)
|
||||
|
|
|
@ -3675,7 +3675,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima)
|
|||
if (R.r.scemode & R_NO_TEX) return;
|
||||
|
||||
if (firsttime) {
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
BLI_thread_lock(LOCK_IMAGE);
|
||||
if (firsttime) {
|
||||
const int num_threads = BLI_system_thread_count();
|
||||
for (a = 0; a < num_threads; a++) {
|
||||
|
@ -3686,7 +3686,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima)
|
|||
|
||||
firsttime= 0;
|
||||
}
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
BLI_thread_unlock(LOCK_IMAGE);
|
||||
}
|
||||
|
||||
tex= &imatex[shi->thread];
|
||||
|
|
|
@ -787,10 +787,10 @@ void makeshadowbuf(Render *re, LampRen *lar)
|
|||
shb->totbuf= lar->buffers;
|
||||
|
||||
/* jitter, weights - not threadsafe! */
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
shb->jit= give_jitter_tab(get_render_shadow_samples(&re->r, shb->samp));
|
||||
make_jitter_weight_tab(re, shb, lar->filtertype);
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
|
||||
if (shb->totbuf==4) jitbuf= give_jitter_tab(2);
|
||||
else if (shb->totbuf==9) jitbuf= give_jitter_tab(3);
|
||||
|
@ -814,21 +814,21 @@ static void *do_shadow_thread(void *re_v)
|
|||
LampRen *lar;
|
||||
|
||||
do {
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
for (lar=re->lampren.first; lar; lar=lar->next) {
|
||||
if (lar->shb && !lar->thread_assigned) {
|
||||
lar->thread_assigned= 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
|
||||
/* if type is irregular, this only sets the perspective matrix and autoclips */
|
||||
if (lar) {
|
||||
makeshadowbuf(re, lar);
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
lar->thread_ready= 1;
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
}
|
||||
} while (lar && !re->test_break(re->tbh));
|
||||
|
||||
|
@ -878,10 +878,10 @@ void threaded_makeshadowbufs(Render *re)
|
|||
lar->thread_ready= 0;
|
||||
}
|
||||
|
||||
BLI_init_threads(&threads, do_shadow_thread, totthread);
|
||||
BLI_threadpool_init(&threads, do_shadow_thread, totthread);
|
||||
|
||||
for (a=0; a<totthread; a++)
|
||||
BLI_insert_thread(&threads, re);
|
||||
BLI_threadpool_insert(&threads, re);
|
||||
|
||||
/* keep rendering as long as there are shadow buffers not ready */
|
||||
do {
|
||||
|
@ -890,14 +890,14 @@ void threaded_makeshadowbufs(Render *re)
|
|||
|
||||
PIL_sleep_ms(50);
|
||||
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
for (lar=re->lampren.first; lar; lar= lar->next)
|
||||
if (lar->shb && !lar->thread_ready)
|
||||
break;
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
} while (lar);
|
||||
|
||||
BLI_end_threads(&threads);
|
||||
BLI_threadpool_end(&threads);
|
||||
|
||||
/* unset threadsafety */
|
||||
re->test_break= test_break;
|
||||
|
|
|
@ -973,9 +973,9 @@ void sss_add_points(Render *re, float (*co)[3], float (*color)[3], float *area,
|
|||
p->area= area;
|
||||
p->totpoint= totpoint;
|
||||
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_lock(LOCK_CUSTOM1);
|
||||
BLI_addtail(re->sss_points, p);
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -418,8 +418,8 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
|
|||
|
||||
// printf("job started: %s\n", wm_job->name);
|
||||
|
||||
BLI_init_threads(&wm_job->threads, do_job_thread, 1);
|
||||
BLI_insert_thread(&wm_job->threads, wm_job);
|
||||
BLI_threadpool_init(&wm_job->threads, do_job_thread, 1);
|
||||
BLI_threadpool_insert(&wm_job->threads, wm_job);
|
||||
}
|
||||
|
||||
/* restarted job has timer already */
|
||||
|
@ -450,7 +450,7 @@ static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job)
|
|||
wm_job->stop = true;
|
||||
|
||||
WM_job_main_thread_lock_release(wm_job);
|
||||
BLI_end_threads(&wm_job->threads);
|
||||
BLI_threadpool_end(&wm_job->threads);
|
||||
WM_job_main_thread_lock_acquire(wm_job);
|
||||
|
||||
if (wm_job->endjob)
|
||||
|
@ -601,7 +601,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
|
|||
wm_job->running = false;
|
||||
|
||||
WM_job_main_thread_lock_release(wm_job);
|
||||
BLI_end_threads(&wm_job->threads);
|
||||
BLI_threadpool_end(&wm_job->threads);
|
||||
WM_job_main_thread_lock_acquire(wm_job);
|
||||
|
||||
if (wm_job->endnote)
|
||||
|
|
|
@ -1376,7 +1376,7 @@ static int arg_handle_render_frame(int argc, const char **argv, void *data)
|
|||
}
|
||||
|
||||
re = RE_NewSceneRender(scene);
|
||||
BLI_begin_threaded_malloc();
|
||||
BLI_threaded_malloc_begin();
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
|
||||
RE_SetReports(re, &reports);
|
||||
|
@ -1393,7 +1393,7 @@ static int arg_handle_render_frame(int argc, const char **argv, void *data)
|
|||
}
|
||||
RE_SetReports(re, NULL);
|
||||
BKE_reports_clear(&reports);
|
||||
BLI_end_threaded_malloc();
|
||||
BLI_threaded_malloc_end();
|
||||
MEM_freeN(frame_range_arr);
|
||||
return 1;
|
||||
}
|
||||
|
@ -1419,13 +1419,13 @@ static int arg_handle_render_animation(int UNUSED(argc), const char **UNUSED(arg
|
|||
Main *bmain = CTX_data_main(C);
|
||||
Render *re = RE_NewSceneRender(scene);
|
||||
ReportList reports;
|
||||
BLI_begin_threaded_malloc();
|
||||
BLI_threaded_malloc_begin();
|
||||
BKE_reports_init(&reports, RPT_STORE);
|
||||
RE_SetReports(re, &reports);
|
||||
RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, scene->r.sfra, scene->r.efra, scene->r.frame_step);
|
||||
RE_SetReports(re, NULL);
|
||||
BKE_reports_clear(&reports);
|
||||
BLI_end_threaded_malloc();
|
||||
BLI_threaded_malloc_end();
|
||||
}
|
||||
else {
|
||||
printf("\nError: no blend loaded. cannot use '-a'.\n");
|
||||
|
|
|
@ -467,8 +467,8 @@ bool VideoFFmpeg::startCache()
|
|||
CachePacket *packet = new CachePacket();
|
||||
BLI_addtail(&m_packetCacheFree, packet);
|
||||
}
|
||||
BLI_init_threads(&m_thread, cacheThread, 1);
|
||||
BLI_insert_thread(&m_thread, this);
|
||||
BLI_threadpool_init(&m_thread, cacheThread, 1);
|
||||
BLI_threadpool_insert(&m_thread, this);
|
||||
m_cacheStarted = true;
|
||||
}
|
||||
return m_cacheStarted;
|
||||
|
@ -479,7 +479,7 @@ void VideoFFmpeg::stopCache()
|
|||
if (m_cacheStarted)
|
||||
{
|
||||
m_stopThread = true;
|
||||
BLI_end_threads(&m_thread);
|
||||
BLI_threadpool_end(&m_thread);
|
||||
// now delete the cache
|
||||
CacheFrame *frame;
|
||||
CachePacket *packet;
|
||||
|
|
Loading…
Reference in New Issue