Fix for threads usage. This solves the hanging 'render baking', cauused
by yesterdays commit. Now a designater LOCK_IMAGE is used for all image write/read.
This commit is contained in:
@@ -1364,7 +1364,7 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser)
|
||||
else if(ima->ok==0)
|
||||
return NULL;
|
||||
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
|
||||
/* handle image source and types */
|
||||
if(ima->source==IMA_SRC_MOVIE) {
|
||||
@@ -1456,7 +1456,7 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser)
|
||||
if(G.rendering==0)
|
||||
tag_image_time(ima);
|
||||
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
|
||||
return ibuf;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#define BLI_THREADS_H
|
||||
|
||||
/* one custom lock available now. can be extended */
|
||||
#define LOCK_IMAGE 0
|
||||
#define LOCK_CUSTOM1 1
|
||||
|
||||
/* for tables, button in UI, etc */
|
||||
|
||||
@@ -84,6 +84,7 @@ A sample loop can look like this (pseudo c);
|
||||
|
||||
************************************************ */
|
||||
static pthread_mutex_t _malloc_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t _image_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t _custom1_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int thread_levels= 0; /* threads can be invoked inside threads */
|
||||
|
||||
@@ -203,13 +204,17 @@ void BLI_end_threads(ListBase *threadbase)
|
||||
|
||||
void BLI_lock_thread(int type)
|
||||
{
|
||||
if (type==LOCK_CUSTOM1)
|
||||
if (type==LOCK_IMAGE)
|
||||
pthread_mutex_lock(&_image_lock);
|
||||
else if (type==LOCK_CUSTOM1)
|
||||
pthread_mutex_lock(&_custom1_lock);
|
||||
}
|
||||
|
||||
void BLI_unlock_thread(int type)
|
||||
{
|
||||
if(type==LOCK_CUSTOM1)
|
||||
if (type==LOCK_IMAGE)
|
||||
pthread_mutex_unlock(&_image_lock);
|
||||
else if(type==LOCK_CUSTOM1)
|
||||
pthread_mutex_unlock(&_custom1_lock);
|
||||
}
|
||||
|
||||
|
||||
@@ -644,12 +644,12 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *dxt, f
|
||||
if(tex->imaflag & TEX_MIPMAP) {
|
||||
if(ibuf->flags & IB_fields);
|
||||
else if(ibuf->mipmap[0]==NULL) {
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
|
||||
if(ibuf->mipmap[0]==NULL)
|
||||
IMB_makemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP);
|
||||
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -640,7 +640,7 @@ static void save_render_result_tile(Render *re, RenderPart *pa)
|
||||
RenderPass *rpassp;
|
||||
int offs, partx, party;
|
||||
|
||||
BLI_lock_thread(LOCK_CUSTOM1);
|
||||
BLI_lock_thread(LOCK_IMAGE);
|
||||
|
||||
for(rlp= rrpart->layers.first; rlp; rlp= rlp->next) {
|
||||
|
||||
@@ -673,7 +673,7 @@ static void save_render_result_tile(Render *re, RenderPart *pa)
|
||||
partx= rrpart->tilerect.xmin + rrpart->crop;
|
||||
IMB_exrtile_write_channels(re->result->exrhandle, partx, party);
|
||||
|
||||
BLI_unlock_thread(LOCK_CUSTOM1);
|
||||
BLI_unlock_thread(LOCK_IMAGE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user