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:
authorKévin Dietrich <kevin.dietrich@mailoo.org>2021-05-02 03:34:56 +0300
committerKévin Dietrich <kevin.dietrich@mailoo.org>2021-05-03 02:21:12 +0300
commit3bc44233c08dfc4af0cff89a14681f86dfebf5ae (patch)
tree1dea6e093f04cd29ef78c7dd64d1164fef17dd2d /intern/cycles/render/osl.cpp
parent5a964664d6cf54deb3d5590f8581683f865af747 (diff)
Cycles: use reference count to detect used shaders
Shaders are only compiled if they are used by some other Node (Geometry, Light, etc.). This usage detection is done before updating the Scene, however it fails at detecting Shaders used by Procedurals not known to Cycles (e.g. ones defined by third party applications), as Procedurals are only updated after the shaders are compiled. To remedy this, we now use the Node reference counting mechanism to detect whether a Shader is used and therefore should be compiled. This removes `ShaderManager::update_shaders_used` as it is not needed anymore, however, since it would also update the Shader ids, this is now performed in `ShaderManager::device_update`, and a new virtual `device_update_specific` method was added to handle device updates for SVM and OSL. Reviewed By: brecht Differential Revision: https://developer.blender.org/D10965
Diffstat (limited to 'intern/cycles/render/osl.cpp')
-rw-r--r--intern/cycles/render/osl.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp
index 53c67049571..9bd6e3a5e2d 100644
--- a/intern/cycles/render/osl.cpp
+++ b/intern/cycles/render/osl.cpp
@@ -91,10 +91,10 @@ void OSLShaderManager::reset(Scene * /*scene*/)
shading_system_init();
}
-void OSLShaderManager::device_update(Device *device,
- DeviceScene *dscene,
- Scene *scene,
- Progress &progress)
+void OSLShaderManager::device_update_specific(Device *device,
+ DeviceScene *dscene,
+ Scene *scene,
+ Progress &progress)
{
if (!need_update())
return;
@@ -1149,7 +1149,7 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
shader->has_integrator_dependency = false;
/* generate surface shader */
- if (shader->used && graph && output->input("Surface")->link) {
+ if (shader->reference_count() && graph && output->input("Surface")->link) {
shader->osl_surface_ref = compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
if (has_bump)
@@ -1165,7 +1165,7 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
}
/* generate volume shader */
- if (shader->used && graph && output->input("Volume")->link) {
+ if (shader->reference_count() && graph && output->input("Volume")->link) {
shader->osl_volume_ref = compile_type(shader, shader->graph, SHADER_TYPE_VOLUME);
shader->has_volume = true;
}
@@ -1173,7 +1173,7 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
shader->osl_volume_ref = OSL::ShaderGroupRef();
/* generate displacement shader */
- if (shader->used && graph && output->input("Displacement")->link) {
+ if (shader->reference_count() && graph && output->input("Displacement")->link) {
shader->osl_displacement_ref = compile_type(shader, shader->graph, SHADER_TYPE_DISPLACEMENT);
shader->has_displacement = true;
}