2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 02:50:24 +01:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2020-12-10 14:18:25 +01:00
|
|
|
#include "bvh/bvh.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "device/device.h"
|
2021-01-25 15:12:00 +01:00
|
|
|
#include "render/alembic.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "render/background.h"
|
|
|
|
|
#include "render/bake.h"
|
|
|
|
|
#include "render/camera.h"
|
|
|
|
|
#include "render/curves.h"
|
|
|
|
|
#include "render/film.h"
|
|
|
|
|
#include "render/integrator.h"
|
|
|
|
|
#include "render/light.h"
|
|
|
|
|
#include "render/mesh.h"
|
|
|
|
|
#include "render/object.h"
|
|
|
|
|
#include "render/osl.h"
|
|
|
|
|
#include "render/particles.h"
|
2021-01-25 14:56:57 +01:00
|
|
|
#include "render/procedural.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "render/scene.h"
|
2020-08-18 10:46:12 +02:00
|
|
|
#include "render/session.h"
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "render/shader.h"
|
|
|
|
|
#include "render/svm.h"
|
|
|
|
|
#include "render/tables.h"
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
#include "render/volume.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "util/util_foreach.h"
|
|
|
|
|
#include "util/util_guarded_allocator.h"
|
|
|
|
|
#include "util/util_logging.h"
|
|
|
|
|
#include "util/util_progress.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2017-10-20 23:31:13 +02:00
|
|
|
DeviceScene::DeviceScene(Device *device)
|
2020-03-12 15:22:18 +01:00
|
|
|
: bvh_nodes(device, "__bvh_nodes", MEM_GLOBAL),
|
|
|
|
|
bvh_leaf_nodes(device, "__bvh_leaf_nodes", MEM_GLOBAL),
|
|
|
|
|
object_node(device, "__object_node", MEM_GLOBAL),
|
|
|
|
|
prim_type(device, "__prim_type", MEM_GLOBAL),
|
|
|
|
|
prim_visibility(device, "__prim_visibility", MEM_GLOBAL),
|
|
|
|
|
prim_index(device, "__prim_index", MEM_GLOBAL),
|
|
|
|
|
prim_object(device, "__prim_object", MEM_GLOBAL),
|
|
|
|
|
prim_time(device, "__prim_time", MEM_GLOBAL),
|
2021-02-28 23:23:24 +01:00
|
|
|
tri_verts(device, "__tri_verts", MEM_GLOBAL),
|
2020-03-12 15:22:18 +01:00
|
|
|
tri_shader(device, "__tri_shader", MEM_GLOBAL),
|
|
|
|
|
tri_vnormal(device, "__tri_vnormal", MEM_GLOBAL),
|
|
|
|
|
tri_vindex(device, "__tri_vindex", MEM_GLOBAL),
|
|
|
|
|
tri_patch(device, "__tri_patch", MEM_GLOBAL),
|
|
|
|
|
tri_patch_uv(device, "__tri_patch_uv", MEM_GLOBAL),
|
|
|
|
|
curves(device, "__curves", MEM_GLOBAL),
|
|
|
|
|
curve_keys(device, "__curve_keys", MEM_GLOBAL),
|
2021-02-28 23:23:24 +01:00
|
|
|
curve_segments(device, "__curve_segments", MEM_GLOBAL),
|
2020-03-12 15:22:18 +01:00
|
|
|
patches(device, "__patches", MEM_GLOBAL),
|
|
|
|
|
objects(device, "__objects", MEM_GLOBAL),
|
|
|
|
|
object_motion_pass(device, "__object_motion_pass", MEM_GLOBAL),
|
|
|
|
|
object_motion(device, "__object_motion", MEM_GLOBAL),
|
|
|
|
|
object_flag(device, "__object_flag", MEM_GLOBAL),
|
2020-03-07 14:38:52 +01:00
|
|
|
object_volume_step(device, "__object_volume_step", MEM_GLOBAL),
|
2020-03-12 15:22:18 +01:00
|
|
|
camera_motion(device, "__camera_motion", MEM_GLOBAL),
|
|
|
|
|
attributes_map(device, "__attributes_map", MEM_GLOBAL),
|
|
|
|
|
attributes_float(device, "__attributes_float", MEM_GLOBAL),
|
|
|
|
|
attributes_float2(device, "__attributes_float2", MEM_GLOBAL),
|
|
|
|
|
attributes_float3(device, "__attributes_float3", MEM_GLOBAL),
|
|
|
|
|
attributes_uchar4(device, "__attributes_uchar4", MEM_GLOBAL),
|
|
|
|
|
light_distribution(device, "__light_distribution", MEM_GLOBAL),
|
|
|
|
|
lights(device, "__lights", MEM_GLOBAL),
|
|
|
|
|
light_background_marginal_cdf(device, "__light_background_marginal_cdf", MEM_GLOBAL),
|
|
|
|
|
light_background_conditional_cdf(device, "__light_background_conditional_cdf", MEM_GLOBAL),
|
|
|
|
|
particles(device, "__particles", MEM_GLOBAL),
|
|
|
|
|
svm_nodes(device, "__svm_nodes", MEM_GLOBAL),
|
|
|
|
|
shaders(device, "__shaders", MEM_GLOBAL),
|
|
|
|
|
lookup_table(device, "__lookup_table", MEM_GLOBAL),
|
|
|
|
|
sample_pattern_lut(device, "__sample_pattern_lut", MEM_GLOBAL),
|
|
|
|
|
ies_lights(device, "__ies", MEM_GLOBAL)
|
2017-10-20 23:31:13 +02:00
|
|
|
{
|
2018-06-11 12:54:17 +02:00
|
|
|
memset((void *)&data, 0, sizeof(data));
|
2017-10-20 23:31:13 +02:00
|
|
|
}
|
|
|
|
|
|
2017-10-20 05:08:26 +02:00
|
|
|
Scene::Scene(const SceneParams ¶ms_, Device *device)
|
2020-03-18 17:54:24 +01:00
|
|
|
: name("Scene"),
|
2021-03-15 18:52:45 +01:00
|
|
|
bvh(NULL),
|
2020-03-18 17:54:24 +01:00
|
|
|
default_surface(NULL),
|
|
|
|
|
default_volume(NULL),
|
|
|
|
|
default_light(NULL),
|
|
|
|
|
default_background(NULL),
|
|
|
|
|
default_empty(NULL),
|
|
|
|
|
device(device),
|
|
|
|
|
dscene(device),
|
2020-10-01 23:16:01 +02:00
|
|
|
params(params_),
|
2021-03-15 18:52:45 +01:00
|
|
|
update_stats(NULL),
|
|
|
|
|
kernels_loaded(false),
|
|
|
|
|
/* TODO(sergey): Check if it's indeed optimal value for the split kernel. */
|
|
|
|
|
max_closure_global(1)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2018-06-11 12:54:17 +02:00
|
|
|
memset((void *)&dscene.data, 0, sizeof(dscene.data));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-15 18:52:45 +01:00
|
|
|
/* OSL only works on the CPU */
|
|
|
|
|
if (device->info.has_osl)
|
|
|
|
|
shader_manager = ShaderManager::create(params.shadingsystem);
|
|
|
|
|
else
|
|
|
|
|
shader_manager = ShaderManager::create(SHADINGSYSTEM_SVM);
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
light_manager = new LightManager();
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_manager = new GeometryManager();
|
2011-04-27 11:58:34 +00:00
|
|
|
object_manager = new ObjectManager();
|
2017-10-20 05:08:26 +02:00
|
|
|
image_manager = new ImageManager(device->info);
|
2012-08-31 17:27:08 +00:00
|
|
|
particle_system_manager = new ParticleSystemManager();
|
2014-01-02 19:05:07 -02:00
|
|
|
bake_manager = new BakeManager();
|
2021-01-25 14:56:57 +01:00
|
|
|
procedural_manager = new ProceduralManager();
|
2020-08-18 10:46:12 +02:00
|
|
|
|
2021-03-15 18:52:45 +01:00
|
|
|
/* Create nodes after managers, since create_node() can tag the managers. */
|
|
|
|
|
camera = create_node<Camera>();
|
|
|
|
|
dicing_camera = create_node<Camera>();
|
|
|
|
|
lookup_tables = new LookupTables();
|
|
|
|
|
film = create_node<Film>();
|
|
|
|
|
background = create_node<Background>();
|
|
|
|
|
integrator = create_node<Integrator>();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-18 12:15:46 +02:00
|
|
|
film->add_default(this);
|
2020-03-11 17:49:00 +01:00
|
|
|
shader_manager->add_default(this);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Scene::~Scene()
|
|
|
|
|
{
|
2012-11-09 08:46:53 +00:00
|
|
|
free_memory(true);
|
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
void Scene::free_memory(bool final)
|
|
|
|
|
{
|
2020-12-10 14:18:25 +01:00
|
|
|
delete bvh;
|
|
|
|
|
bvh = NULL;
|
|
|
|
|
|
2021-05-02 02:23:34 +02:00
|
|
|
/* The order of deletion is important to make sure data is freed based on possible dependencies
|
|
|
|
|
* as the Nodes' reference counts are decremented in the destructors:
|
|
|
|
|
*
|
|
|
|
|
* - Procedurals can create and hold pointers to any other types.
|
|
|
|
|
* - Objects can hold pointers to Geometries and ParticleSystems
|
|
|
|
|
* - Lights and Geometries can hold pointers to Shaders.
|
|
|
|
|
*
|
|
|
|
|
* Similarly, we first delete all nodes and their associated device data, and then the managers
|
|
|
|
|
* and their associated device data.
|
|
|
|
|
*/
|
2021-01-25 14:56:57 +01:00
|
|
|
foreach (Procedural *p, procedurals)
|
|
|
|
|
delete p;
|
2011-04-27 11:58:34 +00:00
|
|
|
foreach (Object *o, objects)
|
|
|
|
|
delete o;
|
2021-05-02 02:23:34 +02:00
|
|
|
foreach (Geometry *g, geometry)
|
|
|
|
|
delete g;
|
2012-08-31 17:27:08 +00:00
|
|
|
foreach (ParticleSystem *p, particle_systems)
|
|
|
|
|
delete p;
|
2021-05-02 02:23:34 +02:00
|
|
|
foreach (Light *l, lights)
|
|
|
|
|
delete l;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
foreach (Pass *p, passes)
|
|
|
|
|
delete p;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry.clear();
|
2013-02-14 16:11:47 +00:00
|
|
|
objects.clear();
|
|
|
|
|
lights.clear();
|
|
|
|
|
particle_systems.clear();
|
2021-01-25 14:56:57 +01:00
|
|
|
procedurals.clear();
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
passes.clear();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
if (device) {
|
2015-10-27 13:16:04 +05:00
|
|
|
camera->device_free(device, &dscene, this);
|
2013-04-01 20:26:43 +00:00
|
|
|
film->device_free(device, &dscene, this);
|
2012-11-09 08:46:53 +00:00
|
|
|
background->device_free(device, &dscene);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
integrator->device_free(device, &dscene, true);
|
2021-05-02 02:23:34 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-05-02 02:23:34 +02:00
|
|
|
if (final) {
|
|
|
|
|
delete camera;
|
|
|
|
|
delete dicing_camera;
|
|
|
|
|
delete film;
|
|
|
|
|
delete background;
|
|
|
|
|
delete integrator;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Delete Shaders after every other nodes to ensure that we do not try to decrement the reference
|
|
|
|
|
* count on some dangling pointer. */
|
|
|
|
|
foreach (Shader *s, shaders)
|
|
|
|
|
delete s;
|
|
|
|
|
|
|
|
|
|
shaders.clear();
|
|
|
|
|
|
|
|
|
|
/* Now that all nodes have been deleted, we can safely delete managers and device data. */
|
|
|
|
|
if (device) {
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
object_manager->device_free(device, &dscene, true);
|
|
|
|
|
geometry_manager->device_free(device, &dscene, true);
|
2013-04-01 20:26:52 +00:00
|
|
|
shader_manager->device_free(device, &dscene, this);
|
2012-11-09 08:46:53 +00:00
|
|
|
light_manager->device_free(device, &dscene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
particle_system_manager->device_free(device, &dscene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-01-02 19:05:07 -02:00
|
|
|
bake_manager->device_free(device, &dscene);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Render: faster animation and re-rendering with Persistent Data
For Cycles, when enabling the Persistent Data option, the full render data
will be preserved from frame-to-frame in animation renders and between
re-renders of the scene. This means that any modifier evaluation, BVH
building, OpenGL vertex buffer uploads, etc, can be done only once for
unchanged objects. This comes at an increased memory cost.
Previously there option was named Persistent Images and had a more limited
impact on render time and memory.
When using multiple view layers, only data from a single view layer is
preserved to keep memory usage somewhat under control. However objects
shared between view layers are preserved, and so this can speedup such
renders as well, even single frame renders.
For Eevee and Workbench this option is not available, however these engines
will now always reuse the depsgraph for animation and multiple view layers.
This can significantly speed up rendering.
These engines do not support sharing the depsgraph between re-renders, due
to technical issues regarding OpenGL contexts. Support for this could be added
if those are solved, see the code comments for details.
2021-04-04 23:51:24 +02:00
|
|
|
if (final)
|
2017-10-20 04:20:37 +02:00
|
|
|
image_manager->device_free(device);
|
2014-05-19 14:45:52 +02:00
|
|
|
else
|
2017-10-20 04:20:37 +02:00
|
|
|
image_manager->device_free_builtin(device);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 20:26:43 +00:00
|
|
|
lookup_tables->device_free(device, &dscene);
|
2012-11-09 08:46:53 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
if (final) {
|
2013-04-01 20:26:43 +00:00
|
|
|
delete lookup_tables;
|
2012-11-09 08:46:53 +00:00
|
|
|
delete object_manager;
|
2020-02-02 12:04:19 +01:00
|
|
|
delete geometry_manager;
|
2012-11-09 08:46:53 +00:00
|
|
|
delete shader_manager;
|
|
|
|
|
delete light_manager;
|
|
|
|
|
delete particle_system_manager;
|
|
|
|
|
delete image_manager;
|
2014-01-02 19:05:07 -02:00
|
|
|
delete bake_manager;
|
2020-10-01 23:16:01 +02:00
|
|
|
delete update_stats;
|
2021-01-25 14:56:57 +01:00
|
|
|
delete procedural_manager;
|
2012-11-09 08:46:53 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Scene::device_update(Device *device_, Progress &progress)
|
|
|
|
|
{
|
|
|
|
|
if (!device)
|
|
|
|
|
device = device_;
|
2016-04-22 10:55:26 +02:00
|
|
|
|
|
|
|
|
bool print_stats = need_data_update();
|
|
|
|
|
|
2021-10-21 14:52:34 +02:00
|
|
|
if (update_stats) {
|
|
|
|
|
update_stats->clear();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-01 23:16:01 +02:00
|
|
|
scoped_callback_timer timer([this, print_stats](double time) {
|
|
|
|
|
if (update_stats) {
|
|
|
|
|
update_stats->scene.times.add_entry({"device_update", time});
|
|
|
|
|
|
|
|
|
|
if (print_stats) {
|
|
|
|
|
printf("Update statistics:\n%s\n", update_stats->full_report().c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* The order of updates is important, because there's dependencies between
|
|
|
|
|
* the different managers, using data computed by previous managers.
|
|
|
|
|
*
|
|
|
|
|
* - Image manager uploads images used by shaders.
|
2014-08-02 16:53:52 +10:00
|
|
|
* - Camera may be used for adaptive subdivision.
|
2011-04-27 11:58:34 +00:00
|
|
|
* - Displacement shader must have all shader data available.
|
2014-02-06 21:09:46 +01:00
|
|
|
* - Light manager needs lookup tables and final mesh data to compute emission CDF.
|
2014-03-12 18:20:42 +01:00
|
|
|
* - Lookup tables are done a second time to handle film tables
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
progress.set_status("Updating Shaders");
|
|
|
|
|
shader_manager->device_update(device, &dscene, this, progress);
|
|
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2021-01-25 14:56:57 +01:00
|
|
|
procedural_manager->update(this, progress);
|
|
|
|
|
|
|
|
|
|
if (progress.get_cancel())
|
|
|
|
|
return;
|
|
|
|
|
|
2013-12-28 16:56:19 +01:00
|
|
|
progress.set_status("Updating Background");
|
|
|
|
|
background->device_update(device, &dscene, this);
|
|
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2013-12-28 16:56:19 +01:00
|
|
|
|
2015-02-02 22:06:31 +05:00
|
|
|
progress.set_status("Updating Camera");
|
|
|
|
|
camera->device_update(device, &dscene, this);
|
|
|
|
|
|
|
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
|
|
|
|
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_manager->device_update_preprocess(device, this, progress);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2016-03-31 17:54:03 +02:00
|
|
|
progress.set_status("Updating Objects");
|
|
|
|
|
object_manager->device_update(device, &dscene, this, progress);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2018-01-18 22:40:48 -05:00
|
|
|
progress.set_status("Updating Particle Systems");
|
|
|
|
|
particle_system_manager->device_update(device, &dscene, this, progress);
|
|
|
|
|
|
|
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
|
|
|
|
|
2015-04-30 01:07:38 +05:00
|
|
|
progress.set_status("Updating Meshes");
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_manager->device_update(device, &dscene, this, progress);
|
2014-10-03 12:11:19 +02:00
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2014-10-03 12:11:19 +02:00
|
|
|
|
2015-04-30 01:07:38 +05:00
|
|
|
progress.set_status("Updating Objects Flags");
|
|
|
|
|
object_manager->device_update_flags(device, &dscene, this, progress);
|
2015-01-19 19:08:58 +05:00
|
|
|
|
|
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
|
|
|
|
|
2015-04-02 20:37:57 +05:00
|
|
|
progress.set_status("Updating Images");
|
2017-10-20 04:20:37 +02:00
|
|
|
image_manager->device_update(device, this, progress);
|
2015-04-02 20:37:57 +05:00
|
|
|
|
|
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
|
|
|
|
|
2015-02-02 22:06:31 +05:00
|
|
|
progress.set_status("Updating Camera Volume");
|
|
|
|
|
camera->device_update_volume(device, &dscene, this);
|
|
|
|
|
|
|
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2018-11-25 08:01:14 +11:00
|
|
|
|
2014-02-06 21:09:46 +01:00
|
|
|
progress.set_status("Updating Lookup Tables");
|
2020-10-01 23:16:01 +02:00
|
|
|
lookup_tables->device_update(device, &dscene, this);
|
2014-02-06 21:09:46 +01:00
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2014-02-06 21:09:46 +01:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
progress.set_status("Updating Lights");
|
|
|
|
|
light_manager->device_update(device, &dscene, this, progress);
|
|
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2016-04-13 10:39:21 +02:00
|
|
|
progress.set_status("Updating Integrator");
|
|
|
|
|
integrator->device_update(device, &dscene, this);
|
2014-03-12 18:20:42 +01:00
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2014-03-12 18:20:42 +01:00
|
|
|
|
2016-04-13 10:39:21 +02:00
|
|
|
progress.set_status("Updating Film");
|
|
|
|
|
film->device_update(device, &dscene, this);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-03-12 18:20:42 +01:00
|
|
|
progress.set_status("Updating Lookup Tables");
|
2020-10-01 23:16:01 +02:00
|
|
|
lookup_tables->device_update(device, &dscene, this);
|
2014-03-12 18:20:42 +01:00
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2014-03-12 18:20:42 +01:00
|
|
|
|
2014-01-02 19:05:07 -02:00
|
|
|
progress.set_status("Updating Baking");
|
|
|
|
|
bake_manager->device_update(device, &dscene, this, progress);
|
|
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (progress.get_cancel() || device->have_error())
|
|
|
|
|
return;
|
2014-01-02 19:05:07 -02:00
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
if (device->have_error() == false) {
|
2021-10-22 14:20:22 +02:00
|
|
|
dscene.data.volume_stack_size = get_volume_stack_size();
|
|
|
|
|
|
2014-12-05 21:00:05 +05:00
|
|
|
progress.set_status("Updating Device", "Writing constant memory");
|
|
|
|
|
device->const_copy_to("__data", &dscene.data, sizeof(dscene.data));
|
|
|
|
|
}
|
2015-02-14 19:39:14 +05:00
|
|
|
|
2016-04-22 10:55:26 +02:00
|
|
|
if (print_stats) {
|
2016-05-29 18:02:05 -04:00
|
|
|
size_t mem_used = util_guarded_get_mem_used();
|
|
|
|
|
size_t mem_peak = util_guarded_get_mem_peak();
|
|
|
|
|
|
2016-04-22 10:55:26 +02:00
|
|
|
VLOG(1) << "System memory statistics after full device sync:\n"
|
2016-05-29 18:02:05 -04:00
|
|
|
<< " Usage: " << string_human_readable_number(mem_used) << " ("
|
|
|
|
|
<< string_human_readable_size(mem_used) << ")\n"
|
|
|
|
|
<< " Peak: " << string_human_readable_number(mem_peak) << " ("
|
|
|
|
|
<< string_human_readable_size(mem_peak) << ")";
|
2016-04-22 10:55:26 +02:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2018-01-12 19:56:52 +01:00
|
|
|
Scene::MotionType Scene::need_motion()
|
2012-04-30 12:49:26 +00:00
|
|
|
{
|
2020-11-04 11:17:38 +01:00
|
|
|
if (integrator->get_motion_blur())
|
2018-01-12 19:56:52 +01:00
|
|
|
return MOTION_BLUR;
|
2020-08-18 12:15:46 +02:00
|
|
|
else if (Pass::contains(passes, PASS_MOTION))
|
2012-04-30 12:49:26 +00:00
|
|
|
return MOTION_PASS;
|
|
|
|
|
else
|
|
|
|
|
return MOTION_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-16 18:56:59 +02:00
|
|
|
float Scene::motion_shutter_time()
|
|
|
|
|
{
|
|
|
|
|
if (need_motion() == Scene::MOTION_PASS)
|
|
|
|
|
return 2.0f;
|
|
|
|
|
else
|
2020-11-04 11:17:38 +01:00
|
|
|
return camera->get_shuttertime();
|
2016-07-16 18:56:59 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
bool Scene::need_global_attribute(AttributeStandard std)
|
|
|
|
|
{
|
|
|
|
|
if (std == ATTR_STD_UV)
|
2020-08-18 12:15:46 +02:00
|
|
|
return Pass::contains(passes, PASS_UV);
|
2014-05-12 10:20:20 +02:00
|
|
|
else if (std == ATTR_STD_MOTION_VERTEX_POSITION)
|
2014-03-29 13:03:46 +01:00
|
|
|
return need_motion() != MOTION_NONE;
|
2014-05-12 10:20:20 +02:00
|
|
|
else if (std == ATTR_STD_MOTION_VERTEX_NORMAL)
|
2014-03-29 13:03:46 +01:00
|
|
|
return need_motion() == MOTION_BLUR;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Scene::need_global_attributes(AttributeRequestSet &attributes)
|
|
|
|
|
{
|
|
|
|
|
for (int std = ATTR_STD_NONE; std < ATTR_STD_NUM; std++)
|
|
|
|
|
if (need_global_attribute((AttributeStandard)std))
|
|
|
|
|
attributes.add((AttributeStandard)std);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
bool Scene::need_update()
|
|
|
|
|
{
|
2020-11-04 11:17:38 +01:00
|
|
|
return (need_reset() || film->is_modified());
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-04-22 10:55:26 +02:00
|
|
|
bool Scene::need_data_update()
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
return (background->is_modified() || image_manager->need_update() ||
|
|
|
|
|
object_manager->need_update() || geometry_manager->need_update() ||
|
|
|
|
|
light_manager->need_update() || lookup_tables->need_update() ||
|
|
|
|
|
integrator->is_modified() || shader_manager->need_update() ||
|
|
|
|
|
particle_system_manager->need_update() || bake_manager->need_update() ||
|
2021-01-25 14:56:57 +01:00
|
|
|
film->is_modified() || procedural_manager->need_update());
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-04-22 10:55:26 +02:00
|
|
|
bool Scene::need_reset()
|
|
|
|
|
{
|
2020-11-04 11:17:38 +01:00
|
|
|
return need_data_update() || camera->is_modified();
|
2016-04-22 10:55:26 +02:00
|
|
|
}
|
|
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
void Scene::reset()
|
|
|
|
|
{
|
2013-02-14 16:11:47 +00:00
|
|
|
shader_manager->reset(this);
|
2012-11-09 08:46:53 +00:00
|
|
|
shader_manager->add_default(this);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
/* ensure all objects are updated */
|
2020-11-04 11:17:38 +01:00
|
|
|
camera->tag_modified();
|
|
|
|
|
dicing_camera->tag_modified();
|
|
|
|
|
film->tag_modified();
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
background->tag_modified();
|
|
|
|
|
|
2012-11-09 08:46:53 +00:00
|
|
|
background->tag_update(this);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
integrator->tag_update(this, Integrator::UPDATE_ALL);
|
|
|
|
|
object_manager->tag_update(this, ObjectManager::UPDATE_ALL);
|
|
|
|
|
geometry_manager->tag_update(this, GeometryManager::UPDATE_ALL);
|
|
|
|
|
light_manager->tag_update(this, LightManager::UPDATE_ALL);
|
2014-06-05 17:39:16 +02:00
|
|
|
particle_system_manager->tag_update(this);
|
2021-01-25 14:56:57 +01:00
|
|
|
procedural_manager->tag_update();
|
2012-11-09 08:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Scene::device_free()
|
|
|
|
|
{
|
|
|
|
|
free_memory(false);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-27 15:46:13 +02:00
|
|
|
void Scene::collect_statistics(RenderStats *stats)
|
|
|
|
|
{
|
2020-02-02 12:04:19 +01:00
|
|
|
geometry_manager->collect_statistics(this, stats);
|
2018-07-27 15:46:13 +02:00
|
|
|
image_manager->collect_statistics(stats);
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-01 23:16:01 +02:00
|
|
|
void Scene::enable_update_stats()
|
|
|
|
|
{
|
|
|
|
|
if (!update_stats) {
|
|
|
|
|
update_stats = new SceneUpdateStats();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
void Scene::update_kernel_features()
|
2020-08-18 10:46:12 +02:00
|
|
|
{
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (!need_update()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-18 10:46:12 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* These features are not being tweaked as often as shaders,
|
|
|
|
|
* so could be done selective magic for the viewport as well. */
|
|
|
|
|
uint kernel_features = shader_manager->get_kernel_features(this);
|
2020-08-18 10:46:12 +02:00
|
|
|
|
|
|
|
|
bool use_motion = need_motion() == Scene::MotionType::MOTION_BLUR;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_PATH_TRACING;
|
|
|
|
|
if (params.hair_shape == CURVE_THICK) {
|
|
|
|
|
kernel_features |= KERNEL_FEATURE_HAIR_THICK;
|
|
|
|
|
}
|
|
|
|
|
if (use_motion && camera->use_motion()) {
|
|
|
|
|
kernel_features |= KERNEL_FEATURE_CAMERA_MOTION;
|
|
|
|
|
}
|
2020-08-18 10:46:12 +02:00
|
|
|
foreach (Object *object, objects) {
|
2020-11-04 11:17:38 +01:00
|
|
|
Geometry *geom = object->get_geometry();
|
2020-08-18 10:46:12 +02:00
|
|
|
if (use_motion) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (object->use_motion() || geom->get_use_motion_blur()) {
|
|
|
|
|
kernel_features |= KERNEL_FEATURE_OBJECT_MOTION;
|
|
|
|
|
}
|
|
|
|
|
if (geom->get_use_motion_blur()) {
|
|
|
|
|
kernel_features |= KERNEL_FEATURE_CAMERA_MOTION;
|
|
|
|
|
}
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
if (object->get_is_shadow_catcher()) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_SHADOW_CATCHER;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
if (geom->is_mesh()) {
|
2020-08-18 10:46:12 +02:00
|
|
|
Mesh *mesh = static_cast<Mesh *>(geom);
|
|
|
|
|
#ifdef WITH_OPENSUBDIV
|
2020-11-04 11:17:38 +01:00
|
|
|
if (mesh->get_subdivision_type() != Mesh::SUBDIVISION_NONE) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_PATCH_EVALUATION;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2020-11-04 11:17:38 +01:00
|
|
|
else if (geom->is_hair()) {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= KERNEL_FEATURE_HAIR;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (bake_manager->get_baking()) {
|
|
|
|
|
kernel_features |= KERNEL_FEATURE_BAKING;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
kernel_features |= film->get_kernel_features(this);
|
2021-10-21 17:42:15 +02:00
|
|
|
kernel_features |= integrator->get_kernel_features(this);
|
2020-08-18 10:46:12 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
dscene.data.kernel_features = kernel_features;
|
2020-08-18 10:46:12 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
/* Currently viewport render is faster with higher max_closures, needs investigating. */
|
|
|
|
|
const uint max_closures = (params.background) ? get_max_closure_count() : MAX_CLOSURE;
|
|
|
|
|
dscene.data.max_closures = max_closures;
|
|
|
|
|
dscene.data.max_shaders = shaders.size();
|
|
|
|
|
}
|
2020-08-18 10:46:12 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
bool Scene::update(Progress &progress)
|
|
|
|
|
{
|
|
|
|
|
if (!need_update()) {
|
|
|
|
|
return false;
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
2021-10-21 14:52:34 +02:00
|
|
|
/* Load render kernels, before device update where we upload data to the GPU. */
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
load_kernels(progress, false);
|
|
|
|
|
|
2021-10-21 14:52:34 +02:00
|
|
|
/* Upload scene data to the GPU. */
|
|
|
|
|
progress.set_status("Updating Scene");
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
MEM_GUARDED_CALL(&progress, device_update, device, progress);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void log_kernel_features(const uint features)
|
|
|
|
|
{
|
|
|
|
|
VLOG(2) << "Requested features:\n";
|
|
|
|
|
VLOG(2) << "Use BSDF " << string_from_bool(features & KERNEL_FEATURE_NODE_BSDF) << "\n";
|
|
|
|
|
VLOG(2) << "Use Principled BSDF " << string_from_bool(features & KERNEL_FEATURE_PRINCIPLED)
|
|
|
|
|
<< "\n";
|
|
|
|
|
VLOG(2) << "Use Emission " << string_from_bool(features & KERNEL_FEATURE_NODE_EMISSION) << "\n";
|
|
|
|
|
VLOG(2) << "Use Volume " << string_from_bool(features & KERNEL_FEATURE_NODE_VOLUME) << "\n";
|
|
|
|
|
VLOG(2) << "Use Hair " << string_from_bool(features & KERNEL_FEATURE_NODE_HAIR) << "\n";
|
|
|
|
|
VLOG(2) << "Use Bump " << string_from_bool(features & KERNEL_FEATURE_NODE_BUMP) << "\n";
|
|
|
|
|
VLOG(2) << "Use Voronoi " << string_from_bool(features & KERNEL_FEATURE_NODE_VORONOI_EXTRA)
|
|
|
|
|
<< "\n";
|
|
|
|
|
VLOG(2) << "Use Shader Raytrace " << string_from_bool(features & KERNEL_FEATURE_NODE_RAYTRACE)
|
|
|
|
|
<< "\n";
|
|
|
|
|
VLOG(2) << "Use Transparent " << string_from_bool(features & KERNEL_FEATURE_TRANSPARENT) << "\n";
|
|
|
|
|
VLOG(2) << "Use Denoising " << string_from_bool(features & KERNEL_FEATURE_DENOISING) << "\n";
|
|
|
|
|
VLOG(2) << "Use Path Tracing " << string_from_bool(features & KERNEL_FEATURE_PATH_TRACING)
|
|
|
|
|
<< "\n";
|
|
|
|
|
VLOG(2) << "Use Hair " << string_from_bool(features & KERNEL_FEATURE_HAIR) << "\n";
|
|
|
|
|
VLOG(2) << "Use Object Motion " << string_from_bool(features & KERNEL_FEATURE_OBJECT_MOTION)
|
|
|
|
|
<< "\n";
|
|
|
|
|
VLOG(2) << "Use Camera Motion " << string_from_bool(features & KERNEL_FEATURE_CAMERA_MOTION)
|
|
|
|
|
<< "\n";
|
|
|
|
|
VLOG(2) << "Use Baking " << string_from_bool(features & KERNEL_FEATURE_BAKING) << "\n";
|
|
|
|
|
VLOG(2) << "Use Subsurface " << string_from_bool(features & KERNEL_FEATURE_SUBSURFACE) << "\n";
|
|
|
|
|
VLOG(2) << "Use Volume " << string_from_bool(features & KERNEL_FEATURE_VOLUME) << "\n";
|
|
|
|
|
VLOG(2) << "Use Patch Evaluation "
|
|
|
|
|
<< string_from_bool(features & KERNEL_FEATURE_PATCH_EVALUATION) << "\n";
|
|
|
|
|
VLOG(2) << "Use Shadow Catcher " << string_from_bool(features & KERNEL_FEATURE_SHADOW_CATCHER)
|
|
|
|
|
<< "\n";
|
2020-08-18 10:46:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Scene::load_kernels(Progress &progress, bool lock_scene)
|
|
|
|
|
{
|
|
|
|
|
thread_scoped_lock scene_lock;
|
|
|
|
|
if (lock_scene) {
|
|
|
|
|
scene_lock = thread_scoped_lock(mutex);
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-22 14:20:22 +02:00
|
|
|
update_kernel_features();
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
const uint kernel_features = dscene.data.kernel_features;
|
2020-08-18 10:46:12 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (!kernels_loaded || loaded_kernel_features != kernel_features) {
|
2020-08-18 10:46:12 +02:00
|
|
|
progress.set_status("Loading render kernels (may take a few minutes the first time)");
|
|
|
|
|
|
|
|
|
|
scoped_timer timer;
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
log_kernel_features(kernel_features);
|
|
|
|
|
if (!device->load_kernels(kernel_features)) {
|
2020-08-18 10:46:12 +02:00
|
|
|
string message = device->error_message();
|
|
|
|
|
if (message.empty())
|
|
|
|
|
message = "Failed loading render kernel, see console for errors";
|
|
|
|
|
|
|
|
|
|
progress.set_error(message);
|
|
|
|
|
progress.set_status(message);
|
|
|
|
|
progress.set_update();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kernels_loaded = true;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
loaded_kernel_features = kernel_features;
|
2020-08-18 10:46:12 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Scene::get_max_closure_count()
|
|
|
|
|
{
|
|
|
|
|
if (shader_manager->use_osl()) {
|
|
|
|
|
/* OSL always needs the maximum as we can't predict the
|
|
|
|
|
* number of closures a shader might generate. */
|
|
|
|
|
return MAX_CLOSURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int max_closures = 0;
|
|
|
|
|
for (int i = 0; i < shaders.size(); i++) {
|
|
|
|
|
Shader *shader = shaders[i];
|
2021-05-02 02:34:56 +02:00
|
|
|
if (shader->reference_count()) {
|
2020-08-18 10:46:12 +02:00
|
|
|
int num_closures = shader->graph->get_num_closures();
|
|
|
|
|
max_closures = max(max_closures, num_closures);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
max_closure_global = max(max_closure_global, max_closures);
|
|
|
|
|
|
|
|
|
|
if (max_closure_global > MAX_CLOSURE) {
|
|
|
|
|
/* This is usually harmless as more complex shader tend to get many
|
|
|
|
|
* closures discarded due to mixing or low weights. We need to limit
|
|
|
|
|
* to MAX_CLOSURE as this is hardcoded in CPU/mega kernels, and it
|
|
|
|
|
* avoids excessive memory usage for split kernels. */
|
|
|
|
|
VLOG(2) << "Maximum number of closures exceeded: " << max_closure_global << " > "
|
|
|
|
|
<< MAX_CLOSURE;
|
|
|
|
|
|
|
|
|
|
max_closure_global = MAX_CLOSURE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return max_closure_global;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-05 15:05:12 +02:00
|
|
|
int Scene::get_volume_stack_size() const
|
|
|
|
|
{
|
2021-10-08 16:38:40 +02:00
|
|
|
int volume_stack_size = 0;
|
|
|
|
|
|
|
|
|
|
/* Space for background volume and terminator.
|
|
|
|
|
* Don't do optional here because camera ray initialization expects that there is space for
|
|
|
|
|
* at least those elements (avoiding extra condition to check if there is actual volume or not).
|
|
|
|
|
*/
|
|
|
|
|
volume_stack_size += 2;
|
|
|
|
|
|
2021-10-05 15:05:12 +02:00
|
|
|
/* Quick non-expensive check. Can over-estimate maximum possible nested level, but does not
|
|
|
|
|
* require expensive calculation during pre-processing. */
|
2021-10-22 14:20:22 +02:00
|
|
|
bool has_volume_object = false;
|
2021-10-05 15:05:12 +02:00
|
|
|
for (const Object *object : objects) {
|
2021-10-22 14:20:22 +02:00
|
|
|
if (!object->get_geometry()->has_volume) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (object->intersects_volume) {
|
|
|
|
|
/* Object intersects another volume, assume it's possible to go deeper in the stack. */
|
|
|
|
|
/* TODO(sergey): This might count nesting twice (A intersects B and B intersects A), but
|
2021-10-25 22:25:50 +11:00
|
|
|
* can't think of a computationally cheap algorithm. Dividing my 2 doesn't work because of
|
2021-10-22 14:20:22 +02:00
|
|
|
* Venn diagram example with 3 circles. */
|
|
|
|
|
++volume_stack_size;
|
|
|
|
|
}
|
|
|
|
|
else if (!has_volume_object) {
|
|
|
|
|
/* Allocate space for at least one volume object. */
|
2021-10-08 16:38:40 +02:00
|
|
|
++volume_stack_size;
|
2021-10-05 15:05:12 +02:00
|
|
|
}
|
|
|
|
|
|
2021-10-22 14:20:22 +02:00
|
|
|
has_volume_object = true;
|
|
|
|
|
|
2021-10-08 16:38:40 +02:00
|
|
|
if (volume_stack_size == MAX_VOLUME_STACK_SIZE) {
|
2021-10-05 15:05:12 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-08 16:38:40 +02:00
|
|
|
volume_stack_size = min(volume_stack_size, MAX_VOLUME_STACK_SIZE);
|
2021-10-05 15:05:12 +02:00
|
|
|
|
2021-10-22 14:20:22 +02:00
|
|
|
VLOG(3) << "Detected required volume stack size " << volume_stack_size;
|
|
|
|
|
|
2021-10-08 16:38:40 +02:00
|
|
|
return volume_stack_size;
|
2021-10-05 15:05:12 +02:00
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
bool Scene::has_shadow_catcher()
|
|
|
|
|
{
|
|
|
|
|
if (shadow_catcher_modified_) {
|
|
|
|
|
has_shadow_catcher_ = false;
|
|
|
|
|
for (Object *object : objects) {
|
|
|
|
|
if (object->get_is_shadow_catcher()) {
|
|
|
|
|
has_shadow_catcher_ = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
shadow_catcher_modified_ = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return has_shadow_catcher_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Scene::tag_shadow_catcher_modified()
|
|
|
|
|
{
|
|
|
|
|
shadow_catcher_modified_ = true;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
template<> Light *Scene::create_node<Light>()
|
|
|
|
|
{
|
|
|
|
|
Light *node = new Light();
|
|
|
|
|
node->set_owner(this);
|
|
|
|
|
lights.push_back(node);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
light_manager->tag_update(this, LightManager::LIGHT_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> Mesh *Scene::create_node<Mesh>()
|
|
|
|
|
{
|
|
|
|
|
Mesh *node = new Mesh();
|
|
|
|
|
node->set_owner(this);
|
|
|
|
|
geometry.push_back(node);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
geometry_manager->tag_update(this, GeometryManager::MESH_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> Hair *Scene::create_node<Hair>()
|
|
|
|
|
{
|
|
|
|
|
Hair *node = new Hair();
|
|
|
|
|
node->set_owner(this);
|
|
|
|
|
geometry.push_back(node);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
geometry_manager->tag_update(this, GeometryManager::HAIR_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> Volume *Scene::create_node<Volume>()
|
|
|
|
|
{
|
|
|
|
|
Volume *node = new Volume();
|
|
|
|
|
node->set_owner(this);
|
|
|
|
|
geometry.push_back(node);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
geometry_manager->tag_update(this, GeometryManager::MESH_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> Object *Scene::create_node<Object>()
|
|
|
|
|
{
|
|
|
|
|
Object *node = new Object();
|
|
|
|
|
node->set_owner(this);
|
|
|
|
|
objects.push_back(node);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
object_manager->tag_update(this, ObjectManager::OBJECT_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> ParticleSystem *Scene::create_node<ParticleSystem>()
|
|
|
|
|
{
|
|
|
|
|
ParticleSystem *node = new ParticleSystem();
|
|
|
|
|
node->set_owner(this);
|
|
|
|
|
particle_systems.push_back(node);
|
|
|
|
|
particle_system_manager->tag_update(this);
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> Shader *Scene::create_node<Shader>()
|
|
|
|
|
{
|
|
|
|
|
Shader *node = new Shader();
|
|
|
|
|
node->set_owner(this);
|
|
|
|
|
shaders.push_back(node);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
shader_manager->tag_update(this, ShaderManager::SHADER_ADDED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 15:12:00 +01:00
|
|
|
template<> AlembicProcedural *Scene::create_node<AlembicProcedural>()
|
|
|
|
|
{
|
|
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
|
AlembicProcedural *node = new AlembicProcedural();
|
|
|
|
|
node->set_owner(this);
|
|
|
|
|
procedurals.push_back(node);
|
|
|
|
|
procedural_manager->tag_update();
|
|
|
|
|
return node;
|
|
|
|
|
#else
|
|
|
|
|
return nullptr;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
template<> Pass *Scene::create_node<Pass>()
|
|
|
|
|
{
|
|
|
|
|
Pass *node = new Pass();
|
|
|
|
|
node->set_owner(this);
|
|
|
|
|
passes.push_back(node);
|
|
|
|
|
film->tag_modified();
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
template<typename T> void delete_node_from_array(vector<T> &nodes, T node)
|
|
|
|
|
{
|
|
|
|
|
for (size_t i = 0; i < nodes.size(); ++i) {
|
|
|
|
|
if (nodes[i] == node) {
|
|
|
|
|
std::swap(nodes[i], nodes[nodes.size() - 1]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nodes.resize(nodes.size() - 1);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
delete node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Light *node)
|
|
|
|
|
{
|
|
|
|
|
delete_node_from_array(lights, node);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
light_manager->tag_update(this, LightManager::LIGHT_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Mesh *node)
|
|
|
|
|
{
|
|
|
|
|
delete_node_from_array(geometry, static_cast<Geometry *>(node));
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
geometry_manager->tag_update(this, GeometryManager::MESH_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Hair *node)
|
|
|
|
|
{
|
|
|
|
|
delete_node_from_array(geometry, static_cast<Geometry *>(node));
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
geometry_manager->tag_update(this, GeometryManager::HAIR_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Volume *node)
|
|
|
|
|
{
|
|
|
|
|
delete_node_from_array(geometry, static_cast<Geometry *>(node));
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
geometry_manager->tag_update(this, GeometryManager::MESH_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Geometry *node)
|
|
|
|
|
{
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
uint flag;
|
|
|
|
|
if (node->is_hair()) {
|
|
|
|
|
flag = GeometryManager::HAIR_REMOVED;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
flag = GeometryManager::MESH_REMOVED;
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
delete_node_from_array(geometry, node);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
geometry_manager->tag_update(this, flag);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(Object *node)
|
|
|
|
|
{
|
|
|
|
|
delete_node_from_array(objects, node);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
object_manager->tag_update(this, ObjectManager::OBJECT_REMOVED);
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_node_impl(ParticleSystem *node)
|
|
|
|
|
{
|
|
|
|
|
delete_node_from_array(particle_systems, node);
|
|
|
|
|
particle_system_manager->tag_update(this);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-02 02:34:56 +02:00
|
|
|
template<> void Scene::delete_node_impl(Shader *shader)
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
{
|
|
|
|
|
/* don't delete unused shaders, not supported */
|
2021-05-02 02:34:56 +02:00
|
|
|
shader->clear_reference_count();
|
Cycles: introduce an ownership system to protect nodes from unwanted deletions.
Problem: the Blender synchronization process creates and tags nodes for usage. It does
this by directly adding and removing nodes from the scene data. If some node is not tagged
as used at the end of a synchronization, it then deletes the node from the scene. This poses
a problem when it comes to supporting procedural nodes who can create other nodes not known
by the Blender synchonization system, which will remove them.
Nodes now have a NodeOwner, which is set after creation. Those owners for now are the Scene
for scene level nodes and ShaderGraph for shader nodes. Instead of creating and deleting
nodes using `new` and `delete` explicitely, we now use `create_node` and `delete_node` methods
found on the owners. `delete_node` will assert that the owner is the right one.
Whenever a scene level node is created or deleted, the appropriate node manager is tagged for
an update, freeing this responsability from BlenderSync or other software exporters.
Concerning BlenderSync, the `id_maps` do not explicitely manipulate scene data anymore, they
only keep track of which nodes are used, employing the scene to create and delete them. To
achieve this, the ParticleSystem is now a Node, although it does not have any sockets.
This is part of T79131.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79131
Differential Revision: https://developer.blender.org/D8540
2020-08-30 23:20:51 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 14:56:57 +01:00
|
|
|
template<> void Scene::delete_node_impl(Procedural *node)
|
|
|
|
|
{
|
|
|
|
|
delete_node_from_array(procedurals, node);
|
|
|
|
|
procedural_manager->tag_update();
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 15:12:00 +01:00
|
|
|
template<> void Scene::delete_node_impl(AlembicProcedural *node)
|
|
|
|
|
{
|
|
|
|
|
#ifdef WITH_ALEMBIC
|
|
|
|
|
delete_node_impl(static_cast<Procedural *>(node));
|
|
|
|
|
#else
|
|
|
|
|
(void)node;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
template<> void Scene::delete_node_impl(Pass *node)
|
|
|
|
|
{
|
|
|
|
|
delete_node_from_array(passes, node);
|
|
|
|
|
film->tag_modified();
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-29 14:40:29 +01:00
|
|
|
template<typename T>
|
|
|
|
|
static void remove_nodes_in_set(const set<T *> &nodes_set,
|
|
|
|
|
vector<T *> &nodes_array,
|
|
|
|
|
const NodeOwner *owner)
|
|
|
|
|
{
|
|
|
|
|
size_t new_size = nodes_array.size();
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < new_size; ++i) {
|
|
|
|
|
T *node = nodes_array[i];
|
|
|
|
|
|
|
|
|
|
if (nodes_set.find(node) != nodes_set.end()) {
|
|
|
|
|
std::swap(nodes_array[i], nodes_array[new_size - 1]);
|
|
|
|
|
|
|
|
|
|
assert(node->get_owner() == owner);
|
|
|
|
|
delete node;
|
|
|
|
|
|
|
|
|
|
i -= 1;
|
|
|
|
|
new_size -= 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nodes_array.resize(new_size);
|
|
|
|
|
(void)owner;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_nodes(const set<Light *> &nodes, const NodeOwner *owner)
|
|
|
|
|
{
|
|
|
|
|
remove_nodes_in_set(nodes, lights, owner);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
light_manager->tag_update(this, LightManager::LIGHT_REMOVED);
|
2020-10-29 14:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_nodes(const set<Geometry *> &nodes, const NodeOwner *owner)
|
|
|
|
|
{
|
|
|
|
|
remove_nodes_in_set(nodes, geometry, owner);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
geometry_manager->tag_update(this, GeometryManager::GEOMETRY_REMOVED);
|
2020-10-29 14:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_nodes(const set<Object *> &nodes, const NodeOwner *owner)
|
|
|
|
|
{
|
|
|
|
|
remove_nodes_in_set(nodes, objects, owner);
|
Cycles: optimize device updates
This optimizes device updates (during user edits or frame changes in
the viewport) by avoiding unnecessary computations. To achieve this,
we use a combination of the sockets' update flags as well as some new
flags passed to the various managers when tagging for an update to tell
exactly what the tagging is for (e.g. shader was modified, object was
removed, etc.).
Besides avoiding recomputations, we also avoid resending to the devices
unmodified data arrays, thus reducing bandwidth usage. For OptiX and
Embree, BVH packing was also multithreaded.
The performance improvements may vary depending on the used device (CPU
or GPU), and the content of the scene. Simple scenes (e.g. with no adaptive
subdivision or volumes) rendered using OptiX will benefit from this work
the most.
On average, for a variety of animated scenes, this gives a 3x speedup.
Reviewed By: #cycles, brecht
Maniphest Tasks: T79174
Differential Revision: https://developer.blender.org/D9555
2021-01-22 15:01:26 +01:00
|
|
|
object_manager->tag_update(this, ObjectManager::OBJECT_REMOVED);
|
2020-10-29 14:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<> void Scene::delete_nodes(const set<ParticleSystem *> &nodes, const NodeOwner *owner)
|
|
|
|
|
{
|
|
|
|
|
remove_nodes_in_set(nodes, particle_systems, owner);
|
|
|
|
|
particle_system_manager->tag_update(this);
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-02 02:34:56 +02:00
|
|
|
template<> void Scene::delete_nodes(const set<Shader *> &nodes, const NodeOwner * /*owner*/)
|
2020-10-29 14:40:29 +01:00
|
|
|
{
|
|
|
|
|
/* don't delete unused shaders, not supported */
|
2021-05-02 02:34:56 +02:00
|
|
|
for (Shader *shader : nodes) {
|
|
|
|
|
shader->clear_reference_count();
|
|
|
|
|
}
|
2020-10-29 14:40:29 +01:00
|
|
|
}
|
|
|
|
|
|
2021-01-25 14:56:57 +01:00
|
|
|
template<> void Scene::delete_nodes(const set<Procedural *> &nodes, const NodeOwner *owner)
|
|
|
|
|
{
|
|
|
|
|
remove_nodes_in_set(nodes, procedurals, owner);
|
|
|
|
|
procedural_manager->tag_update();
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
template<> void Scene::delete_nodes(const set<Pass *> &nodes, const NodeOwner *owner)
|
|
|
|
|
{
|
|
|
|
|
remove_nodes_in_set(nodes, passes, owner);
|
|
|
|
|
film->tag_modified();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|