Fix Cycles build error after recent changes
We need to do aligned alloc of the services instead of globals now since the concurrent map moved there.
This commit is contained in:
@@ -43,7 +43,6 @@
|
||||
#include "render/buffers.h"
|
||||
#include "render/coverage.h"
|
||||
|
||||
#include "util/util_aligned_malloc.h"
|
||||
#include "util/util_debug.h"
|
||||
#include "util/util_foreach.h"
|
||||
#include "util/util_function.h"
|
||||
@@ -166,7 +165,7 @@ class CPUDevice : public Device {
|
||||
bool need_texture_info;
|
||||
|
||||
#ifdef WITH_OSL
|
||||
OSLGlobals *osl_globals;
|
||||
OSLGlobals osl_globals;
|
||||
#endif
|
||||
|
||||
bool use_split_kernel;
|
||||
@@ -283,9 +282,7 @@ class CPUDevice : public Device {
|
||||
}
|
||||
|
||||
#ifdef WITH_OSL
|
||||
/* Must use aligned malloc due to concurrent hash map. */
|
||||
osl_globals = util_aligned_new<OSLGlobals>();
|
||||
kernel_globals.osl = osl_globals;
|
||||
kernel_globals.osl = &osl_globals;
|
||||
#endif
|
||||
use_split_kernel = DebugFlags().cpu.split_kernel;
|
||||
if (use_split_kernel) {
|
||||
@@ -320,9 +317,6 @@ class CPUDevice : public Device {
|
||||
|
||||
~CPUDevice()
|
||||
{
|
||||
#ifdef WITH_OSL
|
||||
util_aligned_delete(osl_globals);
|
||||
#endif
|
||||
task_pool.stop();
|
||||
texture_info.free();
|
||||
}
|
||||
@@ -498,7 +492,7 @@ class CPUDevice : public Device {
|
||||
void *osl_memory()
|
||||
{
|
||||
#ifdef WITH_OSL
|
||||
return osl_globals;
|
||||
return &osl_globals;
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
@@ -987,7 +981,7 @@ class CPUDevice : public Device {
|
||||
KernelGlobals kg = kernel_globals;
|
||||
|
||||
#ifdef WITH_OSL
|
||||
OSLShader::thread_init(&kg, &kernel_globals, osl_globals);
|
||||
OSLShader::thread_init(&kg, &kernel_globals, &osl_globals);
|
||||
#endif
|
||||
for (int sample = 0; sample < task.num_samples; sample++) {
|
||||
for (int x = task.shader_x; x < task.shader_x + task.shader_w; x++)
|
||||
@@ -1059,7 +1053,7 @@ class CPUDevice : public Device {
|
||||
kg.decoupled_volume_steps_index = 0;
|
||||
kg.coverage_asset = kg.coverage_object = kg.coverage_material = NULL;
|
||||
#ifdef WITH_OSL
|
||||
OSLShader::thread_init(&kg, &kernel_globals, osl_globals);
|
||||
OSLShader::thread_init(&kg, &kernel_globals, &osl_globals);
|
||||
#endif
|
||||
return kg;
|
||||
}
|
||||
|
@@ -30,6 +30,7 @@
|
||||
# include "kernel/osl/osl_services.h"
|
||||
# include "kernel/osl/osl_shader.h"
|
||||
|
||||
# include "util/util_aligned_malloc.h"
|
||||
# include "util/util_foreach.h"
|
||||
# include "util/util_logging.h"
|
||||
# include "util/util_md5.h"
|
||||
@@ -224,7 +225,8 @@ void OSLShaderManager::shading_system_init()
|
||||
thread_scoped_lock lock(ss_shared_mutex);
|
||||
|
||||
if (ss_shared_users == 0) {
|
||||
services_shared = new OSLRenderServices(ts_shared);
|
||||
/* Must use aligned new due to concurrent hash map. */
|
||||
services_shared = util_aligned_new<OSLRenderServices>(ts_shared);
|
||||
|
||||
string shader_path = path_get("shader");
|
||||
# ifdef _WIN32
|
||||
@@ -293,7 +295,7 @@ void OSLShaderManager::shading_system_free()
|
||||
delete ss_shared;
|
||||
ss_shared = NULL;
|
||||
|
||||
delete services_shared;
|
||||
util_aligned_delete(services_shared);
|
||||
services_shared = NULL;
|
||||
}
|
||||
|
||||
|
@@ -31,10 +31,10 @@ void *util_aligned_malloc(size_t size, int alignment);
|
||||
void util_aligned_free(void *ptr);
|
||||
|
||||
/* Aligned new operator. */
|
||||
template<typename T> T *util_aligned_new()
|
||||
template<typename T, typename... Args> T *util_aligned_new(Args... args)
|
||||
{
|
||||
void *mem = util_aligned_malloc(sizeof(T), alignof(T));
|
||||
return new (mem) T();
|
||||
return new (mem) T(args...);
|
||||
}
|
||||
|
||||
template<typename T> void util_aligned_delete(T *t)
|
||||
|
Reference in New Issue
Block a user