Commit: 57e5330ffacf714722b459d2e679d5d20a7d4387 Author: Kévin Dietrich Date: Wed Oct 28 15:18:36 2020 +0100 Branches: cycles_procedural_api https://developer.blender.org/rB57e5330ffacf714722b459d2e679d5d20a7d4387
Merge branch 'master' into arcpatch-D8544 =================================================================== =================================================================== diff --cc intern/cycles/render/geometry.cpp index 910148a9d3b,cbd5e7e83fb..e73234240b8 --- a/intern/cycles/render/geometry.cpp +++ b/intern/cycles/render/geometry.cpp @@@ -120,6 -116,16 +120,18 @@@ bool Geometry::need_attribute(Scene * / return false; } + AttributeRequestSet Geometry::needed_attributes() + { + AttributeRequestSet result; + - foreach (Shader *shader, used_shaders) ++ foreach (Node *node, used_shaders) { ++ Shader *shader = static_cast<Shader *>(node); + result.add(shader->attributes); ++ } + + return result; + } + float Geometry::motion_time(int step) const { return (motion_steps > 1) ? 2.0f * step / (motion_steps - 1) - 1.0f : 0.0f; @@@ -382,6 -382,63 +391,63 @@@ void GeometryManager::update_osl_attrib #endif } + /* Generate a normal attribute map entry from an attribute descriptor. */ + static void emit_attribute_map_entry( + uint4 *attr_map, int index, uint id, TypeDesc type, const AttributeDescriptor &desc) + { + attr_map[index].x = id; + attr_map[index].y = desc.element; + attr_map[index].z = as_uint(desc.offset); + + if (type == TypeDesc::TypeFloat) + attr_map[index].w = NODE_ATTR_FLOAT; + else if (type == TypeDesc::TypeMatrix) + attr_map[index].w = NODE_ATTR_MATRIX; + else if (type == TypeFloat2) + attr_map[index].w = NODE_ATTR_FLOAT2; + else if (type == TypeFloat4) + attr_map[index].w = NODE_ATTR_FLOAT4; + else if (type == TypeRGBA) + attr_map[index].w = NODE_ATTR_RGBA; + else + attr_map[index].w = NODE_ATTR_FLOAT3; + + attr_map[index].w |= desc.flags << 8; + } + + /* Generate an attribute map end marker, optionally including a link to another map. + * Links are used to connect object attribute maps to mesh attribute maps. */ + static void emit_attribute_map_terminator(uint4 *attr_map, int index, bool chain, uint chain_link) + { + for (int j = 0; j < ATTR_PRIM_TYPES; j++) { + attr_map[index + j].x = ATTR_STD_NONE; + attr_map[index + j].y = chain; /* link is valid flag */ + attr_map[index + j].z = chain ? chain_link + j : 0; /* link to the correct sub-entry */ + attr_map[index + j].w = 0; + } + } + + /* Generate all necessary attribute map entries from the attribute request. */ + static void emit_attribute_mapping( + uint4 *attr_map, int index, Scene *scene, AttributeRequest &req, Geometry *geom) + { + uint id; + + if (req.std == ATTR_STD_NONE) + id = scene->shader_manager->get_attribute_id(req.name); + else + id = scene->shader_manager->get_attribute_id(req.std); + + emit_attribute_map_entry(attr_map, index, id, req.type, req.desc); + - if (geom->type == Geometry::MESH) { ++ if (geom->is_mesh()) { + Mesh *mesh = static_cast<Mesh *>(geom); - if (mesh->subd_faces.size()) { ++ if (mesh->get_num_subd_faces()) { + emit_attribute_map_entry(attr_map, index + 1, id, req.subd_type, req.subd_desc); + } + } + } + void GeometryManager::update_svm_attributes(Device *, DeviceScene *dscene, Scene *scene, @@@ -652,10 -685,10 +694,11 @@@ void GeometryManager::device_update_att for (size_t i = 0; i < scene->geometry.size(); i++) { Geometry *geom = scene->geometry[i]; + geom->index = i; scene->need_global_attributes(geom_attributes[i]); - foreach (Shader *shader, geom->used_shaders) { + foreach (Node *node, geom->get_used_shaders()) { + Shader *shader = static_cast<Shader *>(node); geom_attributes[i].add(shader->attributes); } } diff --cc intern/cycles/render/geometry.h index 1a374c57463,9367c4a9de7..735fef7d0c2 --- a/intern/cycles/render/geometry.h +++ b/intern/cycles/render/geometry.h @@@ -88,8 -88,12 +88,11 @@@ class Geometry : public Node bool has_surface_bssrdf; /* Set in the device_update_flags(). */ /* Update Flags */ - bool need_update; bool need_update_rebuild; + /* Index into scene->geometry (only valid during update) */ + size_t index; + /* Constructor/Destructor */ explicit Geometry(const NodeType *node_type, const Type type); virtual ~Geometry(); _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs