Blender V5.3
scene/geometry.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include "bvh/bvh.h"
6
7#include "device/device.h"
8
9#include "scene/attribute.h"
10#include "scene/camera.h"
11#include "scene/geometry.h"
12#include "scene/hair.h"
13#include "scene/light.h"
14#include "scene/mesh.h"
15#include "scene/object.h"
16#include "scene/osl.h"
17#include "scene/pointcloud.h"
18#include "scene/scene.h"
19#include "scene/shader.h"
20#include "scene/shader_nodes.h"
21#include "scene/stats.h"
22#include "scene/volume.h"
23
24#include "subd/split.h"
25
26#ifdef WITH_OSL
27# include "kernel/osl/globals.h"
28#endif
29
30#include "util/log.h"
31#include "util/progress.h"
32#include "util/task.h"
33
35
36/* Geometry */
37
39{
40 NodeType *type = NodeType::add("geometry_base", nullptr);
41
42 SOCKET_UINT(motion_steps, "Motion Steps", 0);
43 SOCKET_BOOLEAN(use_motion_blur, "Use Motion Blur", false);
44 SOCKET_NODE_ARRAY(used_shaders, "Shaders", Shader::get_node_type());
45
46 return type;
47}
48
49Geometry::Geometry(const NodeType *node_type, const Type type)
51{
52 need_update_rebuild = false;
54
55 transform_applied = false;
59
60 has_volume = false;
61 has_surface_bssrdf = false;
62
64 prim_offset = 0;
65}
66
71
72void Geometry::clear(bool preserve_shaders)
73{
74 if (!preserve_shaders) {
75 used_shaders.clear();
76 }
77
78 transform_applied = false;
82}
83
85{
87 return attr ? attr->data<packed_float3>() : nullptr;
88}
89
97
99{
101 attr->modified = true;
102 tag_modified();
103}
104
106{
108 return (attr) ? attr->modified : false;
109}
110
111const float *Geometry::get_radius() const
112{
114 return attr ? attr->data<float>() : nullptr;
115}
116
118{
120 attr->modified = true;
121 tag_modified();
122 return attr->data_for_write<float>();
123}
124
126{
128 attr->modified = true;
129 tag_modified();
130}
131
133{
135 return (attr) ? attr->modified : false;
136}
137
138float Geometry::motion_time(const int step) const
139{
140 return (motion_steps > 1) ? 2.0f * step / (motion_steps - 1) - 1.0f : 0.0f;
141}
142
143int Geometry::motion_step(const float time) const
144{
145 if (motion_steps > 1) {
146 int attr_step = 0;
147
148 for (int step = 0; step < motion_steps; step++) {
149 const float step_time = motion_time(step);
150 if (step_time == time) {
151 return attr_step;
152 }
153
154 /* Center step is stored in a separate attribute. */
155 if (step != motion_steps / 2) {
156 attr_step++;
157 }
158 }
159 }
160
161 return -1;
162}
163
165{
166 return is_instanced() || layout == BVH_LAYOUT_OPTIX || layout == BVH_LAYOUT_MULTI_OPTIX ||
167 layout == BVH_LAYOUT_METAL || layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE ||
169 layout == BVH_LAYOUT_HIPRT || layout == BVH_LAYOUT_MULTI_HIPRT ||
172}
173
175{
176 /* Currently we treat subsurface objects as instanced.
177 *
178 * While it might be not very optimal for ray traversal, it avoids having
179 * duplicated BVH in the memory, saving quite some space.
180 */
182}
183
185{
186 for (Node *node : used_shaders) {
187 Shader *shader = static_cast<Shader *>(node);
188 if (shader->has_displacement && shader->get_displacement_method() != DISPLACE_BUMP) {
189 return true;
190 }
191 }
192
193 return false;
194}
195
197{
198 if (!use_motion_blur) {
199 return false;
200 }
202 return attr_P && attr_P->has_motion();
203}
204
205void Geometry::tag_update(Scene *scene, bool rebuild)
206{
207 if (rebuild) {
208 need_update_rebuild = true;
209 scene->light_manager->tag_update(scene, LightManager::MESH_NEED_REBUILD);
210 }
211 else {
212 for (Node *node : used_shaders) {
213 Shader *shader = static_cast<Shader *>(node);
215 scene->light_manager->tag_update(scene, LightManager::EMISSIVE_MESH_MODIFIED);
216 break;
217 }
218 }
219 }
220
221 scene->geometry_manager->tag_update(scene, GeometryManager::GEOMETRY_MODIFIED);
222}
223
224/* Geometry Manager */
225
227{
228 update_flags = UPDATE_ALL;
229 need_flags_update = true;
230}
231
233
235{
236 bool update = false;
237
238 parallel_for(blocked_range<size_t>(0, scene->geometry.size(), 32),
239 [&](const blocked_range<size_t> &r) {
240 for (size_t i = r.begin(); i != r.end(); i++) {
241 Geometry *geom = scene->geometry[i];
242
243 Attribute *attr_P = geom->attributes.find(ATTR_STD_POSITION);
244 if (attr_P == nullptr || !attr_P->has_motion()) {
245 continue;
246 }
247
248 /* Compares pointers in case center and prev are implicitly shared. */
249 const void *center = attr_P->data();
250 const void *prev = attr_P->data(1);
251 if (center == prev ||
252 std::memcmp(center, prev, attr_P->data_sizeof() * attr_P->size) == 0) {
253 continue;
254 }
255
256 if (geom->is_mesh()) {
257 static_cast<Mesh *>(geom)->copy_center_to_motion_step(0);
258 }
259 else if (geom->is_hair()) {
260 static_cast<Hair *>(geom)->copy_center_to_motion_step(0);
261 }
262 else if (geom->is_pointcloud()) {
263 static_cast<PointCloud *>(geom)->copy_center_to_motion_step(0);
264 }
265 attr_P->modified = update = true;
266 }
267 });
268
269 if (update) {
270 tag_update(scene, TRANSFORM_MODIFIED);
271 }
272}
273
275{
276#ifdef WITH_OSL
277 OSLGlobals *og = device->get_cpu_osl_memory();
278 if (og == nullptr) {
279 /* Can happen when rendering with multiple GPUs, but no CPU (in which case the name maps filled
280 * below are not used anyway) */
281 return;
282 }
283
284 og->object_name_map.clear();
285 og->object_names.clear();
286
287 for (size_t i = 0; i < scene->objects.size(); i++) {
288 /* set object name to object index map */
289 Object *object = scene->objects[i];
290 og->object_name_map[object->name] = i;
291 og->object_names.push_back(object->name);
292 }
293#else
294 (void)device;
295 (void)scene;
296#endif
297}
298
299static void update_device_flags_attribute(uint32_t &device_update_flags,
300 const AttributeSet &attributes)
301{
302 for (const Attribute &attr : attributes.attributes) {
303 if (!attr.modified) {
304 continue;
305 }
306
307 const AttrKernelDataType kernel_type = Attribute::kernel_type(attr);
308
309 switch (kernel_type) {
311 device_update_flags |= ATTR_FLOAT_MODIFIED;
312 break;
313 }
315 device_update_flags |= ATTR_FLOAT2_MODIFIED;
316 break;
317 }
319 device_update_flags |= ATTR_FLOAT3_MODIFIED;
320 break;
321 }
323 device_update_flags |= ATTR_FLOAT4_MODIFIED;
324 break;
325 }
327 device_update_flags |= ATTR_UCHAR4_MODIFIED;
328 break;
329 }
331 device_update_flags |= ATTR_NORMAL_MODIFIED;
332 break;
333 }
335 device_update_flags |= ATTR_QUATERNION_MODIFIED;
336 break;
337 }
339 device_update_flags |= ATTR_SPHERICAL_HARMONICS_REST_MODIFIED;
340 break;
341 }
343 break;
344 }
345 }
346 }
347}
348
349static void update_attribute_realloc_flags(uint32_t &device_update_flags,
350 const AttributeSet &attributes)
351{
352 if (attributes.modified(AttrKernelDataType::FLOAT)) {
353 device_update_flags |= ATTR_FLOAT_NEEDS_REALLOC;
354 }
355 if (attributes.modified(AttrKernelDataType::FLOAT2)) {
356 device_update_flags |= ATTR_FLOAT2_NEEDS_REALLOC;
357 }
358 if (attributes.modified(AttrKernelDataType::FLOAT3)) {
359 device_update_flags |= ATTR_FLOAT3_NEEDS_REALLOC;
360 }
361 if (attributes.modified(AttrKernelDataType::FLOAT4)) {
362 device_update_flags |= ATTR_FLOAT4_NEEDS_REALLOC;
363 }
364 if (attributes.modified(AttrKernelDataType::UCHAR4)) {
365 device_update_flags |= ATTR_UCHAR4_NEEDS_REALLOC;
366 }
367 if (attributes.modified(AttrKernelDataType::NORMAL)) {
368 device_update_flags |= ATTR_NORMAL_NEEDS_REALLOC;
369 }
371 device_update_flags |= ATTR_QUATERNION_NEEDS_REALLOC;
372 }
374 device_update_flags |= ATTR_SPHERICAL_HARMONICS_REST_NEEDS_REALLOC;
375 }
376}
377
379{
380 size_t tri_size = 0;
381
382 size_t curve_size = 0;
383 size_t curve_segment_size = 0;
384
385 size_t point_size = 0;
386
387 size_t face_size = 0;
388 size_t corner_size = 0;
389
390 for (Geometry *geom : scene->geometry) {
391 bool prim_offset_changed = false;
392
393 if (geom->is_mesh() || geom->is_volume()) {
394 Mesh *mesh = static_cast<Mesh *>(geom);
395
396 prim_offset_changed = (mesh->prim_offset != tri_size);
397
398 mesh->prim_offset = tri_size;
399
400 mesh->face_offset = face_size;
401 mesh->corner_offset = corner_size;
402
403 tri_size += mesh->num_triangles();
404
405 face_size += mesh->get_num_subd_faces();
406 corner_size += mesh->subd_face_corners.size();
407 }
408 else if (geom->is_hair()) {
409 Hair *hair = static_cast<Hair *>(geom);
410
411 prim_offset_changed = (hair->curve_segment_offset != curve_segment_size);
412 hair->curve_segment_offset = curve_segment_size;
413 hair->prim_offset = curve_size;
414
415 curve_size += hair->num_curves();
416 curve_segment_size += hair->num_segments();
417 }
418 else if (geom->is_pointcloud()) {
419 PointCloud *pointcloud = static_cast<PointCloud *>(geom);
420
421 prim_offset_changed = (pointcloud->prim_offset != point_size);
422
423 /* Changing Render As on point cloud is likely to change its underlying BVH type (i.e. Render
424 * As Points uses hardware-accelerated point primitives, and Render As GSplats uses custom
425 * primitives). */
426 if (pointcloud->render_as_is_modified()) {
427 geom->need_update_rebuild = true;
428 }
429
430 pointcloud->prim_offset = point_size;
431 point_size += pointcloud->num_points();
432 }
433
434 if (prim_offset_changed) {
435 /* Need to rebuild BVH in OptiX, since refit only allows modified mesh data.
436 * Metal has optimization for static BVH, that also require a rebuild. */
437 const bool need_update_rebuild = (bvh_layout == BVH_LAYOUT_OPTIX ||
438 bvh_layout == BVH_LAYOUT_MULTI_OPTIX ||
439 bvh_layout == BVH_LAYOUT_MULTI_OPTIX_EMBREE) ||
440 ((bvh_layout == BVH_LAYOUT_METAL ||
441 bvh_layout == BVH_LAYOUT_MULTI_METAL ||
442 bvh_layout == BVH_LAYOUT_MULTI_METAL_EMBREE) &&
444 geom->need_update_rebuild |= need_update_rebuild;
445 geom->need_update_bvh_for_offset = true;
446 }
447 }
448}
449
451{
452 if (!need_update() && !need_flags_update) {
453 return;
454 }
455
456 uint32_t device_update_flags = 0;
457
458 const scoped_callback_timer timer([scene](double time) {
459 if (scene->update_stats) {
460 scene->update_stats->geometry.times.add_entry({"device_update_preprocess", time});
461 }
462 });
463
464 progress.set_status("Updating Meshes Flags");
465
466 /* Update flags. */
467 bool volume_images_updated = false;
468
469 for (Geometry *geom : scene->geometry) {
470 const bool prev_has_volume = geom->has_volume;
471 geom->has_volume = false;
472
473 update_attribute_realloc_flags(device_update_flags, geom->attributes);
474
475 if (geom->is_mesh()) {
476 Mesh *mesh = static_cast<Mesh *>(geom);
477 update_attribute_realloc_flags(device_update_flags, mesh->subd_attributes);
478 }
479
480 for (Node *node : geom->get_used_shaders()) {
481 Shader *shader = static_cast<Shader *>(node);
482 if (shader->has_volume) {
483 geom->has_volume = true;
484 }
485
486 if (shader->has_surface_bssrdf) {
487 geom->has_surface_bssrdf = true;
488 }
489
490 if (shader->need_update_uvs) {
491 device_update_flags |= ATTR_FLOAT2_NEEDS_REALLOC;
492
493 /* Attributes might need to be tessellated if added. */
494 if (geom->is_mesh()) {
495 Mesh *mesh = static_cast<Mesh *>(geom);
496 if (mesh->need_tessellation()) {
497 mesh->tag_modified();
498 }
499 }
500 }
501
502 if (shader->need_update_attribute) {
503 device_update_flags |= ATTRS_NEED_REALLOC;
504
505 /* Attributes might need to be tessellated if added. */
506 if (geom->is_mesh()) {
507 Mesh *mesh = static_cast<Mesh *>(geom);
508 if (mesh->need_tessellation()) {
509 mesh->tag_modified();
510 }
511 }
512 }
513
514 if (shader->need_update_displacement) {
515 /* tag displacement related sockets as modified */
516 if (geom->is_mesh()) {
517 Mesh *mesh = static_cast<Mesh *>(geom);
518 mesh->tag_position_modified();
519 mesh->tag_subd_dicing_rate_modified();
520 mesh->tag_subd_max_level_modified();
521 mesh->tag_subd_objecttoworld_modified();
522
523 device_update_flags |= ATTRS_NEED_REALLOC;
524 }
525 }
526
527 if (geom->is_hair()) {
529 device_update_flags |= ATTR_FLOAT_NEEDS_REALLOC;
530 }
533 if (attr) {
534 attr->modified = true;
535 }
536 }
537 }
538 }
539
540 /* only check for modified attributes if we do not need to reallocate them already */
541 if ((device_update_flags & ATTRS_NEED_REALLOC) == 0) {
542 update_device_flags_attribute(device_update_flags, geom->attributes);
543 /* don't check for subd_attributes, as if they were modified, we would need to reallocate
544 * anyway */
545 }
546
547 /* Re-create volume mesh if we will rebuild or refit the BVH. Note we
548 * should only do it in that case, otherwise the BVH and mesh can go
549 * out of sync. */
550 if (geom->is_volume() && (geom->is_modified() || (update_flags & VOLUME_MODIFIED))) {
551 /* Create volume meshes if there is voxel data. */
552 if (!volume_images_updated) {
553 progress.set_status("Updating Meshes Volume Bounds");
554 device_update_volume_images(device, scene, progress);
555 volume_images_updated = true;
556 }
557
558 Volume *volume = static_cast<Volume *>(geom);
559 create_volume_mesh(scene, volume, progress);
560
561 /* always reallocate when we have a volume, as we need to rebuild the BVH */
562 device_update_flags |= DEVICE_MESH_DATA_NEEDS_REALLOC;
563 }
564
565 if (geom->has_volume) {
566 if (geom->is_modified()) {
567 scene->volume_manager->tag_update({geom});
568 }
569 if (!prev_has_volume) {
570 scene->volume_manager->tag_update();
571 }
572 }
573 else if (prev_has_volume) {
574 scene->volume_manager->tag_update({geom});
575 }
576
577 if (geom->is_hair()) {
578 Hair *hair = static_cast<Hair *>(geom);
579
580 if (hair->need_update_rebuild) {
581 device_update_flags |= DEVICE_CURVE_DATA_NEEDS_REALLOC;
582 }
583 else if (hair->is_modified()) {
584 device_update_flags |= DEVICE_CURVE_DATA_MODIFIED;
585 }
586 }
587
588 if (geom->is_mesh()) {
589 Mesh *mesh = static_cast<Mesh *>(geom);
590
591 if (mesh->need_update_rebuild) {
592 device_update_flags |= DEVICE_MESH_DATA_NEEDS_REALLOC;
593 }
594 else if (mesh->is_modified()) {
595 device_update_flags |= DEVICE_MESH_DATA_MODIFIED;
596 }
597 }
598
599 if (geom->is_pointcloud()) {
600 PointCloud *pointcloud = static_cast<PointCloud *>(geom);
601
602 if (pointcloud->need_update_rebuild) {
603 device_update_flags |= DEVICE_POINT_DATA_NEEDS_REALLOC;
604 }
605 else if (pointcloud->is_modified()) {
606 device_update_flags |= DEVICE_POINT_DATA_MODIFIED;
607 }
608 }
609 }
610
611 if (update_flags & (MESH_ADDED | MESH_REMOVED | MOTION_PASS_NEEDED)) {
612 device_update_flags |= DEVICE_MESH_DATA_NEEDS_REALLOC;
613 }
614
615 if (update_flags & (HAIR_ADDED | HAIR_REMOVED | MOTION_PASS_NEEDED)) {
616 device_update_flags |= DEVICE_CURVE_DATA_NEEDS_REALLOC;
617 }
618
619 if (update_flags & (POINT_ADDED | POINT_REMOVED | MOTION_PASS_NEEDED)) {
620 device_update_flags |= DEVICE_POINT_DATA_NEEDS_REALLOC;
621 }
622
623 /* tag the device arrays for reallocation or modification */
624 DeviceScene *dscene = &scene->dscene;
625
628 {
629 scene->bvh.reset();
630
631 dscene->bvh_nodes.tag_realloc();
632 dscene->bvh_leaf_nodes.tag_realloc();
633 dscene->object_node.tag_realloc();
634 dscene->prim_type.tag_realloc();
636 dscene->prim_index.tag_realloc();
637 dscene->prim_object.tag_realloc();
638 dscene->prim_time.tag_realloc();
639
640 if (device_update_flags & DEVICE_MESH_DATA_NEEDS_REALLOC) {
641 dscene->tri_vindex.tag_realloc();
642 dscene->tri_shader.tag_realloc();
643 }
644
645 if (device_update_flags & DEVICE_CURVE_DATA_NEEDS_REALLOC) {
646 dscene->curves.tag_realloc();
647 dscene->curve_segments.tag_realloc();
648 }
649
650 if (device_update_flags & DEVICE_POINT_DATA_NEEDS_REALLOC) {
651 dscene->points_shader.tag_realloc();
652 }
653 }
654
655 if ((update_flags & VISIBILITY_MODIFIED) != 0) {
657 }
658
659 if (device_update_flags & ATTR_FLOAT_NEEDS_REALLOC) {
660 dscene->attributes_map.tag_realloc();
662 }
663 else if (device_update_flags & ATTR_FLOAT_MODIFIED) {
665 }
666
667 if (device_update_flags & ATTR_FLOAT2_NEEDS_REALLOC) {
668 dscene->attributes_map.tag_realloc();
670 }
671 else if (device_update_flags & ATTR_FLOAT2_MODIFIED) {
673 }
674
675 if (device_update_flags & ATTR_FLOAT3_NEEDS_REALLOC) {
676 dscene->attributes_map.tag_realloc();
678 dscene->tri_verts.tag_realloc();
679 dscene->curve_keys.tag_realloc();
680 dscene->points.tag_realloc();
681 }
682 else if (device_update_flags & ATTR_FLOAT3_MODIFIED) {
684 }
685
686 if (device_update_flags & ATTR_FLOAT4_NEEDS_REALLOC) {
687 dscene->attributes_map.tag_realloc();
689 }
690 else if (device_update_flags & ATTR_FLOAT4_MODIFIED) {
692 }
693
694 if (device_update_flags & ATTR_UCHAR4_NEEDS_REALLOC) {
695 dscene->attributes_map.tag_realloc();
697 }
698 else if (device_update_flags & ATTR_UCHAR4_MODIFIED) {
700 }
701
702 if (device_update_flags & ATTR_NORMAL_NEEDS_REALLOC) {
703 dscene->attributes_map.tag_realloc();
705 }
706 else if (device_update_flags & ATTR_NORMAL_MODIFIED) {
708 }
709
710 if (device_update_flags & ATTR_QUATERNION_NEEDS_REALLOC) {
711 dscene->attributes_map.tag_realloc();
713 }
714 else if (device_update_flags & ATTR_QUATERNION_MODIFIED) {
716 }
717
718 if (device_update_flags & ATTR_SPHERICAL_HARMONICS_REST_NEEDS_REALLOC) {
719 dscene->attributes_map.tag_realloc();
721 }
722 else if (device_update_flags & ATTR_SPHERICAL_HARMONICS_REST_MODIFIED) {
724 }
725
726 if (device_update_flags & DEVICE_MESH_DATA_MODIFIED) {
727 /* if anything else than vertices or shaders are modified, we would need to reallocate, so
728 * these are the only arrays that can be updated */
729 dscene->tri_shader.tag_modified();
730 }
731
732 if (device_update_flags & DEVICE_CURVE_DATA_MODIFIED) {
733 dscene->curves.tag_modified();
735 }
736
737 if (device_update_flags & DEVICE_POINT_DATA_MODIFIED) {
738 dscene->points_shader.tag_modified();
739 }
740
741 need_flags_update = false;
742}
743
745 Scene *scene,
746 Progress &progress)
747{
748 progress.set_status("Updating Displacement Images");
749 ImageManager *image_manager = scene->image_manager.get();
750 set<const ImageSingle *> bump_images;
751#ifdef WITH_OSL
752 bool has_osl_node = false;
753#endif
754 for (Geometry *geom : scene->geometry) {
755 if (geom->is_modified()) {
756 /* Geometry-level check for hair shadow transparency.
757 * This matches the logic in the `Hair::update_shadow_transparency()`, avoiding access to
758 * possible non-loaded images. */
759 bool need_shadow_transparency = false;
760 if (geom->is_hair()) {
761 Hair *hair = static_cast<Hair *>(geom);
762 need_shadow_transparency = hair->need_shadow_transparency();
763 }
764
765 for (Node *node : geom->get_used_shaders()) {
766 Shader *shader = static_cast<Shader *>(node);
767 const bool is_true_displacement = (shader->has_displacement &&
768 shader->get_displacement_method() != DISPLACE_BUMP);
769 if (!is_true_displacement && !need_shadow_transparency) {
770 continue;
771 }
772 for (ShaderNode *node : shader->graph->nodes) {
773#ifdef WITH_OSL
774 if (node->special_type == SHADER_SPECIAL_TYPE_OSL) {
775 has_osl_node = true;
776 }
777#endif
778 if (node->special_type != SHADER_SPECIAL_TYPE_IMAGE_SLOT) {
779 continue;
780 }
781
782 ImageSlotTextureNode *image_node = static_cast<ImageSlotTextureNode *>(node);
783 if (!image_node->handle.empty()) {
784 image_node->handle.add_to_set(bump_images);
785 }
786 }
787 }
788 }
789 }
790
791#ifdef WITH_OSL
792 /* If any OSL node is used for displacement, it may reference a texture. But it's
793 * unknown which ones, so have to load them all. */
794 if (has_osl_node) {
795 OSLShaderManager::osl_image_handles(device, image_manager, bump_images);
796 }
797#endif
798
799 image_manager->device_load_images(device, scene, progress, bump_images);
800}
801
803{
804 progress.set_status("Updating Volume Images");
805 TaskPool pool;
806 ImageManager *image_manager = scene->image_manager.get();
807 set<const ImageSingle *> volume_images;
808
809 for (Geometry *geom : scene->geometry) {
810 if (!geom->is_modified()) {
811 continue;
812 }
813
814 for (Attribute &attr : geom->attributes.attributes) {
815 if (!(attr.element & ATTR_ELEMENT_VOXEL)) {
816 continue;
817 }
818
819 const ImageHandle &handle = attr.data_voxel();
820 if (!handle.empty()) {
821 handle.add_to_set(volume_images);
822 }
823 }
824 }
825
826 image_manager->device_load_images(device, scene, progress, volume_images);
827}
828
830 DeviceScene *dscene,
831 Scene *scene,
832 Progress &progress)
833{
834 if (!need_update()) {
835 return;
836 }
837
838 LOG_INFO << "Total " << scene->geometry.size() << " meshes.";
839
840 bool true_displacement_used = false;
841 bool curve_need_update_shadow_transparency = false;
842 size_t num_tessellation = 0;
843
844 {
845 const scoped_callback_timer timer([scene](double time) {
846 if (scene->update_stats) {
847 scene->update_stats->geometry.times.add_entry({"device_update (normals)", time});
848 }
849 });
850
851 for (Geometry *geom : scene->geometry) {
852 if (geom->is_modified()) {
853 if (geom->is_mesh() || geom->is_volume()) {
854 Mesh *mesh = static_cast<Mesh *>(geom);
855
856 /* Test if we need tessellation and setup normals if required. */
857 if (mesh->need_tessellation()) {
858 num_tessellation++;
859 /* OPENSUBDIV Catmull-Clark does not make use of input normals and will overwrite them.
860 */
861#ifdef WITH_OPENSUBDIV
862 if (mesh->get_subdivision_type() != Mesh::SUBDIVISION_CATMULL_CLARK)
863#endif
864 {
865 mesh->add_vertex_normals();
866 }
867 }
868 else {
869 mesh->add_vertex_normals();
870 }
871
872 /* Test if we need displacement. */
873 if (mesh->has_true_displacement()) {
874 true_displacement_used = true;
875 }
876 }
877 else if (geom->is_pointcloud()) {
878 /* Precompute gsplat bounding sphere for faster access to its bounds. */
879 PointCloud *pointcloud = static_cast<PointCloud *>(geom);
880 pointcloud->update_gsplat_radii();
881 }
882 }
883
884 if (progress.get_cancel()) {
885 return;
886 }
887 }
888
889 for (Geometry *geom : scene->geometry) {
890 if (geom->is_hair()) {
891 Hair *hair = static_cast<Hair *>(geom);
892 if (hair->need_shadow_transparency() &&
893 (geom->is_modified() || hair->need_update_shadow_transparency()))
894 {
895 curve_need_update_shadow_transparency = true;
896 break;
897 }
898 }
899
900 if (progress.get_cancel()) {
901 return;
902 }
903 }
904 }
905
906 if (progress.get_cancel()) {
907 return;
908 }
909
910 /* Tessellate meshes that are using subdivision */
911 const scoped_callback_timer timer([scene, num_tessellation](double time) {
912 if (scene->update_stats) {
913 scene->update_stats->geometry.times.add_entry(
914 {(num_tessellation) ? "device_update (tessellation and tangents)" :
915 "device_update (tangents)",
916 time});
917 }
918 });
919
920 Camera *dicing_camera = scene->dicing_camera;
921 if (num_tessellation) {
922 dicing_camera->set_screen_size(dicing_camera->get_full_width(),
923 dicing_camera->get_full_height());
924 dicing_camera->update(scene);
925 }
926
927 size_t i = 0;
928 thread_mutex status_mutex;
929 parallel_for_each(scene->geometry.begin(), scene->geometry.end(), [&](Geometry *geom) {
930 if (progress.get_cancel()) {
931 return;
932 }
933
934 if (!(geom->is_modified() && geom->is_mesh())) {
935 return;
936 }
937
938 Mesh *mesh = static_cast<Mesh *>(geom);
939 /* Apply generated attribute if needed or remove if not needed */
940 mesh->update_generated(scene);
941
942 if (num_tessellation && mesh->need_tessellation()) {
943 {
944 const thread_scoped_lock status_lock(status_mutex);
945 string msg = "Tessellating ";
946 if (mesh->name.empty()) {
947 msg += string_printf("%u/%u", (uint)(i + 1), (uint)num_tessellation);
948 }
949 else {
950 msg += string_printf(
951 "%s %u/%u", mesh->name.c_str(), (uint)(i + 1), (uint)num_tessellation);
952 }
953
954 progress.set_status("Updating Mesh", msg);
955 i++;
956 }
957
958 SubdParams subd_params(mesh);
959 subd_params.dicing_rate = mesh->get_subd_dicing_rate();
960 subd_params.max_level = mesh->get_subd_max_level();
961 if (mesh->get_subd_adaptive_space() == Mesh::SUBDIVISION_ADAPTIVE_SPACE_PIXEL) {
962 subd_params.objecttoworld = mesh->get_subd_objecttoworld();
963 subd_params.camera = dicing_camera;
964 }
965
966 mesh->tessellate(subd_params);
967 }
968
969 /* Apply tangents for generated and UVs (if any need them) or remove if not needed */
970 mesh->update_tangents(scene, true);
971 if (!mesh->has_true_displacement()) {
972 mesh->update_tangents(scene, false);
973 }
974 });
975
976 if (progress.get_cancel()) {
977 return;
978 }
979
980 /* Update images needed for true displacement. */
981 if (true_displacement_used || curve_need_update_shadow_transparency) {
982 const scoped_callback_timer timer([scene](double time) {
983 if (scene->update_stats) {
984 scene->update_stats->geometry.times.add_entry(
985 {"device_update (displacement: load images)", time});
986 }
987 });
988 device_update_displacement_images(device, scene, progress);
989 scene->object_manager->device_update_flags(device, dscene, scene, progress, false);
990 }
991
992 /* Device update. */
993 device_free(device, dscene, false);
994
995 const BVHLayout bvh_layout = BVHParams::best_bvh_layout(
996 scene->params.bvh_layout, device->get_bvh_layout_mask(dscene->data.kernel_features));
997 geom_calc_offset(scene, bvh_layout);
998 if (true_displacement_used || curve_need_update_shadow_transparency) {
999 const scoped_callback_timer timer([scene](double time) {
1000 if (scene->update_stats) {
1001 scene->update_stats->geometry.times.add_entry(
1002 {"device_update (displacement: copy meshes to device)", time});
1003 }
1004 });
1005 device_update_mesh(device, dscene, scene, progress);
1006 }
1007
1008 if (progress.get_cancel()) {
1009 return;
1010 }
1011
1012 /* Apply transforms, to prepare for static BVH building. */
1013 if (scene->params.bvh_type == BVH_TYPE_STATIC) {
1014 const scoped_callback_timer timer([scene](double time) {
1015 if (scene->update_stats) {
1016 scene->update_stats->object.times.add_entry(
1017 {"device_update (apply static transforms)", time});
1018 }
1019 });
1020
1021 progress.set_status("Updating Objects", "Applying Static Transformations");
1022 scene->object_manager->apply_static_transforms(dscene, scene, progress);
1023 }
1024
1025 if (progress.get_cancel()) {
1026 return;
1027 }
1028
1029 /* Attributes must be uploaded to the device before displacement and hair shadow
1030 * transparency, which run shader evaluation. Otherwise the upload is deferred
1031 * until after BVH building. */
1032 const bool need_attributes_before_bvh = true_displacement_used ||
1033 curve_need_update_shadow_transparency;
1034
1035 if (need_attributes_before_bvh) {
1036 const scoped_callback_timer timer([scene](double time) {
1037 if (scene->update_stats) {
1038 scene->update_stats->geometry.times.add_entry({"device_update (attributes)", time});
1039 }
1040 });
1041 device_update_attributes(device, dscene, scene, progress);
1042 if (progress.get_cancel()) {
1043 return;
1044 }
1045 }
1046
1047 /* Update displacement. */
1048 bool displacement_done = false;
1049 {
1050 /* Copy constant data needed by shader evaluation. */
1051 device->const_copy_to("data", &dscene->data, sizeof(dscene->data));
1052
1053 const scoped_callback_timer timer([scene](double time) {
1054 if (scene->update_stats) {
1055 scene->update_stats->geometry.times.add_entry({"device_update (displacement)", time});
1056 }
1057 });
1058
1059 for (Geometry *geom : scene->geometry) {
1060 if (geom->is_modified()) {
1061 if (geom->is_mesh()) {
1062 Mesh *mesh = static_cast<Mesh *>(geom);
1063 if (displace(device, scene, mesh, progress)) {
1064 displacement_done = true;
1065 need_flags_update = true;
1066 }
1067 }
1068 }
1069
1070 if (progress.get_cancel()) {
1071 return;
1072 }
1073 }
1074 }
1075
1076 if (progress.get_cancel()) {
1077 return;
1078 }
1079
1080 /* Update hair shadow transparency. */
1081 bool curve_shadow_transparency_done = false;
1082 {
1083 const scoped_callback_timer timer([scene](double time) {
1084 if (scene->update_stats) {
1085 scene->update_stats->geometry.times.add_entry(
1086 {"device_update (curve shadow transparency)", time});
1087 }
1088 });
1089
1090 for (Geometry *geom : scene->geometry) {
1091 if (geom->is_hair()) {
1092 Hair *hair = static_cast<Hair *>(geom);
1093 if (hair->update_shadow_transparency(device, scene, progress)) {
1094 curve_shadow_transparency_done = true;
1095 }
1096 }
1097
1098 if (progress.get_cancel()) {
1099 return;
1100 }
1101 }
1102 }
1103
1104 if (progress.get_cancel()) {
1105 return;
1106 }
1107
1108 /* Displacement and hair shadow transparency modified the geometry. Free device buffers
1109 * that need to be reallocated, so the BVH and attributes are rebuilt from the updated
1110 * data below. Freeing the attribute buffers uploaded earlier also keeps them from
1111 * overlapping with the temporary BVH building buffers, lowering peak memory usage. */
1112 if (displacement_done || curve_shadow_transparency_done) {
1113 device_free(device, dscene, false);
1114 }
1115
1116 /* Update the BVH even when there is no geometry so the kernel's BVH data is still valid,
1117 * especially when removing all of the objects during interactive renders.
1118 * Also update the BVH if the transformations change, we cannot rely on tagging the Geometry
1119 * as modified in this case, as we may accumulate displacement if the vertices do not also
1120 * change. */
1121 bool need_update_scene_bvh = (scene->bvh == nullptr ||
1122 (update_flags & (TRANSFORM_MODIFIED | VISIBILITY_MODIFIED)) != 0);
1123 {
1124 const scoped_callback_timer timer([scene](double time) {
1125 if (scene->update_stats) {
1126 scene->update_stats->geometry.times.add_entry({"device_update (build object BVHs)", time});
1127 }
1128 });
1129
1130 size_t i = 0;
1131 size_t num_bvh = 0;
1132 for (Geometry *geom : scene->geometry) {
1133 if (geom->is_modified() || geom->need_update_bvh_for_offset) {
1134 need_update_scene_bvh = true;
1135
1136 if (geom->need_build_bvh(bvh_layout)) {
1137 i++;
1138 num_bvh++;
1139 }
1140
1141 /* Note the use of #bvh_task_pool_, see its definition for details. */
1142 bvh_task_pool_.push([geom, device, dscene, scene, &progress, i, &num_bvh] {
1143 geom->compute_bvh(device, dscene, &scene->params, &progress, i, num_bvh);
1144 });
1145 }
1146 }
1147
1148 TaskPool::Summary summary;
1149 bvh_task_pool_.wait_work(&summary);
1150 LOG_DEBUG << "Objects BVH build pool statistics:\n" << summary.full_report();
1151 }
1152
1153 for (Shader *shader : scene->shaders) {
1154 shader->need_update_uvs = false;
1155 shader->need_update_attribute = false;
1156 shader->need_update_displacement = false;
1157 shader->need_update_shadow_transparency = false;
1158 shader->shadow_transparency_needs_realloc = false;
1159 }
1160
1161 const Scene::MotionType need_motion = scene->need_motion();
1162 const bool motion_blur = need_motion == Scene::MOTION_BLUR;
1163
1164 /* Update objects. */
1165 {
1166 const scoped_callback_timer timer([scene](double time) {
1167 if (scene->update_stats) {
1168 scene->update_stats->geometry.times.add_entry({"device_update (compute bounds)", time});
1169 }
1170 });
1171 for (Object *object : scene->objects) {
1172 object->compute_bounds(motion_blur);
1173 }
1174 }
1175
1176 if (progress.get_cancel()) {
1177 return;
1178 }
1179
1180 if (need_update_scene_bvh) {
1181 const scoped_callback_timer timer([scene](double time) {
1182 if (scene->update_stats) {
1183 scene->update_stats->geometry.times.add_entry({"device_update (build scene BVH)", time});
1184 }
1185 });
1186 device_update_bvh(device, dscene, scene, progress);
1187 if (progress.get_cancel()) {
1188 return;
1189 }
1190 }
1191
1192 /* Always set BVH layout again after displacement where it was set to none,
1193 * to avoid ray-tracing at that stage. */
1194 dscene->data.bvh.bvh_layout = BVHParams::best_bvh_layout(
1195 scene->params.bvh_layout, device->get_bvh_layout_mask(dscene->data.kernel_features));
1196
1197 /* Upload attributes to the device.
1198 *
1199 * This is deferred until after BVH building so the attribute buffers do not overlap with
1200 * the temporary buffers allocated during BVH building. */
1201 {
1202 const scoped_callback_timer timer([scene](double time) {
1203 if (scene->update_stats) {
1204 scene->update_stats->geometry.times.add_entry({"device_update (attributes)", time});
1205 }
1206 });
1207 device_update_attributes(device, dscene, scene, progress);
1208 if (progress.get_cancel()) {
1209 return;
1210 }
1211 }
1212
1213 {
1214 const scoped_callback_timer timer([scene](double time) {
1215 if (scene->update_stats) {
1216 scene->update_stats->geometry.times.add_entry(
1217 {"device_update (copy meshes to device)", time});
1218 }
1219 });
1220 device_update_mesh(device, dscene, scene, progress);
1221 if (progress.get_cancel()) {
1222 return;
1223 }
1224 }
1225
1226 /* unset flags */
1227
1228 for (Geometry *geom : scene->geometry) {
1229 geom->clear_modified();
1230 geom->attributes.clear_modified();
1231
1232 if (geom->is_mesh()) {
1233 Mesh *mesh = static_cast<Mesh *>(geom);
1235 }
1236 }
1237
1238 update_flags = UPDATE_NONE;
1239
1240 dscene->bvh_nodes.clear_modified();
1241 dscene->bvh_leaf_nodes.clear_modified();
1242 dscene->object_node.clear_modified();
1243 dscene->prim_type.clear_modified();
1244 dscene->prim_visibility.clear_modified();
1245 dscene->prim_index.clear_modified();
1246 dscene->prim_object.clear_modified();
1247 dscene->prim_time.clear_modified();
1248 dscene->tri_shader.clear_modified();
1249 dscene->tri_vindex.clear_modified();
1250 dscene->tri_verts.clear_modified();
1251 dscene->curves.clear_modified();
1252 dscene->curve_keys.clear_modified();
1253 dscene->curve_segments.clear_modified();
1254 dscene->points.clear_modified();
1255 dscene->points_shader.clear_modified();
1256 dscene->attributes_map.clear_modified();
1257 dscene->attributes_float.clear_modified();
1258 dscene->attributes_float2.clear_modified();
1259 dscene->attributes_float3.clear_modified();
1260 dscene->attributes_float4.clear_modified();
1261 dscene->attributes_uchar4.clear_modified();
1262 dscene->attributes_normal.clear_modified();
1263 dscene->attributes_quaternion.clear_modified();
1264 dscene->attributes_spherical_harmonics_rest.clear_modified();
1265}
1266
1267void GeometryManager::device_free(Device *device, DeviceScene *dscene, bool force_free)
1268{
1269 dscene->bvh_nodes.free_if_need_realloc(force_free);
1270 dscene->bvh_leaf_nodes.free_if_need_realloc(force_free);
1271 dscene->object_node.free_if_need_realloc(force_free);
1272 dscene->prim_type.free_if_need_realloc(force_free);
1273 dscene->prim_visibility.free_if_need_realloc(force_free);
1274 dscene->prim_index.free_if_need_realloc(force_free);
1275 dscene->prim_object.free_if_need_realloc(force_free);
1276 dscene->prim_time.free_if_need_realloc(force_free);
1277 dscene->tri_shader.free_if_need_realloc(force_free);
1278 dscene->tri_vindex.free_if_need_realloc(force_free);
1279 dscene->tri_verts.free_if_need_realloc(force_free);
1280 dscene->curves.free_if_need_realloc(force_free);
1281 dscene->curve_keys.free_if_need_realloc(force_free);
1282 dscene->curve_segments.free_if_need_realloc(force_free);
1283 dscene->points.free_if_need_realloc(force_free);
1284 dscene->points_shader.free_if_need_realloc(force_free);
1285 dscene->attributes_map.free_if_need_realloc(force_free);
1286 dscene->attributes_float.free_if_need_realloc(force_free);
1287 dscene->attributes_float2.free_if_need_realloc(force_free);
1288 dscene->attributes_float3.free_if_need_realloc(force_free);
1289 dscene->attributes_float4.free_if_need_realloc(force_free);
1290 dscene->attributes_uchar4.free_if_need_realloc(force_free);
1291 dscene->attributes_normal.free_if_need_realloc(force_free);
1292 dscene->attributes_quaternion.free_if_need_realloc(force_free);
1294
1295 /* Signal for shaders like displacement not to do ray tracing. */
1296 dscene->data.bvh.bvh_layout = BVH_LAYOUT_NONE;
1297
1298#ifdef WITH_OSL
1299 OSLGlobals *og = device->get_cpu_osl_memory();
1300
1301 if (og) {
1302 og->object_name_map.clear();
1303 og->object_names.clear();
1304 }
1305#else
1306 (void)device;
1307#endif
1308}
1309
1310void GeometryManager::tag_update(Scene *scene, const uint32_t flag)
1311{
1312 update_flags |= flag;
1313
1314 /* do not tag the object manager for an update if it is the one who tagged us */
1315 if ((flag & OBJECT_MANAGER) == 0) {
1316 scene->object_manager->tag_update(scene, ObjectManager::GEOMETRY_MANAGER);
1317 }
1318}
1319
1321{
1322 return update_flags != UPDATE_NONE;
1323}
1324
1326{
1327 for (const Geometry *geometry : scene->geometry) {
1328 stats->mesh.geometry.add_entry(
1329 NamedSizeEntry(string(geometry->name.c_str()), geometry->get_total_size_in_bytes()));
1330 }
1331}
1332
list< Attribute > attributes
Attribute * find(ustring name) const
bool modified(AttrKernelDataType kernel_type) const
Attribute * add(ustring name, const TypeDesc type, AttributeElement element)
void clear_modified()
AttributeElement element
const T * data(const int step=0) const
static AttrKernelDataType kernel_type(const Attribute &attr)
T * data_for_write(const int step=0)
const ImageHandle & data_voxel() const
bool has_motion() const
static BVHLayout best_bvh_layout(BVHLayout requested_layout, BVHLayoutMask supported_layouts)
Definition bvh.cpp:65
device_vector< uint > points_shader
Definition devicescene.h:39
device_vector< float2 > prim_time
Definition devicescene.h:26
device_vector< float4 > points
Definition devicescene.h:38
device_vector< uint > prim_visibility
Definition devicescene.h:23
device_vector< float4 > attributes_float4
Definition devicescene.h:56
device_vector< KernelCurveSegment > curve_segments
Definition devicescene.h:35
device_vector< float2 > attributes_float2
Definition devicescene.h:54
device_vector< packed_normal > attributes_normal
Definition devicescene.h:58
device_vector< AttributeMap > attributes_map
Definition devicescene.h:52
device_vector< KernelCurve > curves
Definition devicescene.h:33
device_vector< packed_uint3 > tri_vindex
Definition devicescene.h:30
device_vector< int > object_node
Definition devicescene.h:21
device_vector< packed_float3 > attributes_float3
Definition devicescene.h:55
device_vector< int > prim_object
Definition devicescene.h:25
device_vector< float4 > curve_keys
Definition devicescene.h:34
device_vector< Quaternion > attributes_quaternion
Definition devicescene.h:59
device_vector< int4 > bvh_leaf_nodes
Definition devicescene.h:20
device_vector< uint > tri_shader
Definition devicescene.h:29
device_vector< packed_float3 > tri_verts
Definition devicescene.h:31
device_vector< float > attributes_float
Definition devicescene.h:53
KernelData data
device_vector< int > prim_type
Definition devicescene.h:22
device_vector< PackedSphericalHarmonicsRest > attributes_spherical_harmonics_rest
Definition devicescene.h:60
device_vector< int4 > bvh_nodes
Definition devicescene.h:19
device_vector< int > prim_index
Definition devicescene.h:24
device_vector< uchar4 > attributes_uchar4
Definition devicescene.h:57
virtual OSLGlobals * get_cpu_osl_memory()
void device_update_displacement_images(Device *device, Scene *scene, Progress &progress)
void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void geom_calc_offset(Scene *scene, BVHLayout bvh_layout)
void tag_update(Scene *scene, const uint32_t flag)
void update_osl_globals(Device *device, Scene *scene)
void create_volume_mesh(const Scene *scene, Volume *volume, Progress &progress)
void device_free(Device *device, DeviceScene *dscene, bool force_free)
void collect_statistics(const Scene *scene, RenderStats *stats)
void device_update_preprocess(Device *device, Scene *scene, Progress &progress)
void device_update_volume_images(Device *device, Scene *scene, Progress &progress)
bool need_update() const
void update_interactive_motion(Scene *scene)
Transform transform_normal
bool radius_is_modified() const
Type geometry_type
int motion_step(const float time) const
BoundBox bounds
bool need_update_bvh_for_offset
bool transform_applied
bool has_true_displacement() const
void tag_position_modified()
bool need_build_bvh(BVHLayout layout) const
bool is_volume() const
bool is_pointcloud() const
bool is_hair() const
bool has_surface_bssrdf
bool is_instanced() const
void compute_bvh(Device *device, DeviceScene *dscene, SceneParams *params, Progress *progress, const size_t n, size_t total)
~Geometry() override
size_t attr_map_offset
const packed_float3 * get_position() const
size_t prim_offset
virtual bool has_motion_blur() const
void tag_update(Scene *scene, bool rebuild)
float * get_radius_for_write()
bool position_is_modified() const
bool need_update_rebuild
const float * get_radius() const
AttributeSet attributes
bool is_mesh() const
Geometry(const NodeType *node_type, const Type type)
bool transform_negative_scaled
float motion_time(const int step) const
void tag_radius_modified()
virtual void clear(bool preserve_shaders=false)
packed_float3 * get_position_for_write()
Definition hair.h:13
bool need_update_shadow_transparency() const
Definition hair.cpp:521
bool need_shadow_transparency() const
Definition hair.cpp:505
size_t curve_segment_offset
Definition hair.h:76
size_t num_curves() const
Definition hair.h:109
bool update_shadow_transparency(Device *device, Scene *scene, Progress &progress)
Definition hair.cpp:537
size_t num_segments() const
Definition hair.h:114
bool empty() const
void add_to_set(set< const ImageSingle * > &images) const
void device_load_images(Device *device, Scene *scene, Progress &progress, const set< const ImageSingle * > &images)
NamedSizeStats geometry
size_t get_num_subd_faces() const
Definition scene/mesh.h:221
@ SUBDIVISION_ADAPTIVE_SPACE_PIXEL
Definition scene/mesh.h:135
size_t face_offset
Definition scene/mesh.h:172
size_t corner_offset
Definition scene/mesh.h:173
void add_vertex_normals()
AttributeSet subd_attributes
Definition scene/mesh.h:169
bool need_tessellation()
@ SUBDIVISION_CATMULL_CLARK
Definition scene/mesh.h:116
size_t num_triangles() const
Definition scene/mesh.h:73
void update_generated(Scene *scene)
void add_entry(const NamedSizeEntry &entry)
Definition stats.cpp:58
void update_gsplat_radii()
size_t num_points() const
bool get_cancel() const
Definition progress.h:77
void set_status(const string &status_, const string &substatus_="")
Definition progress.h:248
MeshStats mesh
BVHType bvh_type
Definition scene.h:74
Definition scene.h:133
unique_ptr< ObjectManager > object_manager
Definition scene.h:171
unique_ptr< LightManager > light_manager
Definition scene.h:167
Camera * dicing_camera
Definition scene.h:146
SceneParams params
Definition scene.h:190
unique_ptr_vector< Geometry > geometry
Definition scene.h:161
unique_ptr< SceneUpdateStats > update_stats
Definition scene.h:197
MotionType
Definition scene.h:207
@ MOTION_BLUR
Definition scene.h:207
unique_ptr< GeometryManager > geometry_manager
Definition scene.h:170
unique_ptr_vector< Object > objects
Definition scene.h:162
unique_ptr< ImageManager > image_manager
Definition scene.h:166
unique_ptr< BVH > bvh
Definition scene.h:142
DeviceScene dscene
Definition scene.h:187
unique_ptr< VolumeManager > volume_manager
Definition scene.h:175
bool has_surface_bssrdf
bool need_update_attribute
bool has_volume
bool need_update_displacement
EmissionSampling emission_sampling
bool shadow_transparency_needs_realloc
bool need_update_uvs
bool has_displacement
NODE_DECLARE unique_ptr< ShaderGraph > graph
bool need_update_shadow_transparency
void free_if_need_realloc(bool force_free)
ConstIterator begin() const
void push_back(unique_ptr< T > &&value)
ConstIterator end() const
size_t size() const
#define CCL_NAMESPACE_END
#define point_size
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
if(state< num_states)
@ EMISSION_SAMPLING_NONE
@ BVH_LAYOUT_OPTIX
@ BVH_LAYOUT_MULTI_HIPRT_EMBREE
@ BVH_LAYOUT_NONE
@ BVH_LAYOUT_MULTI_EMBREEGPU
@ BVH_LAYOUT_METAL
@ BVH_LAYOUT_MULTI_HIPRT
@ BVH_LAYOUT_HIPRT
@ BVH_LAYOUT_MULTI_OPTIX
@ BVH_LAYOUT_EMBREEGPU
@ BVH_LAYOUT_MULTI_METAL
@ BVH_LAYOUT_MULTI_METAL_EMBREE
@ BVH_LAYOUT_MULTI_EMBREEGPU_EMBREE
@ BVH_LAYOUT_MULTI_OPTIX_EMBREE
@ ATTR_ELEMENT_VOXEL
@ ATTR_PRIM_GEOMETRY
@ ATTR_STD_SHADOW_TRANSPARENCY
@ ATTR_STD_POSITION
@ ATTR_STD_RADIUS
#define LOG_DEBUG
Definition log.h:107
#define LOG_INFO
Definition log.h:106
std::string time(const std::tm &date_time, TimeFormat format=TimeFormat::H24)
#define SOCKET_NODE_ARRAY(name, ui_name, node_type,...)
Definition node_type.h:316
#define SOCKET_UINT(name, ui_name, default_value,...)
Definition node_type.h:215
#define SOCKET_BOOLEAN(name, ui_name, default_value,...)
Definition node_type.h:211
#define NODE_ABSTRACT_DEFINE(structname)
Definition node_type.h:182
KernelBVHLayout BVHLayout
Definition params.h:22
@ BVH_TYPE_STATIC
Definition params.h:40
AttrKernelDataType
static void update_device_flags_attribute(uint32_t &device_update_flags, const AttributeSet &attributes)
static void update_attribute_realloc_flags(uint32_t &device_update_flags, const AttributeSet &attributes)
@ ATTR_FLOAT4_MODIFIED
@ ATTR_UCHAR4_MODIFIED
@ ATTR_SPHERICAL_HARMONICS_REST_NEEDS_REALLOC
@ DEVICE_MESH_DATA_NEEDS_REALLOC
@ ATTR_FLOAT3_MODIFIED
@ ATTR_NORMAL_NEEDS_REALLOC
@ DEVICE_POINT_DATA_MODIFIED
@ DEVICE_POINT_DATA_NEEDS_REALLOC
@ ATTR_FLOAT4_NEEDS_REALLOC
@ ATTR_UCHAR4_NEEDS_REALLOC
@ ATTR_SPHERICAL_HARMONICS_REST_MODIFIED
@ ATTR_FLOAT_MODIFIED
@ ATTR_FLOAT2_NEEDS_REALLOC
@ DEVICE_MESH_DATA_MODIFIED
@ DEVICE_CURVE_DATA_MODIFIED
@ ATTR_QUATERNION_NEEDS_REALLOC
@ ATTR_NORMAL_MODIFIED
@ ATTR_FLOAT2_MODIFIED
@ ATTR_FLOAT_NEEDS_REALLOC
@ DEVICE_CURVE_DATA_NEEDS_REALLOC
@ ATTR_FLOAT3_NEEDS_REALLOC
@ ATTRS_NEED_REALLOC
@ ATTR_QUATERNION_MODIFIED
@ DISPLACE_BUMP
@ SHADER_SPECIAL_TYPE_IMAGE_SLOT
@ SHADER_SPECIAL_TYPE_OSL
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=nullptr)
const NodeType * type
Definition graph/node.h:179
void dereference_all_used_nodes()
ustring name
Definition graph/node.h:178
size_t get_total_size_in_bytes() const
void clear_modified()
void tag_modified()
bool is_modified() const
Node(const NodeType *type, ustring name=ustring())
float dicing_rate
Definition dice.h:31
string full_report() const
Definition task.cpp:233
std::mutex thread_mutex
Definition thread.h:27
ccl_device_inline Transform transform_identity()
Definition transform.h:355