From 0f82931e5fe89ed245a03a4608e524c2423c0d64 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 3 Jun 2005 18:44:01 +0000 Subject: Added threadsafe patch from Martin. Now envmaps of type "Load" should not give errors. I assume Martin tested! --- source/blender/render/intern/source/envmap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 37af5f77c82..168fe271f13 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -64,6 +64,10 @@ #include "MTC_matrixops.h" +#include "SDL_thread.h" +#undef main +#define main main /* stupid SDL_main redefines main as SDL_main */ + /* this module */ #include "RE_callbacks.h" #include "render.h" @@ -634,6 +638,7 @@ static void set_dxtdyt(float *dxts, float *dyts, float *dxt, float *dyt, int fac int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexResult *texres) { + extern SDL_mutex *load_ibuf_lock; // initrender.c /* texvec should be the already reflected normal */ EnvMap *env; Image *ima; @@ -648,8 +653,10 @@ int envmaptex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, TexRe if(env->stype==ENV_LOAD) { env->ima= tex->ima; if(env->ima && env->ima->ok) { - // not threadsafe yet! + // Now thread safe + if(load_ibuf_lock) SDL_mutexP(load_ibuf_lock); if(env->ima->ibuf==NULL) ima_ibuf_is_nul(tex, tex->ima); + if(load_ibuf_lock) SDL_mutexV(load_ibuf_lock); if(env->ima->ok && env->ok==0) envmap_split_ima(env); } } -- cgit v1.2.3