OSX : Bugfix [#21293] add OpenMP apple gcc bug workaround for render preview

All openMP calls from a background thread need to have this thread var init workaround
This commit is contained in:
Damien Plisson
2010-02-22 10:29:49 +00:00
parent b65a983d39
commit dd03793f4e
3 changed files with 33 additions and 1 deletions

View File

@@ -54,3 +54,9 @@ CPPFLAGS += -I../../render/extern/include
# own include
CPPFLAGS += -I../include
ifeq ($(OS), darwin)
ifeq ($(WITH_BF_OPENMP), true)
CPPFLAGS += -DPARALLEL=1
endif
endif

View File

@@ -24,4 +24,8 @@ if env['WITH_BF_QUICKTIME']:
if env['USE_QTKIT']:
env.Append(CFLAGS=['-DUSE_QTKIT'])
if env['OURPLATFORM'] == 'darwin':
if env['WITH_BF_OPENMP']:
env.Append(CFLAGS=['-DPARALLEL=1'])
env.BlenderLib ( 'bf_editors_render', sources, Split(incs), [], libtype=['core'], priority=[45])

View File

@@ -100,6 +100,13 @@
#define PR_XMAX 200
#define PR_YMAX 195
#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
/* ************** libgomp (Apple gcc 4.2.1) TLS bug workaround *************** */
#include <pthread.h>
extern pthread_key_t gomp_tls_key;
static void *thread_tls_data;
#endif
/* XXX */
static int qtest() {return 0;}
/* XXX */
@@ -1098,6 +1105,11 @@ static void common_preview_startjob(void *customdata, short *stop, short *do_upd
{
ShaderPreview *sp= customdata;
#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
// Workaround for Apple gcc 4.2.1 omp vs background thread bug
pthread_setspecific (gomp_tls_key, thread_tls_data);
#endif
if(sp->pr_method == PR_ICON_RENDER)
icon_preview_startjob(customdata, stop, do_update);
else
@@ -1127,7 +1139,12 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
WM_jobs_customdata(steve, sp, shader_preview_free);
WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL);
WM_jobs_callbacks(steve, common_preview_startjob, NULL, NULL);
#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
// Workaround for Apple gcc 4.2.1 omp vs background thread bug
thread_tls_data = pthread_getspecific(gomp_tls_key);
#endif
WM_jobs_start(CTX_wm_manager(C), steve);
}
@@ -1154,6 +1171,11 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL);
WM_jobs_callbacks(steve, common_preview_startjob, NULL, shader_preview_updatejob);
#if defined(__APPLE__) && (PARALLEL == 1) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 2)
// Workaround for Apple gcc 4.2.1 omp vs background thread bug
thread_tls_data = pthread_getspecific(gomp_tls_key);
#endif
WM_jobs_start(CTX_wm_manager(C), steve);
}