Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2005-06-02 13:53:53 +0400
committerTon Roosendaal <ton@blender.org>2005-06-02 13:53:53 +0400
commite0bc6357436da194a5d7a3bff75a907d377f6432 (patch)
tree7bd332981a283e0264f0150f95c2d90deaa0a02a /source
parent9c869b1237a818754e222a31cd33e7a1c5def9cc (diff)
Bugfix #2648
Thread render with using Area lights was not fully thread safe yet. I thought I had a smart method to trick threads, but apparently it can best (and only) be done with Mutexes...
Diffstat (limited to 'source')
-rw-r--r--source/blender/render/intern/source/initrender.c7
-rw-r--r--source/blender/render/intern/source/ray.c41
2 files changed, 31 insertions, 17 deletions
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index fba9593fbbf..23fbffa8861 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -872,7 +872,7 @@ static void yafrayRender(void)
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
// exported to other files, belongs in include... later
-SDL_mutex *render_abuf_lock=NULL, *load_ibuf_lock=NULL;
+SDL_mutex *render_abuf_lock=NULL, *load_ibuf_lock=NULL, *make_table_lock= NULL;
static void renderloop_setblending(void)
@@ -916,7 +916,8 @@ static void mainRenderLoop(void) /* here the PART and FIELD loops */
/* create mutexes for threaded render */
render_abuf_lock = SDL_CreateMutex();
load_ibuf_lock = SDL_CreateMutex();
-
+ make_table_lock = SDL_CreateMutex();
+
if(R.rectz) MEM_freeN(R.rectz);
R.rectz = NULL;
if(R.rectftot) MEM_freeN(R.rectftot);
@@ -1170,8 +1171,10 @@ static void mainRenderLoop(void) /* here the PART and FIELD loops */
/* mutexes free */
SDL_DestroyMutex(load_ibuf_lock);
SDL_DestroyMutex(render_abuf_lock);
+ SDL_DestroyMutex(make_table_lock);
load_ibuf_lock= NULL;
render_abuf_lock= NULL;
+ make_table_lock= NULL;
}
void render() {
diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c
index 8a856883752..6aa157e8983 100644
--- a/source/blender/render/intern/source/ray.c
+++ b/source/blender/render/intern/source/ray.c
@@ -51,6 +51,8 @@
#include "jitter.h"
#include "texture.h"
+#include "SDL_thread.h"
+
#define DDA_SHADOW 0
#define DDA_MIRROR 1
#define DDA_SHADOW_TRA 2
@@ -1636,25 +1638,34 @@ static float *jitter_plane(LampRen *lar, int xs, int ys)
tot= lar->ray_totsamp;
if(lar->jitter==NULL) {
- lar->jitter= (float *)4; // mislead thread quickly (tsk!)
- fp=lar->jitter= MEM_mallocN(4*tot*2*sizeof(float), "lamp jitter tab");
-
- /* fill table with random locations, area_size large */
- for(x=0; x<tot; x++, fp+=2) {
- fp[0]= (BLI_frand()-0.5)*lar->area_size;
- fp[1]= (BLI_frand()-0.5)*lar->area_sizey;
- }
+ extern SDL_mutex *make_table_lock; // initrender.c
+ if(make_table_lock) SDL_mutexP(make_table_lock);
- while(iter--) {
- fp= lar->jitter;
- for(x=tot; x>0; x--, fp+=2) {
- DP_energy(lar->jitter, fp, tot, lar->area_size, lar->area_sizey);
+ /* check again, since other thread could have entered */
+ if(lar->jitter==NULL) {
+
+
+ fp=lar->jitter= MEM_mallocN(4*tot*2*sizeof(float), "lamp jitter tab");
+
+ /* fill table with random locations, area_size large */
+ for(x=0; x<tot; x++, fp+=2) {
+ fp[0]= (BLI_frand()-0.5)*lar->area_size;
+ fp[1]= (BLI_frand()-0.5)*lar->area_sizey;
}
+
+ while(iter--) {
+ fp= lar->jitter;
+ for(x=tot; x>0; x--, fp+=2) {
+ DP_energy(lar->jitter, fp, tot, lar->area_size, lar->area_sizey);
+ }
+ }
+
+ jitter_plane_offset(lar->jitter, lar->jitter+2*tot, tot, lar->area_size, lar->area_sizey, 0.5, 0.0);
+ jitter_plane_offset(lar->jitter, lar->jitter+4*tot, tot, lar->area_size, lar->area_sizey, 0.5, 0.5);
+ jitter_plane_offset(lar->jitter, lar->jitter+6*tot, tot, lar->area_size, lar->area_sizey, 0.0, 0.5);
}
- jitter_plane_offset(lar->jitter, lar->jitter+2*tot, tot, lar->area_size, lar->area_sizey, 0.5, 0.0);
- jitter_plane_offset(lar->jitter, lar->jitter+4*tot, tot, lar->area_size, lar->area_sizey, 0.5, 0.5);
- jitter_plane_offset(lar->jitter, lar->jitter+6*tot, tot, lar->area_size, lar->area_sizey, 0.0, 0.5);
+ if(make_table_lock) SDL_mutexV(make_table_lock);
}
if(lar->ray_samp_type & LA_SAMP_JITTER) {