Refactor: Cycles: Replace foreach() by range based for loops
Pull Request: https://projects.blender.org/blender/blender/pulls/132361
This commit is contained in:
@@ -12,7 +12,6 @@
|
|||||||
#include "session/session.h"
|
#include "session/session.h"
|
||||||
|
|
||||||
#include "util/args.h"
|
#include "util/args.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/path.h"
|
#include "util/path.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
@@ -385,7 +384,7 @@ static void options_parse(int argc, const char **argv)
|
|||||||
|
|
||||||
/* List devices for which support is compiled in. */
|
/* List devices for which support is compiled in. */
|
||||||
vector<DeviceType> types = Device::available_types();
|
vector<DeviceType> types = Device::available_types();
|
||||||
foreach (DeviceType type, types) {
|
for (DeviceType type : types) {
|
||||||
if (!device_names.empty()) {
|
if (!device_names.empty()) {
|
||||||
device_names += ", ";
|
device_names += ", ";
|
||||||
}
|
}
|
||||||
@@ -474,7 +473,7 @@ static void options_parse(int argc, const char **argv)
|
|||||||
vector<DeviceInfo> devices = Device::available_devices();
|
vector<DeviceInfo> devices = Device::available_devices();
|
||||||
printf("Devices:\n");
|
printf("Devices:\n");
|
||||||
|
|
||||||
foreach (DeviceInfo &info, devices) {
|
for (DeviceInfo &info : devices) {
|
||||||
printf(" %-10s%s%s\n",
|
printf(" %-10s%s%s\n",
|
||||||
Device::string_from_type(info.type).c_str(),
|
Device::string_from_type(info.type).c_str(),
|
||||||
info.description.c_str(),
|
info.description.c_str(),
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "scene/shader_graph.h"
|
#include "scene/shader_graph.h"
|
||||||
#include "scene/shader_nodes.h"
|
#include "scene/shader_nodes.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/path.h"
|
#include "util/path.h"
|
||||||
#include "util/projection.h"
|
#include "util/projection.h"
|
||||||
#include "util/transform.h"
|
#include "util/transform.h"
|
||||||
@@ -71,8 +70,9 @@ static bool xml_read_int_array(vector<int> &value, xml_node node, const char *na
|
|||||||
vector<string> tokens;
|
vector<string> tokens;
|
||||||
string_split(tokens, attr.value());
|
string_split(tokens, attr.value());
|
||||||
|
|
||||||
foreach (const string &token, tokens)
|
for (const string &token : tokens) {
|
||||||
value.push_back(atoi(token.c_str()));
|
value.push_back(atoi(token.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -100,8 +100,9 @@ static bool xml_read_float_array(vector<float> &value, xml_node node, const char
|
|||||||
vector<string> tokens;
|
vector<string> tokens;
|
||||||
string_split(tokens, attr.value());
|
string_split(tokens, attr.value());
|
||||||
|
|
||||||
foreach (const string &token, tokens)
|
for (const string &token : tokens) {
|
||||||
value.push_back((float)atof(token.c_str()));
|
value.push_back((float)atof(token.c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -251,10 +252,11 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node
|
|||||||
if (graph_reader.node_map.find(from_node_name) != graph_reader.node_map.end()) {
|
if (graph_reader.node_map.find(from_node_name) != graph_reader.node_map.end()) {
|
||||||
ShaderNode *fromnode = (ShaderNode *)graph_reader.node_map[from_node_name];
|
ShaderNode *fromnode = (ShaderNode *)graph_reader.node_map[from_node_name];
|
||||||
|
|
||||||
foreach (ShaderOutput *out, fromnode->outputs)
|
for (ShaderOutput *out : fromnode->outputs) {
|
||||||
if (string_iequals(out->socket_type.name.string(), from_socket_name.string())) {
|
if (string_iequals(out->socket_type.name.string(), from_socket_name.string())) {
|
||||||
output = out;
|
output = out;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!output) {
|
if (!output) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -270,10 +272,11 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node
|
|||||||
if (graph_reader.node_map.find(to_node_name) != graph_reader.node_map.end()) {
|
if (graph_reader.node_map.find(to_node_name) != graph_reader.node_map.end()) {
|
||||||
ShaderNode *tonode = (ShaderNode *)graph_reader.node_map[to_node_name];
|
ShaderNode *tonode = (ShaderNode *)graph_reader.node_map[to_node_name];
|
||||||
|
|
||||||
foreach (ShaderInput *in, tonode->inputs)
|
for (ShaderInput *in : tonode->inputs) {
|
||||||
if (string_iequals(in->socket_type.name.string(), to_socket_name.string())) {
|
if (string_iequals(in->socket_type.name.string(), to_socket_name.string())) {
|
||||||
input = in;
|
input = in;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!input) {
|
if (!input) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@@ -691,7 +694,7 @@ static void xml_read_state(XMLReadState &state, xml_node node)
|
|||||||
if (xml_read_string(&shadername, node, "shader")) {
|
if (xml_read_string(&shadername, node, "shader")) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
foreach (Shader *shader, state.scene->shaders) {
|
for (Shader *shader : state.scene->shaders) {
|
||||||
if (shader->name == shadername) {
|
if (shader->name == shadername) {
|
||||||
state.shader = shader;
|
state.shader = shader;
|
||||||
found = true;
|
found = true;
|
||||||
@@ -710,7 +713,7 @@ static void xml_read_state(XMLReadState &state, xml_node node)
|
|||||||
if (xml_read_string(&objectname, node, "object")) {
|
if (xml_read_string(&objectname, node, "object")) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
foreach (Object *object, state.scene->objects) {
|
for (Object *object : state.scene->objects) {
|
||||||
if (object->name == objectname) {
|
if (object->name == objectname) {
|
||||||
state.object = object;
|
state.object = object;
|
||||||
found = true;
|
found = true;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "scene/scene.h"
|
#include "scene/scene.h"
|
||||||
|
|
||||||
#include "util/color.h"
|
#include "util/color.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
#include "blender/session.h"
|
#include "blender/session.h"
|
||||||
#include "blender/util.h"
|
#include "blender/util.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
enum ComputeDevice {
|
enum ComputeDevice {
|
||||||
@@ -63,7 +61,7 @@ void static adjust_device_info_from_preferences(DeviceInfo &info, PointerRNA cpr
|
|||||||
void static adjust_device_info(DeviceInfo &device, PointerRNA cpreferences, bool preview)
|
void static adjust_device_info(DeviceInfo &device, PointerRNA cpreferences, bool preview)
|
||||||
{
|
{
|
||||||
adjust_device_info_from_preferences(device, cpreferences);
|
adjust_device_info_from_preferences(device, cpreferences);
|
||||||
foreach (DeviceInfo &info, device.multi_devices) {
|
for (DeviceInfo &info : device.multi_devices) {
|
||||||
adjust_device_info_from_preferences(info, cpreferences);
|
adjust_device_info_from_preferences(info, cpreferences);
|
||||||
|
|
||||||
/* There is an accumulative logic here, because Multi-devices are supported only for
|
/* There is an accumulative logic here, because Multi-devices are supported only for
|
||||||
@@ -139,7 +137,7 @@ DeviceInfo blender_device_info(BL::Preferences &b_preferences,
|
|||||||
RNA_BEGIN (&cpreferences, device, "devices") {
|
RNA_BEGIN (&cpreferences, device, "devices") {
|
||||||
if (get_boolean(device, "use")) {
|
if (get_boolean(device, "use")) {
|
||||||
string id = get_string(device, "id");
|
string id = get_string(device, "id");
|
||||||
foreach (DeviceInfo &info, devices) {
|
for (DeviceInfo &info : devices) {
|
||||||
if (info.id == id) {
|
if (info.id == id) {
|
||||||
used_devices.push_back(info);
|
used_devices.push_back(info);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "blender/sync.h"
|
#include "blender/sync.h"
|
||||||
#include "blender/util.h"
|
#include "blender/util.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/task.h"
|
#include "util/task.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
@@ -130,7 +129,7 @@ Geometry *BlenderSync::sync_geometry(BL::Depsgraph &b_depsgraph,
|
|||||||
* because the shader needs different geometry attributes. */
|
* because the shader needs different geometry attributes. */
|
||||||
bool attribute_recalc = false;
|
bool attribute_recalc = false;
|
||||||
|
|
||||||
foreach (Node *node, geom->get_used_shaders()) {
|
for (Node *node : geom->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->need_update_geometry()) {
|
if (shader->need_update_geometry()) {
|
||||||
attribute_recalc = true;
|
attribute_recalc = true;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "util/algorithm.h"
|
#include "util/algorithm.h"
|
||||||
#include "util/disjoint_set.h"
|
#include "util/disjoint_set.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/math.h"
|
#include "util/math.h"
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "scene/shader_graph.h"
|
#include "scene/shader_graph.h"
|
||||||
#include "scene/shader_nodes.h"
|
#include "scene/shader_nodes.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/task.h"
|
#include "util/task.h"
|
||||||
@@ -420,7 +419,7 @@ bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update attribute values. */
|
/* Update attribute values. */
|
||||||
foreach (AttributeRequest &req, requests.requests) {
|
for (AttributeRequest &req : requests.requests) {
|
||||||
ustring name = req.name;
|
ustring name = req.name;
|
||||||
|
|
||||||
std::string real_name;
|
std::string real_name;
|
||||||
@@ -732,7 +731,7 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* note iteration over motion_times set happens in sorted order */
|
/* note iteration over motion_times set happens in sorted order */
|
||||||
foreach (float relative_time, motion_times) {
|
for (float relative_time : motion_times) {
|
||||||
/* center time is already handled. */
|
/* center time is already handled. */
|
||||||
if (relative_time == 0.0f) {
|
if (relative_time == 0.0f) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
#include "blender/sync.h"
|
#include "blender/sync.h"
|
||||||
#include "blender/util.h"
|
#include "blender/util.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
/* Utilities */
|
/* Utilities */
|
||||||
|
|||||||
@@ -12,8 +12,6 @@
|
|||||||
#include "blender/sync.h"
|
#include "blender/sync.h"
|
||||||
#include "blender/util.h"
|
#include "blender/util.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
|
|
||||||
#include "DNA_pointcloud_types.h"
|
#include "DNA_pointcloud_types.h"
|
||||||
|
|
||||||
#include "BKE_attribute.hh"
|
#include "BKE_attribute.hh"
|
||||||
@@ -220,7 +218,7 @@ void BlenderSync::sync_pointcloud(PointCloud *pointcloud, BObjectInfo &b_ob_info
|
|||||||
}
|
}
|
||||||
|
|
||||||
pointcloud->attributes.clear();
|
pointcloud->attributes.clear();
|
||||||
foreach (Attribute &attr, new_pointcloud.attributes.attributes) {
|
for (Attribute &attr : new_pointcloud.attributes.attributes) {
|
||||||
pointcloud->attributes.attributes.push_back(std::move(attr));
|
pointcloud->attributes.attributes.push_back(std::move(attr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include "session/merge.h"
|
#include "session/merge.h"
|
||||||
|
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/guiding.h"
|
#include "util/guiding.h"
|
||||||
#include "util/md5.h"
|
#include "util/md5.h"
|
||||||
#include "util/openimagedenoise.h"
|
#include "util/openimagedenoise.h"
|
||||||
@@ -897,7 +897,7 @@ static PyObject *get_device_types_func(PyObject * /*self*/, PyObject * /*args*/)
|
|||||||
vector<DeviceType> device_types = Device::available_types();
|
vector<DeviceType> device_types = Device::available_types();
|
||||||
bool has_cuda = false, has_optix = false, has_hip = false, has_metal = false, has_oneapi = false,
|
bool has_cuda = false, has_optix = false, has_hip = false, has_metal = false, has_oneapi = false,
|
||||||
has_hiprt = false;
|
has_hiprt = false;
|
||||||
foreach (DeviceType device_type, device_types) {
|
for (DeviceType device_type : device_types) {
|
||||||
has_cuda |= (device_type == DEVICE_CUDA);
|
has_cuda |= (device_type == DEVICE_CUDA);
|
||||||
has_optix |= (device_type == DEVICE_OPTIX);
|
has_optix |= (device_type == DEVICE_OPTIX);
|
||||||
has_hip |= (device_type == DEVICE_HIP);
|
has_hip |= (device_type == DEVICE_HIP);
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "session/buffers.h"
|
#include "session/buffers.h"
|
||||||
#include "session/session.h"
|
#include "session/session.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/murmurhash.h"
|
#include "util/murmurhash.h"
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#include "blender/texture.h"
|
#include "blender/texture.h"
|
||||||
#include "blender/util.h"
|
#include "blender/util.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/set.h"
|
#include "util/set.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
#include "util/task.h"
|
#include "util/task.h"
|
||||||
@@ -1474,7 +1473,7 @@ void BlenderSync::resolve_view_layer_attributes(Shader *shader,
|
|||||||
{
|
{
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
|
|
||||||
foreach (ShaderNode *node, graph->nodes) {
|
for (ShaderNode *node : graph->nodes) {
|
||||||
if (node->is_a(AttributeNode::node_type)) {
|
if (node->is_a(AttributeNode::node_type)) {
|
||||||
AttributeNode *attr_node = static_cast<AttributeNode *>(node);
|
AttributeNode *attr_node = static_cast<AttributeNode *>(node);
|
||||||
|
|
||||||
@@ -1496,7 +1495,7 @@ void BlenderSync::resolve_view_layer_attributes(Shader *shader,
|
|||||||
/* Replace all outgoing links, using appropriate output types. */
|
/* Replace all outgoing links, using appropriate output types. */
|
||||||
float val_avg = (value.x + value.y + value.z) / 3.0f;
|
float val_avg = (value.x + value.y + value.z) / 3.0f;
|
||||||
|
|
||||||
foreach (ShaderOutput *output, node->outputs) {
|
for (ShaderOutput *output : node->outputs) {
|
||||||
float val_float;
|
float val_float;
|
||||||
float3 val_float3;
|
float3 val_float3;
|
||||||
|
|
||||||
@@ -1509,7 +1508,7 @@ void BlenderSync::resolve_view_layer_attributes(Shader *shader,
|
|||||||
val_float3 = make_float3(value);
|
val_float3 = make_float3(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (ShaderInput *sock, output->links) {
|
for (ShaderInput *sock : output->links) {
|
||||||
if (sock->type() == SocketType::FLOAT) {
|
if (sock->type() == SocketType::FLOAT) {
|
||||||
sock->set(val_float);
|
sock->set(val_float);
|
||||||
}
|
}
|
||||||
@@ -1633,7 +1632,7 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
|
|||||||
|
|
||||||
pool.wait_work();
|
pool.wait_work();
|
||||||
|
|
||||||
foreach (Shader *shader, updated_shaders) {
|
for (Shader *shader : updated_shaders) {
|
||||||
shader->tag_update(scene);
|
shader->tag_update(scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "integrator/denoiser.h"
|
#include "integrator/denoiser.h"
|
||||||
|
|
||||||
#include "util/debug.h"
|
#include "util/debug.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include "scene/scene.h"
|
#include "scene/scene.h"
|
||||||
|
|
||||||
#include "util/algorithm.h"
|
#include "util/algorithm.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
#include "util/stack_allocator.h"
|
#include "util/stack_allocator.h"
|
||||||
@@ -411,7 +411,7 @@ void BVHBuild::add_references(BVHRange &root)
|
|||||||
/* reserve space for references */
|
/* reserve space for references */
|
||||||
size_t num_alloc_references = 0;
|
size_t num_alloc_references = 0;
|
||||||
|
|
||||||
foreach (Object *ob, objects) {
|
for (Object *ob : objects) {
|
||||||
if (params.top_level) {
|
if (params.top_level) {
|
||||||
if (!ob->is_traceable()) {
|
if (!ob->is_traceable()) {
|
||||||
continue;
|
continue;
|
||||||
@@ -434,7 +434,7 @@ void BVHBuild::add_references(BVHRange &root)
|
|||||||
BoundBox bounds = BoundBox::empty, center = BoundBox::empty;
|
BoundBox bounds = BoundBox::empty, center = BoundBox::empty;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
foreach (Object *ob, objects) {
|
for (Object *ob : objects) {
|
||||||
if (params.top_level) {
|
if (params.top_level) {
|
||||||
if (!ob->is_traceable()) {
|
if (!ob->is_traceable()) {
|
||||||
++i;
|
++i;
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#include "bvh/node.h"
|
#include "bvh/node.h"
|
||||||
#include "bvh/unaligned.h"
|
#include "bvh/unaligned.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
@@ -505,7 +504,7 @@ void BVH2::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
|
|||||||
size_t pack_leaf_nodes_offset = leaf_nodes_size;
|
size_t pack_leaf_nodes_offset = leaf_nodes_size;
|
||||||
size_t object_offset = 0;
|
size_t object_offset = 0;
|
||||||
|
|
||||||
foreach (Geometry *geom, geometry) {
|
for (Geometry *geom : geometry) {
|
||||||
BVH2 *bvh = static_cast<BVH2 *>(geom->bvh);
|
BVH2 *bvh = static_cast<BVH2 *>(geom->bvh);
|
||||||
|
|
||||||
if (geom->need_build_bvh(params.bvh_layout)) {
|
if (geom->need_build_bvh(params.bvh_layout)) {
|
||||||
@@ -541,7 +540,7 @@ void BVH2::pack_instances(size_t nodes_size, size_t leaf_nodes_size)
|
|||||||
unordered_map<Geometry *, int> geometry_map;
|
unordered_map<Geometry *, int> geometry_map;
|
||||||
|
|
||||||
/* merge */
|
/* merge */
|
||||||
foreach (Object *ob, objects) {
|
for (Object *ob : objects) {
|
||||||
Geometry *geom = ob->get_geometry();
|
Geometry *geom = ob->get_geometry();
|
||||||
|
|
||||||
/* We assume that if mesh doesn't need own BVH it was already included
|
/* We assume that if mesh doesn't need own BVH it was already included
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
# include "scene/object.h"
|
# include "scene/object.h"
|
||||||
# include "scene/pointcloud.h"
|
# include "scene/pointcloud.h"
|
||||||
|
|
||||||
# include "util/foreach.h"
|
|
||||||
# include "util/log.h"
|
# include "util/log.h"
|
||||||
# include "util/progress.h"
|
# include "util/progress.h"
|
||||||
# include "util/stats.h"
|
# include "util/stats.h"
|
||||||
@@ -145,7 +144,7 @@ void BVHEmbree::build(Progress &progress,
|
|||||||
rtcSetSceneBuildQuality(scene, build_quality);
|
rtcSetSceneBuildQuality(scene, build_quality);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (Object *ob, objects) {
|
for (Object *ob : objects) {
|
||||||
if (params.top_level) {
|
if (params.top_level) {
|
||||||
if (!ob->is_traceable()) {
|
if (!ob->is_traceable()) {
|
||||||
++i;
|
++i;
|
||||||
@@ -688,7 +687,7 @@ void BVHEmbree::refit(Progress &progress)
|
|||||||
|
|
||||||
/* Update all vertex buffers, then tell Embree to rebuild/-fit the BVHs. */
|
/* Update all vertex buffers, then tell Embree to rebuild/-fit the BVHs. */
|
||||||
unsigned geom_id = 0;
|
unsigned geom_id = 0;
|
||||||
foreach (Object *ob, objects) {
|
for (Object *ob : objects) {
|
||||||
if (!params.top_level || (ob->is_traceable() && !ob->get_geometry()->is_instanced())) {
|
if (!params.top_level || (ob->is_traceable() && !ob->get_geometry()->is_instanced())) {
|
||||||
Geometry *geom = ob->get_geometry();
|
Geometry *geom = ob->get_geometry();
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
#include "bvh/multi.h"
|
#include "bvh/multi.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
BVHMulti::BVHMulti(const BVHParams ¶ms_,
|
BVHMulti::BVHMulti(const BVHParams ¶ms_,
|
||||||
@@ -17,7 +15,7 @@ BVHMulti::BVHMulti(const BVHParams ¶ms_,
|
|||||||
|
|
||||||
BVHMulti::~BVHMulti()
|
BVHMulti::~BVHMulti()
|
||||||
{
|
{
|
||||||
foreach (BVH *bvh, sub_bvhs) {
|
for (BVH *bvh : sub_bvhs) {
|
||||||
delete bvh;
|
delete bvh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +23,7 @@ BVHMulti::~BVHMulti()
|
|||||||
void BVHMulti::replace_geometry(const vector<Geometry *> &geometry,
|
void BVHMulti::replace_geometry(const vector<Geometry *> &geometry,
|
||||||
const vector<Object *> &objects)
|
const vector<Object *> &objects)
|
||||||
{
|
{
|
||||||
foreach (BVH *bvh, sub_bvhs) {
|
for (BVH *bvh : sub_bvhs) {
|
||||||
bvh->replace_geometry(geometry, objects);
|
bvh->replace_geometry(geometry, objects);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
#include "session/buffers.h"
|
#include "session/buffers.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/guiding.h"
|
#include "util/guiding.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
# include "device/cuda/device_impl.h"
|
# include "device/cuda/device_impl.h"
|
||||||
|
|
||||||
# include "util/debug.h"
|
# include "util/debug.h"
|
||||||
# include "util/foreach.h"
|
|
||||||
# include "util/log.h"
|
# include "util/log.h"
|
||||||
# include "util/md5.h"
|
# include "util/md5.h"
|
||||||
# include "util/path.h"
|
# include "util/path.h"
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
# include <hiprtew.h>
|
# include <hiprtew.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/math.h"
|
#include "util/math.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
@@ -230,7 +229,7 @@ vector<DeviceInfo> Device::available_devices(uint mask)
|
|||||||
devices_initialized_mask |= DEVICE_MASK_CUDA;
|
devices_initialized_mask |= DEVICE_MASK_CUDA;
|
||||||
}
|
}
|
||||||
if (mask & DEVICE_MASK_CUDA) {
|
if (mask & DEVICE_MASK_CUDA) {
|
||||||
foreach (DeviceInfo &info, cuda_devices) {
|
for (DeviceInfo &info : cuda_devices) {
|
||||||
devices.push_back(info);
|
devices.push_back(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,7 +244,7 @@ vector<DeviceInfo> Device::available_devices(uint mask)
|
|||||||
}
|
}
|
||||||
devices_initialized_mask |= DEVICE_MASK_OPTIX;
|
devices_initialized_mask |= DEVICE_MASK_OPTIX;
|
||||||
}
|
}
|
||||||
foreach (DeviceInfo &info, optix_devices) {
|
for (DeviceInfo &info : optix_devices) {
|
||||||
devices.push_back(info);
|
devices.push_back(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +258,7 @@ vector<DeviceInfo> Device::available_devices(uint mask)
|
|||||||
}
|
}
|
||||||
devices_initialized_mask |= DEVICE_MASK_HIP;
|
devices_initialized_mask |= DEVICE_MASK_HIP;
|
||||||
}
|
}
|
||||||
foreach (DeviceInfo &info, hip_devices) {
|
for (DeviceInfo &info : hip_devices) {
|
||||||
devices.push_back(info);
|
devices.push_back(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,7 +272,7 @@ vector<DeviceInfo> Device::available_devices(uint mask)
|
|||||||
}
|
}
|
||||||
devices_initialized_mask |= DEVICE_MASK_ONEAPI;
|
devices_initialized_mask |= DEVICE_MASK_ONEAPI;
|
||||||
}
|
}
|
||||||
foreach (DeviceInfo &info, oneapi_devices) {
|
for (DeviceInfo &info : oneapi_devices) {
|
||||||
devices.push_back(info);
|
devices.push_back(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +283,7 @@ vector<DeviceInfo> Device::available_devices(uint mask)
|
|||||||
device_cpu_info(cpu_devices);
|
device_cpu_info(cpu_devices);
|
||||||
devices_initialized_mask |= DEVICE_MASK_CPU;
|
devices_initialized_mask |= DEVICE_MASK_CPU;
|
||||||
}
|
}
|
||||||
foreach (DeviceInfo &info, cpu_devices) {
|
for (DeviceInfo &info : cpu_devices) {
|
||||||
devices.push_back(info);
|
devices.push_back(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,7 +296,7 @@ vector<DeviceInfo> Device::available_devices(uint mask)
|
|||||||
}
|
}
|
||||||
devices_initialized_mask |= DEVICE_MASK_METAL;
|
devices_initialized_mask |= DEVICE_MASK_METAL;
|
||||||
}
|
}
|
||||||
foreach (DeviceInfo &info, metal_devices) {
|
for (DeviceInfo &info : metal_devices) {
|
||||||
devices.push_back(info);
|
devices.push_back(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -401,7 +400,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices,
|
|||||||
info.use_hardware_raytracing = false;
|
info.use_hardware_raytracing = false;
|
||||||
info.denoisers = DENOISER_ALL;
|
info.denoisers = DENOISER_ALL;
|
||||||
|
|
||||||
foreach (const DeviceInfo &device, subdevices) {
|
for (const DeviceInfo &device : subdevices) {
|
||||||
/* Ensure CPU device does not slow down GPU. */
|
/* Ensure CPU device does not slow down GPU. */
|
||||||
if (device.type == DEVICE_CPU && subdevices.size() > 1) {
|
if (device.type == DEVICE_CPU && subdevices.size() > 1) {
|
||||||
if (background) {
|
if (background) {
|
||||||
@@ -561,7 +560,7 @@ void GPUDevice::move_textures_to_host(size_t size, bool for_texture)
|
|||||||
bool max_is_image = false;
|
bool max_is_image = false;
|
||||||
|
|
||||||
thread_scoped_lock lock(device_mem_map_mutex);
|
thread_scoped_lock lock(device_mem_map_mutex);
|
||||||
foreach (MemMap::value_type &pair, device_mem_map) {
|
for (MemMap::value_type &pair : device_mem_map) {
|
||||||
device_memory &mem = *pair.first;
|
device_memory &mem = *pair.first;
|
||||||
Mem *cmem = &pair.second;
|
Mem *cmem = &pair.second;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
# include "device/hip/device_impl.h"
|
# include "device/hip/device_impl.h"
|
||||||
|
|
||||||
# include "util/debug.h"
|
# include "util/debug.h"
|
||||||
# include "util/foreach.h"
|
|
||||||
# include "util/log.h"
|
# include "util/log.h"
|
||||||
# include "util/md5.h"
|
# include "util/md5.h"
|
||||||
# include "util/path.h"
|
# include "util/path.h"
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
# include "device/hiprt/device_impl.h"
|
# include "device/hiprt/device_impl.h"
|
||||||
# include "kernel/device/hiprt/globals.h"
|
# include "kernel/device/hiprt/globals.h"
|
||||||
|
|
||||||
# include "util/foreach.h"
|
|
||||||
# include "util/log.h"
|
# include "util/log.h"
|
||||||
# include "util/md5.h"
|
# include "util/md5.h"
|
||||||
# include "util/path.h"
|
# include "util/path.h"
|
||||||
@@ -882,7 +881,7 @@ hiprtScene HIPRTDevice::build_tlas(BVHHIPRT *bvh,
|
|||||||
custom_prim_info_offset.alloc(num_object);
|
custom_prim_info_offset.alloc(num_object);
|
||||||
prim_time_offset.alloc(num_object);
|
prim_time_offset.alloc(num_object);
|
||||||
|
|
||||||
foreach (Object *ob, objects) {
|
for (Object *ob : objects) {
|
||||||
uint32_t mask = 0;
|
uint32_t mask = 0;
|
||||||
if (ob->is_traceable()) {
|
if (ob->is_traceable()) {
|
||||||
mask = ob->visibility_for_tracing();
|
mask = ob->visibility_for_tracing();
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include "scene/geometry.h"
|
#include "scene/geometry.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/list.h"
|
#include "util/list.h"
|
||||||
#include "util/map.h"
|
#include "util/map.h"
|
||||||
|
|
||||||
@@ -36,7 +35,7 @@ class MultiDevice : public Device {
|
|||||||
MultiDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler, bool headless)
|
MultiDevice(const DeviceInfo &info, Stats &stats, Profiler &profiler, bool headless)
|
||||||
: Device(info, stats, profiler, headless)
|
: Device(info, stats, profiler, headless)
|
||||||
{
|
{
|
||||||
foreach (const DeviceInfo &subinfo, info.multi_devices) {
|
for (const DeviceInfo &subinfo : info.multi_devices) {
|
||||||
/* Always add CPU devices at the back since GPU devices can change
|
/* Always add CPU devices at the back since GPU devices can change
|
||||||
* host memory pointers, which CPU uses as device pointer. */
|
* host memory pointers, which CPU uses as device pointer. */
|
||||||
SubDevice *sub;
|
SubDevice *sub;
|
||||||
@@ -55,7 +54,7 @@ class MultiDevice : public Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Build a list of peer islands for the available render devices */
|
/* Build a list of peer islands for the available render devices */
|
||||||
foreach (SubDevice &sub, devices) {
|
for (SubDevice &sub : devices) {
|
||||||
/* First ensure that every device is in at least once peer island */
|
/* First ensure that every device is in at least once peer island */
|
||||||
if (sub.peer_island_index < 0) {
|
if (sub.peer_island_index < 0) {
|
||||||
peer_islands.emplace_back();
|
peer_islands.emplace_back();
|
||||||
@@ -68,7 +67,7 @@ class MultiDevice : public Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Second check peer access between devices and fill up the islands accordingly */
|
/* Second check peer access between devices and fill up the islands accordingly */
|
||||||
foreach (SubDevice &peer_sub, devices) {
|
for (SubDevice &peer_sub : devices) {
|
||||||
if (peer_sub.peer_island_index < 0 &&
|
if (peer_sub.peer_island_index < 0 &&
|
||||||
peer_sub.device->info.type == sub.device->info.type &&
|
peer_sub.device->info.type == sub.device->info.type &&
|
||||||
peer_sub.device->check_peer_access(sub.device))
|
peer_sub.device->check_peer_access(sub.device))
|
||||||
@@ -82,16 +81,18 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
~MultiDevice() override
|
~MultiDevice() override
|
||||||
{
|
{
|
||||||
foreach (SubDevice &sub, devices)
|
for (SubDevice &sub : devices) {
|
||||||
delete sub.device;
|
delete sub.device;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const string &error_message() override
|
const string &error_message() override
|
||||||
{
|
{
|
||||||
error_msg.clear();
|
error_msg.clear();
|
||||||
|
|
||||||
foreach (SubDevice &sub, devices)
|
for (SubDevice &sub : devices) {
|
||||||
error_msg += sub.device->error_message();
|
error_msg += sub.device->error_message();
|
||||||
|
}
|
||||||
|
|
||||||
return error_msg;
|
return error_msg;
|
||||||
}
|
}
|
||||||
@@ -100,7 +101,7 @@ class MultiDevice : public Device {
|
|||||||
{
|
{
|
||||||
BVHLayoutMask bvh_layout_mask = BVH_LAYOUT_ALL;
|
BVHLayoutMask bvh_layout_mask = BVH_LAYOUT_ALL;
|
||||||
BVHLayoutMask bvh_layout_mask_all = BVH_LAYOUT_NONE;
|
BVHLayoutMask bvh_layout_mask_all = BVH_LAYOUT_NONE;
|
||||||
foreach (const SubDevice &sub_device, devices) {
|
for (const SubDevice &sub_device : devices) {
|
||||||
BVHLayoutMask device_bvh_layout_mask = sub_device.device->get_bvh_layout_mask(
|
BVHLayoutMask device_bvh_layout_mask = sub_device.device->get_bvh_layout_mask(
|
||||||
kernel_features);
|
kernel_features);
|
||||||
bvh_layout_mask &= device_bvh_layout_mask;
|
bvh_layout_mask &= device_bvh_layout_mask;
|
||||||
@@ -150,20 +151,22 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
bool load_kernels(const uint kernel_features) override
|
bool load_kernels(const uint kernel_features) override
|
||||||
{
|
{
|
||||||
foreach (SubDevice &sub, devices)
|
for (SubDevice &sub : devices) {
|
||||||
if (!sub.device->load_kernels(kernel_features)) {
|
if (!sub.device->load_kernels(kernel_features)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool load_osl_kernels() override
|
bool load_osl_kernels() override
|
||||||
{
|
{
|
||||||
foreach (SubDevice &sub, devices)
|
for (SubDevice &sub : devices) {
|
||||||
if (!sub.device->load_osl_kernels()) {
|
if (!sub.device->load_osl_kernels()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -190,13 +193,13 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
vector<BVHMulti *> geom_bvhs;
|
vector<BVHMulti *> geom_bvhs;
|
||||||
geom_bvhs.reserve(bvh->geometry.size());
|
geom_bvhs.reserve(bvh->geometry.size());
|
||||||
foreach (Geometry *geom, bvh->geometry) {
|
for (Geometry *geom : bvh->geometry) {
|
||||||
geom_bvhs.push_back(static_cast<BVHMulti *>(geom->bvh));
|
geom_bvhs.push_back(static_cast<BVHMulti *>(geom->bvh));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Broadcast acceleration structure build to all render devices */
|
/* Broadcast acceleration structure build to all render devices */
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
foreach (SubDevice &sub, devices) {
|
for (SubDevice &sub : devices) {
|
||||||
/* Change geometry BVH pointers to the sub BVH */
|
/* Change geometry BVH pointers to the sub BVH */
|
||||||
for (size_t k = 0; k < bvh->geometry.size(); ++k) {
|
for (size_t k = 0; k < bvh->geometry.size(); ++k) {
|
||||||
bvh->geometry[k]->bvh = geom_bvhs[k]->sub_bvhs[i];
|
bvh->geometry[k]->bvh = geom_bvhs[k]->sub_bvhs[i];
|
||||||
@@ -266,7 +269,7 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
bool is_resident(device_ptr key, Device *sub_device) override
|
bool is_resident(device_ptr key, Device *sub_device) override
|
||||||
{
|
{
|
||||||
foreach (SubDevice &sub, devices) {
|
for (SubDevice &sub : devices) {
|
||||||
if (sub.device == sub_device) {
|
if (sub.device == sub_device) {
|
||||||
return find_matching_mem_device(key, sub)->device == sub_device;
|
return find_matching_mem_device(key, sub)->device == sub_device;
|
||||||
}
|
}
|
||||||
@@ -281,7 +284,7 @@ class MultiDevice : public Device {
|
|||||||
/* Get the memory owner of this key (first try current device, then peer devices) */
|
/* Get the memory owner of this key (first try current device, then peer devices) */
|
||||||
SubDevice *owner_sub = ⊂
|
SubDevice *owner_sub = ⊂
|
||||||
if (owner_sub->ptr_map.find(key) == owner_sub->ptr_map.end()) {
|
if (owner_sub->ptr_map.find(key) == owner_sub->ptr_map.end()) {
|
||||||
foreach (SubDevice *island_sub, peer_islands[sub.peer_island_index]) {
|
for (SubDevice *island_sub : peer_islands[sub.peer_island_index]) {
|
||||||
if (island_sub != owner_sub && island_sub->ptr_map.find(key) != island_sub->ptr_map.end())
|
if (island_sub != owner_sub && island_sub->ptr_map.find(key) != island_sub->ptr_map.end())
|
||||||
{
|
{
|
||||||
owner_sub = island_sub;
|
owner_sub = island_sub;
|
||||||
@@ -297,7 +300,7 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
/* Get the memory owner of this key or the device with the lowest memory usage when new */
|
/* Get the memory owner of this key or the device with the lowest memory usage when new */
|
||||||
SubDevice *owner_sub = island.front();
|
SubDevice *owner_sub = island.front();
|
||||||
foreach (SubDevice *island_sub, island) {
|
for (SubDevice *island_sub : island) {
|
||||||
if (key ? (island_sub->ptr_map.find(key) != island_sub->ptr_map.end()) :
|
if (key ? (island_sub->ptr_map.find(key) != island_sub->ptr_map.end()) :
|
||||||
(island_sub->device->stats.mem_used < owner_sub->device->stats.mem_used))
|
(island_sub->device->stats.mem_used < owner_sub->device->stats.mem_used))
|
||||||
{
|
{
|
||||||
@@ -307,7 +310,7 @@ class MultiDevice : public Device {
|
|||||||
return owner_sub;
|
return owner_sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline device_ptr find_matching_mem(device_ptr key, SubDevice &sub)
|
device_ptr find_matching_mem(device_ptr key, SubDevice &sub)
|
||||||
{
|
{
|
||||||
return find_matching_mem_device(key, sub)->ptr_map[key];
|
return find_matching_mem_device(key, sub)->ptr_map[key];
|
||||||
}
|
}
|
||||||
@@ -318,7 +321,7 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
assert(mem.type == MEM_READ_ONLY || mem.type == MEM_READ_WRITE || mem.type == MEM_DEVICE_ONLY);
|
assert(mem.type == MEM_READ_ONLY || mem.type == MEM_READ_WRITE || mem.type == MEM_DEVICE_ONLY);
|
||||||
/* The remaining memory types can be distributed across devices */
|
/* The remaining memory types can be distributed across devices */
|
||||||
foreach (const vector<SubDevice *> &island, peer_islands) {
|
for (const vector<SubDevice *> &island : peer_islands) {
|
||||||
SubDevice *owner_sub = find_suitable_mem_device(key, island);
|
SubDevice *owner_sub = find_suitable_mem_device(key, island);
|
||||||
mem.device = owner_sub->device;
|
mem.device = owner_sub->device;
|
||||||
mem.device_pointer = 0;
|
mem.device_pointer = 0;
|
||||||
@@ -340,7 +343,7 @@ class MultiDevice : public Device {
|
|||||||
size_t existing_size = mem.device_size;
|
size_t existing_size = mem.device_size;
|
||||||
|
|
||||||
/* The tile buffers are allocated on each device (see below), so copy to all of them */
|
/* The tile buffers are allocated on each device (see below), so copy to all of them */
|
||||||
foreach (const vector<SubDevice *> &island, peer_islands) {
|
for (const vector<SubDevice *> &island : peer_islands) {
|
||||||
SubDevice *owner_sub = find_suitable_mem_device(existing_key, island);
|
SubDevice *owner_sub = find_suitable_mem_device(existing_key, island);
|
||||||
mem.device = owner_sub->device;
|
mem.device = owner_sub->device;
|
||||||
mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0;
|
mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0;
|
||||||
@@ -351,7 +354,7 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
if (mem.type == MEM_GLOBAL || mem.type == MEM_TEXTURE) {
|
if (mem.type == MEM_GLOBAL || mem.type == MEM_TEXTURE) {
|
||||||
/* Need to create texture objects and update pointer in kernel globals on all devices */
|
/* Need to create texture objects and update pointer in kernel globals on all devices */
|
||||||
foreach (SubDevice *island_sub, island) {
|
for (SubDevice *island_sub : island) {
|
||||||
if (island_sub != owner_sub) {
|
if (island_sub != owner_sub) {
|
||||||
island_sub->device->mem_copy_to(mem);
|
island_sub->device->mem_copy_to(mem);
|
||||||
}
|
}
|
||||||
@@ -369,7 +372,7 @@ class MultiDevice : public Device {
|
|||||||
device_ptr key = mem.device_pointer;
|
device_ptr key = mem.device_pointer;
|
||||||
size_t i = 0, sub_h = h / devices.size();
|
size_t i = 0, sub_h = h / devices.size();
|
||||||
|
|
||||||
foreach (SubDevice &sub, devices) {
|
for (SubDevice &sub : devices) {
|
||||||
size_t sy = y + i * sub_h;
|
size_t sy = y + i * sub_h;
|
||||||
size_t sh = (i == (size_t)devices.size() - 1) ? h - sub_h * i : sub_h;
|
size_t sh = (i == (size_t)devices.size() - 1) ? h - sub_h * i : sub_h;
|
||||||
|
|
||||||
@@ -391,7 +394,7 @@ class MultiDevice : public Device {
|
|||||||
device_ptr key = (existing_key) ? existing_key : unique_key++;
|
device_ptr key = (existing_key) ? existing_key : unique_key++;
|
||||||
size_t existing_size = mem.device_size;
|
size_t existing_size = mem.device_size;
|
||||||
|
|
||||||
foreach (const vector<SubDevice *> &island, peer_islands) {
|
for (const vector<SubDevice *> &island : peer_islands) {
|
||||||
SubDevice *owner_sub = find_suitable_mem_device(existing_key, island);
|
SubDevice *owner_sub = find_suitable_mem_device(existing_key, island);
|
||||||
mem.device = owner_sub->device;
|
mem.device = owner_sub->device;
|
||||||
mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0;
|
mem.device_pointer = (existing_key) ? owner_sub->ptr_map[existing_key] : 0;
|
||||||
@@ -412,7 +415,7 @@ class MultiDevice : public Device {
|
|||||||
size_t existing_size = mem.device_size;
|
size_t existing_size = mem.device_size;
|
||||||
|
|
||||||
/* Free memory that was allocated for all devices (see above) on each device */
|
/* Free memory that was allocated for all devices (see above) on each device */
|
||||||
foreach (const vector<SubDevice *> &island, peer_islands) {
|
for (const vector<SubDevice *> &island : peer_islands) {
|
||||||
SubDevice *owner_sub = find_matching_mem_device(key, *island.front());
|
SubDevice *owner_sub = find_matching_mem_device(key, *island.front());
|
||||||
mem.device = owner_sub->device;
|
mem.device = owner_sub->device;
|
||||||
mem.device_pointer = owner_sub->ptr_map[key];
|
mem.device_pointer = owner_sub->ptr_map[key];
|
||||||
@@ -423,7 +426,7 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
if (mem.type == MEM_TEXTURE) {
|
if (mem.type == MEM_TEXTURE) {
|
||||||
/* Free texture objects on all devices */
|
/* Free texture objects on all devices */
|
||||||
foreach (SubDevice *island_sub, island) {
|
for (SubDevice *island_sub : island) {
|
||||||
if (island_sub != owner_sub) {
|
if (island_sub != owner_sub) {
|
||||||
island_sub->device->mem_free(mem);
|
island_sub->device->mem_free(mem);
|
||||||
}
|
}
|
||||||
@@ -439,15 +442,16 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
void const_copy_to(const char *name, void *host, size_t size) override
|
void const_copy_to(const char *name, void *host, size_t size) override
|
||||||
{
|
{
|
||||||
foreach (SubDevice &sub, devices)
|
for (SubDevice &sub : devices) {
|
||||||
sub.device->const_copy_to(name, host, size);
|
sub.device->const_copy_to(name, host, size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int device_number(Device *sub_device) override
|
int device_number(Device *sub_device) override
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
foreach (SubDevice &sub, devices) {
|
for (SubDevice &sub : devices) {
|
||||||
if (sub.device == sub_device) {
|
if (sub.device == sub_device) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -459,7 +463,7 @@ class MultiDevice : public Device {
|
|||||||
|
|
||||||
void foreach_device(const std::function<void(Device *)> &callback) override
|
void foreach_device(const std::function<void(Device *)> &callback) override
|
||||||
{
|
{
|
||||||
foreach (SubDevice &sub, devices) {
|
for (SubDevice &sub : devices) {
|
||||||
sub.device->foreach_device(callback);
|
sub.device->foreach_device(callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
# include "device/oneapi/device_impl.h"
|
# include "device/oneapi/device_impl.h"
|
||||||
|
|
||||||
# include "util/foreach.h"
|
|
||||||
# include "util/log.h"
|
# include "util/log.h"
|
||||||
|
|
||||||
# ifdef WITH_EMBREE_GPU
|
# ifdef WITH_EMBREE_GPU
|
||||||
@@ -138,8 +137,9 @@ OneapiDevice::~OneapiDevice()
|
|||||||
usm_free(device_queue_, kg_memory_);
|
usm_free(device_queue_, kg_memory_);
|
||||||
usm_free(device_queue_, kg_memory_device_);
|
usm_free(device_queue_, kg_memory_device_);
|
||||||
|
|
||||||
for (ConstMemMap::iterator mt = const_mem_map_.begin(); mt != const_mem_map_.end(); mt++)
|
for (ConstMemMap::iterator mt = const_mem_map_.begin(); mt != const_mem_map_.end(); mt++) {
|
||||||
delete mt->second;
|
delete mt->second;
|
||||||
|
}
|
||||||
|
|
||||||
if (device_queue_) {
|
if (device_queue_) {
|
||||||
free_queue(device_queue_);
|
free_queue(device_queue_);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "graph/node.h"
|
#include "graph/node.h"
|
||||||
#include "graph/node_type.h"
|
#include "graph/node_type.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/md5.h"
|
#include "util/md5.h"
|
||||||
#include "util/param.h"
|
#include "util/param.h"
|
||||||
#include "util/transform.h"
|
#include "util/transform.h"
|
||||||
@@ -29,7 +28,7 @@ Node::Node(const NodeType *type_, ustring name_) : name(name_), type(type_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* initialize default values */
|
/* initialize default values */
|
||||||
foreach (const SocketType &socket, type->inputs) {
|
for (const SocketType &socket : type->inputs) {
|
||||||
set_default_value(socket);
|
set_default_value(socket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -563,7 +562,7 @@ bool Node::equals(const Node &other) const
|
|||||||
{
|
{
|
||||||
assert(type == other.type);
|
assert(type == other.type);
|
||||||
|
|
||||||
foreach (const SocketType &socket, type->inputs) {
|
for (const SocketType &socket : type->inputs) {
|
||||||
if (!equals_value(other, socket)) {
|
if (!equals_value(other, socket)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -610,7 +609,7 @@ void Node::hash(MD5Hash &md5)
|
|||||||
{
|
{
|
||||||
md5.append(type->name.string());
|
md5.append(type->name.string());
|
||||||
|
|
||||||
foreach (const SocketType &socket, type->inputs) {
|
for (const SocketType &socket : type->inputs) {
|
||||||
md5.append(socket.name.string());
|
md5.append(socket.name.string());
|
||||||
|
|
||||||
switch (socket.type) {
|
switch (socket.type) {
|
||||||
@@ -713,7 +712,7 @@ template<typename T> size_t array_size_in_bytes(const Node *node, const SocketTy
|
|||||||
size_t Node::get_total_size_in_bytes() const
|
size_t Node::get_total_size_in_bytes() const
|
||||||
{
|
{
|
||||||
size_t total_size = 0;
|
size_t total_size = 0;
|
||||||
foreach (const SocketType &socket, type->inputs) {
|
for (const SocketType &socket : type->inputs) {
|
||||||
switch (socket.type) {
|
switch (socket.type) {
|
||||||
case SocketType::BOOLEAN:
|
case SocketType::BOOLEAN:
|
||||||
case SocketType::FLOAT:
|
case SocketType::FLOAT:
|
||||||
@@ -798,7 +797,7 @@ void Node::set_owner(const NodeOwner *owner_)
|
|||||||
|
|
||||||
void Node::dereference_all_used_nodes()
|
void Node::dereference_all_used_nodes()
|
||||||
{
|
{
|
||||||
foreach (const SocketType &socket, type->inputs) {
|
for (const SocketType &socket : type->inputs) {
|
||||||
if (socket.type == SocketType::NODE) {
|
if (socket.type == SocketType::NODE) {
|
||||||
Node *node = get_socket_value<Node *>(this, socket);
|
Node *node = get_socket_value<Node *>(this, socket);
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* SPDX-License-Identifier: Apache-2.0 */
|
* SPDX-License-Identifier: Apache-2.0 */
|
||||||
|
|
||||||
#include "graph/node_type.h"
|
#include "graph/node_type.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/transform.h"
|
#include "util/transform.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
@@ -181,7 +181,7 @@ void NodeType::register_output(ustring name, ustring ui_name, SocketType::Type t
|
|||||||
|
|
||||||
const SocketType *NodeType::find_input(ustring name) const
|
const SocketType *NodeType::find_input(ustring name) const
|
||||||
{
|
{
|
||||||
foreach (const SocketType &socket, inputs) {
|
for (const SocketType &socket : inputs) {
|
||||||
if (socket.name == name) {
|
if (socket.name == name) {
|
||||||
return &socket;
|
return &socket;
|
||||||
}
|
}
|
||||||
@@ -192,7 +192,7 @@ const SocketType *NodeType::find_input(ustring name) const
|
|||||||
|
|
||||||
const SocketType *NodeType::find_output(ustring name) const
|
const SocketType *NodeType::find_output(ustring name) const
|
||||||
{
|
{
|
||||||
foreach (const SocketType &socket, outputs) {
|
for (const SocketType &socket : outputs) {
|
||||||
if (socket.name == name) {
|
if (socket.name == name) {
|
||||||
return &socket;
|
return &socket;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
# include "graph/node_xml.h"
|
# include "graph/node_xml.h"
|
||||||
# include "graph/node.h"
|
# include "graph/node.h"
|
||||||
|
|
||||||
# include "util/foreach.h"
|
|
||||||
# include "util/string.h"
|
# include "util/string.h"
|
||||||
# include "util/transform.h"
|
# include "util/transform.h"
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ void xml_read_node(XMLReader &reader, Node *node, xml_node xml_node)
|
|||||||
node->name = ustring(name_attr.value());
|
node->name = ustring(name_attr.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const SocketType &socket, node->type->inputs) {
|
for (const SocketType &socket : node->type->inputs) {
|
||||||
if (socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
|
if (socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -240,7 +239,7 @@ xml_node xml_write_node(Node *node, xml_node xml_root)
|
|||||||
|
|
||||||
xml_node.append_attribute("name") = node->name.c_str();
|
xml_node.append_attribute("name") = node->name.c_str();
|
||||||
|
|
||||||
foreach (const SocketType &socket, node->type->inputs) {
|
for (const SocketType &socket : node->type->inputs) {
|
||||||
if (socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
|
if (socket.type == SocketType::CLOSURE || socket.type == SocketType::UNDEFINED) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "scene/scene.h"
|
#include "scene/scene.h"
|
||||||
#include "scene/shader.h"
|
#include "scene/shader.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
#include "util/transform.h"
|
#include "util/transform.h"
|
||||||
@@ -397,7 +396,7 @@ static void concatenate_xform_samples(const MatrixSampleMap &parent_samples,
|
|||||||
union_of_samples.insert(pair.first);
|
union_of_samples.insert(pair.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (chrono_t time, union_of_samples) {
|
for (chrono_t time : union_of_samples) {
|
||||||
M44d parent_matrix = get_interpolated_matrix_for_time(parent_samples, time);
|
M44d parent_matrix = get_interpolated_matrix_for_time(parent_samples, time);
|
||||||
M44d local_matrix = get_interpolated_matrix_for_time(local_samples, time);
|
M44d local_matrix = get_interpolated_matrix_for_time(local_samples, time);
|
||||||
|
|
||||||
@@ -698,10 +697,10 @@ AttributeRequestSet AlembicObject::get_requested_attributes()
|
|||||||
Geometry *geometry = object->get_geometry();
|
Geometry *geometry = object->get_geometry();
|
||||||
assert(geometry);
|
assert(geometry);
|
||||||
|
|
||||||
foreach (Node *node, geometry->get_used_shaders()) {
|
for (Node *node : geometry->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
|
|
||||||
foreach (const AttributeRequest &attr, shader->attributes.requests) {
|
for (const AttributeRequest &attr : shader->attributes.requests) {
|
||||||
if (!attr.name.empty()) {
|
if (!attr.name.empty()) {
|
||||||
requested_attributes.add(attr.name);
|
requested_attributes.add(attr.name);
|
||||||
}
|
}
|
||||||
@@ -797,7 +796,7 @@ AlembicProcedural::~AlembicProcedural()
|
|||||||
ccl::set<Object *> objects_set;
|
ccl::set<Object *> objects_set;
|
||||||
ccl::set<AlembicObject *> abc_objects_set;
|
ccl::set<AlembicObject *> abc_objects_set;
|
||||||
|
|
||||||
foreach (Node *node, objects) {
|
for (Node *node : objects) {
|
||||||
AlembicObject *abc_object = static_cast<AlembicObject *>(node);
|
AlembicObject *abc_object = static_cast<AlembicObject *>(node);
|
||||||
|
|
||||||
if (abc_object->get_object()) {
|
if (abc_object->get_object()) {
|
||||||
@@ -835,7 +834,7 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress)
|
|||||||
bool need_shader_updates = false;
|
bool need_shader_updates = false;
|
||||||
bool need_data_updates = false;
|
bool need_data_updates = false;
|
||||||
|
|
||||||
foreach (Node *object_node, objects) {
|
for (Node *object_node : objects) {
|
||||||
AlembicObject *object = static_cast<AlembicObject *>(object_node);
|
AlembicObject *object = static_cast<AlembicObject *>(object_node);
|
||||||
|
|
||||||
if (object->is_modified()) {
|
if (object->is_modified()) {
|
||||||
@@ -853,7 +852,7 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for changes in shaders (e.g. newly requested attributes). */
|
/* Check for changes in shaders (e.g. newly requested attributes). */
|
||||||
foreach (Node *shader_node, object->get_used_shaders()) {
|
for (Node *shader_node : object->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(shader_node);
|
Shader *shader = static_cast<Shader *>(shader_node);
|
||||||
|
|
||||||
if (shader->need_update_geometry()) {
|
if (shader->need_update_geometry()) {
|
||||||
@@ -938,7 +937,7 @@ void AlembicProcedural::generate(Scene *scene, Progress &progress)
|
|||||||
|
|
||||||
build_caches(progress);
|
build_caches(progress);
|
||||||
|
|
||||||
foreach (Node *node, objects) {
|
for (Node *node : objects) {
|
||||||
AlembicObject *object = static_cast<AlembicObject *>(node);
|
AlembicObject *object = static_cast<AlembicObject *>(node);
|
||||||
|
|
||||||
if (progress.get_cancel()) {
|
if (progress.get_cancel()) {
|
||||||
@@ -985,7 +984,7 @@ void AlembicProcedural::tag_update(Scene *scene)
|
|||||||
|
|
||||||
AlembicObject *AlembicProcedural::get_or_create_object(const ustring &path)
|
AlembicObject *AlembicProcedural::get_or_create_object(const ustring &path)
|
||||||
{
|
{
|
||||||
foreach (Node *node, objects) {
|
for (Node *node : objects) {
|
||||||
AlembicObject *object = static_cast<AlembicObject *>(node);
|
AlembicObject *object = static_cast<AlembicObject *>(node);
|
||||||
|
|
||||||
if (object->get_path() == path) {
|
if (object->get_path() == path) {
|
||||||
@@ -1005,7 +1004,7 @@ void AlembicProcedural::load_objects(Progress &progress)
|
|||||||
{
|
{
|
||||||
unordered_map<string, AlembicObject *> object_map;
|
unordered_map<string, AlembicObject *> object_map;
|
||||||
|
|
||||||
foreach (Node *node, objects) {
|
for (Node *node : objects) {
|
||||||
AlembicObject *object = static_cast<AlembicObject *>(node);
|
AlembicObject *object = static_cast<AlembicObject *>(node);
|
||||||
|
|
||||||
/* only consider newly added objects */
|
/* only consider newly added objects */
|
||||||
@@ -1058,7 +1057,7 @@ void AlembicProcedural::load_objects(Progress &progress)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Share geometries between instances. */
|
/* Share geometries between instances. */
|
||||||
foreach (Node *node, objects) {
|
for (Node *node : objects) {
|
||||||
AlembicObject *abc_object = static_cast<AlembicObject *>(node);
|
AlembicObject *abc_object = static_cast<AlembicObject *>(node);
|
||||||
|
|
||||||
if (abc_object->instance_of) {
|
if (abc_object->instance_of) {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "scene/mesh.h"
|
#include "scene/mesh.h"
|
||||||
#include "scene/pointcloud.h"
|
#include "scene/pointcloud.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/transform.h"
|
#include "util/transform.h"
|
||||||
|
|
||||||
@@ -495,10 +494,11 @@ Attribute *AttributeSet::add(ustring name, TypeDesc type, AttributeElement eleme
|
|||||||
|
|
||||||
Attribute *AttributeSet::find(ustring name) const
|
Attribute *AttributeSet::find(ustring name) const
|
||||||
{
|
{
|
||||||
foreach (const Attribute &attr, attributes)
|
for (const Attribute &attr : attributes) {
|
||||||
if (attr.name == name) {
|
if (attr.name == name) {
|
||||||
return (Attribute *)&attr;
|
return (Attribute *)&attr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -676,10 +676,11 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
|
|||||||
|
|
||||||
Attribute *AttributeSet::find(AttributeStandard std) const
|
Attribute *AttributeSet::find(AttributeStandard std) const
|
||||||
{
|
{
|
||||||
foreach (const Attribute &attr, attributes)
|
for (const Attribute &attr : attributes) {
|
||||||
if (attr.std == std) {
|
if (attr.std == std) {
|
||||||
return (Attribute *)&attr;
|
return (Attribute *)&attr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -746,7 +747,7 @@ void AttributeSet::remove(list<Attribute>::iterator it)
|
|||||||
|
|
||||||
void AttributeSet::resize(bool reserve_only)
|
void AttributeSet::resize(bool reserve_only)
|
||||||
{
|
{
|
||||||
foreach (Attribute &attr, attributes) {
|
for (Attribute &attr : attributes) {
|
||||||
attr.resize(geometry, prim, reserve_only);
|
attr.resize(geometry, prim, reserve_only);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -784,7 +785,7 @@ void AttributeSet::update(AttributeSet &&new_attributes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Add or update old_attributes based on the new_attributes. */
|
/* Add or update old_attributes based on the new_attributes. */
|
||||||
foreach (Attribute &attr, new_attributes.attributes) {
|
for (Attribute &attr : new_attributes.attributes) {
|
||||||
Attribute *nattr = add(attr.name, attr.type, attr.element);
|
Attribute *nattr = add(attr.name, attr.type, attr.element);
|
||||||
nattr->std = attr.std;
|
nattr->std = attr.std;
|
||||||
nattr->set_data_from(std::move(attr));
|
nattr->set_data_from(std::move(attr));
|
||||||
@@ -796,7 +797,7 @@ void AttributeSet::update(AttributeSet &&new_attributes)
|
|||||||
|
|
||||||
void AttributeSet::clear_modified()
|
void AttributeSet::clear_modified()
|
||||||
{
|
{
|
||||||
foreach (Attribute &attr, attributes) {
|
for (Attribute &attr : attributes) {
|
||||||
attr.modified = false;
|
attr.modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -887,7 +888,7 @@ bool AttributeRequestSet::modified(const AttributeRequestSet &other)
|
|||||||
|
|
||||||
void AttributeRequestSet::add(ustring name)
|
void AttributeRequestSet::add(ustring name)
|
||||||
{
|
{
|
||||||
foreach (AttributeRequest &req, requests) {
|
for (AttributeRequest &req : requests) {
|
||||||
if (req.name == name) {
|
if (req.name == name) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -898,17 +899,18 @@ void AttributeRequestSet::add(ustring name)
|
|||||||
|
|
||||||
void AttributeRequestSet::add(AttributeStandard std)
|
void AttributeRequestSet::add(AttributeStandard std)
|
||||||
{
|
{
|
||||||
foreach (AttributeRequest &req, requests)
|
for (AttributeRequest &req : requests) {
|
||||||
if (req.std == std) {
|
if (req.std == std) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
requests.push_back(AttributeRequest(std));
|
requests.push_back(AttributeRequest(std));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttributeRequestSet::add(AttributeRequestSet &reqs)
|
void AttributeRequestSet::add(AttributeRequestSet &reqs)
|
||||||
{
|
{
|
||||||
foreach (AttributeRequest &req, reqs.requests) {
|
for (AttributeRequest &req : reqs.requests) {
|
||||||
if (req.std == ATTR_STD_NONE) {
|
if (req.std == ATTR_STD_NONE) {
|
||||||
add(req.name);
|
add(req.name);
|
||||||
}
|
}
|
||||||
@@ -936,20 +938,22 @@ void AttributeRequestSet::add_standard(ustring name)
|
|||||||
|
|
||||||
bool AttributeRequestSet::find(ustring name)
|
bool AttributeRequestSet::find(ustring name)
|
||||||
{
|
{
|
||||||
foreach (AttributeRequest &req, requests)
|
for (AttributeRequest &req : requests) {
|
||||||
if (req.name == name) {
|
if (req.name == name) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AttributeRequestSet::find(AttributeStandard std)
|
bool AttributeRequestSet::find(AttributeStandard std)
|
||||||
{
|
{
|
||||||
foreach (AttributeRequest &req, requests)
|
for (AttributeRequest &req : requests) {
|
||||||
if (req.std == std) {
|
if (req.std == std) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include "scene/shader_nodes.h"
|
#include "scene/shader_nodes.h"
|
||||||
#include "scene/stats.h"
|
#include "scene/stats.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/math.h"
|
#include "util/math.h"
|
||||||
#include "util/time.h"
|
#include "util/time.h"
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
#include "scene/stats.h"
|
#include "scene/stats.h"
|
||||||
#include "session/buffers.h"
|
#include "session/buffers.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
bool BakeManager::get_baking() const
|
bool BakeManager::get_baking() const
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include "device/device.h"
|
#include "device/device.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/math_cdf.h"
|
#include "util/math_cdf.h"
|
||||||
#include "util/tbb.h"
|
#include "util/tbb.h"
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "scene/constant_fold.h"
|
#include "scene/constant_fold.h"
|
||||||
#include "scene/shader_graph.h"
|
#include "scene/shader_graph.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
@@ -20,7 +19,7 @@ ConstantFolder::ConstantFolder(ShaderGraph *graph,
|
|||||||
|
|
||||||
bool ConstantFolder::all_inputs_constant() const
|
bool ConstantFolder::all_inputs_constant() const
|
||||||
{
|
{
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (input->link) {
|
if (input->link) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -34,7 +33,7 @@ void ConstantFolder::make_constant(float value) const
|
|||||||
VLOG_DEBUG << "Folding " << node->name << "::" << output->name() << " to constant (" << value
|
VLOG_DEBUG << "Folding " << node->name << "::" << output->name() << " to constant (" << value
|
||||||
<< ").";
|
<< ").";
|
||||||
|
|
||||||
foreach (ShaderInput *sock, output->links) {
|
for (ShaderInput *sock : output->links) {
|
||||||
sock->set(value);
|
sock->set(value);
|
||||||
sock->constant_folded_in = true;
|
sock->constant_folded_in = true;
|
||||||
}
|
}
|
||||||
@@ -47,7 +46,7 @@ void ConstantFolder::make_constant(float3 value) const
|
|||||||
VLOG_DEBUG << "Folding " << node->name << "::" << output->name() << " to constant " << value
|
VLOG_DEBUG << "Folding " << node->name << "::" << output->name() << " to constant " << value
|
||||||
<< ".";
|
<< ".";
|
||||||
|
|
||||||
foreach (ShaderInput *sock, output->links) {
|
for (ShaderInput *sock : output->links) {
|
||||||
sock->set(value);
|
sock->set(value);
|
||||||
sock->constant_folded_in = true;
|
sock->constant_folded_in = true;
|
||||||
}
|
}
|
||||||
@@ -60,7 +59,7 @@ void ConstantFolder::make_constant(int value) const
|
|||||||
VLOG_DEBUG << "Folding " << node->name << "::" << output->name() << " to constant (" << value
|
VLOG_DEBUG << "Folding " << node->name << "::" << output->name() << " to constant (" << value
|
||||||
<< ").";
|
<< ").";
|
||||||
|
|
||||||
foreach (ShaderInput *sock, output->links) {
|
for (ShaderInput *sock : output->links) {
|
||||||
sock->set(value);
|
sock->set(value);
|
||||||
sock->constant_folded_in = true;
|
sock->constant_folded_in = true;
|
||||||
}
|
}
|
||||||
@@ -124,7 +123,7 @@ void ConstantFolder::bypass(ShaderOutput *new_output) const
|
|||||||
|
|
||||||
graph->disconnect(output);
|
graph->disconnect(output);
|
||||||
|
|
||||||
foreach (ShaderInput *sock, outputs) {
|
for (ShaderInput *sock : outputs) {
|
||||||
graph->connect(new_output, sock);
|
graph->connect(new_output, sock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,7 +170,7 @@ bool ConstantFolder::try_bypass_or_make_constant(ShaderInput *input, bool clamp)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* disconnect other inputs if we can't fully bypass due to clamp */
|
/* disconnect other inputs if we can't fully bypass due to clamp */
|
||||||
foreach (ShaderInput *other, node->inputs) {
|
for (ShaderInput *other : node->inputs) {
|
||||||
if (other != input && other->link) {
|
if (other != input && other->link) {
|
||||||
graph->disconnect(other);
|
graph->disconnect(other);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "scene/curves.h"
|
#include "scene/curves.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/math.h"
|
#include "util/math.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include "scene/tables.h"
|
#include "scene/tables.h"
|
||||||
|
|
||||||
#include "util/algorithm.h"
|
#include "util/algorithm.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/math.h"
|
#include "util/math.h"
|
||||||
#include "util/math_cdf.h"
|
#include "util/math_cdf.h"
|
||||||
#include "util/time.h"
|
#include "util/time.h"
|
||||||
@@ -426,7 +426,7 @@ void Film::device_free(Device * /*device*/, DeviceScene * /*dscene*/, Scene *sce
|
|||||||
int Film::get_aov_offset(Scene *scene, string name, bool &is_color)
|
int Film::get_aov_offset(Scene *scene, string name, bool &is_color)
|
||||||
{
|
{
|
||||||
int offset_color = 0, offset_value = 0;
|
int offset_color = 0, offset_value = 0;
|
||||||
foreach (const Pass *pass, scene->passes) {
|
for (const Pass *pass : scene->passes) {
|
||||||
if (pass->get_name() == name) {
|
if (pass->get_name() == name) {
|
||||||
if (pass->get_type() == PASS_AOV_VALUE) {
|
if (pass->get_type() == PASS_AOV_VALUE) {
|
||||||
is_color = false;
|
is_color = false;
|
||||||
@@ -453,7 +453,7 @@ bool Film::update_lightgroups(Scene *scene)
|
|||||||
{
|
{
|
||||||
map<ustring, int> lightgroups;
|
map<ustring, int> lightgroups;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (const Pass *pass, scene->passes) {
|
for (const Pass *pass : scene->passes) {
|
||||||
ustring lightgroup = pass->get_lightgroup();
|
ustring lightgroup = pass->get_lightgroup();
|
||||||
if (!lightgroup.empty()) {
|
if (!lightgroup.empty()) {
|
||||||
if (!lightgroups.count(lightgroup)) {
|
if (!lightgroups.count(lightgroup)) {
|
||||||
@@ -578,8 +578,9 @@ void Film::update_passes(Scene *scene, bool add_sample_count_pass)
|
|||||||
|
|
||||||
if (have_uv_pass != prev_have_uv_pass) {
|
if (have_uv_pass != prev_have_uv_pass) {
|
||||||
scene->geometry_manager->tag_update(scene, GeometryManager::UV_PASS_NEEDED);
|
scene->geometry_manager->tag_update(scene, GeometryManager::UV_PASS_NEEDED);
|
||||||
foreach (Shader *shader, scene->shaders)
|
for (Shader *shader : scene->shaders) {
|
||||||
shader->need_update_uvs = true;
|
shader->need_update_uvs = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (have_motion_pass != prev_have_motion_pass) {
|
if (have_motion_pass != prev_have_motion_pass) {
|
||||||
scene->geometry_manager->tag_update(scene, GeometryManager::MOTION_PASS_NEEDED);
|
scene->geometry_manager->tag_update(scene, GeometryManager::MOTION_PASS_NEEDED);
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
# include "kernel/osl/globals.h"
|
# include "kernel/osl/globals.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
#include "util/task.h"
|
#include "util/task.h"
|
||||||
@@ -133,7 +132,7 @@ bool Geometry::is_instanced() const
|
|||||||
|
|
||||||
bool Geometry::has_true_displacement() const
|
bool Geometry::has_true_displacement() const
|
||||||
{
|
{
|
||||||
foreach (Node *node, used_shaders) {
|
for (Node *node : used_shaders) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->has_displacement && shader->get_displacement_method() != DISPLACE_BUMP) {
|
if (shader->has_displacement && shader->get_displacement_method() != DISPLACE_BUMP) {
|
||||||
return true;
|
return true;
|
||||||
@@ -155,7 +154,7 @@ void Geometry::tag_update(Scene *scene, bool rebuild)
|
|||||||
scene->light_manager->tag_update(scene, LightManager::MESH_NEED_REBUILD);
|
scene->light_manager->tag_update(scene, LightManager::MESH_NEED_REBUILD);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach (Node *node, used_shaders) {
|
for (Node *node : used_shaders) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->emission_sampling != EMISSION_SAMPLING_NONE) {
|
if (shader->emission_sampling != EMISSION_SAMPLING_NONE) {
|
||||||
scene->light_manager->tag_update(scene, LightManager::EMISSIVE_MESH_MODIFIED);
|
scene->light_manager->tag_update(scene, LightManager::EMISSIVE_MESH_MODIFIED);
|
||||||
@@ -214,7 +213,7 @@ void GeometryManager::update_osl_globals(Device *device, Scene *scene)
|
|||||||
static void update_device_flags_attribute(uint32_t &device_update_flags,
|
static void update_device_flags_attribute(uint32_t &device_update_flags,
|
||||||
const AttributeSet &attributes)
|
const AttributeSet &attributes)
|
||||||
{
|
{
|
||||||
foreach (const Attribute &attr, attributes.attributes) {
|
for (const Attribute &attr : attributes.attributes) {
|
||||||
if (!attr.modified) {
|
if (!attr.modified) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -284,7 +283,7 @@ void GeometryManager::geom_calc_offset(Scene *scene, BVHLayout bvh_layout)
|
|||||||
size_t face_size = 0;
|
size_t face_size = 0;
|
||||||
size_t corner_size = 0;
|
size_t corner_size = 0;
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
bool prim_offset_changed = false;
|
bool prim_offset_changed = false;
|
||||||
|
|
||||||
if (geom->is_mesh() || geom->is_volume()) {
|
if (geom->is_mesh() || geom->is_volume()) {
|
||||||
@@ -367,7 +366,7 @@ void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Pro
|
|||||||
/* Update flags. */
|
/* Update flags. */
|
||||||
bool volume_images_updated = false;
|
bool volume_images_updated = false;
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
geom->has_volume = false;
|
geom->has_volume = false;
|
||||||
|
|
||||||
update_attribute_realloc_flags(device_update_flags, geom->attributes);
|
update_attribute_realloc_flags(device_update_flags, geom->attributes);
|
||||||
@@ -377,7 +376,7 @@ void GeometryManager::device_update_preprocess(Device *device, Scene *scene, Pro
|
|||||||
update_attribute_realloc_flags(device_update_flags, mesh->subd_attributes);
|
update_attribute_realloc_flags(device_update_flags, mesh->subd_attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Node *node, geom->get_used_shaders()) {
|
for (Node *node : geom->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->has_volume) {
|
if (shader->has_volume) {
|
||||||
geom->has_volume = true;
|
geom->has_volume = true;
|
||||||
@@ -615,7 +614,7 @@ void GeometryManager::device_update_displacement_images(Device *device,
|
|||||||
#ifdef WITH_OSL
|
#ifdef WITH_OSL
|
||||||
bool has_osl_node = false;
|
bool has_osl_node = false;
|
||||||
#endif
|
#endif
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (geom->is_modified()) {
|
if (geom->is_modified()) {
|
||||||
/* Geometry-level check for hair shadow transparency.
|
/* Geometry-level check for hair shadow transparency.
|
||||||
* This matches the logic in the `Hair::update_shadow_transparency()`, avoiding access to
|
* This matches the logic in the `Hair::update_shadow_transparency()`, avoiding access to
|
||||||
@@ -626,14 +625,14 @@ void GeometryManager::device_update_displacement_images(Device *device,
|
|||||||
need_shadow_transparency = hair->need_shadow_transparency();
|
need_shadow_transparency = hair->need_shadow_transparency();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Node *node, geom->get_used_shaders()) {
|
for (Node *node : geom->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
const bool is_true_displacement = (shader->has_displacement &&
|
const bool is_true_displacement = (shader->has_displacement &&
|
||||||
shader->get_displacement_method() != DISPLACE_BUMP);
|
shader->get_displacement_method() != DISPLACE_BUMP);
|
||||||
if (!is_true_displacement && !need_shadow_transparency) {
|
if (!is_true_displacement && !need_shadow_transparency) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach (ShaderNode *node, shader->graph->nodes) {
|
for (ShaderNode *node : shader->graph->nodes) {
|
||||||
#ifdef WITH_OSL
|
#ifdef WITH_OSL
|
||||||
if (node->special_type == SHADER_SPECIAL_TYPE_OSL) {
|
if (node->special_type == SHADER_SPECIAL_TYPE_OSL) {
|
||||||
has_osl_node = true;
|
has_osl_node = true;
|
||||||
@@ -663,7 +662,7 @@ void GeometryManager::device_update_displacement_images(Device *device,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foreach (int slot, bump_images) {
|
for (int slot : bump_images) {
|
||||||
pool.push([image_manager, device, scene, slot, &progress] {
|
pool.push([image_manager, device, scene, slot, &progress] {
|
||||||
image_manager->device_update_slot(device, scene, slot, progress);
|
image_manager->device_update_slot(device, scene, slot, progress);
|
||||||
});
|
});
|
||||||
@@ -678,12 +677,12 @@ void GeometryManager::device_update_volume_images(Device *device, Scene *scene,
|
|||||||
ImageManager *image_manager = scene->image_manager;
|
ImageManager *image_manager = scene->image_manager;
|
||||||
set<int> volume_images;
|
set<int> volume_images;
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (!geom->is_modified()) {
|
if (!geom->is_modified()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Attribute &attr, geom->attributes.attributes) {
|
for (Attribute &attr : geom->attributes.attributes) {
|
||||||
if (attr.element != ATTR_ELEMENT_VOXEL) {
|
if (attr.element != ATTR_ELEMENT_VOXEL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -700,7 +699,7 @@ void GeometryManager::device_update_volume_images(Device *device, Scene *scene,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (int slot, volume_images) {
|
for (int slot : volume_images) {
|
||||||
pool.push([image_manager, device, scene, slot, &progress] {
|
pool.push([image_manager, device, scene, slot, &progress] {
|
||||||
image_manager->device_update_slot(device, scene, slot, progress);
|
image_manager->device_update_slot(device, scene, slot, progress);
|
||||||
});
|
});
|
||||||
@@ -730,7 +729,7 @@ void GeometryManager::device_update(Device *device,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (geom->is_modified()) {
|
if (geom->is_modified()) {
|
||||||
if (geom->is_mesh() || geom->is_volume()) {
|
if (geom->is_mesh() || geom->is_volume()) {
|
||||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||||
@@ -795,7 +794,7 @@ void GeometryManager::device_update(Device *device,
|
|||||||
dicing_camera->update(scene);
|
dicing_camera->update(scene);
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (!(geom->is_modified() && geom->is_mesh())) {
|
if (!(geom->is_modified() && geom->is_mesh())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -888,7 +887,7 @@ void GeometryManager::device_update(Device *device,
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (geom->is_modified()) {
|
if (geom->is_modified()) {
|
||||||
if (geom->is_mesh()) {
|
if (geom->is_mesh()) {
|
||||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||||
@@ -952,7 +951,7 @@ void GeometryManager::device_update(Device *device,
|
|||||||
TaskPool pool;
|
TaskPool pool;
|
||||||
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (geom->is_modified() || geom->need_update_bvh_for_offset) {
|
if (geom->is_modified() || geom->need_update_bvh_for_offset) {
|
||||||
need_update_scene_bvh = true;
|
need_update_scene_bvh = true;
|
||||||
pool.push([geom, device, dscene, scene, &progress, i, num_bvh] {
|
pool.push([geom, device, dscene, scene, &progress, i, num_bvh] {
|
||||||
@@ -969,7 +968,7 @@ void GeometryManager::device_update(Device *device,
|
|||||||
VLOG_WORK << "Objects BVH build pool statistics:\n" << summary.full_report();
|
VLOG_WORK << "Objects BVH build pool statistics:\n" << summary.full_report();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Shader *shader, scene->shaders) {
|
for (Shader *shader : scene->shaders) {
|
||||||
shader->need_update_uvs = false;
|
shader->need_update_uvs = false;
|
||||||
shader->need_update_attribute = false;
|
shader->need_update_attribute = false;
|
||||||
shader->need_update_displacement = false;
|
shader->need_update_displacement = false;
|
||||||
@@ -985,7 +984,7 @@ void GeometryManager::device_update(Device *device,
|
|||||||
scene->update_stats->geometry.times.add_entry({"device_update (compute bounds)", time});
|
scene->update_stats->geometry.times.add_entry({"device_update (compute bounds)", time});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
object->compute_bounds(motion_blur);
|
object->compute_bounds(motion_blur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1026,7 +1025,7 @@ void GeometryManager::device_update(Device *device,
|
|||||||
|
|
||||||
/* unset flags */
|
/* unset flags */
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
geom->clear_modified();
|
geom->clear_modified();
|
||||||
geom->attributes.clear_modified();
|
geom->attributes.clear_modified();
|
||||||
|
|
||||||
@@ -1127,7 +1126,7 @@ bool GeometryManager::need_update() const
|
|||||||
|
|
||||||
void GeometryManager::collect_statistics(const Scene *scene, RenderStats *stats)
|
void GeometryManager::collect_statistics(const Scene *scene, RenderStats *stats)
|
||||||
{
|
{
|
||||||
foreach (Geometry *geometry, scene->geometry) {
|
for (Geometry *geometry : scene->geometry) {
|
||||||
stats->mesh.geometry.add_entry(
|
stats->mesh.geometry.add_entry(
|
||||||
NamedSizeEntry(string(geometry->name.c_str()), geometry->get_total_size_in_bytes()));
|
NamedSizeEntry(string(geometry->name.c_str()), geometry->get_total_size_in_bytes()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "subd/split.h"
|
#include "subd/split.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
|
|
||||||
@@ -35,7 +34,7 @@ bool Geometry::need_attribute(Scene *scene, AttributeStandard std)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Node *node, used_shaders) {
|
for (Node *node : used_shaders) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->attributes.find(std)) {
|
if (shader->attributes.find(std)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -51,7 +50,7 @@ bool Geometry::need_attribute(Scene * /*scene*/, ustring name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Node *node, used_shaders) {
|
for (Node *node : used_shaders) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->attributes.find(name)) {
|
if (shader->attributes.find(name)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -65,7 +64,7 @@ AttributeRequestSet Geometry::needed_attributes()
|
|||||||
{
|
{
|
||||||
AttributeRequestSet result;
|
AttributeRequestSet result;
|
||||||
|
|
||||||
foreach (Node *node, used_shaders) {
|
for (Node *node : used_shaders) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
result.add(shader->attributes);
|
result.add(shader->attributes);
|
||||||
}
|
}
|
||||||
@@ -75,7 +74,7 @@ AttributeRequestSet Geometry::needed_attributes()
|
|||||||
|
|
||||||
bool Geometry::has_voxel_attributes() const
|
bool Geometry::has_voxel_attributes() const
|
||||||
{
|
{
|
||||||
foreach (const Attribute &attr, attributes.attributes) {
|
for (const Attribute &attr : attributes.attributes) {
|
||||||
if (attr.element == ATTR_ELEMENT_VOXEL) {
|
if (attr.element == ATTR_ELEMENT_VOXEL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -165,7 +164,7 @@ void GeometryManager::update_svm_attributes(Device * /*unused*/,
|
|||||||
|
|
||||||
#ifdef WITH_OSL
|
#ifdef WITH_OSL
|
||||||
size_t attr_count = 0;
|
size_t attr_count = 0;
|
||||||
foreach (AttributeRequest &req, geom_attributes[i].requests) {
|
for (AttributeRequest &req : geom_attributes[i].requests) {
|
||||||
if (req.std != ATTR_STD_NONE &&
|
if (req.std != ATTR_STD_NONE &&
|
||||||
scene->shader_manager->get_attribute_id(req.std) != (uint64_t)req.std)
|
scene->shader_manager->get_attribute_id(req.std) != (uint64_t)req.std)
|
||||||
{
|
{
|
||||||
@@ -214,7 +213,7 @@ void GeometryManager::update_svm_attributes(Device * /*unused*/,
|
|||||||
/* set geometry attributes */
|
/* set geometry attributes */
|
||||||
size_t index = geom->attr_map_offset;
|
size_t index = geom->attr_map_offset;
|
||||||
|
|
||||||
foreach (AttributeRequest &req, attributes.requests) {
|
for (AttributeRequest &req : attributes.requests) {
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
if (req.std == ATTR_STD_NONE) {
|
if (req.std == ATTR_STD_NONE) {
|
||||||
id = scene->shader_manager->get_attribute_id(req.name);
|
id = scene->shader_manager->get_attribute_id(req.name);
|
||||||
@@ -247,7 +246,7 @@ void GeometryManager::update_svm_attributes(Device * /*unused*/,
|
|||||||
if (attributes.size() > 0) {
|
if (attributes.size() > 0) {
|
||||||
size_t index = object->attr_map_offset;
|
size_t index = object->attr_map_offset;
|
||||||
|
|
||||||
foreach (AttributeRequest &req, attributes.requests) {
|
for (AttributeRequest &req : attributes.requests) {
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
if (req.std == ATTR_STD_NONE) {
|
if (req.std == ATTR_STD_NONE) {
|
||||||
id = scene->shader_manager->get_attribute_id(req.name);
|
id = scene->shader_manager->get_attribute_id(req.name);
|
||||||
@@ -495,7 +494,7 @@ void GeometryManager::device_update_attributes(Device *device,
|
|||||||
geom->index = i;
|
geom->index = i;
|
||||||
scene->need_global_attributes(geom_attributes[i]);
|
scene->need_global_attributes(geom_attributes[i]);
|
||||||
|
|
||||||
foreach (Node *node, geom->get_used_shaders()) {
|
for (Node *node : geom->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
geom_attributes[i].add(shader->attributes);
|
geom_attributes[i].add(shader->attributes);
|
||||||
}
|
}
|
||||||
@@ -554,7 +553,7 @@ void GeometryManager::device_update_attributes(Device *device,
|
|||||||
for (size_t i = 0; i < scene->geometry.size(); i++) {
|
for (size_t i = 0; i < scene->geometry.size(); i++) {
|
||||||
Geometry *geom = scene->geometry[i];
|
Geometry *geom = scene->geometry[i];
|
||||||
AttributeRequestSet &attributes = geom_attributes[i];
|
AttributeRequestSet &attributes = geom_attributes[i];
|
||||||
foreach (AttributeRequest &req, attributes.requests) {
|
for (AttributeRequest &req : attributes.requests) {
|
||||||
Attribute *attr = geom->attributes.find(req);
|
Attribute *attr = geom->attributes.find(req);
|
||||||
|
|
||||||
update_attribute_element_size(geom,
|
update_attribute_element_size(geom,
|
||||||
@@ -585,7 +584,7 @@ void GeometryManager::device_update_attributes(Device *device,
|
|||||||
for (size_t i = 0; i < scene->objects.size(); i++) {
|
for (size_t i = 0; i < scene->objects.size(); i++) {
|
||||||
Object *object = scene->objects[i];
|
Object *object = scene->objects[i];
|
||||||
|
|
||||||
foreach (Attribute &attr, object_attribute_values[i].attributes) {
|
for (Attribute &attr : object_attribute_values[i].attributes) {
|
||||||
update_attribute_element_size(object->geometry,
|
update_attribute_element_size(object->geometry,
|
||||||
&attr,
|
&attr,
|
||||||
ATTR_PRIM_GEOMETRY,
|
ATTR_PRIM_GEOMETRY,
|
||||||
@@ -625,7 +624,7 @@ void GeometryManager::device_update_attributes(Device *device,
|
|||||||
|
|
||||||
/* todo: we now store std and name attributes from requests even if
|
/* todo: we now store std and name attributes from requests even if
|
||||||
* they actually refer to the same mesh attributes, optimize */
|
* they actually refer to the same mesh attributes, optimize */
|
||||||
foreach (AttributeRequest &req, attributes.requests) {
|
for (AttributeRequest &req : attributes.requests) {
|
||||||
Attribute *attr = geom->attributes.find(req);
|
Attribute *attr = geom->attributes.find(req);
|
||||||
|
|
||||||
if (attr) {
|
if (attr) {
|
||||||
@@ -686,7 +685,7 @@ void GeometryManager::device_update_attributes(Device *device,
|
|||||||
AttributeRequestSet &attributes = object_attributes[i];
|
AttributeRequestSet &attributes = object_attributes[i];
|
||||||
AttributeSet &values = object_attribute_values[i];
|
AttributeSet &values = object_attribute_values[i];
|
||||||
|
|
||||||
foreach (AttributeRequest &req, attributes.requests) {
|
for (AttributeRequest &req : attributes.requests) {
|
||||||
Attribute *attr = values.find(req);
|
Attribute *attr = values.find(req);
|
||||||
|
|
||||||
if (attr) {
|
if (attr) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#include "scene/shader.h"
|
#include "scene/shader.h"
|
||||||
#include "scene/shader_nodes.h"
|
#include "scene/shader_nodes.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "subd/patch_table.h"
|
#include "subd/patch_table.h"
|
||||||
#include "subd/split.h"
|
#include "subd/split.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
@@ -44,7 +43,7 @@ void GeometryManager::device_update_mesh(Device * /*unused*/,
|
|||||||
|
|
||||||
size_t patch_size = 0;
|
size_t patch_size = 0;
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (geom->is_mesh() || geom->is_volume()) {
|
if (geom->is_mesh() || geom->is_volume()) {
|
||||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||||
|
|
||||||
@@ -93,7 +92,7 @@ void GeometryManager::device_update_mesh(Device * /*unused*/,
|
|||||||
dscene->tri_patch.need_realloc() ||
|
dscene->tri_patch.need_realloc() ||
|
||||||
dscene->tri_patch_uv.need_realloc();
|
dscene->tri_patch_uv.need_realloc();
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (geom->is_mesh() || geom->is_volume()) {
|
if (geom->is_mesh() || geom->is_volume()) {
|
||||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||||
|
|
||||||
@@ -144,7 +143,7 @@ void GeometryManager::device_update_mesh(Device * /*unused*/,
|
|||||||
dscene->curves.need_realloc() ||
|
dscene->curves.need_realloc() ||
|
||||||
dscene->curve_segments.need_realloc();
|
dscene->curve_segments.need_realloc();
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (geom->is_hair()) {
|
if (geom->is_hair()) {
|
||||||
Hair *hair = static_cast<Hair *>(geom);
|
Hair *hair = static_cast<Hair *>(geom);
|
||||||
|
|
||||||
@@ -178,7 +177,7 @@ void GeometryManager::device_update_mesh(Device * /*unused*/,
|
|||||||
float4 *points = dscene->points.alloc(point_size);
|
float4 *points = dscene->points.alloc(point_size);
|
||||||
uint *points_shader = dscene->points_shader.alloc(point_size);
|
uint *points_shader = dscene->points_shader.alloc(point_size);
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (geom->is_pointcloud()) {
|
if (geom->is_pointcloud()) {
|
||||||
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
||||||
pointcloud->pack(
|
pointcloud->pack(
|
||||||
@@ -198,7 +197,7 @@ void GeometryManager::device_update_mesh(Device * /*unused*/,
|
|||||||
|
|
||||||
uint *patch_data = dscene->patches.alloc(patch_size);
|
uint *patch_data = dscene->patches.alloc(patch_size);
|
||||||
|
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
if (geom->is_mesh()) {
|
if (geom->is_mesh()) {
|
||||||
Mesh *mesh = static_cast<Mesh *>(geom);
|
Mesh *mesh = static_cast<Mesh *>(geom);
|
||||||
mesh->pack_patches(&patch_data[mesh->patch_offset]);
|
mesh->pack_patches(&patch_data[mesh->patch_offset]);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include "scene/scene.h"
|
#include "scene/scene.h"
|
||||||
#include "scene/stats.h"
|
#include "scene/stats.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/image.h"
|
#include "util/image.h"
|
||||||
#include "util/image_impl.h"
|
#include "util/image_impl.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
@@ -71,7 +70,7 @@ ImageHandle::ImageHandle(const ImageHandle &other)
|
|||||||
: tile_slots(other.tile_slots), manager(other.manager)
|
: tile_slots(other.tile_slots), manager(other.manager)
|
||||||
{
|
{
|
||||||
/* Increase image user count. */
|
/* Increase image user count. */
|
||||||
foreach (const size_t slot, tile_slots) {
|
for (const size_t slot : tile_slots) {
|
||||||
manager->add_image_user(slot);
|
manager->add_image_user(slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,7 +81,7 @@ ImageHandle &ImageHandle::operator=(const ImageHandle &other)
|
|||||||
manager = other.manager;
|
manager = other.manager;
|
||||||
tile_slots = other.tile_slots;
|
tile_slots = other.tile_slots;
|
||||||
|
|
||||||
foreach (const size_t slot, tile_slots) {
|
for (const size_t slot : tile_slots) {
|
||||||
manager->add_image_user(slot);
|
manager->add_image_user(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +95,7 @@ ImageHandle::~ImageHandle()
|
|||||||
|
|
||||||
void ImageHandle::clear()
|
void ImageHandle::clear()
|
||||||
{
|
{
|
||||||
foreach (const size_t slot, tile_slots) {
|
for (const size_t slot : tile_slots) {
|
||||||
manager->remove_image_user(slot);
|
manager->remove_image_user(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +386,7 @@ ImageHandle ImageManager::add_image(const string &filename,
|
|||||||
ImageHandle handle;
|
ImageHandle handle;
|
||||||
handle.manager = this;
|
handle.manager = this;
|
||||||
|
|
||||||
foreach (int tile, tiles) {
|
for (int tile : tiles) {
|
||||||
string tile_filename = filename;
|
string tile_filename = filename;
|
||||||
|
|
||||||
/* Since we don't have information about the exact tile format used in this code location,
|
/* Since we don't have information about the exact tile format used in this code location,
|
||||||
@@ -922,7 +921,7 @@ void ImageManager::device_free(Device *device)
|
|||||||
|
|
||||||
void ImageManager::collect_statistics(RenderStats *stats)
|
void ImageManager::collect_statistics(RenderStats *stats)
|
||||||
{
|
{
|
||||||
foreach (const Image *image, images) {
|
for (const Image *image : images) {
|
||||||
if (!image) {
|
if (!image) {
|
||||||
/* Image may have been freed due to lack of users. */
|
/* Image may have been freed due to lack of users. */
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
#include "kernel/types.h"
|
#include "kernel/types.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/task.h"
|
#include "util/task.h"
|
||||||
@@ -210,7 +209,7 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene
|
|||||||
* transparent shaders in the scene. Otherwise we can disable it
|
* transparent shaders in the scene. Otherwise we can disable it
|
||||||
* to improve performance a bit. */
|
* to improve performance a bit. */
|
||||||
kintegrator->transparent_shadows = false;
|
kintegrator->transparent_shadows = false;
|
||||||
foreach (Shader *shader, scene->shaders) {
|
for (Shader *shader : scene->shaders) {
|
||||||
/* keep this in sync with SD_HAS_TRANSPARENT_SHADOW in shader.cpp */
|
/* keep this in sync with SD_HAS_TRANSPARENT_SHADOW in shader.cpp */
|
||||||
if ((shader->has_surface_transparent && shader->get_use_transparent_shadow()) ||
|
if ((shader->has_surface_transparent && shader->get_use_transparent_shadow()) ||
|
||||||
shader->has_volume)
|
shader->has_volume)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "integrator/shader_eval.h"
|
#include "integrator/shader_eval.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/path.h"
|
#include "util/path.h"
|
||||||
@@ -220,14 +219,14 @@ LightManager::LightManager()
|
|||||||
|
|
||||||
LightManager::~LightManager()
|
LightManager::~LightManager()
|
||||||
{
|
{
|
||||||
foreach (IESSlot *slot, ies_slots) {
|
for (IESSlot *slot : ies_slots) {
|
||||||
delete slot;
|
delete slot;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LightManager::has_background_light(Scene *scene)
|
bool LightManager::has_background_light(Scene *scene)
|
||||||
{
|
{
|
||||||
foreach (Light *light, scene->lights) {
|
for (Light *light : scene->lights) {
|
||||||
if (light->light_type == LIGHT_BACKGROUND && light->is_enabled) {
|
if (light->light_type == LIGHT_BACKGROUND && light->is_enabled) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -242,7 +241,7 @@ void LightManager::test_enabled_lights(Scene *scene)
|
|||||||
* got portals or not).
|
* got portals or not).
|
||||||
*/
|
*/
|
||||||
bool has_portal = false, has_background = false;
|
bool has_portal = false, has_background = false;
|
||||||
foreach (Light *light, scene->lights) {
|
for (Light *light : scene->lights) {
|
||||||
light->is_enabled = light->has_contribution(scene);
|
light->is_enabled = light->has_contribution(scene);
|
||||||
has_portal |= light->is_portal;
|
has_portal |= light->is_portal;
|
||||||
has_background |= light->light_type == LIGHT_BACKGROUND;
|
has_background |= light->light_type == LIGHT_BACKGROUND;
|
||||||
@@ -261,7 +260,7 @@ void LightManager::test_enabled_lights(Scene *scene)
|
|||||||
if (disable_mis) {
|
if (disable_mis) {
|
||||||
VLOG_INFO << "Background MIS has been disabled.\n";
|
VLOG_INFO << "Background MIS has been disabled.\n";
|
||||||
}
|
}
|
||||||
foreach (Light *light, scene->lights) {
|
for (Light *light : scene->lights) {
|
||||||
if (light->light_type == LIGHT_BACKGROUND) {
|
if (light->light_type == LIGHT_BACKGROUND) {
|
||||||
light->is_enabled = !disable_mis;
|
light->is_enabled = !disable_mis;
|
||||||
background_enabled = !disable_mis;
|
background_enabled = !disable_mis;
|
||||||
@@ -298,7 +297,7 @@ void LightManager::device_update_distribution(Device * /*unused*/,
|
|||||||
|
|
||||||
const int num_lights = kintegrator->num_lights;
|
const int num_lights = kintegrator->num_lights;
|
||||||
const size_t max_num_triangles = std::numeric_limits<int>::max() - 1 - kintegrator->num_lights;
|
const size_t max_num_triangles = std::numeric_limits<int>::max() - 1 - kintegrator->num_lights;
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
if (progress.get_cancel()) {
|
if (progress.get_cancel()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -344,7 +343,7 @@ void LightManager::device_update_distribution(Device * /*unused*/,
|
|||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
if (progress.get_cancel()) {
|
if (progress.get_cancel()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -421,7 +420,7 @@ void LightManager::device_update_distribution(Device * /*unused*/,
|
|||||||
|
|
||||||
if (num_lights > 0) {
|
if (num_lights > 0) {
|
||||||
float lightarea = (totarea > 0.0f) ? totarea / num_lights : 1.0f;
|
float lightarea = (totarea > 0.0f) ? totarea / num_lights : 1.0f;
|
||||||
foreach (Light *light, scene->lights) {
|
for (Light *light : scene->lights) {
|
||||||
if (!light->is_enabled) {
|
if (!light->is_enabled) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -951,7 +950,7 @@ void LightManager::device_update_background(Device *device,
|
|||||||
bool background_mis = false;
|
bool background_mis = false;
|
||||||
|
|
||||||
/* find background light */
|
/* find background light */
|
||||||
foreach (Light *light, scene->lights) {
|
for (Light *light : scene->lights) {
|
||||||
if (light->light_type == LIGHT_BACKGROUND && light->is_enabled) {
|
if (light->light_type == LIGHT_BACKGROUND && light->is_enabled) {
|
||||||
background_light = light;
|
background_light = light;
|
||||||
background_mis |= light->use_mis;
|
background_mis |= light->use_mis;
|
||||||
@@ -976,7 +975,7 @@ void LightManager::device_update_background(Device *device,
|
|||||||
Shader *shader = scene->background->get_shader(scene);
|
Shader *shader = scene->background->get_shader(scene);
|
||||||
int num_suns = 0;
|
int num_suns = 0;
|
||||||
float sun_average_radiance = 0.0f;
|
float sun_average_radiance = 0.0f;
|
||||||
foreach (ShaderNode *node, shader->graph->nodes) {
|
for (ShaderNode *node : shader->graph->nodes) {
|
||||||
if (node->type == EnvironmentTextureNode::get_node_type()) {
|
if (node->type == EnvironmentTextureNode::get_node_type()) {
|
||||||
EnvironmentTextureNode *env = (EnvironmentTextureNode *)node;
|
EnvironmentTextureNode *env = (EnvironmentTextureNode *)node;
|
||||||
if (!env->handle.empty()) {
|
if (!env->handle.empty()) {
|
||||||
@@ -1125,7 +1124,7 @@ void LightManager::device_update_lights(DeviceScene *dscene, Scene *scene)
|
|||||||
size_t num_distant_lights = 0;
|
size_t num_distant_lights = 0;
|
||||||
bool use_light_mis = false;
|
bool use_light_mis = false;
|
||||||
|
|
||||||
foreach (Light *light, scene->lights) {
|
for (Light *light : scene->lights) {
|
||||||
if (light->is_enabled) {
|
if (light->is_enabled) {
|
||||||
num_lights++;
|
num_lights++;
|
||||||
|
|
||||||
@@ -1165,7 +1164,7 @@ void LightManager::device_update_lights(DeviceScene *dscene, Scene *scene)
|
|||||||
int light_index = 0;
|
int light_index = 0;
|
||||||
int portal_index = num_lights;
|
int portal_index = num_lights;
|
||||||
|
|
||||||
foreach (Light *light, scene->lights) {
|
for (Light *light : scene->lights) {
|
||||||
/* Consider moving portals update to their own function
|
/* Consider moving portals update to their own function
|
||||||
* keeping this one more manageable. */
|
* keeping this one more manageable. */
|
||||||
if (light->is_portal) {
|
if (light->is_portal) {
|
||||||
@@ -1560,7 +1559,7 @@ void LightManager::remove_ies(int slot)
|
|||||||
void LightManager::device_update_ies(DeviceScene *dscene)
|
void LightManager::device_update_ies(DeviceScene *dscene)
|
||||||
{
|
{
|
||||||
/* Clear empty slots. */
|
/* Clear empty slots. */
|
||||||
foreach (IESSlot *slot, ies_slots) {
|
for (IESSlot *slot : ies_slots) {
|
||||||
if (slot->users == 0) {
|
if (slot->users == 0) {
|
||||||
slot->hash = 0;
|
slot->hash = 0;
|
||||||
slot->ies.clear();
|
slot->ies.clear();
|
||||||
@@ -1581,7 +1580,7 @@ void LightManager::device_update_ies(DeviceScene *dscene)
|
|||||||
|
|
||||||
if (!ies_slots.empty()) {
|
if (!ies_slots.empty()) {
|
||||||
int packed_size = 0;
|
int packed_size = 0;
|
||||||
foreach (IESSlot *slot, ies_slots) {
|
for (IESSlot *slot : ies_slots) {
|
||||||
packed_size += slot->ies.packed_size();
|
packed_size += slot->ies.packed_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
#include "subd/patch_table.h"
|
#include "subd/patch_table.h"
|
||||||
#include "subd/split.h"
|
#include "subd/split.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/set.h"
|
#include "util/set.h"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "scene/scene.h"
|
#include "scene/scene.h"
|
||||||
#include "scene/shader.h"
|
#include "scene/shader.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/map.h"
|
#include "util/map.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
#include "util/set.h"
|
#include "util/set.h"
|
||||||
@@ -237,7 +236,7 @@ bool GeometryManager::displace(Device *device, Scene *scene, Mesh *mesh, Progres
|
|||||||
|
|
||||||
bool need_recompute_vertex_normals = false;
|
bool need_recompute_vertex_normals = false;
|
||||||
|
|
||||||
foreach (Node *node, mesh->get_used_shaders()) {
|
for (Node *node : mesh->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->has_displacement && shader->get_displacement_method() == DISPLACE_TRUE) {
|
if (shader->has_displacement && shader->get_displacement_method() == DISPLACE_TRUE) {
|
||||||
need_recompute_vertex_normals = true;
|
need_recompute_vertex_normals = true;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "subd/split.h"
|
#include "subd/split.h"
|
||||||
|
|
||||||
#include "util/algorithm.h"
|
#include "util/algorithm.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
@@ -417,7 +416,7 @@ void Mesh::tessellate(DiagSplit *split)
|
|||||||
subdivision_type = SUBDIVISION_LINEAR;
|
subdivision_type = SUBDIVISION_LINEAR;
|
||||||
|
|
||||||
/* force disable attribute subdivision for same reason as above */
|
/* force disable attribute subdivision for same reason as above */
|
||||||
foreach (Attribute &attr, subd_attributes.attributes) {
|
for (Attribute &attr : subd_attributes.attributes) {
|
||||||
attr.flags &= ~ATTR_SUBDIVIDED;
|
attr.flags &= ~ATTR_SUBDIVIDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -566,7 +565,7 @@ void Mesh::tessellate(DiagSplit *split)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* interpolate center points for attributes */
|
/* interpolate center points for attributes */
|
||||||
foreach (Attribute &attr, subd_attributes.attributes) {
|
for (Attribute &attr : subd_attributes.attributes) {
|
||||||
#ifdef WITH_OPENSUBDIV
|
#ifdef WITH_OPENSUBDIV
|
||||||
if (subdivision_type == SUBDIVISION_CATMULL_CLARK && attr.flags & ATTR_SUBDIVIDED) {
|
if (subdivision_type == SUBDIVISION_CATMULL_CLARK && attr.flags & ATTR_SUBDIVIDED) {
|
||||||
if (attr.element == ATTR_ELEMENT_CORNER || attr.element == ATTR_ELEMENT_CORNER_BYTE) {
|
if (attr.element == ATTR_ELEMENT_CORNER || attr.element == ATTR_ELEMENT_CORNER_BYTE) {
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#include "scene/stats.h"
|
#include "scene/stats.h"
|
||||||
#include "scene/volume.h"
|
#include "scene/volume.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/map.h"
|
#include "util/map.h"
|
||||||
#include "util/murmurhash.h"
|
#include "util/murmurhash.h"
|
||||||
@@ -236,7 +235,7 @@ void Object::tag_update(Scene *scene)
|
|||||||
flag |= ObjectManager::VISIBILITY_MODIFIED;
|
flag |= ObjectManager::VISIBILITY_MODIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Node *node, geometry->get_used_shaders()) {
|
for (Node *node : geometry->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->emission_sampling != EMISSION_SAMPLING_NONE) {
|
if (shader->emission_sampling != EMISSION_SAMPLING_NONE) {
|
||||||
scene->light_manager->tag_update(scene, LightManager::EMISSIVE_MESH_MODIFIED);
|
scene->light_manager->tag_update(scene, LightManager::EMISSIVE_MESH_MODIFIED);
|
||||||
@@ -301,7 +300,7 @@ float Object::compute_volume_step_size() const
|
|||||||
/* Compute step rate from shaders. */
|
/* Compute step rate from shaders. */
|
||||||
float step_rate = FLT_MAX;
|
float step_rate = FLT_MAX;
|
||||||
|
|
||||||
foreach (Node *node, mesh->get_used_shaders()) {
|
for (Node *node : mesh->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->has_volume) {
|
if (shader->has_volume) {
|
||||||
if ((shader->get_heterogeneous_volume() && shader->has_volume_spatial_varying) ||
|
if ((shader->get_heterogeneous_volume() && shader->has_volume_spatial_varying) ||
|
||||||
@@ -322,7 +321,7 @@ float Object::compute_volume_step_size() const
|
|||||||
if (geometry->is_volume()) {
|
if (geometry->is_volume()) {
|
||||||
Volume *volume = static_cast<Volume *>(geometry);
|
Volume *volume = static_cast<Volume *>(geometry);
|
||||||
|
|
||||||
foreach (Attribute &attr, volume->attributes.attributes) {
|
for (Attribute &attr : volume->attributes.attributes) {
|
||||||
if (attr.element == ATTR_ELEMENT_VOXEL) {
|
if (attr.element == ATTR_ELEMENT_VOXEL) {
|
||||||
ImageHandle &handle = attr.data_voxel();
|
ImageHandle &handle = attr.data_voxel();
|
||||||
const ImageMetaData &metadata = handle.metadata();
|
const ImageMetaData &metadata = handle.metadata();
|
||||||
@@ -404,7 +403,7 @@ bool Object::usable_as_light() const
|
|||||||
* iterate all geometry shaders twice (when counting and when calculating
|
* iterate all geometry shaders twice (when counting and when calculating
|
||||||
* triangle area.
|
* triangle area.
|
||||||
*/
|
*/
|
||||||
foreach (Node *node, geom->get_used_shaders()) {
|
for (Node *node : geom->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->emission_sampling != EMISSION_SAMPLING_NONE) {
|
if (shader->emission_sampling != EMISSION_SAMPLING_NONE) {
|
||||||
return true;
|
return true;
|
||||||
@@ -651,7 +650,7 @@ void ObjectManager::device_update_prim_offsets(Device *device, DeviceScene *dsce
|
|||||||
/* On MetalRT, primitive / curve segment offsets can't be baked at BVH build time. Intersection
|
/* On MetalRT, primitive / curve segment offsets can't be baked at BVH build time. Intersection
|
||||||
* handlers need to apply the offset manually. */
|
* handlers need to apply the offset manually. */
|
||||||
uint *object_prim_offset = dscene->object_prim_offset.alloc(scene->objects.size());
|
uint *object_prim_offset = dscene->object_prim_offset.alloc(scene->objects.size());
|
||||||
foreach (Object *ob, scene->objects) {
|
for (Object *ob : scene->objects) {
|
||||||
uint32_t prim_offset = 0;
|
uint32_t prim_offset = 0;
|
||||||
if (Geometry *const geom = ob->geometry) {
|
if (Geometry *const geom = ob->geometry) {
|
||||||
if (geom->is_hair()) {
|
if (geom->is_hair()) {
|
||||||
@@ -695,7 +694,7 @@ void ObjectManager::device_update_transforms(DeviceScene *dscene, Scene *scene,
|
|||||||
uint *motion_offsets = state.motion_offset.resize(scene->objects.size());
|
uint *motion_offsets = state.motion_offset.resize(scene->objects.size());
|
||||||
uint motion_offset = 0;
|
uint motion_offset = 0;
|
||||||
|
|
||||||
foreach (Object *ob, scene->objects) {
|
for (Object *ob : scene->objects) {
|
||||||
*motion_offsets = motion_offset;
|
*motion_offsets = motion_offset;
|
||||||
motion_offsets++;
|
motion_offsets++;
|
||||||
|
|
||||||
@@ -711,7 +710,7 @@ void ObjectManager::device_update_transforms(DeviceScene *dscene, Scene *scene,
|
|||||||
* 0 is dummy particle, index starts at 1.
|
* 0 is dummy particle, index starts at 1.
|
||||||
*/
|
*/
|
||||||
int numparticles = 1;
|
int numparticles = 1;
|
||||||
foreach (ParticleSystem *psys, scene->particle_systems) {
|
for (ParticleSystem *psys : scene->particle_systems) {
|
||||||
state.particle_offset[psys] = numparticles;
|
state.particle_offset[psys] = numparticles;
|
||||||
numparticles += psys->particles.size();
|
numparticles += psys->particles.size();
|
||||||
}
|
}
|
||||||
@@ -794,7 +793,7 @@ void ObjectManager::device_update(Device *device,
|
|||||||
});
|
});
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
object->index = index++;
|
object->index = index++;
|
||||||
|
|
||||||
/* this is a bit too broad, however a bigger refactor might be needed to properly separate
|
/* this is a bit too broad, however a bigger refactor might be needed to properly separate
|
||||||
@@ -840,7 +839,7 @@ void ObjectManager::device_update(Device *device,
|
|||||||
apply_static_transforms(dscene, scene, progress);
|
apply_static_transforms(dscene, scene, progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
object->clear_modified();
|
object->clear_modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -882,7 +881,7 @@ void ObjectManager::device_update_flags(Device * /*unused*/,
|
|||||||
/* Object volume intersection. */
|
/* Object volume intersection. */
|
||||||
vector<Object *> volume_objects;
|
vector<Object *> volume_objects;
|
||||||
bool has_volume_objects = false;
|
bool has_volume_objects = false;
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
if (object->geometry->has_volume) {
|
if (object->geometry->has_volume) {
|
||||||
/* If the bounds are not valid it is not always possible to calculate the volume step, and
|
/* If the bounds are not valid it is not always possible to calculate the volume step, and
|
||||||
* the step size is not needed for the displacement. So, delay calculation of the volume
|
* the step size is not needed for the displacement. So, delay calculation of the volume
|
||||||
@@ -901,12 +900,12 @@ void ObjectManager::device_update_flags(Device * /*unused*/,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
if (object->geometry->has_volume) {
|
if (object->geometry->has_volume) {
|
||||||
object_flag[object->index] |= SD_OBJECT_HAS_VOLUME;
|
object_flag[object->index] |= SD_OBJECT_HAS_VOLUME;
|
||||||
object_flag[object->index] &= ~SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
|
object_flag[object->index] &= ~SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
|
||||||
|
|
||||||
foreach (Attribute &attr, object->geometry->attributes.attributes) {
|
for (Attribute &attr : object->geometry->attributes.attributes) {
|
||||||
if (attr.element == ATTR_ELEMENT_VOXEL) {
|
if (attr.element == ATTR_ELEMENT_VOXEL) {
|
||||||
object_flag[object->index] |= SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
|
object_flag[object->index] |= SD_OBJECT_HAS_VOLUME_ATTRIBUTES;
|
||||||
}
|
}
|
||||||
@@ -925,7 +924,7 @@ void ObjectManager::device_update_flags(Device * /*unused*/,
|
|||||||
|
|
||||||
if (bounds_valid) {
|
if (bounds_valid) {
|
||||||
object->intersects_volume = false;
|
object->intersects_volume = false;
|
||||||
foreach (Object *volume_object, volume_objects) {
|
for (Object *volume_object : volume_objects) {
|
||||||
if (object == volume_object) {
|
if (object == volume_object) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -964,7 +963,7 @@ void ObjectManager::device_update_geom_offsets(Device * /*unused*/,
|
|||||||
|
|
||||||
bool update = false;
|
bool update = false;
|
||||||
|
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
Geometry *geom = object->geometry;
|
Geometry *geom = object->geometry;
|
||||||
|
|
||||||
if (geom->is_mesh()) {
|
if (geom->is_mesh()) {
|
||||||
@@ -1021,7 +1020,7 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, P
|
|||||||
bool apply_to_motion = need_motion != Scene::MOTION_PASS;
|
bool apply_to_motion = need_motion != Scene::MOTION_PASS;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
map<Geometry *, int>::iterator it = geometry_users.find(object->geometry);
|
map<Geometry *, int>::iterator it = geometry_users.find(object->geometry);
|
||||||
|
|
||||||
if (it == geometry_users.end()) {
|
if (it == geometry_users.end()) {
|
||||||
@@ -1039,7 +1038,7 @@ void ObjectManager::apply_static_transforms(DeviceScene *dscene, Scene *scene, P
|
|||||||
uint *object_flag = dscene->object_flag.data();
|
uint *object_flag = dscene->object_flag.data();
|
||||||
|
|
||||||
/* apply transforms for objects with single user geometry */
|
/* apply transforms for objects with single user geometry */
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
/* Annoying feedback loop here: we can't use is_instanced() because
|
/* Annoying feedback loop here: we can't use is_instanced() because
|
||||||
* it'll use uninitialized transform_applied flag.
|
* it'll use uninitialized transform_applied flag.
|
||||||
*
|
*
|
||||||
@@ -1122,7 +1121,7 @@ string ObjectManager::get_cryptomatte_objects(Scene *scene)
|
|||||||
string manifest = "{";
|
string manifest = "{";
|
||||||
|
|
||||||
unordered_set<ustring> objects;
|
unordered_set<ustring> objects;
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
if (objects.count(object->name)) {
|
if (objects.count(object->name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -1138,7 +1137,7 @@ string ObjectManager::get_cryptomatte_assets(Scene *scene)
|
|||||||
{
|
{
|
||||||
string manifest = "{";
|
string manifest = "{";
|
||||||
unordered_set<ustring> assets;
|
unordered_set<ustring> assets;
|
||||||
foreach (Object *ob, scene->objects) {
|
for (Object *ob : scene->objects) {
|
||||||
if (assets.count(ob->asset_name)) {
|
if (assets.count(ob->asset_name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
# include "kernel/osl/services.h"
|
# include "kernel/osl/services.h"
|
||||||
|
|
||||||
# include "util/aligned_malloc.h"
|
# include "util/aligned_malloc.h"
|
||||||
# include "util/foreach.h"
|
|
||||||
# include "util/log.h"
|
# include "util/log.h"
|
||||||
# include "util/md5.h"
|
# include "util/md5.h"
|
||||||
# include "util/path.h"
|
# include "util/path.h"
|
||||||
@@ -120,7 +119,7 @@ void OSLShaderManager::device_update_specific(Device *device,
|
|||||||
|
|
||||||
/* compile each shader to OSL shader groups */
|
/* compile each shader to OSL shader groups */
|
||||||
TaskPool task_pool;
|
TaskPool task_pool;
|
||||||
foreach (Shader *shader, scene->shaders) {
|
for (Shader *shader : scene->shaders) {
|
||||||
assert(shader->graph);
|
assert(shader->graph);
|
||||||
|
|
||||||
auto compile = [this, scene, shader, background_shader](Device *sub_device) {
|
auto compile = [this, scene, shader, background_shader](Device *sub_device) {
|
||||||
@@ -140,7 +139,7 @@ void OSLShaderManager::device_update_specific(Device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* collect shader groups from all shaders */
|
/* collect shader groups from all shaders */
|
||||||
foreach (Shader *shader, scene->shaders) {
|
for (Shader *shader : scene->shaders) {
|
||||||
device->foreach_device([shader, background_shader](Device *sub_device) {
|
device->foreach_device([shader, background_shader](Device *sub_device) {
|
||||||
OSLGlobals *og = (OSLGlobals *)sub_device->get_cpu_osl_memory();
|
OSLGlobals *og = (OSLGlobals *)sub_device->get_cpu_osl_memory();
|
||||||
|
|
||||||
@@ -172,8 +171,9 @@ void OSLShaderManager::device_update_specific(Device *device,
|
|||||||
og->use = true;
|
og->use = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (Shader *shader, scene->shaders)
|
for (Shader *shader : scene->shaders) {
|
||||||
shader->clear_modified();
|
shader->clear_modified();
|
||||||
|
}
|
||||||
|
|
||||||
update_flags = UPDATE_NONE;
|
update_flags = UPDATE_NONE;
|
||||||
|
|
||||||
@@ -763,7 +763,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderInput *input)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if output exists with the same name, add "In" suffix */
|
/* if output exists with the same name, add "In" suffix */
|
||||||
foreach (ShaderOutput *output, node->outputs) {
|
for (ShaderOutput *output : node->outputs) {
|
||||||
if (input->name() == output->name()) {
|
if (input->name() == output->name()) {
|
||||||
sname += "In";
|
sname += "In";
|
||||||
break;
|
break;
|
||||||
@@ -784,7 +784,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderOutput *output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if input exists with the same name, add "Out" suffix */
|
/* if input exists with the same name, add "Out" suffix */
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (input->name() == output->name()) {
|
if (input->name() == output->name()) {
|
||||||
sname += "Out";
|
sname += "Out";
|
||||||
break;
|
break;
|
||||||
@@ -843,7 +843,7 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* pass in fixed parameter values */
|
/* pass in fixed parameter values */
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (!input->link) {
|
if (!input->link) {
|
||||||
/* checks to untangle graphs */
|
/* checks to untangle graphs */
|
||||||
if (node_skip_input(node, input)) {
|
if (node_skip_input(node, input)) {
|
||||||
@@ -904,7 +904,7 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* link inputs to other nodes */
|
/* link inputs to other nodes */
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (input->link) {
|
if (input->link) {
|
||||||
if (node_skip_input(node, input)) {
|
if (node_skip_input(node, input)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1208,10 +1208,11 @@ void OSLCompiler::find_dependencies(ShaderNodeSet &dependencies, ShaderInput *in
|
|||||||
ShaderNode *node = (input->link) ? input->link->parent : nullptr;
|
ShaderNode *node = (input->link) ? input->link->parent : nullptr;
|
||||||
|
|
||||||
if (node != nullptr && dependencies.find(node) == dependencies.end()) {
|
if (node != nullptr && dependencies.find(node) == dependencies.end()) {
|
||||||
foreach (ShaderInput *in, node->inputs)
|
for (ShaderInput *in : node->inputs) {
|
||||||
if (!node_skip_input(node, in)) {
|
if (!node_skip_input(node, in)) {
|
||||||
find_dependencies(dependencies, in);
|
find_dependencies(dependencies, in);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies.insert(node);
|
dependencies.insert(node);
|
||||||
}
|
}
|
||||||
@@ -1225,16 +1226,17 @@ void OSLCompiler::generate_nodes(const ShaderNodeSet &nodes)
|
|||||||
do {
|
do {
|
||||||
nodes_done = true;
|
nodes_done = true;
|
||||||
|
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (done.find(node) == done.end()) {
|
if (done.find(node) == done.end()) {
|
||||||
bool inputs_done = true;
|
bool inputs_done = true;
|
||||||
|
|
||||||
foreach (ShaderInput *input, node->inputs)
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (!node_skip_input(node, input)) {
|
if (!node_skip_input(node, input)) {
|
||||||
if (input->link && done.find(input->link->parent) == done.end()) {
|
if (input->link && done.find(input->link->parent) == done.end()) {
|
||||||
inputs_done = false;
|
inputs_done = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (inputs_done) {
|
if (inputs_done) {
|
||||||
node->compile(*this);
|
node->compile(*this);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "scene/scene.h"
|
#include "scene/scene.h"
|
||||||
#include "scene/stats.h"
|
#include "scene/stats.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include "scene/scene.h"
|
#include "scene/scene.h"
|
||||||
#include "scene/stats.h"
|
#include "scene/stats.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
@@ -42,7 +41,7 @@ void ProceduralManager::update(Scene *scene, Progress &progress)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (Procedural *procedural, scene->procedurals) {
|
for (Procedural *procedural : scene->procedurals) {
|
||||||
if (progress.get_cancel()) {
|
if (progress.get_cancel()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
#include "scene/volume.h"
|
#include "scene/volume.h"
|
||||||
#include "session/session.h"
|
#include "session/session.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/guarded_allocator.h"
|
#include "util/guarded_allocator.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
@@ -97,18 +96,24 @@ void Scene::free_memory(bool final)
|
|||||||
* Similarly, we first delete all nodes and their associated device data, and then the managers
|
* Similarly, we first delete all nodes and their associated device data, and then the managers
|
||||||
* and their associated device data.
|
* and their associated device data.
|
||||||
*/
|
*/
|
||||||
foreach (Procedural *p, procedurals)
|
for (Procedural *p : procedurals) {
|
||||||
delete p;
|
delete p;
|
||||||
foreach (Object *o, objects)
|
}
|
||||||
|
for (Object *o : objects) {
|
||||||
delete o;
|
delete o;
|
||||||
foreach (Geometry *g, geometry)
|
}
|
||||||
|
for (Geometry *g : geometry) {
|
||||||
delete g;
|
delete g;
|
||||||
foreach (ParticleSystem *p, particle_systems)
|
}
|
||||||
|
for (ParticleSystem *p : particle_systems) {
|
||||||
delete p;
|
delete p;
|
||||||
foreach (Light *l, lights)
|
}
|
||||||
|
for (Light *l : lights) {
|
||||||
delete l;
|
delete l;
|
||||||
foreach (Pass *p, passes)
|
}
|
||||||
|
for (Pass *p : passes) {
|
||||||
delete p;
|
delete p;
|
||||||
|
}
|
||||||
|
|
||||||
geometry.clear();
|
geometry.clear();
|
||||||
objects.clear();
|
objects.clear();
|
||||||
@@ -134,8 +139,9 @@ void Scene::free_memory(bool final)
|
|||||||
|
|
||||||
/* Delete Shaders after every other nodes to ensure that we do not try to decrement the reference
|
/* Delete Shaders after every other nodes to ensure that we do not try to decrement the reference
|
||||||
* count on some dangling pointer. */
|
* count on some dangling pointer. */
|
||||||
foreach (Shader *s, shaders)
|
for (Shader *s : shaders) {
|
||||||
delete s;
|
delete s;
|
||||||
|
}
|
||||||
|
|
||||||
shaders.clear();
|
shaders.clear();
|
||||||
|
|
||||||
@@ -491,7 +497,7 @@ void Scene::update_kernel_features()
|
|||||||
bool has_caustics_caster = false;
|
bool has_caustics_caster = false;
|
||||||
bool has_caustics_light = false;
|
bool has_caustics_light = false;
|
||||||
|
|
||||||
foreach (Object *object, objects) {
|
for (Object *object : objects) {
|
||||||
if (object->get_is_caustics_caster()) {
|
if (object->get_is_caustics_caster()) {
|
||||||
has_caustics_caster = true;
|
has_caustics_caster = true;
|
||||||
}
|
}
|
||||||
@@ -529,7 +535,7 @@ void Scene::update_kernel_features()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Light *light, lights) {
|
for (Light *light : lights) {
|
||||||
if (light->get_use_caustics()) {
|
if (light->get_use_caustics()) {
|
||||||
has_caustics_light = true;
|
has_caustics_light = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "scene/svm.h"
|
#include "scene/svm.h"
|
||||||
#include "scene/tables.h"
|
#include "scene/tables.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/murmurhash.h"
|
#include "util/murmurhash.h"
|
||||||
#include "util/transform.h"
|
#include "util/transform.h"
|
||||||
@@ -236,7 +235,7 @@ static float3 output_estimate_emission(ShaderOutput *output, bool &is_constant)
|
|||||||
estimate = zero_float3();
|
estimate = zero_float3();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const ShaderInput *in, node->inputs) {
|
for (const ShaderInput *in : node->inputs) {
|
||||||
if (in->type() == SocketType::CLOSURE && in->link) {
|
if (in->type() == SocketType::CLOSURE && in->link) {
|
||||||
estimate += output_estimate_emission(in->link, is_constant);
|
estimate += output_estimate_emission(in->link, is_constant);
|
||||||
}
|
}
|
||||||
@@ -255,7 +254,7 @@ void Shader::estimate_emission()
|
|||||||
/* If the shader has AOVs, they need to be evaluated, so we can't skip the shader. */
|
/* If the shader has AOVs, they need to be evaluated, so we can't skip the shader. */
|
||||||
emission_is_constant = true;
|
emission_is_constant = true;
|
||||||
|
|
||||||
foreach (ShaderNode *node, graph->nodes) {
|
for (ShaderNode *node : graph->nodes) {
|
||||||
if (node->special_type == SHADER_SPECIAL_TYPE_OUTPUT_AOV) {
|
if (node->special_type == SHADER_SPECIAL_TYPE_OUTPUT_AOV) {
|
||||||
emission_is_constant = false;
|
emission_is_constant = false;
|
||||||
}
|
}
|
||||||
@@ -350,9 +349,9 @@ void Shader::tag_update(Scene *scene)
|
|||||||
if (!has_surface && !has_volume) {
|
if (!has_surface && !has_volume) {
|
||||||
/* If we need to output surface AOVs, add a Transparent BSDF so that the
|
/* If we need to output surface AOVs, add a Transparent BSDF so that the
|
||||||
* surface shader runs. */
|
* surface shader runs. */
|
||||||
foreach (ShaderNode *node, graph->nodes) {
|
for (ShaderNode *node : graph->nodes) {
|
||||||
if (node->special_type == SHADER_SPECIAL_TYPE_OUTPUT_AOV) {
|
if (node->special_type == SHADER_SPECIAL_TYPE_OUTPUT_AOV) {
|
||||||
foreach (const ShaderInput *in, node->inputs) {
|
for (const ShaderInput *in : node->inputs) {
|
||||||
if (in->link) {
|
if (in->link) {
|
||||||
TransparentBsdfNode *transparent = graph->create_node<TransparentBsdfNode>();
|
TransparentBsdfNode *transparent = graph->create_node<TransparentBsdfNode>();
|
||||||
graph->add(transparent);
|
graph->add(transparent);
|
||||||
@@ -376,7 +375,7 @@ void Shader::tag_update(Scene *scene)
|
|||||||
AttributeRequestSet prev_attributes = attributes;
|
AttributeRequestSet prev_attributes = attributes;
|
||||||
|
|
||||||
attributes.clear();
|
attributes.clear();
|
||||||
foreach (ShaderNode *node, graph->nodes) {
|
for (ShaderNode *node : graph->nodes) {
|
||||||
node->attributes(this, &attributes);
|
node->attributes(this, &attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,7 +499,7 @@ void ShaderManager::device_update(Device *device,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint id = 0;
|
uint id = 0;
|
||||||
foreach (Shader *shader, scene->shaders) {
|
for (Shader *shader : scene->shaders) {
|
||||||
shader->id = id++;
|
shader->id = id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,7 +528,7 @@ void ShaderManager::device_update_common(Device * /*device*/,
|
|||||||
bool has_volumes = false;
|
bool has_volumes = false;
|
||||||
bool has_transparent_shadow = false;
|
bool has_transparent_shadow = false;
|
||||||
|
|
||||||
foreach (Shader *shader, scene->shaders) {
|
for (Shader *shader : scene->shaders) {
|
||||||
uint flag = 0;
|
uint flag = 0;
|
||||||
|
|
||||||
if (shader->emission_sampling == EMISSION_SAMPLING_FRONT) {
|
if (shader->emission_sampling == EMISSION_SAMPLING_FRONT) {
|
||||||
@@ -743,7 +742,7 @@ uint ShaderManager::get_graph_kernel_features(ShaderGraph *graph)
|
|||||||
{
|
{
|
||||||
uint kernel_features = 0;
|
uint kernel_features = 0;
|
||||||
|
|
||||||
foreach (ShaderNode *node, graph->nodes) {
|
for (ShaderNode *node : graph->nodes) {
|
||||||
kernel_features |= node->get_feature();
|
kernel_features |= node->get_feature();
|
||||||
if (node->special_type == SHADER_SPECIAL_TYPE_CLOSURE) {
|
if (node->special_type == SHADER_SPECIAL_TYPE_CLOSURE) {
|
||||||
BsdfBaseNode *bsdf_node = static_cast<BsdfBaseNode *>(node);
|
BsdfBaseNode *bsdf_node = static_cast<BsdfBaseNode *>(node);
|
||||||
@@ -818,7 +817,7 @@ string ShaderManager::get_cryptomatte_materials(Scene *scene)
|
|||||||
{
|
{
|
||||||
string manifest = "{";
|
string manifest = "{";
|
||||||
unordered_set<ustring> materials;
|
unordered_set<ustring> materials;
|
||||||
foreach (Shader *shader, scene->shaders) {
|
for (Shader *shader : scene->shaders) {
|
||||||
if (materials.count(shader->name)) {
|
if (materials.count(shader->name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "scene/shader_nodes.h"
|
#include "scene/shader_nodes.h"
|
||||||
|
|
||||||
#include "util/algorithm.h"
|
#include "util/algorithm.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/md5.h"
|
#include "util/md5.h"
|
||||||
#include "util/queue.h"
|
#include "util/queue.h"
|
||||||
@@ -21,7 +21,7 @@ namespace {
|
|||||||
|
|
||||||
bool check_node_inputs_has_links(const ShaderNode *node)
|
bool check_node_inputs_has_links(const ShaderNode *node)
|
||||||
{
|
{
|
||||||
foreach (const ShaderInput *in, node->inputs) {
|
for (const ShaderInput *in : node->inputs) {
|
||||||
if (in->link) {
|
if (in->link) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ bool check_node_inputs_has_links(const ShaderNode *node)
|
|||||||
|
|
||||||
bool check_node_inputs_traversed(const ShaderNode *node, const ShaderNodeSet &done)
|
bool check_node_inputs_traversed(const ShaderNode *node, const ShaderNodeSet &done)
|
||||||
{
|
{
|
||||||
foreach (const ShaderInput *in, node->inputs) {
|
for (const ShaderInput *in : node->inputs) {
|
||||||
if (in->link) {
|
if (in->link) {
|
||||||
if (done.find(in->link->parent) == done.end()) {
|
if (done.find(in->link->parent) == done.end()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -55,7 +55,7 @@ void ShaderInput::disconnect()
|
|||||||
|
|
||||||
void ShaderOutput::disconnect()
|
void ShaderOutput::disconnect()
|
||||||
{
|
{
|
||||||
foreach (ShaderInput *sock, links) {
|
for (ShaderInput *sock : links) {
|
||||||
sock->link = nullptr;
|
sock->link = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,29 +76,31 @@ ShaderNode::ShaderNode(const NodeType *type) : Node(type)
|
|||||||
|
|
||||||
ShaderNode::~ShaderNode()
|
ShaderNode::~ShaderNode()
|
||||||
{
|
{
|
||||||
foreach (ShaderInput *socket, inputs)
|
for (ShaderInput *socket : inputs) {
|
||||||
delete socket;
|
delete socket;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (ShaderOutput *socket, outputs)
|
for (ShaderOutput *socket : outputs) {
|
||||||
delete socket;
|
delete socket;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderNode::create_inputs_outputs(const NodeType *type)
|
void ShaderNode::create_inputs_outputs(const NodeType *type)
|
||||||
{
|
{
|
||||||
foreach (const SocketType &socket, type->inputs) {
|
for (const SocketType &socket : type->inputs) {
|
||||||
if (socket.flags & SocketType::LINKABLE) {
|
if (socket.flags & SocketType::LINKABLE) {
|
||||||
inputs.push_back(new ShaderInput(socket, this));
|
inputs.push_back(new ShaderInput(socket, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const SocketType &socket, type->outputs) {
|
for (const SocketType &socket : type->outputs) {
|
||||||
outputs.push_back(new ShaderOutput(socket, this));
|
outputs.push_back(new ShaderOutput(socket, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderInput *ShaderNode::input(const char *name)
|
ShaderInput *ShaderNode::input(const char *name)
|
||||||
{
|
{
|
||||||
foreach (ShaderInput *socket, inputs) {
|
for (ShaderInput *socket : inputs) {
|
||||||
if (socket->name() == name) {
|
if (socket->name() == name) {
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
@@ -109,17 +111,18 @@ ShaderInput *ShaderNode::input(const char *name)
|
|||||||
|
|
||||||
ShaderOutput *ShaderNode::output(const char *name)
|
ShaderOutput *ShaderNode::output(const char *name)
|
||||||
{
|
{
|
||||||
foreach (ShaderOutput *socket, outputs)
|
for (ShaderOutput *socket : outputs) {
|
||||||
if (socket->name() == name) {
|
if (socket->name() == name) {
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderInput *ShaderNode::input(ustring name)
|
ShaderInput *ShaderNode::input(ustring name)
|
||||||
{
|
{
|
||||||
foreach (ShaderInput *socket, inputs) {
|
for (ShaderInput *socket : inputs) {
|
||||||
if (socket->name() == name) {
|
if (socket->name() == name) {
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
@@ -130,10 +133,11 @@ ShaderInput *ShaderNode::input(ustring name)
|
|||||||
|
|
||||||
ShaderOutput *ShaderNode::output(ustring name)
|
ShaderOutput *ShaderNode::output(ustring name)
|
||||||
{
|
{
|
||||||
foreach (ShaderOutput *socket, outputs)
|
for (ShaderOutput *socket : outputs) {
|
||||||
if (socket->name() == name) {
|
if (socket->name() == name) {
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -147,7 +151,7 @@ void ShaderNode::remove_input(ShaderInput *input)
|
|||||||
|
|
||||||
void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
|
void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
|
||||||
{
|
{
|
||||||
foreach (ShaderInput *input, inputs) {
|
for (ShaderInput *input : inputs) {
|
||||||
if (!input->link) {
|
if (!input->link) {
|
||||||
if (input->flags() & SocketType::LINK_TEXTURE_GENERATED) {
|
if (input->flags() & SocketType::LINK_TEXTURE_GENERATED) {
|
||||||
if (shader->has_surface_link()) {
|
if (shader->has_surface_link()) {
|
||||||
@@ -175,7 +179,7 @@ bool ShaderNode::equals(const ShaderNode &other)
|
|||||||
assert(inputs.size() == other.inputs.size());
|
assert(inputs.size() == other.inputs.size());
|
||||||
|
|
||||||
/* Compare unlinkable sockets */
|
/* Compare unlinkable sockets */
|
||||||
foreach (const SocketType &socket, type->inputs) {
|
for (const SocketType &socket : type->inputs) {
|
||||||
if (!(socket.flags & SocketType::LINKABLE)) {
|
if (!(socket.flags & SocketType::LINKABLE)) {
|
||||||
if (!Node::equals_value(other, socket)) {
|
if (!Node::equals_value(other, socket)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -327,7 +331,7 @@ void ShaderGraph::relink(ShaderOutput *from, ShaderOutput *to)
|
|||||||
/* Copy because disconnect modifies this list. */
|
/* Copy because disconnect modifies this list. */
|
||||||
vector<ShaderInput *> outputs = from->links;
|
vector<ShaderInput *> outputs = from->links;
|
||||||
|
|
||||||
foreach (ShaderInput *sock, outputs) {
|
for (ShaderInput *sock : outputs) {
|
||||||
disconnect(sock);
|
disconnect(sock);
|
||||||
if (to) {
|
if (to) {
|
||||||
connect(to, sock);
|
connect(to, sock);
|
||||||
@@ -343,13 +347,13 @@ void ShaderGraph::relink(ShaderNode *node, ShaderOutput *from, ShaderOutput *to)
|
|||||||
vector<ShaderInput *> outputs = from->links;
|
vector<ShaderInput *> outputs = from->links;
|
||||||
|
|
||||||
/* Bypass node by moving all links from "from" to "to" */
|
/* Bypass node by moving all links from "from" to "to" */
|
||||||
foreach (ShaderInput *sock, node->inputs) {
|
for (ShaderInput *sock : node->inputs) {
|
||||||
if (sock->link) {
|
if (sock->link) {
|
||||||
disconnect(sock);
|
disconnect(sock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (ShaderInput *sock, outputs) {
|
for (ShaderInput *sock : outputs) {
|
||||||
disconnect(sock);
|
disconnect(sock);
|
||||||
if (to) {
|
if (to) {
|
||||||
connect(to, sock);
|
connect(to, sock);
|
||||||
@@ -405,8 +409,9 @@ void ShaderGraph::find_dependencies(ShaderNodeSet &dependencies, ShaderInput *in
|
|||||||
ShaderNode *node = (input->link) ? input->link->parent : nullptr;
|
ShaderNode *node = (input->link) ? input->link->parent : nullptr;
|
||||||
|
|
||||||
if (node != nullptr && dependencies.find(node) == dependencies.end()) {
|
if (node != nullptr && dependencies.find(node) == dependencies.end()) {
|
||||||
foreach (ShaderInput *in, node->inputs)
|
for (ShaderInput *in : node->inputs) {
|
||||||
find_dependencies(dependencies, in);
|
find_dependencies(dependencies, in);
|
||||||
|
}
|
||||||
|
|
||||||
dependencies.insert(node);
|
dependencies.insert(node);
|
||||||
}
|
}
|
||||||
@@ -414,7 +419,7 @@ void ShaderGraph::find_dependencies(ShaderNodeSet &dependencies, ShaderInput *in
|
|||||||
|
|
||||||
void ShaderGraph::clear_nodes()
|
void ShaderGraph::clear_nodes()
|
||||||
{
|
{
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
delete_node(node);
|
delete_node(node);
|
||||||
}
|
}
|
||||||
nodes.clear();
|
nodes.clear();
|
||||||
@@ -426,7 +431,7 @@ void ShaderGraph::copy_nodes(ShaderNodeSet &nodes, ShaderNodeMap &nnodemap)
|
|||||||
* made that all nodes that inputs are linked to are in the set too. */
|
* made that all nodes that inputs are linked to are in the set too. */
|
||||||
|
|
||||||
/* copy nodes */
|
/* copy nodes */
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
ShaderNode *nnode = node->clone(this);
|
ShaderNode *nnode = node->clone(this);
|
||||||
nnodemap[node] = nnode;
|
nnodemap[node] = nnode;
|
||||||
|
|
||||||
@@ -439,8 +444,8 @@ void ShaderGraph::copy_nodes(ShaderNodeSet &nodes, ShaderNodeMap &nnodemap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* recreate links */
|
/* recreate links */
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (input->link) {
|
if (input->link) {
|
||||||
/* find new input and output */
|
/* find new input and output */
|
||||||
ShaderNode *nfrom = nnodemap[input->link->parent];
|
ShaderNode *nfrom = nnodemap[input->link->parent];
|
||||||
@@ -468,7 +473,7 @@ void ShaderGraph::remove_proxy_nodes()
|
|||||||
vector<bool> removed(num_node_ids, false);
|
vector<bool> removed(num_node_ids, false);
|
||||||
bool any_node_removed = false;
|
bool any_node_removed = false;
|
||||||
|
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (node->special_type == SHADER_SPECIAL_TYPE_PROXY) {
|
if (node->special_type == SHADER_SPECIAL_TYPE_PROXY) {
|
||||||
ConvertNode *proxy = static_cast<ConvertNode *>(node);
|
ConvertNode *proxy = static_cast<ConvertNode *>(node);
|
||||||
ShaderInput *input = proxy->inputs[0];
|
ShaderInput *input = proxy->inputs[0];
|
||||||
@@ -482,7 +487,7 @@ void ShaderGraph::remove_proxy_nodes()
|
|||||||
/* Copy because disconnect modifies this list */
|
/* Copy because disconnect modifies this list */
|
||||||
vector<ShaderInput *> links(output->links);
|
vector<ShaderInput *> links(output->links);
|
||||||
|
|
||||||
foreach (ShaderInput *to, links) {
|
for (ShaderInput *to : links) {
|
||||||
/* Remove any auto-convert nodes too if they lead to
|
/* Remove any auto-convert nodes too if they lead to
|
||||||
* sockets with an automatically set default value. */
|
* sockets with an automatically set default value. */
|
||||||
ShaderNode *tonode = to->parent;
|
ShaderNode *tonode = to->parent;
|
||||||
@@ -491,7 +496,7 @@ void ShaderGraph::remove_proxy_nodes()
|
|||||||
bool all_links_removed = true;
|
bool all_links_removed = true;
|
||||||
vector<ShaderInput *> links = tonode->outputs[0]->links;
|
vector<ShaderInput *> links = tonode->outputs[0]->links;
|
||||||
|
|
||||||
foreach (ShaderInput *autoin, links) {
|
for (ShaderInput *autoin : links) {
|
||||||
if (autoin->flags() & SocketType::DEFAULT_LINK_MASK) {
|
if (autoin->flags() & SocketType::DEFAULT_LINK_MASK) {
|
||||||
disconnect(autoin);
|
disconnect(autoin);
|
||||||
}
|
}
|
||||||
@@ -521,7 +526,7 @@ void ShaderGraph::remove_proxy_nodes()
|
|||||||
if (any_node_removed) {
|
if (any_node_removed) {
|
||||||
list<ShaderNode *> newnodes;
|
list<ShaderNode *> newnodes;
|
||||||
|
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (!removed[node->id]) {
|
if (!removed[node->id]) {
|
||||||
newnodes.push_back(node);
|
newnodes.push_back(node);
|
||||||
}
|
}
|
||||||
@@ -547,7 +552,7 @@ void ShaderGraph::constant_fold(Scene *scene)
|
|||||||
bool has_displacement = (output()->input("Displacement")->link != nullptr);
|
bool has_displacement = (output()->input("Displacement")->link != nullptr);
|
||||||
|
|
||||||
/* Schedule nodes which doesn't have any dependencies. */
|
/* Schedule nodes which doesn't have any dependencies. */
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (!check_node_inputs_has_links(node)) {
|
if (!check_node_inputs_has_links(node)) {
|
||||||
traverse_queue.push(node);
|
traverse_queue.push(node);
|
||||||
scheduled.insert(node);
|
scheduled.insert(node);
|
||||||
@@ -558,14 +563,14 @@ void ShaderGraph::constant_fold(Scene *scene)
|
|||||||
ShaderNode *node = traverse_queue.front();
|
ShaderNode *node = traverse_queue.front();
|
||||||
traverse_queue.pop();
|
traverse_queue.pop();
|
||||||
done.insert(node);
|
done.insert(node);
|
||||||
foreach (ShaderOutput *output, node->outputs) {
|
for (ShaderOutput *output : node->outputs) {
|
||||||
if (output->links.empty()) {
|
if (output->links.empty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* Schedule node which was depending on the value,
|
/* Schedule node which was depending on the value,
|
||||||
* when possible. Do it before disconnect.
|
* when possible. Do it before disconnect.
|
||||||
*/
|
*/
|
||||||
foreach (ShaderInput *input, output->links) {
|
for (ShaderInput *input : output->links) {
|
||||||
if (scheduled.find(input->parent) != scheduled.end()) {
|
if (scheduled.find(input->parent) != scheduled.end()) {
|
||||||
/* Node might not be optimized yet but scheduled already
|
/* Node might not be optimized yet but scheduled already
|
||||||
* by other dependencies. No need to re-schedule it.
|
* by other dependencies. No need to re-schedule it.
|
||||||
@@ -599,7 +604,7 @@ void ShaderGraph::constant_fold(Scene *scene)
|
|||||||
/* Simplification. */
|
/* Simplification. */
|
||||||
void ShaderGraph::simplify_settings(Scene *scene)
|
void ShaderGraph::simplify_settings(Scene *scene)
|
||||||
{
|
{
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
node->simplify_settings(scene);
|
node->simplify_settings(scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -622,7 +627,7 @@ void ShaderGraph::deduplicate_nodes()
|
|||||||
int num_deduplicated = 0;
|
int num_deduplicated = 0;
|
||||||
|
|
||||||
/* Schedule nodes which doesn't have any dependencies. */
|
/* Schedule nodes which doesn't have any dependencies. */
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (!check_node_inputs_has_links(node)) {
|
if (!check_node_inputs_has_links(node)) {
|
||||||
traverse_queue.push(node);
|
traverse_queue.push(node);
|
||||||
scheduled.insert(node);
|
scheduled.insert(node);
|
||||||
@@ -635,8 +640,8 @@ void ShaderGraph::deduplicate_nodes()
|
|||||||
done.insert(node);
|
done.insert(node);
|
||||||
/* Schedule the nodes which were depending on the current node. */
|
/* Schedule the nodes which were depending on the current node. */
|
||||||
bool has_output_links = false;
|
bool has_output_links = false;
|
||||||
foreach (ShaderOutput *output, node->outputs) {
|
for (ShaderOutput *output : node->outputs) {
|
||||||
foreach (ShaderInput *input, output->links) {
|
for (ShaderInput *input : output->links) {
|
||||||
has_output_links = true;
|
has_output_links = true;
|
||||||
if (scheduled.find(input->parent) != scheduled.end()) {
|
if (scheduled.find(input->parent) != scheduled.end()) {
|
||||||
/* Node might not be optimized yet but scheduled already
|
/* Node might not be optimized yet but scheduled already
|
||||||
@@ -657,7 +662,7 @@ void ShaderGraph::deduplicate_nodes()
|
|||||||
}
|
}
|
||||||
/* Try to merge this node with another one. */
|
/* Try to merge this node with another one. */
|
||||||
ShaderNode *merge_with = nullptr;
|
ShaderNode *merge_with = nullptr;
|
||||||
foreach (ShaderNode *other_node, candidates[node->type->name]) {
|
for (ShaderNode *other_node : candidates[node->type->name]) {
|
||||||
if (node != other_node && node->equals(*other_node)) {
|
if (node != other_node && node->equals(*other_node)) {
|
||||||
merge_with = other_node;
|
merge_with = other_node;
|
||||||
break;
|
break;
|
||||||
@@ -705,7 +710,7 @@ void ShaderGraph::verify_volume_output()
|
|||||||
has_valid_volume = true;
|
has_valid_volume = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (input->link == nullptr) {
|
if (input->link == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -727,7 +732,7 @@ void ShaderGraph::break_cycles(ShaderNode *node, vector<bool> &visited, vector<b
|
|||||||
visited[node->id] = true;
|
visited[node->id] = true;
|
||||||
on_stack[node->id] = true;
|
on_stack[node->id] = true;
|
||||||
|
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (input->link) {
|
if (input->link) {
|
||||||
ShaderNode *depnode = input->link->parent;
|
ShaderNode *depnode = input->link->parent;
|
||||||
|
|
||||||
@@ -761,9 +766,9 @@ void ShaderGraph::compute_displacement_hash()
|
|||||||
find_dependencies(nodes_displace, displacement_in);
|
find_dependencies(nodes_displace, displacement_in);
|
||||||
|
|
||||||
MD5Hash md5;
|
MD5Hash md5;
|
||||||
foreach (ShaderNode *node, nodes_displace) {
|
for (ShaderNode *node : nodes_displace) {
|
||||||
node->hash(md5);
|
node->hash(md5);
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
int link_id = (input->link) ? input->link->parent->id : 0;
|
int link_id = (input->link) ? input->link->parent->id : 0;
|
||||||
md5.append((uint8_t *)&link_id, sizeof(link_id));
|
md5.append((uint8_t *)&link_id, sizeof(link_id));
|
||||||
md5.append((input->link) ? input->link->name().c_str() : "");
|
md5.append((input->link) ? input->link->name().c_str() : "");
|
||||||
@@ -799,16 +804,16 @@ void ShaderGraph::clean(Scene *scene)
|
|||||||
|
|
||||||
/* break cycles */
|
/* break cycles */
|
||||||
break_cycles(output(), visited, on_stack);
|
break_cycles(output(), visited, on_stack);
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (node->special_type == SHADER_SPECIAL_TYPE_OUTPUT_AOV) {
|
if (node->special_type == SHADER_SPECIAL_TYPE_OUTPUT_AOV) {
|
||||||
break_cycles(node, visited, on_stack);
|
break_cycles(node, visited, on_stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* disconnect unused nodes */
|
/* disconnect unused nodes */
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (!visited[node->id]) {
|
if (!visited[node->id]) {
|
||||||
foreach (ShaderInput *to, node->inputs) {
|
for (ShaderInput *to : node->inputs) {
|
||||||
ShaderOutput *from = to->link;
|
ShaderOutput *from = to->link;
|
||||||
|
|
||||||
if (from) {
|
if (from) {
|
||||||
@@ -822,7 +827,7 @@ void ShaderGraph::clean(Scene *scene)
|
|||||||
/* remove unused nodes */
|
/* remove unused nodes */
|
||||||
list<ShaderNode *> newnodes;
|
list<ShaderNode *> newnodes;
|
||||||
|
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (visited[node->id]) {
|
if (visited[node->id]) {
|
||||||
newnodes.push_back(node);
|
newnodes.push_back(node);
|
||||||
}
|
}
|
||||||
@@ -837,7 +842,7 @@ void ShaderGraph::clean(Scene *scene)
|
|||||||
void ShaderGraph::expand()
|
void ShaderGraph::expand()
|
||||||
{
|
{
|
||||||
/* Call expand on all nodes, to generate additional nodes. */
|
/* Call expand on all nodes, to generate additional nodes. */
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
node->expand(this);
|
node->expand(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -851,8 +856,8 @@ void ShaderGraph::default_inputs(bool do_osl)
|
|||||||
TextureCoordinateNode *texco = nullptr;
|
TextureCoordinateNode *texco = nullptr;
|
||||||
VectorTransformNode *normal_transform = nullptr;
|
VectorTransformNode *normal_transform = nullptr;
|
||||||
|
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (!input->link && (!(input->flags() & SocketType::OSL_INTERNAL) || do_osl)) {
|
if (!input->link && (!(input->flags() & SocketType::OSL_INTERNAL) || do_osl)) {
|
||||||
if (input->flags() & SocketType::LINK_TEXTURE_GENERATED) {
|
if (input->flags() & SocketType::LINK_TEXTURE_GENERATED) {
|
||||||
if (!texco) {
|
if (!texco) {
|
||||||
@@ -939,7 +944,7 @@ void ShaderGraph::refine_bump_nodes()
|
|||||||
* input to the inputs "center","dx" and "dy" What is in "bump" input is moved
|
* input to the inputs "center","dx" and "dy" What is in "bump" input is moved
|
||||||
* to "center" input. */
|
* to "center" input. */
|
||||||
|
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (node->special_type == SHADER_SPECIAL_TYPE_BUMP && node->input("Height")->link) {
|
if (node->special_type == SHADER_SPECIAL_TYPE_BUMP && node->input("Height")->link) {
|
||||||
ShaderInput *bump_input = node->input("Height");
|
ShaderInput *bump_input = node->input("Height");
|
||||||
ShaderNodeSet nodes_bump;
|
ShaderNodeSet nodes_bump;
|
||||||
@@ -956,12 +961,15 @@ void ShaderGraph::refine_bump_nodes()
|
|||||||
|
|
||||||
/* Mark nodes to indicate they are use for bump computation, so
|
/* Mark nodes to indicate they are use for bump computation, so
|
||||||
* that any texture coordinates are shifted by dx/dy when sampling. */
|
* that any texture coordinates are shifted by dx/dy when sampling. */
|
||||||
foreach (ShaderNode *node, nodes_bump)
|
for (ShaderNode *node : nodes_bump) {
|
||||||
node->bump = SHADER_BUMP_CENTER;
|
node->bump = SHADER_BUMP_CENTER;
|
||||||
foreach (NodePair &pair, nodes_dx)
|
}
|
||||||
|
for (NodePair &pair : nodes_dx) {
|
||||||
pair.second->bump = SHADER_BUMP_DX;
|
pair.second->bump = SHADER_BUMP_DX;
|
||||||
foreach (NodePair &pair, nodes_dy)
|
}
|
||||||
|
for (NodePair &pair : nodes_dy) {
|
||||||
pair.second->bump = SHADER_BUMP_DY;
|
pair.second->bump = SHADER_BUMP_DY;
|
||||||
|
}
|
||||||
|
|
||||||
ShaderOutput *out = bump_input->link;
|
ShaderOutput *out = bump_input->link;
|
||||||
ShaderOutput *out_dx = nodes_dx[out->parent]->output(out->name());
|
ShaderOutput *out_dx = nodes_dx[out->parent]->output(out->name());
|
||||||
@@ -971,10 +979,12 @@ void ShaderGraph::refine_bump_nodes()
|
|||||||
connect(out_dy, node->input("SampleY"));
|
connect(out_dy, node->input("SampleY"));
|
||||||
|
|
||||||
/* Add generated nodes. */
|
/* Add generated nodes. */
|
||||||
foreach (NodePair &pair, nodes_dx)
|
for (NodePair &pair : nodes_dx) {
|
||||||
add(pair.second);
|
add(pair.second);
|
||||||
foreach (NodePair &pair, nodes_dy)
|
}
|
||||||
|
for (NodePair &pair : nodes_dy) {
|
||||||
add(pair.second);
|
add(pair.second);
|
||||||
|
}
|
||||||
|
|
||||||
/* Connect what is connected is bump to sample-center input. */
|
/* Connect what is connected is bump to sample-center input. */
|
||||||
connect(out, node->input("SampleCenter"));
|
connect(out, node->input("SampleCenter"));
|
||||||
@@ -1023,12 +1033,15 @@ void ShaderGraph::bump_from_displacement(bool use_object_space)
|
|||||||
|
|
||||||
/* mark nodes to indicate they are use for bump computation, so
|
/* mark nodes to indicate they are use for bump computation, so
|
||||||
* that any texture coordinates are shifted by dx/dy when sampling */
|
* that any texture coordinates are shifted by dx/dy when sampling */
|
||||||
foreach (NodePair &pair, nodes_center)
|
for (NodePair &pair : nodes_center) {
|
||||||
pair.second->bump = SHADER_BUMP_CENTER;
|
pair.second->bump = SHADER_BUMP_CENTER;
|
||||||
foreach (NodePair &pair, nodes_dx)
|
}
|
||||||
|
for (NodePair &pair : nodes_dx) {
|
||||||
pair.second->bump = SHADER_BUMP_DX;
|
pair.second->bump = SHADER_BUMP_DX;
|
||||||
foreach (NodePair &pair, nodes_dy)
|
}
|
||||||
|
for (NodePair &pair : nodes_dy) {
|
||||||
pair.second->bump = SHADER_BUMP_DY;
|
pair.second->bump = SHADER_BUMP_DY;
|
||||||
|
}
|
||||||
|
|
||||||
/* add set normal node and connect the bump normal output to the set normal
|
/* add set normal node and connect the bump normal output to the set normal
|
||||||
* output, so it can finally set the shader normal, note we are only doing
|
* output, so it can finally set the shader normal, note we are only doing
|
||||||
@@ -1077,12 +1090,15 @@ void ShaderGraph::bump_from_displacement(bool use_object_space)
|
|||||||
|
|
||||||
/* finally, add the copied nodes to the graph. we can't do this earlier
|
/* finally, add the copied nodes to the graph. we can't do this earlier
|
||||||
* because we would create dependency cycles in the above loop */
|
* because we would create dependency cycles in the above loop */
|
||||||
foreach (NodePair &pair, nodes_center)
|
for (NodePair &pair : nodes_center) {
|
||||||
add(pair.second);
|
add(pair.second);
|
||||||
foreach (NodePair &pair, nodes_dx)
|
}
|
||||||
|
for (NodePair &pair : nodes_dx) {
|
||||||
add(pair.second);
|
add(pair.second);
|
||||||
foreach (NodePair &pair, nodes_dy)
|
}
|
||||||
|
for (NodePair &pair : nodes_dy) {
|
||||||
add(pair.second);
|
add(pair.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight_out, bool volume)
|
void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight_out, bool volume)
|
||||||
@@ -1179,7 +1195,7 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight
|
|||||||
int ShaderGraph::get_num_closures()
|
int ShaderGraph::get_num_closures()
|
||||||
{
|
{
|
||||||
int num_closures = 0;
|
int num_closures = 0;
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
ClosureType closure_type = node->get_closure_type();
|
ClosureType closure_type = node->get_closure_type();
|
||||||
if (closure_type == CLOSURE_NONE_ID) {
|
if (closure_type == CLOSURE_NONE_ID) {
|
||||||
continue;
|
continue;
|
||||||
@@ -1228,12 +1244,12 @@ void ShaderGraph::dump_graph(const char *filename)
|
|||||||
fprintf(fd, "rankdir=LR\n");
|
fprintf(fd, "rankdir=LR\n");
|
||||||
fprintf(fd, "splines=false\n");
|
fprintf(fd, "splines=false\n");
|
||||||
|
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
fprintf(fd, "// NODE: %p\n", node);
|
fprintf(fd, "// NODE: %p\n", node);
|
||||||
fprintf(fd, "\"%p\" [shape=record,label=\"{", node);
|
fprintf(fd, "\"%p\" [shape=record,label=\"{", node);
|
||||||
if (!node->inputs.empty()) {
|
if (!node->inputs.empty()) {
|
||||||
fprintf(fd, "{");
|
fprintf(fd, "{");
|
||||||
foreach (ShaderInput *socket, node->inputs) {
|
for (ShaderInput *socket : node->inputs) {
|
||||||
if (socket != node->inputs[0]) {
|
if (socket != node->inputs[0]) {
|
||||||
fprintf(fd, "|");
|
fprintf(fd, "|");
|
||||||
}
|
}
|
||||||
@@ -1253,7 +1269,7 @@ void ShaderGraph::dump_graph(const char *filename)
|
|||||||
}
|
}
|
||||||
if (!node->outputs.empty()) {
|
if (!node->outputs.empty()) {
|
||||||
fprintf(fd, "|{");
|
fprintf(fd, "|{");
|
||||||
foreach (ShaderOutput *socket, node->outputs) {
|
for (ShaderOutput *socket : node->outputs) {
|
||||||
if (socket != node->outputs[0]) {
|
if (socket != node->outputs[0]) {
|
||||||
fprintf(fd, "|");
|
fprintf(fd, "|");
|
||||||
}
|
}
|
||||||
@@ -1264,9 +1280,9 @@ void ShaderGraph::dump_graph(const char *filename)
|
|||||||
fprintf(fd, "}\"]");
|
fprintf(fd, "}\"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
foreach (ShaderOutput *output, node->outputs) {
|
for (ShaderOutput *output : node->outputs) {
|
||||||
foreach (ShaderInput *input, output->links) {
|
for (ShaderInput *input : output->links) {
|
||||||
fprintf(fd,
|
fprintf(fd,
|
||||||
"// CONNECTION: OUT_%p->IN_%p (%s:%s)\n",
|
"// CONNECTION: OUT_%p->IN_%p (%s:%s)\n",
|
||||||
output,
|
output,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
#include "sky_model.h"
|
#include "sky_model.h"
|
||||||
|
|
||||||
#include "util/color.h"
|
#include "util/color.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/transform.h"
|
#include "util/transform.h"
|
||||||
|
|
||||||
@@ -326,8 +326,8 @@ void ImageTextureNode::cull_tiles(Scene *scene, ShaderGraph *graph)
|
|||||||
/* TODO(lukas): This is quite inefficient. A fairly simple improvement would
|
/* TODO(lukas): This is quite inefficient. A fairly simple improvement would
|
||||||
* be to have a cache in each mesh that is indexed by attribute.
|
* be to have a cache in each mesh that is indexed by attribute.
|
||||||
* Additionally, building a graph-to-meshes list once could help. */
|
* Additionally, building a graph-to-meshes list once could help. */
|
||||||
foreach (Geometry *geom, scene->geometry) {
|
for (Geometry *geom : scene->geometry) {
|
||||||
foreach (Node *node, geom->get_used_shaders()) {
|
for (Node *node : geom->get_used_shaders()) {
|
||||||
Shader *shader = static_cast<Shader *>(node);
|
Shader *shader = static_cast<Shader *>(node);
|
||||||
if (shader->graph == graph) {
|
if (shader->graph == graph) {
|
||||||
geom->get_uv_tiles(attribute, used_tiles);
|
geom->get_uv_tiles(attribute, used_tiles);
|
||||||
@@ -336,7 +336,7 @@ void ImageTextureNode::cull_tiles(Scene *scene, ShaderGraph *graph)
|
|||||||
}
|
}
|
||||||
|
|
||||||
array<int> new_tiles;
|
array<int> new_tiles;
|
||||||
foreach (int tile, tiles) {
|
for (int tile : tiles) {
|
||||||
if (used_tiles.count(tile)) {
|
if (used_tiles.count(tile)) {
|
||||||
new_tiles.push_back_slow(tile);
|
new_tiles.push_back_slow(tile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "scene/stats.h"
|
#include "scene/stats.h"
|
||||||
#include "scene/object.h"
|
#include "scene/object.h"
|
||||||
#include "util/algorithm.h"
|
#include "util/algorithm.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
@@ -69,7 +69,7 @@ string NamedSizeStats::full_report(int indent_level)
|
|||||||
string_human_readable_size(total_size).c_str(),
|
string_human_readable_size(total_size).c_str(),
|
||||||
string_human_readable_number(total_size).c_str());
|
string_human_readable_number(total_size).c_str());
|
||||||
sort(entries.begin(), entries.end(), namedSizeEntryComparator);
|
sort(entries.begin(), entries.end(), namedSizeEntryComparator);
|
||||||
foreach (const NamedSizeEntry &entry, entries) {
|
for (const NamedSizeEntry &entry : entries) {
|
||||||
result += string_printf("%s%-32s %s (%s)\n",
|
result += string_printf("%s%-32s %s (%s)\n",
|
||||||
double_indent.c_str(),
|
double_indent.c_str(),
|
||||||
entry.name.c_str(),
|
entry.name.c_str(),
|
||||||
@@ -86,7 +86,7 @@ string NamedTimeStats::full_report(int indent_level)
|
|||||||
string result;
|
string result;
|
||||||
result += string_printf("%sTotal time: %fs\n", indent.c_str(), total_time);
|
result += string_printf("%sTotal time: %fs\n", indent.c_str(), total_time);
|
||||||
sort(entries.begin(), entries.end(), namedTimeEntryComparator);
|
sort(entries.begin(), entries.end(), namedTimeEntryComparator);
|
||||||
foreach (const NamedTimeEntry &entry, entries) {
|
for (const NamedTimeEntry &entry : entries) {
|
||||||
result += string_printf(
|
result += string_printf(
|
||||||
"%s%-40s %fs\n", double_indent.c_str(), entry.name.c_str(), entry.time);
|
"%s%-40s %fs\n", double_indent.c_str(), entry.name.c_str(), entry.time);
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ NamedNestedSampleStats &NamedNestedSampleStats::add_entry(const string &name_, u
|
|||||||
void NamedNestedSampleStats::update_sum()
|
void NamedNestedSampleStats::update_sum()
|
||||||
{
|
{
|
||||||
sum_samples = self_samples;
|
sum_samples = self_samples;
|
||||||
foreach (NamedNestedSampleStats &entry, entries) {
|
for (NamedNestedSampleStats &entry : entries) {
|
||||||
entry.update_sum();
|
entry.update_sum();
|
||||||
sum_samples += entry.sum_samples;
|
sum_samples += entry.sum_samples;
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ string NamedNestedSampleStats::full_report(int indent_level, uint64_t total_samp
|
|||||||
string result = indent + info;
|
string result = indent + info;
|
||||||
|
|
||||||
sort(entries.begin(), entries.end(), namedTimeSampleEntryComparator);
|
sort(entries.begin(), entries.end(), namedTimeSampleEntryComparator);
|
||||||
foreach (NamedNestedSampleStats &entry, entries) {
|
for (NamedNestedSampleStats &entry : entries) {
|
||||||
result += entry.full_report(indent_level + 1, total_samples);
|
result += entry.full_report(indent_level + 1, total_samples);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -174,7 +174,7 @@ string NamedSampleCountStats::full_report(int indent_level)
|
|||||||
sorted_entries.reserve(entries.size());
|
sorted_entries.reserve(entries.size());
|
||||||
|
|
||||||
uint64_t total_hits = 0, total_samples = 0;
|
uint64_t total_hits = 0, total_samples = 0;
|
||||||
foreach (entry_map::const_reference entry, entries) {
|
for (entry_map::const_reference entry : entries) {
|
||||||
const NamedSampleCountPair &pair = entry.second;
|
const NamedSampleCountPair &pair = entry.second;
|
||||||
|
|
||||||
total_hits += pair.hits;
|
total_hits += pair.hits;
|
||||||
@@ -187,7 +187,7 @@ string NamedSampleCountStats::full_report(int indent_level)
|
|||||||
sort(sorted_entries.begin(), sorted_entries.end(), namedSampleCountPairComparator);
|
sort(sorted_entries.begin(), sorted_entries.end(), namedSampleCountPairComparator);
|
||||||
|
|
||||||
string result;
|
string result;
|
||||||
foreach (const NamedSampleCountPair &entry, sorted_entries) {
|
for (const NamedSampleCountPair &entry : sorted_entries) {
|
||||||
const double seconds = entry.samples * 0.001;
|
const double seconds = entry.samples * 0.001;
|
||||||
const double relative = ((double)entry.samples) / (entry.hits * avg_samples_per_hit);
|
const double relative = ((double)entry.samples) / (entry.hits * avg_samples_per_hit);
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ void RenderStats::collect_profiling(Scene *scene, Profiler &prof)
|
|||||||
light.add_entry("Shader Evaluation", prof.get_event(PROFILING_SHADE_LIGHT_EVAL));
|
light.add_entry("Shader Evaluation", prof.get_event(PROFILING_SHADE_LIGHT_EVAL));
|
||||||
|
|
||||||
shaders.entries.clear();
|
shaders.entries.clear();
|
||||||
foreach (Shader *shader, scene->shaders) {
|
for (Shader *shader : scene->shaders) {
|
||||||
uint64_t samples, hits;
|
uint64_t samples, hits;
|
||||||
if (prof.get_shader(shader->id, samples, hits)) {
|
if (prof.get_shader(shader->id, samples, hits)) {
|
||||||
shaders.add(shader->name, samples, hits);
|
shaders.add(shader->name, samples, hits);
|
||||||
@@ -274,7 +274,7 @@ void RenderStats::collect_profiling(Scene *scene, Profiler &prof)
|
|||||||
}
|
}
|
||||||
|
|
||||||
objects.entries.clear();
|
objects.entries.clear();
|
||||||
foreach (Object *object, scene->objects) {
|
for (Object *object : scene->objects) {
|
||||||
uint64_t samples, hits;
|
uint64_t samples, hits;
|
||||||
if (prof.get_object(object->get_device_index(), samples, hits)) {
|
if (prof.get_object(object->get_device_index(), samples, hits)) {
|
||||||
objects.add(object->name, samples, hits);
|
objects.add(object->name, samples, hits);
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "scene/stats.h"
|
#include "scene/stats.h"
|
||||||
#include "scene/svm.h"
|
#include "scene/svm.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/progress.h"
|
#include "util/progress.h"
|
||||||
#include "util/task.h"
|
#include "util/task.h"
|
||||||
@@ -339,24 +338,26 @@ void SVMCompiler::stack_clear_users(ShaderNode *node, ShaderNodeSet &done)
|
|||||||
* outputs. this used to work, but was disabled because it gave trouble
|
* outputs. this used to work, but was disabled because it gave trouble
|
||||||
* with inputs getting stack positions assigned */
|
* with inputs getting stack positions assigned */
|
||||||
|
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
ShaderOutput *output = input->link;
|
ShaderOutput *output = input->link;
|
||||||
|
|
||||||
if (output && output->stack_offset != SVM_STACK_INVALID) {
|
if (output && output->stack_offset != SVM_STACK_INVALID) {
|
||||||
bool all_done = true;
|
bool all_done = true;
|
||||||
|
|
||||||
/* optimization we should add: verify if in->parent is actually used */
|
/* optimization we should add: verify if in->parent is actually used */
|
||||||
foreach (ShaderInput *in, output->links)
|
for (ShaderInput *in : output->links) {
|
||||||
if (in->parent != node && done.find(in->parent) == done.end()) {
|
if (in->parent != node && done.find(in->parent) == done.end()) {
|
||||||
all_done = false;
|
all_done = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (all_done) {
|
if (all_done) {
|
||||||
stack_clear_offset(output->type(), output->stack_offset);
|
stack_clear_offset(output->type(), output->stack_offset);
|
||||||
output->stack_offset = SVM_STACK_INVALID;
|
output->stack_offset = SVM_STACK_INVALID;
|
||||||
|
|
||||||
foreach (ShaderInput *in, output->links)
|
for (ShaderInput *in : output->links) {
|
||||||
in->stack_offset = SVM_STACK_INVALID;
|
in->stack_offset = SVM_STACK_INVALID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,7 +365,7 @@ void SVMCompiler::stack_clear_users(ShaderNode *node, ShaderNodeSet &done)
|
|||||||
|
|
||||||
void SVMCompiler::stack_clear_temporary(ShaderNode *node)
|
void SVMCompiler::stack_clear_temporary(ShaderNode *node)
|
||||||
{
|
{
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (!input->link && input->stack_offset != SVM_STACK_INVALID) {
|
if (!input->link && input->stack_offset != SVM_STACK_INVALID) {
|
||||||
stack_clear_offset(input->type(), input->stack_offset);
|
stack_clear_offset(input->type(), input->stack_offset);
|
||||||
input->stack_offset = SVM_STACK_INVALID;
|
input->stack_offset = SVM_STACK_INVALID;
|
||||||
@@ -431,7 +432,7 @@ void SVMCompiler::find_dependencies(ShaderNodeSet &dependencies,
|
|||||||
if (node != nullptr && done.find(node) == done.end() && node != skip_node &&
|
if (node != nullptr && done.find(node) == done.end() && node != skip_node &&
|
||||||
dependencies.find(node) == dependencies.end())
|
dependencies.find(node) == dependencies.end())
|
||||||
{
|
{
|
||||||
foreach (ShaderInput *in, node->inputs) {
|
for (ShaderInput *in : node->inputs) {
|
||||||
find_dependencies(dependencies, done, in, skip_node);
|
find_dependencies(dependencies, done, in, skip_node);
|
||||||
}
|
}
|
||||||
dependencies.insert(node);
|
dependencies.insert(node);
|
||||||
@@ -471,11 +472,11 @@ void SVMCompiler::generate_svm_nodes(const ShaderNodeSet &nodes, CompilerState *
|
|||||||
do {
|
do {
|
||||||
nodes_done = true;
|
nodes_done = true;
|
||||||
|
|
||||||
foreach (ShaderNode *node, nodes) {
|
for (ShaderNode *node : nodes) {
|
||||||
if (!done_flag[node->id]) {
|
if (!done_flag[node->id]) {
|
||||||
bool inputs_done = true;
|
bool inputs_done = true;
|
||||||
|
|
||||||
foreach (ShaderInput *input, node->inputs) {
|
for (ShaderInput *input : node->inputs) {
|
||||||
if (input->link && !done_flag[input->link->parent->id]) {
|
if (input->link && !done_flag[input->link->parent->id]) {
|
||||||
inputs_done = false;
|
inputs_done = false;
|
||||||
}
|
}
|
||||||
@@ -503,7 +504,7 @@ void SVMCompiler::generate_closure_node(ShaderNode *node, CompilerState *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* execute dependencies for closure */
|
/* execute dependencies for closure */
|
||||||
foreach (ShaderInput *in, node->inputs) {
|
for (ShaderInput *in : node->inputs) {
|
||||||
if (in->link != nullptr) {
|
if (in->link != nullptr) {
|
||||||
ShaderNodeSet dependencies;
|
ShaderNodeSet dependencies;
|
||||||
find_dependencies(dependencies, state->nodes_done, in);
|
find_dependencies(dependencies, state->nodes_done, in);
|
||||||
@@ -553,7 +554,7 @@ void SVMCompiler::generated_shared_closure_nodes(ShaderNode *root_node,
|
|||||||
generate_multi_closure(root_node, node, state);
|
generate_multi_closure(root_node, node, state);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
foreach (ShaderInput *in, node->inputs) {
|
for (ShaderInput *in : node->inputs) {
|
||||||
if (in->type() == SocketType::CLOSURE && in->link) {
|
if (in->type() == SocketType::CLOSURE && in->link) {
|
||||||
generated_shared_closure_nodes(root_node, in->link->parent, state, shared);
|
generated_shared_closure_nodes(root_node, in->link->parent, state, shared);
|
||||||
}
|
}
|
||||||
@@ -565,12 +566,12 @@ void SVMCompiler::find_aov_nodes_and_dependencies(ShaderNodeSet &aov_nodes,
|
|||||||
ShaderGraph *graph,
|
ShaderGraph *graph,
|
||||||
CompilerState *state)
|
CompilerState *state)
|
||||||
{
|
{
|
||||||
foreach (ShaderNode *node, graph->nodes) {
|
for (ShaderNode *node : graph->nodes) {
|
||||||
if (node->special_type == SHADER_SPECIAL_TYPE_OUTPUT_AOV) {
|
if (node->special_type == SHADER_SPECIAL_TYPE_OUTPUT_AOV) {
|
||||||
OutputAOVNode *aov_node = static_cast<OutputAOVNode *>(node);
|
OutputAOVNode *aov_node = static_cast<OutputAOVNode *>(node);
|
||||||
if (aov_node->offset >= 0) {
|
if (aov_node->offset >= 0) {
|
||||||
aov_nodes.insert(aov_node);
|
aov_nodes.insert(aov_node);
|
||||||
foreach (ShaderInput *in, node->inputs) {
|
for (ShaderInput *in : node->inputs) {
|
||||||
if (in->link != nullptr) {
|
if (in->link != nullptr) {
|
||||||
find_dependencies(aov_nodes, state->nodes_done, in);
|
find_dependencies(aov_nodes, state->nodes_done, in);
|
||||||
}
|
}
|
||||||
@@ -629,7 +630,7 @@ void SVMCompiler::generate_multi_closure(ShaderNode *root_node,
|
|||||||
* happens when a node of current subbranch is used by a parent
|
* happens when a node of current subbranch is used by a parent
|
||||||
* node or so */
|
* node or so */
|
||||||
if (root_node != node) {
|
if (root_node != node) {
|
||||||
foreach (ShaderInput *in, root_node->inputs) {
|
for (ShaderInput *in : root_node->inputs) {
|
||||||
ShaderNodeSet rootdeps;
|
ShaderNodeSet rootdeps;
|
||||||
find_dependencies(rootdeps, state->nodes_done, in, node);
|
find_dependencies(rootdeps, state->nodes_done, in, node);
|
||||||
set_intersection(rootdeps.begin(),
|
set_intersection(rootdeps.begin(),
|
||||||
@@ -779,11 +780,13 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
|
|||||||
memset((void *)&active_stack, 0, sizeof(active_stack));
|
memset((void *)&active_stack, 0, sizeof(active_stack));
|
||||||
current_svm_nodes.clear();
|
current_svm_nodes.clear();
|
||||||
|
|
||||||
foreach (ShaderNode *node, graph->nodes) {
|
for (ShaderNode *node : graph->nodes) {
|
||||||
foreach (ShaderInput *input, node->inputs)
|
for (ShaderInput *input : node->inputs) {
|
||||||
input->stack_offset = SVM_STACK_INVALID;
|
input->stack_offset = SVM_STACK_INVALID;
|
||||||
foreach (ShaderOutput *output, node->outputs)
|
}
|
||||||
|
for (ShaderOutput *output : node->outputs) {
|
||||||
output->stack_offset = SVM_STACK_INVALID;
|
output->stack_offset = SVM_STACK_INVALID;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for the bump shader we need add a node to store the shader state */
|
/* for the bump shader we need add a node to store the shader state */
|
||||||
@@ -984,7 +987,7 @@ string SVMCompiler::Summary::full_report() const
|
|||||||
SVMCompiler::CompilerState::CompilerState(ShaderGraph *graph)
|
SVMCompiler::CompilerState::CompilerState(ShaderGraph *graph)
|
||||||
{
|
{
|
||||||
int max_id = 0;
|
int max_id = 0;
|
||||||
foreach (ShaderNode *node, graph->nodes) {
|
for (ShaderNode *node : graph->nodes) {
|
||||||
max_id = max(node->id, max_id);
|
max_id = max(node->id, max_id);
|
||||||
}
|
}
|
||||||
nodes_done_flag.resize(max_id + 1, false);
|
nodes_done_flag.resize(max_id + 1, false);
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#include "device/device.h"
|
#include "device/device.h"
|
||||||
#include "session/buffers.h"
|
#include "session/buffers.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
/* --------------------------------------------------------------------
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include "session/output_driver.h"
|
#include "session/output_driver.h"
|
||||||
#include "session/session.h"
|
#include "session/session.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/math.h"
|
#include "util/math.h"
|
||||||
#include "util/task.h"
|
#include "util/task.h"
|
||||||
|
|||||||
@@ -14,7 +14,6 @@
|
|||||||
#include "scene/scene.h"
|
#include "scene/scene.h"
|
||||||
#include "session/session.h"
|
#include "session/session.h"
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/path.h"
|
#include "util/path.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#include "subd/split.h"
|
#include "subd/split.h"
|
||||||
|
|
||||||
#include "util/algorithm.h"
|
#include "util/algorithm.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/hash.h"
|
#include "util/hash.h"
|
||||||
#include "util/math.h"
|
#include "util/math.h"
|
||||||
#include "util/types.h"
|
#include "util/types.h"
|
||||||
@@ -596,7 +596,7 @@ void DiagSplit::post_split()
|
|||||||
|
|
||||||
/* All patches are now split, and all T values known. */
|
/* All patches are now split, and all T values known. */
|
||||||
|
|
||||||
foreach (Edge &edge, edges) {
|
for (Edge &edge : edges) {
|
||||||
if (edge.second_vert_index < 0) {
|
if (edge.second_vert_index < 0) {
|
||||||
edge.second_vert_index = alloc_verts(edge.T - 1);
|
edge.second_vert_index = alloc_verts(edge.T - 1);
|
||||||
}
|
}
|
||||||
@@ -619,7 +619,7 @@ void DiagSplit::post_split()
|
|||||||
using edge_stitch_verts_map_t = unordered_map<pair<int, int>, int, pair_hasher>;
|
using edge_stitch_verts_map_t = unordered_map<pair<int, int>, int, pair_hasher>;
|
||||||
edge_stitch_verts_map_t edge_stitch_verts_map;
|
edge_stitch_verts_map_t edge_stitch_verts_map;
|
||||||
|
|
||||||
foreach (Edge &edge, edges) {
|
for (Edge &edge : edges) {
|
||||||
if (edge.is_stitch_edge) {
|
if (edge.is_stitch_edge) {
|
||||||
if (edge.stitch_edge_T == 0) {
|
if (edge.stitch_edge_T == 0) {
|
||||||
edge.stitch_edge_T = edge.T;
|
edge.stitch_edge_T = edge.T;
|
||||||
@@ -633,7 +633,7 @@ void DiagSplit::post_split()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Set start and end indices for edges generated from a split. */
|
/* Set start and end indices for edges generated from a split. */
|
||||||
foreach (Edge &edge, edges) {
|
for (Edge &edge : edges) {
|
||||||
if (edge.start_vert_index < 0) {
|
if (edge.start_vert_index < 0) {
|
||||||
/* Fix up offsets. */
|
/* Fix up offsets. */
|
||||||
if (edge.top_indices_decrease) {
|
if (edge.top_indices_decrease) {
|
||||||
@@ -655,7 +655,7 @@ void DiagSplit::post_split()
|
|||||||
int vert_offset = params.mesh->verts.size();
|
int vert_offset = params.mesh->verts.size();
|
||||||
|
|
||||||
/* Add verts to stitching map. */
|
/* Add verts to stitching map. */
|
||||||
foreach (const Edge &edge, edges) {
|
for (const Edge &edge : edges) {
|
||||||
if (edge.is_stitch_edge) {
|
if (edge.is_stitch_edge) {
|
||||||
int second_stitch_vert_index = edge_stitch_verts_map[edge.stitch_edge_key];
|
int second_stitch_vert_index = edge_stitch_verts_map[edge.stitch_edge_key];
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ set(SRC_HEADERS
|
|||||||
deque.h
|
deque.h
|
||||||
disjoint_set.h
|
disjoint_set.h
|
||||||
guarded_allocator.cpp
|
guarded_allocator.cpp
|
||||||
foreach.h
|
|
||||||
guarded_allocator.h
|
guarded_allocator.h
|
||||||
guiding.h
|
guiding.h
|
||||||
half.h
|
half.h
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0 */
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/* Nice foreach() loops for STL data structures. */
|
|
||||||
|
|
||||||
#define foreach(x, y) for (x : y)
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/ies.h"
|
#include "util/ies.h"
|
||||||
#include "util/math.h"
|
#include "util/math.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/profiling.h"
|
#include "util/profiling.h"
|
||||||
|
|
||||||
CCL_NAMESPACE_BEGIN
|
CCL_NAMESPACE_BEGIN
|
||||||
@@ -23,7 +22,7 @@ void Profiler::run()
|
|||||||
auto start_time = std::chrono::system_clock::now();
|
auto start_time = std::chrono::system_clock::now();
|
||||||
while (!do_stop_worker) {
|
while (!do_stop_worker) {
|
||||||
thread_scoped_lock lock(mutex);
|
thread_scoped_lock lock(mutex);
|
||||||
foreach (ProfilingState *state, states) {
|
for (ProfilingState *state : states) {
|
||||||
uint32_t cur_event = state->event;
|
uint32_t cur_event = state->event;
|
||||||
int32_t cur_shader = state->shader;
|
int32_t cur_shader = state->shader;
|
||||||
int32_t cur_object = state->object;
|
int32_t cur_object = state->object;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
#include "util/types_float4.h"
|
#include "util/types_float4.h"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* SPDX-License-Identifier: Apache-2.0 */
|
* SPDX-License-Identifier: Apache-2.0 */
|
||||||
|
|
||||||
#include "util/task.h"
|
#include "util/task.h"
|
||||||
#include "util/foreach.h"
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
#include "util/time.h"
|
#include "util/time.h"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user