Blender V5.3
geometry_attributes.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/pointcloud.h"
17#include "scene/scene.h"
18#include "scene/shader.h"
19#include "scene/shader_nodes.h"
20
21#include "util/map.h"
22#include "util/progress.h"
23#include "util/set.h"
24
26
28{
29 if (std == ATTR_STD_NONE) {
30 return false;
31 }
32
33 if (scene->need_global_attribute(std)) {
34 return true;
35 }
36
37 for (Node *node : used_shaders) {
38 Shader *shader = static_cast<Shader *>(node);
39 if (shader->attributes.find(std)) {
40 return true;
41 }
42 }
43
44 return false;
45}
46
47bool Geometry::need_attribute(Scene *scene, ustring name)
48{
49 if (name.empty()) {
50 return false;
51 }
52
53 for (const Shader *shader : scene->shaders) {
54 if (shader->global_attributes.find(name)) {
55 return true;
56 }
57 }
58
59 for (Node *node : used_shaders) {
60 Shader *shader = static_cast<Shader *>(node);
61 if (shader->attributes.find(name)) {
62 return true;
63 }
64 }
65
66 return false;
67}
68
70{
72
73 for (Node *node : used_shaders) {
74 Shader *shader = static_cast<Shader *>(node);
75 result.add(shader->attributes);
76 }
77
78 return result;
79}
80
82{
83 for (const Attribute &attr : attributes.attributes) {
84 if (attr.element & ATTR_ELEMENT_VOXEL) {
85 return true;
86 }
87 }
88
89 return false;
90}
91
92/* Generate a normal attribute map entry from an attribute descriptor. */
94 const size_t index,
95 const uint64_t id,
96 const TypeDesc type,
97 const AttributeDescriptor &desc)
98{
99 attr_map[index].id = id;
100 attr_map[index].element = desc.element;
101 attr_map[index].offset = as_uint(desc.offset);
102
103 if (type == TypeFloat) {
104 attr_map[index].type = NODE_ATTR_FLOAT;
105 }
106 else if (type == TypeMatrix) {
107 attr_map[index].type = NODE_ATTR_MATRIX;
108 }
109 else if (type == TypeFloat2) {
110 attr_map[index].type = NODE_ATTR_FLOAT2;
111 }
112 else if (type == TypeFloat4) {
113 attr_map[index].type = NODE_ATTR_FLOAT4;
114 }
115 else if (type == TypeRGBA) {
116 attr_map[index].type = NODE_ATTR_RGBA;
117 }
118 else if (type == TypeQuaternion) {
119 attr_map[index].type = NODE_ATTR_QUATERNION;
120 }
121 else if (type == TypePackedSphericalHarmonicsRest) {
123 }
124 else {
125 attr_map[index].type = NODE_ATTR_FLOAT3;
126 }
127}
128
129/* Generate an attribute map end marker, optionally including a link to another map.
130 * Links are used to connect object attribute maps to mesh attribute maps. */
132 const size_t index,
133 const bool chain,
134 const uint chain_link)
135{
136 for (int j = 0; j < ATTR_PRIM_TYPES; j++) {
137 attr_map[index + j].id = ATTR_STD_NONE;
138 attr_map[index + j].element = chain; /* link is valid flag */
139 attr_map[index + j].offset = chain ? chain_link + j : 0; /* link to the correct sub-entry */
140 attr_map[index + j].type = 0;
141 }
142}
143
144/* Generate all necessary attribute map entries from the attribute request. */
146 const size_t index,
147 const uint64_t id,
148 AttributeRequest &req)
149{
150 emit_attribute_map_entry(attr_map, index, id, req.type, req.desc);
151}
152
154 DeviceScene *dscene,
155 Scene *scene,
156 vector<AttributeRequestSet> &geom_attributes,
157 vector<AttributeRequestSet> &object_attributes)
158{
159 /* for SVM, the attributes_map table is used to lookup the offset of an
160 * attribute, based on a unique shader attribute id. */
161 const bool use_osl = scene->shader_manager->use_osl();
162
163 /* compute array stride */
164 size_t attr_map_size = 0;
165
166 for (size_t i = 0; i < scene->geometry.size(); i++) {
167 Geometry *geom = scene->geometry[i];
168 geom->attr_map_offset = attr_map_size;
169
170 size_t attr_count = 0;
171 if (use_osl) {
172 for (const AttributeRequest &req : geom_attributes[i].requests) {
173 if (req.std != ATTR_STD_NONE &&
174 scene->shader_manager->get_attribute_id(req.std) != (uint64_t)req.std)
175 {
176 attr_count += 2;
177 }
178 else {
179 attr_count += 1;
180 }
181 }
182 }
183 else {
184 attr_count = geom_attributes[i].size();
185 }
186
187 attr_map_size += (attr_count + 1) * ATTR_PRIM_TYPES;
188 }
189
190 for (size_t i = 0; i < scene->objects.size(); i++) {
191 Object *object = scene->objects[i];
192
193 /* only allocate a table for the object if it actually has attributes */
194 if (object_attributes[i].size() == 0) {
195 object->attr_map_offset = 0;
196 }
197 else {
198 object->attr_map_offset = attr_map_size;
199 attr_map_size += (object_attributes[i].size() + 1) * ATTR_PRIM_TYPES;
200 }
201 }
202
203 if (attr_map_size == 0) {
204 return;
205 }
206
207 if ((attr_map_size == dscene->attributes_map.size()) && !dscene->attributes_map.need_realloc()) {
208 return;
209 }
210
211 /* create attribute map */
212 AttributeMap *attr_map = dscene->attributes_map.alloc(attr_map_size);
213 memset(attr_map, 0, dscene->attributes_map.size() * sizeof(*attr_map));
214
215 for (size_t i = 0; i < scene->geometry.size(); i++) {
216 Geometry *geom = scene->geometry[i];
217 AttributeRequestSet &attributes = geom_attributes[i];
218
219 /* set geometry attributes */
220 size_t index = geom->attr_map_offset;
221
222 for (AttributeRequest &req : attributes.requests) {
223 uint64_t id;
224 if (req.std == ATTR_STD_NONE) {
225 id = scene->shader_manager->get_attribute_id(req.name);
226 }
227 else {
228 id = scene->shader_manager->get_attribute_id(req.std);
229 }
230
231 emit_attribute_mapping(attr_map, index, id, req);
233
234 if (use_osl) {
235 /* Some standard attributes are explicitly referenced via their standard ID, so add those
236 * again in case they were added under a different attribute ID. */
237 if (req.std != ATTR_STD_NONE && id != (uint64_t)req.std) {
238 emit_attribute_mapping(attr_map, index, (uint64_t)req.std, req);
240 }
241 }
242 }
243
244 emit_attribute_map_terminator(attr_map, index, false, 0);
245 }
246
247 for (size_t i = 0; i < scene->objects.size(); i++) {
248 Object *object = scene->objects[i];
249 AttributeRequestSet &attributes = object_attributes[i];
250
251 /* set object attributes */
252 if (attributes.size() > 0) {
253 size_t index = object->attr_map_offset;
254
255 for (AttributeRequest &req : attributes.requests) {
256 uint64_t id;
257 if (req.std == ATTR_STD_NONE) {
258 id = scene->shader_manager->get_attribute_id(req.name);
259 }
260 else {
261 id = scene->shader_manager->get_attribute_id(req.std);
262 }
263
264 emit_attribute_mapping(attr_map, index, id, req);
266 }
267
268 emit_attribute_map_terminator(attr_map, index, true, object->geometry->attr_map_offset);
269 }
270 }
271
272 /* copy to device */
274}
275
276template<typename T> struct AttributeTableEntry {
278 size_t offset;
279 size_t size;
280
281 void reserve(const size_t attr_size)
282 {
283 size += attr_size;
284 }
285
286 /* Templated on U since we'll want to assign float3 values to a packed_float3 device_vector. */
287 template<typename U> size_t add(const U *attr_data, const size_t attr_size, const bool modified)
288 {
289 assert(data.size() >= offset + attr_size);
290 size_t start_offset = offset;
291 if (modified) {
292 for (size_t k = 0; k < attr_size; k++) {
293 data[offset + k] = attr_data[k];
294 }
295 data.tag_modified();
296 }
297 offset += attr_size;
298 return start_offset;
299 }
300
301 void alloc()
302 {
303 data.alloc(size);
304 }
305};
306
308 public:
310 : attr_float{dscene->attributes_float, 0, 0},
311 attr_float2{dscene->attributes_float2, 0, 0},
312 attr_float3{dscene->attributes_float3, 0, 0},
313 attr_float4{dscene->attributes_float4, 0, 0},
314 attr_uchar4{dscene->attributes_uchar4, 0, 0},
315 attr_normal{dscene->attributes_normal, 0, 0},
316 attr_quaternion{dscene->attributes_quaternion, 0, 0},
317 attr_spherical_harmonics_rest{dscene->attributes_spherical_harmonics_rest, 0, 0},
318 tri_verts{dscene->tri_verts, 0, 0},
319 curve_keys{dscene->curve_keys, 0, 0},
320 points{dscene->points, 0, 0}
321 {
322 }
323
332
333 /* Positions in dedicated arrays, gives better BVH2 performance. */
337
338 void add(Geometry *geom,
339 Attribute *mattr,
341 TypeDesc &type,
343 {
344 if (mattr == nullptr) {
345 /* attribute not found */
347 desc.offset = 0;
348 return;
349 }
350
351 /* For hair and pointcloud, pack combined position + radius as float4. */
352 if (mattr->std == ATTR_STD_POSITION && (geom->is_hair() || geom->is_pointcloud())) {
353 add_position_radius(geom, mattr, type, desc);
354 return;
355 }
356 if (mattr->std == ATTR_STD_RADIUS && (geom->is_hair() || geom->is_pointcloud())) {
358 desc.offset = 0;
359 return;
360 }
361
362 /* Store element and type. */
363 desc.element = mattr->element;
364 type = mattr->type;
365
366 /* Store attribute data in arrays, including possible motion steps. */
367 const size_t per_step = Attribute::element_size(geom, mattr->element, prim);
368 const int num_motion = mattr->motion.size();
369
370 const AttributeElement &element = desc.element;
371 int &offset = desc.offset;
372
373 if (mattr->element & ATTR_ELEMENT_VOXEL) {
374 /* store slot in offset value */
375 const ImageHandle &handle = mattr->data_voxel();
376 offset = handle.kernel_id();
377 }
378 else if (mattr->element & ATTR_ELEMENT_IS_BYTE) {
379 offset = attr_uchar4.add(mattr->data<uchar4>(), per_step, mattr->modified);
380 for (int step = 1; step <= num_motion; step++) {
381 attr_uchar4.add(mattr->data<uchar4>(step), per_step, mattr->modified);
382 }
383 }
384 else if (mattr->element & ATTR_ELEMENT_IS_NORMAL) {
385 offset = attr_normal.add(mattr->data<packed_normal>(), per_step, mattr->modified);
386 for (int step = 1; step <= num_motion; step++) {
387 attr_normal.add(mattr->data<packed_normal>(step), per_step, mattr->modified);
388 }
389 }
390 else if (mattr->type == TypeFloat) {
391 offset = attr_float.add(mattr->data<float>(), per_step, mattr->modified);
392 for (int step = 1; step <= num_motion; step++) {
393 attr_float.add(mattr->data<float>(step), per_step, mattr->modified);
394 }
395 }
396 else if (mattr->type == TypeFloat2) {
397 offset = attr_float2.add(mattr->data<float2>(), per_step, mattr->modified);
398 for (int step = 1; step <= num_motion; step++) {
399 attr_float2.add(mattr->data<float2>(step), per_step, mattr->modified);
400 }
401 }
402 else if (mattr->type == TypeMatrix) {
403 offset = attr_float4.add(
404 (const float4 *)mattr->data<Transform>(), per_step * 3, mattr->modified);
405 for (int step = 1; step <= num_motion; step++) {
407 (const float4 *)mattr->data<Transform>(step), per_step * 3, mattr->modified);
408 }
409 }
410 else if (mattr->type == TypeQuaternion) {
411 offset = attr_quaternion.add(mattr->data<Quaternion>(), per_step, mattr->modified);
412 for (int step = 1; step <= num_motion; step++) {
413 attr_quaternion.add(mattr->data<Quaternion>(step), per_step, mattr->modified);
414 }
415 }
416 else if (mattr->type == TypePackedSphericalHarmonicsRest) {
418 mattr->data<PackedSphericalHarmonicsRest>(), per_step, mattr->modified);
419 for (int step = 1; step <= num_motion; step++) {
421 mattr->data<PackedSphericalHarmonicsRest>(step), per_step, mattr->modified);
422 }
423 }
424 else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) {
425 offset = attr_float4.add(mattr->data<float4>(), per_step, mattr->modified);
426 for (int step = 1; step <= num_motion; step++) {
427 attr_float4.add(mattr->data<float4>(step), per_step, mattr->modified);
428 }
429 }
430 else {
433 offset = table.add(mattr->data<packed_float3>(), per_step, mattr->modified);
434 for (int step = 1; step <= num_motion; step++) {
435 table.add(mattr->data<packed_float3>(step), per_step, mattr->modified);
436 }
437 }
438
439 /* Primitive index is global, not per object, so we sneak a correction
440 * for that in here. Vertex index is per object. */
441 if (geom->is_mesh() || geom->is_volume()) {
442 Mesh *mesh = static_cast<Mesh *>(geom);
443 if (element & ATTR_ELEMENT_FACE) {
444 offset -= mesh->prim_offset;
445 }
446 else if (element & ATTR_ELEMENT_CORNER) {
447 offset -= 3 * mesh->prim_offset;
448 }
449 }
450 else if (geom->is_hair()) {
451 Hair *hair = static_cast<Hair *>(geom);
452 if (element & ATTR_ELEMENT_CURVE) {
453 offset -= hair->prim_offset;
454 }
455 }
456 else if (geom->is_pointcloud()) {
457 if (element & ATTR_ELEMENT_VERTEX) {
458 offset -= geom->prim_offset;
459 }
460 }
461 }
462
464 {
465 if (mattr == nullptr) {
466 return;
467 }
468
469 /* Must match the number of steps written by add(), which is derived from
470 * the attribute's own stored motion steps rather than geom->get_motion_steps(). */
471 const int steps = mattr->num_motion_steps();
472 const size_t size = Attribute::element_size(geom, mattr->element, prim) * steps;
473
474 if (mattr->element & ATTR_ELEMENT_VOXEL) {
475 /* pass */
476 }
477 else if (mattr->element & ATTR_ELEMENT_IS_BYTE) {
478 attr_uchar4.reserve(size);
479 }
480 else if (mattr->element & ATTR_ELEMENT_IS_NORMAL) {
481 attr_normal.reserve(size);
482 }
483 else if (mattr->type == TypeFloat) {
484 attr_float.reserve(size);
485 }
486 else if (mattr->type == TypeFloat2) {
487 attr_float2.reserve(size);
488 }
489 else if (mattr->type == TypeMatrix) {
490 attr_float4.reserve(size * 3);
491 }
492 else if (mattr->type == TypeFloat4 || mattr->type == TypeRGBA) {
493 attr_float4.reserve(size);
494 }
495 else if (mattr->type == TypeQuaternion) {
497 }
498 else if (mattr->type == TypePackedSphericalHarmonicsRest) {
500 }
501 else {
504 table.reserve(size);
505 }
506 }
507
508 /* Pack combined position + radius for hair and point cloud. */
510 Attribute *attr_P,
511 TypeDesc &type,
513 {
514 Attribute *attr_R = geom->attributes.find(ATTR_STD_RADIUS);
515 const size_t base_size = attr_P->size;
516 const int steps = attr_P->has_motion() ? geom->get_motion_steps() : 1;
517 const size_t total_size = base_size * steps;
518
519 vector<float4> combined(total_size);
520 for (int step = 0; step < steps; step++) {
521 const packed_float3 *P = attr_P->data<packed_float3>(step);
522 const float *R = attr_R->data<float>(step);
523 const size_t dst_offset = size_t(step) * base_size;
524 for (size_t i = 0; i < base_size; i++) {
525 combined[dst_offset + i] = make_float4(P[i], R[i]);
526 }
527 }
528
529 desc.element = attr_P->element;
530 type = TypeFloat4;
531
532 int &offset = desc.offset;
533 const bool modified = attr_P->modified || attr_R->modified;
535 offset = table.add(combined.data(), total_size, modified);
536
537 /* Pointcloud uses global primitive index. */
538 if (geom->is_pointcloud()) {
539 offset -= geom->prim_offset;
540 }
541 }
542
544 {
545 const int steps = attr_P->has_motion() ? geom->get_motion_steps() : 1;
546 const size_t total_size = attr_P->size * steps;
548 table.reserve(total_size);
549 }
550
565
567 {
568 attr_float.data.copy_to_device_if_modified();
569 attr_float2.data.copy_to_device_if_modified();
570 attr_float3.data.copy_to_device_if_modified();
571 attr_float4.data.copy_to_device_if_modified();
572 attr_uchar4.data.copy_to_device_if_modified();
573 attr_normal.data.copy_to_device_if_modified();
574 attr_quaternion.data.copy_to_device_if_modified();
575 attr_spherical_harmonics_rest.data.copy_to_device_if_modified();
576 tri_verts.data.copy_to_device_if_modified();
577 curve_keys.data.copy_to_device_if_modified();
578 points.data.copy_to_device_if_modified();
579 }
580};
581
583 DeviceScene *dscene,
584 Scene *scene,
585 Progress &progress)
586{
587 progress.set_status("Updating Mesh", "Computing attributes");
588
589 /* gather per mesh requested attributes. as meshes may have multiple
590 * shaders assigned, this merges the requested attributes that have
591 * been set per shader by the shader manager */
592 vector<AttributeRequestSet> geom_attributes(scene->geometry.size());
593 AttributeRequestSet global_attributes;
594 scene->need_global_attributes(global_attributes);
595
596 for (size_t i = 0; i < scene->geometry.size(); i++) {
597 Geometry *geom = scene->geometry[i];
598
599 geom->index = i;
600 geom_attributes[i].add(global_attributes);
601
602 for (Node *node : geom->get_used_shaders()) {
603 Shader *shader = static_cast<Shader *>(node);
604 geom_attributes[i].add(shader->attributes);
605 }
606
607 for (const Attribute &attr : geom->attributes.attributes) {
608 switch (attr.std) {
613 geom_attributes[i].add(attr.std);
614 break;
615 default:
616 break;
617 }
618 if (geom->is_pointcloud() &&
619 static_cast<PointCloud *>(geom)->get_render_as() == PointCloud::RENDER_AS_GSPLATS)
620 {
621 switch (attr.std) {
626 geom_attributes[i].add(attr.std);
627 break;
628 default:
629 break;
630 }
631 }
632 }
633 }
634
635 /* convert object attributes to use the same data structures as geometry ones */
636 vector<AttributeRequestSet> object_attributes(scene->objects.size());
637 vector<AttributeSet> object_attribute_values;
638
639 object_attribute_values.reserve(scene->objects.size());
640
641 for (size_t i = 0; i < scene->objects.size(); i++) {
642 Object *object = scene->objects[i];
643 Geometry *geom = object->geometry;
644 const size_t geom_idx = geom->index;
645
646 assert(geom_idx < scene->geometry.size() && scene->geometry[geom_idx] == geom);
647
648 object_attribute_values.push_back(AttributeSet(geom, ATTR_PRIM_GEOMETRY));
649
650 AttributeRequestSet &geom_requests = geom_attributes[geom_idx];
651 AttributeRequestSet &attributes = object_attributes[i];
652 AttributeSet &values = object_attribute_values[i];
653
654 for (size_t j = 0; j < object->attributes.size(); j++) {
655 const ParamValue &param = object->attributes[j];
656
657 /* add attributes that are requested and not already handled by the mesh */
658 if (geom_requests.find(param.name()) && !geom->attributes.find(param.name())) {
659 attributes.add(param.name());
660
661 Attribute *attr = values.add(param.name(), param.type(), ATTR_ELEMENT_OBJECT);
662 assert(param.nvalues() == attr->size);
663 memcpy(attr->data_for_write(), param.data(), param.datasize());
664 }
665 }
666 }
667
668 /* mesh attribute are stored in a single array per data type. here we fill
669 * those arrays, and set the offset and element type to create attribute
670 * maps next */
671
672 /* Pre-allocate attributes to avoid arrays re-allocation which would
673 * take 2x of overall attribute memory usage.
674 */
675 AttributeTableBuilder builder(dscene);
676
677 for (size_t i = 0; i < scene->geometry.size(); i++) {
678 Geometry *geom = scene->geometry[i];
679 AttributeRequestSet &attributes = geom_attributes[i];
680 unordered_set<const Attribute *> reserved;
681 for (AttributeRequest &req : attributes.requests) {
682 Attribute *attr = geom->attributes.find(req);
683 if (attr && !reserved.insert(attr).second) {
684 /* Store attribute requested in different ways once. */
685 continue;
686 }
687 if (attr && (geom->is_hair() || geom->is_pointcloud())) {
688 /* Special cases for packed position + radius. */
689 if (attr->std == ATTR_STD_POSITION) {
690 builder.reserve_position_radius(geom, attr);
691 continue;
692 }
693 if (attr->std == ATTR_STD_RADIUS) {
694 continue;
695 }
696 }
697 builder.reserve(geom, attr, ATTR_PRIM_GEOMETRY);
698 }
699 }
700
701 for (size_t i = 0; i < scene->objects.size(); i++) {
702 Object *object = scene->objects[i];
703
704 for (Attribute &attr : object_attribute_values[i].attributes) {
705 builder.reserve(object->geometry, &attr, ATTR_PRIM_GEOMETRY);
706 }
707 }
708
709 builder.alloc();
710
711 /* The order of those flags needs to match that of AttrKernelDataType. */
712 const bool attributes_need_realloc[int(AttrKernelDataType::NUM)] = {
721 };
722
723 /* Fill in attributes. */
724 for (size_t i = 0; i < scene->geometry.size(); i++) {
725 Geometry *geom = scene->geometry[i];
726 AttributeRequestSet &attributes = geom_attributes[i];
727
728 unordered_map<const Attribute *, const AttributeRequest *> added;
729
730 for (AttributeRequest &req : attributes.requests) {
731 Attribute *attr = geom->attributes.find(req);
732
733 if (attr) {
734 const auto it = added.find(attr);
735 if (it != added.end()) {
736 /* Store attribute requested in different ways once. */
737 req.type = it->second->type;
738 req.desc = it->second->desc;
739 continue;
740 }
741 added[attr] = &req;
742
743 /* force a copy if we need to reallocate all the data */
744 attr->modified |= attributes_need_realloc[int(Attribute::kernel_type(*attr))];
745 }
746
747 builder.add(geom, attr, ATTR_PRIM_GEOMETRY, req.type, req.desc);
748
749 if (progress.get_cancel()) {
750 return;
751 }
752 }
753 }
754
755 for (size_t i = 0; i < scene->objects.size(); i++) {
756 Object *object = scene->objects[i];
757 AttributeRequestSet &attributes = object_attributes[i];
758 AttributeSet &values = object_attribute_values[i];
759
760 unordered_map<const Attribute *, const AttributeRequest *> added;
761
762 for (AttributeRequest &req : attributes.requests) {
763 Attribute *attr = values.find(req);
764
765 if (attr) {
766 const auto it = added.find(attr);
767 if (it != added.end()) {
768 /* Store attribute requested in different ways once. */
769 req.type = it->second->type;
770 req.desc = it->second->desc;
771 continue;
772 }
773 added[attr] = &req;
774
775 attr->modified |= attributes_need_realloc[int(Attribute::kernel_type(*attr))];
776 }
777
778 builder.add(object->geometry, attr, ATTR_PRIM_GEOMETRY, req.type, req.desc);
779
780 if (progress.get_cancel()) {
781 return;
782 }
783 }
784 }
785
786 /* create attribute lookup maps */
787 if (scene->shader_manager->use_osl()) {
788 update_osl_globals(device, scene);
789 }
790
791 update_svm_attributes(device, dscene, scene, geom_attributes, object_attributes);
792
793 if (progress.get_cancel()) {
794 return;
795 }
796
797 /* copy to device */
798 progress.set_status("Updating Mesh", "Copying Attributes to device");
799
801
802 if (progress.get_cancel()) {
803 return;
804 }
805
806 /* After mesh attributes and patch tables have been copied to device memory,
807 * we need to update offsets in the objects. */
808 scene->object_manager->device_update_geom_offsets(device, dscene, scene);
809}
810
#define U
unsigned long long int uint64_t
vector< AttributeRequest > requests
void add(ustring name)
size_t size() const
bool find(ustring name) const
AttributeDescriptor desc
AttributeStandard std
list< Attribute > attributes
Attribute * find(ustring name) const
Attribute * add(ustring name, const TypeDesc type, AttributeElement element)
AttributeSet(Geometry *geometry, AttributePrimitive prim)
void add(Geometry *geom, Attribute *mattr, AttributePrimitive prim, TypeDesc &type, AttributeDescriptor &desc)
AttributeTableEntry< packed_float3 > attr_float3
AttributeTableEntry< Quaternion > attr_quaternion
AttributeTableEntry< float2 > attr_float2
AttributeTableEntry< float4 > curve_keys
AttributeTableEntry< float4 > points
AttributeTableBuilder(DeviceScene *dscene)
AttributeTableEntry< packed_float3 > tri_verts
void reserve_position_radius(Geometry *geom, Attribute *attr_P)
void reserve(Geometry *geom, Attribute *mattr, AttributePrimitive prim)
AttributeTableEntry< PackedSphericalHarmonicsRest > attr_spherical_harmonics_rest
AttributeTableEntry< packed_normal > attr_normal
AttributeTableEntry< uchar4 > attr_uchar4
AttributeTableEntry< float > attr_float
void add_position_radius(Geometry *geom, Attribute *attr_P, TypeDesc &type, AttributeDescriptor &desc)
AttributeTableEntry< float4 > attr_float4
AttributeElement element
vector< Buffer > motion
const T * data(const int step=0) const
static AttrKernelDataType kernel_type(const Attribute &attr)
T * data_for_write(const int step=0)
static size_t element_size(Geometry *geom, AttributeElement element, AttributePrimitive prim)
const ImageHandle & data_voxel() const
bool has_motion() const
TypeDesc type
AttributeStandard std
int num_motion_steps() const
device_vector< float4 > attributes_float4
Definition devicescene.h:56
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< packed_float3 > attributes_float3
Definition devicescene.h:55
device_vector< Quaternion > attributes_quaternion
Definition devicescene.h:59
device_vector< float > attributes_float
Definition devicescene.h:53
device_vector< PackedSphericalHarmonicsRest > attributes_spherical_harmonics_rest
Definition devicescene.h:60
device_vector< uchar4 > attributes_uchar4
Definition devicescene.h:57
void device_update_attributes(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)
void update_osl_globals(Device *device, Scene *scene)
void update_svm_attributes(Device *device, DeviceScene *dscene, Scene *scene, vector< AttributeRequestSet > &geom_attributes, vector< AttributeRequestSet > &object_attributes)
bool has_voxel_attributes() const
bool is_volume() const
bool is_pointcloud() const
bool is_hair() const
AttributeRequestSet needed_attributes()
size_t attr_map_offset
size_t prim_offset
AttributeSet attributes
bool is_mesh() const
bool need_attribute(const Scene *scene, AttributeStandard std)
Definition hair.h:13
int kernel_id() const
size_t attr_map_offset
bool get_cancel() const
Definition progress.h:77
void set_status(const string &status_, const string &substatus_="")
Definition progress.h:248
Definition scene.h:133
unique_ptr< ObjectManager > object_manager
Definition scene.h:171
bool need_global_attribute(AttributeStandard std) const
Definition scene.cpp:455
void need_global_attributes(AttributeRequestSet &attributes)
Definition scene.cpp:469
unique_ptr_vector< Geometry > geometry
Definition scene.h:161
unique_ptr_vector< Shader > shaders
Definition scene.h:158
unique_ptr< ShaderManager > shader_manager
Definition scene.h:169
unique_ptr_vector< Object > objects
Definition scene.h:162
AttributeRequestSet global_attributes
AttributeRequestSet attributes
size_t size() const
T * alloc(const size_t width, const size_t height=0)
size_t size() const
#define CCL_NAMESPACE_END
static void emit_attribute_mapping(AttributeMap *attr_map, const size_t index, const uint64_t id, AttributeRequest &req)
static void emit_attribute_map_terminator(AttributeMap *attr_map, const size_t index, const bool chain, const uint chain_link)
static void emit_attribute_map_entry(AttributeMap *attr_map, const size_t index, const uint64_t id, const TypeDesc type, const AttributeDescriptor &desc)
#define assert(assertion)
#define index(i)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
uint as_uint(string_t)
@ NODE_ATTR_FLOAT
@ NODE_ATTR_QUATERNION
@ NODE_ATTR_FLOAT3
@ NODE_ATTR_RGBA
@ NODE_ATTR_FLOAT2
@ NODE_ATTR_SPHERICAL_HARMONICS_REST
@ NODE_ATTR_FLOAT4
@ NODE_ATTR_MATRIX
AttributeElement
@ ATTR_ELEMENT_NONE
@ ATTR_ELEMENT_VOXEL
@ ATTR_ELEMENT_CORNER
@ ATTR_ELEMENT_OBJECT
@ ATTR_ELEMENT_VERTEX
@ ATTR_ELEMENT_IS_BYTE
@ ATTR_ELEMENT_IS_NORMAL
@ ATTR_ELEMENT_FACE
@ ATTR_ELEMENT_CURVE
AttributePrimitive
@ ATTR_PRIM_TYPES
@ ATTR_PRIM_GEOMETRY
AttributeStandard
@ ATTR_STD_GSPLAT_SCALE
@ ATTR_STD_VERTEX_NORMAL
@ ATTR_STD_NONE
@ ATTR_STD_GSPLAT_RADIANCE_BASE
@ ATTR_STD_GSPLAT_ROTATION
@ ATTR_STD_SHADOW_TRANSPARENCY
@ ATTR_STD_POSITION
@ ATTR_STD_CORNER_NORMAL
@ ATTR_STD_GSPLAT_RADIANCE_SPHERICAL_HARMONICS_REST
@ ATTR_STD_RADIUS
#define R
#define make_float4
AttributeElement element
uint16_t element
size_t add(const U *attr_data, const size_t attr_size, const bool modified)
void reserve(const size_t attr_size)
device_vector< T > & data
ustring name
Definition graph/node.h:178
Node(const NodeType *type, ustring name=ustring())