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
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-02 13:40:24 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-03 16:36:20 +0300
commitfadb6f34662fb60e1a48c2c053c500f017206f27 (patch)
tree48c16c2215e7110e00b4255f6230aa3491d94ee0 /intern/cycles/device
parent08a44d29815f6b0b9b675a503829d2e2ce7f6426 (diff)
Cleanup: refactor Cycles OSL texture handling
This adds our own OSL texture handle, that has info for OIIO textures or our own custom texture types. A filename to handle hash map is used for lookups. This is efficient because it happens at OSL compile time, because the optimizer can figure out constant strings and replace them with texture handles.
Diffstat (limited to 'intern/cycles/device')
-rw-r--r--intern/cycles/device/device_cpu.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp
index 837a8186064..32911e054fe 100644
--- a/intern/cycles/device/device_cpu.cpp
+++ b/intern/cycles/device/device_cpu.cpp
@@ -43,6 +43,7 @@
#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"
@@ -165,7 +166,7 @@ class CPUDevice : public Device {
bool need_texture_info;
#ifdef WITH_OSL
- OSLGlobals osl_globals;
+ OSLGlobals *osl_globals;
#endif
bool use_split_kernel;
@@ -282,7 +283,9 @@ class CPUDevice : public Device {
}
#ifdef WITH_OSL
- kernel_globals.osl = &osl_globals;
+ /* Must use aligned malloc due to concurrent hash map. */
+ osl_globals = util_aligned_new<OSLGlobals>();
+ kernel_globals.osl = osl_globals;
#endif
use_split_kernel = DebugFlags().cpu.split_kernel;
if (use_split_kernel) {
@@ -317,6 +320,9 @@ class CPUDevice : public Device {
~CPUDevice()
{
+#ifdef WITH_OSL
+ delete osl_globals;
+#endif
task_pool.stop();
texture_info.free();
}
@@ -492,7 +498,7 @@ class CPUDevice : public Device {
void *osl_memory()
{
#ifdef WITH_OSL
- return &osl_globals;
+ return osl_globals;
#else
return NULL;
#endif
@@ -981,7 +987,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++)
@@ -1053,7 +1059,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;
}