From 24d53f79b217ff7c62e4c32a49967447a0230fef Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 12 Jun 2016 17:12:25 +0200 Subject: Fix Cycles debug build assert on some platforms, tighten checks to avoid this in the future. --- intern/cycles/graph/node.cpp | 12 ++++++++++++ intern/cycles/graph/node.h | 2 ++ intern/cycles/graph/node_type.cpp | 1 + intern/cycles/graph/node_type.h | 5 ++++- intern/cycles/graph/node_xml.cpp | 10 ++++++++++ 5 files changed, 29 insertions(+), 1 deletion(-) (limited to 'intern/cycles/graph') diff --git a/intern/cycles/graph/node.cpp b/intern/cycles/graph/node.cpp index 941a66741c5..3c228a716d5 100644 --- a/intern/cycles/graph/node.cpp +++ b/intern/cycles/graph/node.cpp @@ -82,6 +82,12 @@ void Node::set(const SocketType& input, int value) get_socket_value(this, input) = value; } +void Node::set(const SocketType& input, uint value) +{ + assert(input.type == SocketType::UINT); + get_socket_value(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(this, input); } +uint Node::get_uint(const SocketType& input) const +{ + assert(input.type == SocketType::UINT); + return get_socket_value(this, input); +} + float Node::get_float(const SocketType& input) const { assert(input.type == SocketType::FLOAT); diff --git a/intern/cycles/graph/node.h b/intern/cycles/graph/node.h index bb84f982fb3..64410f4539b 100644 --- a/intern/cycles/graph/node.h +++ b/intern/cycles/graph/node.h @@ -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; diff --git a/intern/cycles/graph/node_type.cpp b/intern/cycles/graph/node_type.cpp index 7f68ae9c7c7..6c6035fdb22 100644 --- a/intern/cycles/graph/node_type.cpp +++ b/intern/cycles/graph/node_type.cpp @@ -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); diff --git a/intern/cycles/graph/node_type.h b/intern/cycles/graph/node_type.h index 20816f634cd..e84631cd59d 100644 --- a/intern/cycles/graph/node_type.h +++ b/intern/cycles/graph/node_type.h @@ -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, ...) \ diff --git a/intern/cycles/graph/node_xml.cpp b/intern/cycles/graph/node_xml.cpp index 022de7cf32a..590e09645ed 100644 --- a/intern/cycles/graph/node_xml.cpp +++ b/intern/cycles/graph/node_xml.cpp @@ -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 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; -- cgit v1.2.3