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:
Diffstat (limited to 'intern/cycles')
-rw-r--r--intern/cycles/kernel/filter/filter_reconstruction.h2
-rw-r--r--intern/cycles/kernel/svm/svm_ies.h2
-rw-r--r--intern/cycles/render/graph.cpp2
-rw-r--r--intern/cycles/render/osl.cpp2
-rw-r--r--intern/cycles/render/session.cpp2
-rw-r--r--intern/cycles/render/svm.cpp106
-rw-r--r--intern/cycles/render/svm.h5
7 files changed, 67 insertions, 54 deletions
diff --git a/intern/cycles/kernel/filter/filter_reconstruction.h b/intern/cycles/kernel/filter/filter_reconstruction.h
index a69397bc6a6..17941689ad5 100644
--- a/intern/cycles/kernel/filter/filter_reconstruction.h
+++ b/intern/cycles/kernel/filter/filter_reconstruction.h
@@ -108,7 +108,7 @@ ccl_device_inline void kernel_filter_finalize(int x,
/* The weighted average of pixel colors (essentially, the NLM-filtered image).
* In case the solution of the linear model fails due to numerical issues or
- * returns non-sensical negative values, fall back to this value. */
+ * returns nonsensical negative values, fall back to this value. */
float3 mean_color = XtWY[0] / XtWX[0];
math_trimatrix_vec3_solve(XtWX, XtWY, (*rank) + 1, stride);
diff --git a/intern/cycles/kernel/svm/svm_ies.h b/intern/cycles/kernel/svm/svm_ies.h
index f13527c03db..e57e54ef123 100644
--- a/intern/cycles/kernel/svm/svm_ies.h
+++ b/intern/cycles/kernel/svm/svm_ies.h
@@ -25,7 +25,7 @@ ccl_device_inline float interpolate_ies_vertical(
* of v (corresponding to the north pole) would result in artifacts. The proper way of dealing
* with this would be to lookup the corresponding value on the other side of the pole, but since
* the horizontal coordinates might be nonuniform, this would require yet another interpolation.
- * Therefore, the assumtion is made that the light is going to be symmetrical, which means that
+ * Therefore, the assumption is made that the light is going to be symmetrical, which means that
* we can just take the corresponding value at the current horizontal coordinate. */
#define IES_LOOKUP(v) kernel_tex_fetch(__ies, ofs + h * v_num + (v))
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index a56871779cf..501d1e33a9b 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -978,7 +978,7 @@ void ShaderGraph::bump_from_displacement(bool use_object_space)
foreach (NodePair &pair, nodes_dy)
pair.second->bump = SHADER_BUMP_DY;
- /* add set normal node and connect the bump normal ouput to the set normal
+ /* add set normal node and connect the bump normal output to the set normal
* output, so it can finally set the shader normal, note we are only doing
* this for bump from displacement, this will be the only bump allowed to
* overwrite the shader normal */
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp
index 6f927bd5c42..19d27a7ef46 100644
--- a/intern/cycles/render/osl.cpp
+++ b/intern/cycles/render/osl.cpp
@@ -152,7 +152,7 @@ void OSLShaderManager::device_update(Device *device,
{
/* Perform greedyjit optimization.
*
- * This might waste time on optimizing gorups which are never actually
+ * This might waste time on optimizing groups which are never actually
* used, but this prevents OSL from allocating data on TLS at render
* time.
*
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index da2be0b147b..157bb6d63d3 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -985,7 +985,7 @@ void Session::update_status_time(bool show_pause, bool show_done)
substatus += string_printf(", Prefiltered %d tiles", progress.get_denoised_tiles());
}
}
- else if (tile_manager.num_samples == INT_MAX)
+ else if (tile_manager.num_samples == Integrator::MAX_SAMPLES)
substatus = string_printf("Path Tracing Sample %d", progressive_sample + 1);
else
substatus = string_printf("Path Tracing Sample %d/%d", progressive_sample + 1, num_samples);
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index 040aa074f28..f69c89b1fd4 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -47,46 +47,23 @@ void SVMShaderManager::reset(Scene * /*scene*/)
void SVMShaderManager::device_update_shader(Scene *scene,
Shader *shader,
Progress *progress,
- array<int4> *global_svm_nodes)
+ array<int4> *svm_nodes)
{
if (progress->get_cancel()) {
return;
}
assert(shader->graph);
- array<int4> svm_nodes;
- svm_nodes.push_back_slow(make_int4(NODE_SHADER_JUMP, 0, 0, 0));
+ svm_nodes->push_back_slow(make_int4(NODE_SHADER_JUMP, 0, 0, 0));
SVMCompiler::Summary summary;
SVMCompiler compiler(scene->shader_manager, scene->image_manager, scene->light_manager);
compiler.background = (shader == scene->default_background);
- compiler.compile(scene, shader, svm_nodes, 0, &summary);
+ compiler.compile(scene, shader, *svm_nodes, 0, &summary);
VLOG(2) << "Compilation summary:\n"
<< "Shader name: " << shader->name << "\n"
<< summary.full_report();
-
- nodes_lock_.lock();
- if (shader->use_mis && shader->has_surface_emission) {
- scene->light_manager->need_update = true;
- }
-
- /* The copy needs to be done inside the lock, if another thread resizes the array
- * while memcpy is running, it'll be copying into possibly invalid/freed ram.
- */
- size_t global_nodes_size = global_svm_nodes->size();
- global_svm_nodes->resize(global_nodes_size + svm_nodes.size());
-
- /* Offset local SVM nodes to a global address space. */
- int4 &jump_node = (*global_svm_nodes)[shader->id];
- jump_node.y = svm_nodes[0].y + global_nodes_size - 1;
- jump_node.z = svm_nodes[0].z + global_nodes_size - 1;
- jump_node.w = svm_nodes[0].w + global_nodes_size - 1;
- /* Copy new nodes to global storage. */
- memcpy(&(*global_svm_nodes)[global_nodes_size],
- &svm_nodes[1],
- sizeof(int4) * (svm_nodes.size() - 1));
- nodes_lock_.unlock();
}
void SVMShaderManager::device_update(Device *device,
@@ -97,7 +74,9 @@ void SVMShaderManager::device_update(Device *device,
if (!need_update)
return;
- VLOG(1) << "Total " << scene->shaders.size() << " shaders.";
+ const int num_shaders = scene->shaders.size();
+
+ VLOG(1) << "Total " << num_shaders << " shaders.";
double start_time = time_dt();
@@ -107,20 +86,17 @@ void SVMShaderManager::device_update(Device *device,
/* determine which shaders are in use */
device_update_shaders_used(scene);
- /* svm_nodes */
- array<int4> svm_nodes;
- size_t i;
-
- for (i = 0; i < scene->shaders.size(); i++) {
- svm_nodes.push_back_slow(make_int4(NODE_SHADER_JUMP, 0, 0, 0));
- }
-
+ /* Build all shaders. */
TaskPool task_pool;
- foreach (Shader *shader, scene->shaders) {
- task_pool.push(
- function_bind(
- &SVMShaderManager::device_update_shader, this, scene, shader, &progress, &svm_nodes),
- false);
+ vector<array<int4>> shader_svm_nodes(num_shaders);
+ for (int i = 0; i < num_shaders; i++) {
+ task_pool.push(function_bind(&SVMShaderManager::device_update_shader,
+ this,
+ scene,
+ scene->shaders[i],
+ &progress,
+ &shader_svm_nodes[i]),
+ false);
}
task_pool.wait_work();
@@ -128,20 +104,60 @@ void SVMShaderManager::device_update(Device *device,
return;
}
- dscene->svm_nodes.steal_data(svm_nodes);
- dscene->svm_nodes.copy_to_device();
+ /* The global node list contains a jump table (one node per shader)
+ * followed by the nodes of all shaders. */
+ int svm_nodes_size = num_shaders;
+ for (int i = 0; i < num_shaders; i++) {
+ /* Since we're not copying the local jump node, the size ends up being one node lower. */
+ svm_nodes_size += shader_svm_nodes[i].size() - 1;
+ }
+
+ int4 *svm_nodes = dscene->svm_nodes.alloc(svm_nodes_size);
- for (i = 0; i < scene->shaders.size(); i++) {
+ int node_offset = num_shaders;
+ for (int i = 0; i < num_shaders; i++) {
Shader *shader = scene->shaders[i];
+
shader->need_update = false;
+ if (shader->use_mis && shader->has_surface_emission) {
+ scene->light_manager->need_update = true;
+ }
+
+ /* Update the global jump table.
+ * Each compiled shader starts with a jump node that has offsets local
+ * to the shader, so copy those and add the offset into the global node list. */
+ int4 &global_jump_node = svm_nodes[shader->id];
+ int4 &local_jump_node = shader_svm_nodes[i][0];
+
+ global_jump_node.x = NODE_SHADER_JUMP;
+ global_jump_node.y = local_jump_node.y - 1 + node_offset;
+ global_jump_node.z = local_jump_node.z - 1 + node_offset;
+ global_jump_node.w = local_jump_node.w - 1 + node_offset;
+
+ node_offset += shader_svm_nodes[i].size() - 1;
+ }
+
+ /* Copy the nodes of each shader into the correct location. */
+ svm_nodes += num_shaders;
+ for (int i = 0; i < num_shaders; i++) {
+ int shader_size = shader_svm_nodes[i].size() - 1;
+
+ memcpy(svm_nodes, &shader_svm_nodes[i][1], sizeof(int4) * shader_size);
+ svm_nodes += shader_size;
}
+ if (progress.get_cancel()) {
+ return;
+ }
+
+ dscene->svm_nodes.copy_to_device();
+
device_update_common(device, dscene, scene, progress);
need_update = false;
- VLOG(1) << "Shader manager updated " << scene->shaders.size() << " shaders in "
- << time_dt() - start_time << " seconds.";
+ VLOG(1) << "Shader manager updated " << num_shaders << " shaders in " << time_dt() - start_time
+ << " seconds.";
}
void SVMShaderManager::device_free(Device *device, DeviceScene *dscene, Scene *scene)
diff --git a/intern/cycles/render/svm.h b/intern/cycles/render/svm.h
index d6964fb158b..7eac3e19bb3 100644
--- a/intern/cycles/render/svm.h
+++ b/intern/cycles/render/svm.h
@@ -50,13 +50,10 @@ class SVMShaderManager : public ShaderManager {
void device_free(Device *device, DeviceScene *dscene, Scene *scene);
protected:
- /* Lock used to synchronize threaded nodes compilation. */
- thread_spin_lock nodes_lock_;
-
void device_update_shader(Scene *scene,
Shader *shader,
Progress *progress,
- array<int4> *global_svm_nodes);
+ array<int4> *svm_nodes);
};
/* Graph Compiler */