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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user