Fix Cycles debug build assert on some platforms, tighten checks to avoid this in...
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 12 Jun 2016 15:12:25 +0000 (17:12 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 12 Jun 2016 15:35:15 +0000 (17:35 +0200)
13 files changed:
intern/cycles/app/cycles_xml.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/graph/node.cpp
intern/cycles/graph/node.h
intern/cycles/graph/node_type.cpp
intern/cycles/graph/node_type.h
intern/cycles/graph/node_xml.cpp
intern/cycles/render/background.cpp
intern/cycles/render/camera.cpp
intern/cycles/render/mesh.cpp
intern/cycles/render/nodes.cpp
intern/cycles/render/nodes.h
intern/cycles/render/object.cpp

index 48a2b12b23a24238e05246b8f80dd64128b0415e..3aca46e2dc72be75c3cbc8b27fabb9e0d3d4062d 100644 (file)
@@ -343,11 +343,11 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
 
                if(node_name == "image_texture") {
                        ImageTextureNode *img = (ImageTextureNode*) snode;
-                       img->filename = path_join(state.base, img->filename);
+                       img->filename = path_join(state.base, img->filename.string());
                }
                else if(node_name == "environment_texture") {
                        EnvironmentTextureNode *env = (EnvironmentTextureNode*) snode;
-                       env->filename = path_join(state.base, env->filename);
+                       env->filename = path_join(state.base, env->filename.string());
                }
 
                if(snode) {
index 0b61cbb0f627a4c0724ee52d7c54a1e96b76e6af..78a28b7feedccbbaf726c14540b372be9ad81561 100644 (file)
@@ -619,7 +619,7 @@ static ShaderNode *add_node(Scene *scene,
                        /* TODO(sergey): Does not work properly when we change builtin type. */
                        if(b_image.is_updated()) {
                                scene->image_manager->tag_reload_image(
-                                       image->filename,
+                                       image->filename.string(),
                                        image->builtin_data,
                                        get_image_interpolation(b_image_node),
                                        get_image_extension(b_image_node));
@@ -665,7 +665,7 @@ static ShaderNode *add_node(Scene *scene,
                        /* TODO(sergey): Does not work properly when we change builtin type. */
                        if(b_image.is_updated()) {
                                scene->image_manager->tag_reload_image(
-                                       env->filename,
+                                       env->filename.string(),
                                        env->builtin_data,
                                        get_image_interpolation(b_env_node),
                                        EXTENSION_REPEAT);
index 941a66741c590197398b94df0b7d00197cc15655..3c228a716d544bde96eb622c500390db315674b3 100644 (file)
@@ -82,6 +82,12 @@ void Node::set(const SocketType& input, int value)
        get_socket_value<int>(this, input) = value;
 }
 
+void Node::set(const SocketType& input, uint value)
+{
+       assert(input.type == SocketType::UINT);
+       get_socket_value<uint>(this, input) = value;
+}
+
 void Node::set(const SocketType& input, float value)
 {
        assert(input.type == SocketType::FLOAT);
@@ -198,6 +204,12 @@ int Node::get_int(const SocketType& input) const
        return get_socket_value<int>(this, input);
 }
 
+uint Node::get_uint(const SocketType& input) const
+{
+       assert(input.type == SocketType::UINT);
+       return get_socket_value<uint>(this, input);
+}
+
 float Node::get_float(const SocketType& input) const
 {
        assert(input.type == SocketType::FLOAT);
index bb84f982fb36523f92c9f379fff2ce592a8dbf05..64410f4539b3f92e18c661ed473d2deb395a9453 100644 (file)
@@ -38,6 +38,7 @@ struct Node
        /* set values */
        void set(const SocketType& input, bool value);
        void set(const SocketType& input, int value);
+       void set(const SocketType& input, uint value);
        void set(const SocketType& input, float value);
        void set(const SocketType& input, float2 value);
        void set(const SocketType& input, float3 value);
@@ -60,6 +61,7 @@ struct Node
        /* get values */
        bool get_bool(const SocketType& input) const;
        int get_int(const SocketType& input) const;
+       uint get_uint(const SocketType& input) const;
        float get_float(const SocketType& input) const;
        float2 get_float2(const SocketType& input) const;
        float3 get_float3(const SocketType& input) const;
index 7f68ae9c7c72a56e5e533af37f7d8ab0162aff64..6c6035fdb22c82adb5530fac2b82616d99311703 100644 (file)
@@ -41,6 +41,7 @@ size_t SocketType::size(Type type)
                case BOOLEAN: return sizeof(bool);
                case FLOAT: return sizeof(float);
                case INT: return sizeof(int);
+               case UINT: return sizeof(uint);
                case COLOR: return sizeof(float3);
                case VECTOR: return sizeof(float3);
                case POINT: return sizeof(float3);
index 20816f634cd18725d8952d9ac4cc49203c00c370..e84631cd59d29ec0a8c01aaf29450f9312b37d2d 100644 (file)
@@ -39,6 +39,7 @@ struct SocketType
                BOOLEAN,
                FLOAT,
                INT,
+               UINT,
                COLOR,
                VECTOR,
                POINT,
@@ -154,7 +155,7 @@ const NodeType *structname::register_type()
 #define SOCKET_DEFINE(name, ui_name, default_value, datatype, TYPE, flags, ...) \
        { \
                static datatype defval = default_value; \
-               assert(SOCKET_SIZEOF(T, name) == sizeof(datatype)); \
+               CHECK_TYPE_PAIR(((T *)1)->name, datatype); \
                type->register_input(ustring(#name), ustring(ui_name), TYPE, SOCKET_OFFSETOF(T, name), &defval, NULL, NULL, flags, ##__VA_ARGS__); \
        }
 
@@ -162,6 +163,8 @@ const NodeType *structname::register_type()
        SOCKET_DEFINE(name, ui_name, default_value, bool, SocketType::BOOLEAN, 0, ##__VA_ARGS__)
 #define SOCKET_INT(name, ui_name, default_value, ...) \
        SOCKET_DEFINE(name, ui_name, default_value, int, SocketType::INT, 0, ##__VA_ARGS__)
+#define SOCKET_UINT(name, ui_name, default_value, ...) \
+       SOCKET_DEFINE(name, ui_name, default_value, uint, SocketType::UINT, 0, ##__VA_ARGS__)
 #define SOCKET_FLOAT(name, ui_name, default_value, ...) \
        SOCKET_DEFINE(name, ui_name, default_value, float, SocketType::FLOAT, 0, ##__VA_ARGS__)
 #define SOCKET_COLOR(name, ui_name, default_value, ...) \
index 022de7cf32a36f6d7ada615234d671d6055b9498..590e09645edaf3340f8076976714c99a0bcad4ac 100644 (file)
@@ -108,6 +108,11 @@ void xml_read_node(XMLReader& reader, Node *node, pugi::xml_node xml_node)
                                node->set(socket, (int)atoi(attr.value()));
                                break;
                        }
+                       case SocketType::UINT:
+                       {
+                               node->set(socket, (uint)atoi(attr.value()));
+                               break;
+                       }
                        case SocketType::INT_ARRAY:
                        {
                                vector<string> tokens;
@@ -310,6 +315,11 @@ pugi::xml_node xml_write_node(Node *node, pugi::xml_node xml_root)
                                attr = node->get_int(socket);
                                break;
                        }
+                       case SocketType::UINT:
+                       {
+                               attr = node->get_uint(socket);
+                               break;
+                       }
                        case SocketType::INT_ARRAY:
                        {
                                std::stringstream ss;
index 20536b74e87d8f8a45f37d3559c3d7d75cb13291..8d7d7b847fda8eead259b20dc6fff10a80db44ff 100644 (file)
@@ -32,12 +32,12 @@ NODE_DEFINE(Background)
 {
        NodeType* type = NodeType::add("background", create);
 
-       SOCKET_INT(ao_factor, "AO Factor", 0.0f);
+       SOCKET_FLOAT(ao_factor, "AO Factor", 0.0f);
        SOCKET_FLOAT(ao_distance, "AO Distance", FLT_MAX);
 
        SOCKET_BOOLEAN(use_shader, "Use Shader", true);
        SOCKET_BOOLEAN(use_ao, "Use AO", false);
-       SOCKET_INT(visibility, "Visibility", PATH_RAY_ALL_VISIBILITY);
+       SOCKET_UINT(visibility, "Visibility", PATH_RAY_ALL_VISIBILITY);
        SOCKET_BOOLEAN(transparent, "Transparent", false);
 
        SOCKET_NODE(shader, "Shader", &Shader::node_type);
index 2310798be2ec292527fbf160eb52ccdd69039f4a..a6df656d22012c435286173e93b4d9c5bebb3195 100644 (file)
@@ -68,7 +68,7 @@ NODE_DEFINE(Camera)
 
        SOCKET_FLOAT(aperturesize, "Aperture Size", 0.0f);
        SOCKET_FLOAT(focaldistance, "Focal Distance", 10.0f);
-       SOCKET_INT(blades, "Blades", 0);
+       SOCKET_UINT(blades, "Blades", 0);
        SOCKET_FLOAT(bladesrotation, "Blades Rotation", 0.0f);
 
        SOCKET_TRANSFORM(matrix, "Matrix", transform_identity());
index e25155630bd6e878b70d19323bf4bd93dd28162f..764a925983e64e361976e9db00a3201da398537b 100644 (file)
@@ -85,7 +85,7 @@ NODE_DEFINE(Mesh)
        displacement_method_enum.insert("both", DISPLACE_BOTH);
        SOCKET_ENUM(displacement_method, "Displacement Method", displacement_method_enum, DISPLACE_BUMP);
 
-       SOCKET_INT(motion_steps, "Motion Steps", 3);
+       SOCKET_UINT(motion_steps, "Motion Steps", 3);
        SOCKET_BOOLEAN(use_motion_blur, "Use Motion Blur", false);
 
        SOCKET_INT_ARRAY(triangles, "Triangles", array<int>());
index d018c4f40b6a42512bda67e7fa13c1f094ca3b3b..6530bff084824efd4f4fd19d2a03173dda5e19f3 100644 (file)
@@ -257,7 +257,7 @@ ImageTextureNode::ImageTextureNode()
 ImageTextureNode::~ImageTextureNode()
 {
        if(image_manager) {
-               image_manager->remove_image(filename,
+               image_manager->remove_image(filename.string(),
                                            builtin_data,
                                            interpolation,
                                            extension);
@@ -298,7 +298,7 @@ void ImageTextureNode::compile(SVMCompiler& compiler)
        image_manager = compiler.image_manager;
        if(is_float == -1) {
                bool is_float_bool;
-               slot = image_manager->add_image(filename,
+               slot = image_manager->add_image(filename.string(),
                                                builtin_data,
                                                animated,
                                                0,
@@ -360,13 +360,13 @@ void ImageTextureNode::compile(OSLCompiler& compiler)
        if(is_float == -1) {
                if(builtin_data == NULL) {
                        ImageManager::ImageDataType type;
-                       type = image_manager->get_image_metadata(filename, NULL, is_linear);
+                       type = image_manager->get_image_metadata(filename.string(), NULL, is_linear);
                        if(type == ImageManager::IMAGE_DATA_TYPE_FLOAT || type == ImageManager::IMAGE_DATA_TYPE_FLOAT4)
                                is_float = 1;
                }
                else {
                        bool is_float_bool;
-                       slot = image_manager->add_image(filename,
+                       slot = image_manager->add_image(filename.string(),
                                                        builtin_data,
                                                        animated,
                                                        0,
@@ -456,7 +456,7 @@ EnvironmentTextureNode::EnvironmentTextureNode()
 EnvironmentTextureNode::~EnvironmentTextureNode()
 {
        if(image_manager) {
-               image_manager->remove_image(filename,
+               image_manager->remove_image(filename.string(),
                                            builtin_data,
                                            interpolation,
                                            EXTENSION_REPEAT);
@@ -495,7 +495,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
        image_manager = compiler.image_manager;
        if(slot == -1) {
                bool is_float_bool;
-               slot = image_manager->add_image(filename,
+               slot = image_manager->add_image(filename.string(),
                                                builtin_data,
                                                animated,
                                                0,
@@ -548,13 +548,13 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler)
        if(is_float == -1) {
                if(builtin_data == NULL) {
                        ImageManager::ImageDataType type;
-                       type = image_manager->get_image_metadata(filename, NULL, is_linear);
+                       type = image_manager->get_image_metadata(filename.string(), NULL, is_linear);
                        if(type == ImageManager::IMAGE_DATA_TYPE_FLOAT || type == ImageManager::IMAGE_DATA_TYPE_FLOAT4)
                                is_float = 1;
                }
                else {
                        bool is_float_bool;
-                       slot = image_manager->add_image(filename,
+                       slot = image_manager->add_image(filename.string(),
                                                        builtin_data,
                                                        animated,
                                                        0,
index a0c09f0807a5fd8b452a927b40ea116912c468b8..41894dce86ae457f35041fd42317175ee472c892 100644 (file)
@@ -87,7 +87,7 @@ public:
        int is_float;
        bool is_linear;
        bool use_alpha;
-       string filename;
+       ustring filename;
        void *builtin_data;
        NodeImageColorSpace color_space;
        NodeImageProjection projection;
@@ -118,7 +118,7 @@ public:
        int is_float;
        bool is_linear;
        bool use_alpha;
-       string filename;
+       ustring filename;
        void *builtin_data;
        NodeImageColorSpace color_space;
        NodeEnvironmentProjection projection;
index 644e581bf4b972a59d211ec4239b13d30ddecf18..ff1f678c2d278bf52407dfa87de99bc7e5482366 100644 (file)
@@ -39,8 +39,8 @@ NODE_DEFINE(Object)
 
        SOCKET_NODE(mesh, "Mesh", &Mesh::node_type);
        SOCKET_TRANSFORM(tfm, "Transform", transform_identity());
-       SOCKET_INT(visibility, "Visibility", ~0);
-       SOCKET_INT(random_id, "Random ID", 0);
+       SOCKET_UINT(visibility, "Visibility", ~0);
+       SOCKET_UINT(random_id, "Random ID", 0);
        SOCKET_INT(pass_id, "Pass ID", 0);
        SOCKET_BOOLEAN(use_holdout, "Use Holdout", false);
        SOCKET_POINT(dupli_generated, "Dupli Generated", make_float3(0.0f, 0.0f, 0.0f));