#include "zbuf.h"
#include "SDL_thread.h"
+#include "SDL_mutex.h"
/* render flow
/* ********* alloc and free ******** */
-static SDL_mutex *malloc_lock= NULL;
+SDL_mutex *malloc_lock= NULL;
void *RE_mallocN(int len, char *name)
{
}
if(res->rect32)
- MEM_freeN(res->rect32);
+ RE_freeN(res->rect32);
if(res->rectz)
- MEM_freeN(res->rectz);
+ RE_freeN(res->rectz);
if(res->rectf)
- MEM_freeN(res->rectf);
+ RE_freeN(res->rectf);
RE_freeN(res);
}
rl= RE_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
- rl->rectf= RE_callocN(rectx*recty*sizeof(float)*4, "layer float rgba");
- rl->rectz= RE_callocN(rectx*recty*sizeof(float), "layer float Z");
+ rl->rectf= RE_callocN(rectx*recty*sizeof(float)*4, "prev/env float rgba");
+ rl->rectz= RE_callocN(rectx*recty*sizeof(float), "prev/env float Z");
/* note, this has to be in sync with scene.c */
rl->lay= (1<<20) -1;
typedef struct ThreadSlot {
RenderPart *part;
+ SDL_Thread *sdlthread;
int avail;
} ThreadSlot;
for(a=0; a< RE_MAX_THREAD; a++) {
threadslots[a].part= NULL;
+ threadslots[a].sdlthread= NULL;
if(a<tot)
threadslots[a].avail= 1;
else
return counter;
}
+/* prototype for functional below */
+static int do_part_thread(void *pa_v);
+
static void insert_threadslot(RenderPart *pa)
{
int a;
for(a=0; a< RE_MAX_THREAD; a++) {
if(threadslots[a].avail) {
+ pa->thread= a;
threadslots[a].avail= 0;
threadslots[a].part= pa;
- pa->thread= a;
+ threadslots[a].sdlthread= SDL_CreateThread(do_part_thread, pa);
break;
}
}
if(threadslots[a].part==pa) {
threadslots[a].avail= 1;
threadslots[a].part= NULL;
+ SDL_WaitThread(threadslots[a].sdlthread, NULL);
+ threadslots[a].sdlthread= NULL;
}
}
}
}
pa->ready= 1;
- remove_threadslot(pa);
return 0;
}
if(available_threadslots() && !re->test_break()) {
pa= find_nicest_part(re);
if(pa) {
- insert_threadslot(pa);
pa->nr= counter++; /* only for stats */
- SDL_CreateThread(do_part_thread, pa);
+ insert_threadslot(pa);
}
}
else
for(pa= re->parts.first; pa; pa= pa->next) {
if(pa->ready) {
if(pa->result) {
+ remove_threadslot(pa); /* do it here, not in thread */
re->display_draw(pa->result, NULL);
free_render_result(pa->result);
pa->result= NULL;