Fix #33125: cycles OSL crash with multiple render sessions running at the same time.

This commit is contained in:
Brecht Van Lommel
2012-11-09 03:10:22 +00:00
parent 1c3640997c
commit f171d0f29c
4 changed files with 42 additions and 4 deletions

View File

@@ -68,6 +68,11 @@ struct OSLGlobals {
};
static tls_ptr(ThreadData, thread_data);
static thread_mutex thread_data_mutex;
static volatile int thread_data_users;
void thread_data_init();
void thread_data_free();
};
CCL_NAMESPACE_END

View File

@@ -32,9 +32,32 @@
CCL_NAMESPACE_BEGIN
tls_ptr(OSLGlobals::ThreadData, OSLGlobals::thread_data);
volatile int OSLGlobals::thread_data_users = 0;
thread_mutex OSLGlobals::thread_data_mutex;
/* Threads */
void OSLGlobals::thread_data_init()
{
thread_scoped_lock thread_data_lock(thread_data_mutex);
if(thread_data_users == 0)
tls_create(OSLGlobals::ThreadData, thread_data);
thread_data_users++;
}
void OSLGlobals::thread_data_free()
{
/* thread local storage delete */
thread_scoped_lock thread_data_lock(thread_data_mutex);
thread_data_users--;
if(thread_data_users == 0)
tls_delete(OSLGlobals::ThreadData, thread_data);
}
void OSLShader::thread_init(KernelGlobals *kg)
{
OSL::ShadingSystem *ss = kg->osl.ss;