[Bf-blender-cvs] [a30a863] object_nodes: Removed 'Value' node types for pointer and mesh data, and disallow hardcoding them as constants.

Lukas Tönne noreply at git.blender.org
Thu Dec 10 11:26:31 CET 2015


Commit: a30a863a547b7a94bffa85f6369c09c52536acef
Author: Lukas Tönne
Date:   Thu Dec 10 11:23:31 2015 +0100
Branches: object_nodes
https://developer.blender.org/rBa30a863a547b7a94bffa85f6369c09c52536acef

Removed 'Value' node types for pointer and mesh data, and disallow hardcoding them as constants.

Pointers in the instruction lists are bound to be invalid most of the time. They should only be
supplied externally via graph input arguments.

Note that opcodes still exist for POINTER/MESH, but these always store a NULL/empty DM
default value, rather than reading from instructions. They are only used by the code generator
as fallbacks if such sockets are not connected.

===================================================================

M	source/blender/blenvm/bvm/bvm_eval.cc
M	source/blender/blenvm/bvm/bvm_function.h
M	source/blender/blenvm/compile/bvm_codegen.cc
M	source/blender/blenvm/compile/bvm_nodegraph.cc

===================================================================

diff --git a/source/blender/blenvm/bvm/bvm_eval.cc b/source/blender/blenvm/bvm/bvm_eval.cc
index 62bfe1f..e444e1c 100644
--- a/source/blender/blenvm/bvm/bvm_eval.cc
+++ b/source/blender/blenvm/bvm/bvm_eval.cc
@@ -85,9 +85,12 @@ static void eval_op_value_matrix44(float *stack, matrix44 value, StackIndex offs
 	stack_store_matrix44(stack, offset, value);
 }
 
-static void eval_op_value_pointer(float *stack, PointerRNA value, StackIndex offset)
+/* Note: pointer data is not explicitly stored on the stack,
+ * this function always creates simply a NULL pointer.
+ */
+static void eval_op_value_pointer(float *stack, StackIndex offset)
 {
-	stack_store_pointer(stack, offset, value);
+	stack_store_pointer(stack, offset, PointerRNA_NULL);
 }
 
 /* Note: mesh data is not explicitly stored on the stack,
@@ -258,9 +261,8 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const Function *
 				break;
 			}
 			case OP_VALUE_POINTER: {
-				PointerRNA value = fn->read_pointer(&instr);
 				StackIndex offset = fn->read_stack_index(&instr);
-				eval_op_value_pointer(stack, value, offset);
+				eval_op_value_pointer(stack, offset);
 				break;
 			}
 			case OP_VALUE_MESH: {
diff --git a/source/blender/blenvm/bvm/bvm_function.h b/source/blender/blenvm/bvm/bvm_function.h
index f8875ce..fd436e9 100644
--- a/source/blender/blenvm/bvm/bvm_function.h
+++ b/source/blender/blenvm/bvm/bvm_function.h
@@ -61,20 +61,6 @@ static inline Instruction int_to_instruction(int v)
 	return u.i;
 }
 
-static inline Instruction pointer_to_instruction_lo(void *v)
-{
-	union { uint32_t i[2]; void *v; } u;
-	u.v = v;
-	return u.i[1];
-}
-
-static inline Instruction pointer_to_instruction_hi(void *v)
-{
-	union { uint32_t i[2]; void *v; } u;
-	u.v = v;
-	return u.i[0];
-}
-
 static inline float instruction_to_float(Instruction i)
 {
 	union { uint32_t i; float f; } u;
@@ -89,14 +75,6 @@ static inline int instruction_to_int(Instruction i)
 	return u.v;
 }
 
-static inline void *instruction_to_pointer(Instruction hi, Instruction lo)
-{
-	union { uint32_t i[2]; void *v; } u;
-	u.i[0] = hi;
-	u.i[1] = lo;
-	return u.v;
-}
-
 struct Argument {
 	Argument(const TypeDesc &typedesc, const string &name, StackIndex stack_offset) :
 	    typedesc(typedesc),
@@ -197,18 +175,6 @@ struct Function {
 		return m;
 	}
 	
-	PointerRNA read_pointer(int *instr) const
-	{
-		ID *id = (ID *)instruction_to_pointer(m_instructions[*instr + 0], m_instructions[*instr + 1]);
-		StructRNA *type = (StructRNA *)instruction_to_pointer(m_instructions[*instr + 2], m_instructions[*instr + 3]);
-		void *data = instruction_to_pointer(m_instructions[*instr + 4], m_instructions[*instr + 5]);
-		(*instr) += 6;
-		
-		PointerRNA ptr;
-		RNA_pointer_create(id, type, data, &ptr);
-		return ptr;
-	}
-	
 	void add_instruction(Instruction v);
 	int get_instruction_count() const { return m_instructions.size(); }
 	
diff --git a/source/blender/blenvm/compile/bvm_codegen.cc b/source/blender/blenvm/compile/bvm_codegen.cc
index 66a6c58..9d081c0 100644
--- a/source/blender/blenvm/compile/bvm_codegen.cc
+++ b/source/blender/blenvm/compile/bvm_codegen.cc
@@ -284,16 +284,6 @@ void BVMCompiler::push_matrix44(matrix44 m) const
 	fn->add_instruction(float_to_instruction(m.data[3][3]));
 }
 
-void BVMCompiler::push_pointer(PointerRNA p) const
-{
-	fn->add_instruction(pointer_to_instruction_hi(p.id.data));
-	fn->add_instruction(pointer_to_instruction_lo(p.id.data));
-	fn->add_instruction(pointer_to_instruction_hi(p.type));
-	fn->add_instruction(pointer_to_instruction_lo(p.type));
-	fn->add_instruction(pointer_to_instruction_hi(p.data));
-	fn->add_instruction(pointer_to_instruction_lo(p.data));
-}
-
 void BVMCompiler::push_constant(const Value *value) const
 {
 	switch (value->typedesc().base_type) {
@@ -333,14 +323,12 @@ void BVMCompiler::push_constant(const Value *value) const
 			break;
 		}
 		case BVM_POINTER: {
-			PointerRNA p = PointerRNA_NULL;
-			value->get(&p);
-			
-			push_pointer(p);
+			BLI_assert(!"POINTER type can not be stored as a constant!");
 			break;
 		}
 		
 		case BVM_MESH:
+			BLI_assert(!"MESH type can not be stored as a constant!");
 			break;
 	}
 }
@@ -394,11 +382,7 @@ void BVMCompiler::codegen_value(const Value *value, StackIndex offset) const
 			break;
 		}
 		case BVM_POINTER: {
-			PointerRNA p = PointerRNA_NULL;
-			value->get(&p);
-			
 			push_opcode(OP_VALUE_POINTER);
-			push_pointer(p);
 			push_stack_index(offset);
 			break;
 		}
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.cc b/source/blender/blenvm/compile/bvm_nodegraph.cc
index 7d2647d..113e4aa 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.cc
+++ b/source/blender/blenvm/compile/bvm_nodegraph.cc
@@ -1068,8 +1068,6 @@ OpCode get_opcode_from_node_type(const string &node)
 	NODETYPE(VALUE_FLOAT4);
 	NODETYPE(VALUE_INT);
 	NODETYPE(VALUE_MATRIX44);
-	NODETYPE(VALUE_POINTER);
-	NODETYPE(VALUE_MESH);
 	
 	NODETYPE(FLOAT_TO_INT);
 	NODETYPE(INT_TO_FLOAT);
@@ -1236,14 +1234,6 @@ static void register_opcode_node_types()
 	nt->add_input("value", BVM_MATRIX44, matrix44::identity(), INPUT_CONSTANT);
 	nt->add_output("value", BVM_MATRIX44);
 	
-	nt = NodeGraph::add_function_node_type("VALUE_POINTER");
-	nt->add_input("value", BVM_POINTER, PointerRNA_NULL, INPUT_CONSTANT);
-	nt->add_output("value", BVM_POINTER);
-	
-	nt = NodeGraph::add_function_node_type("VALUE_MESH");
-	nt->add_input("value", BVM_MESH, __empty_mesh__, INPUT_CONSTANT);
-	nt->add_output("value", BVM_MESH);
-	
 	nt = NodeGraph::add_function_node_type("GET_ELEM_FLOAT3");
 	nt->add_input("index", BVM_INT, 0, INPUT_CONSTANT);
 	nt->add_input("value", BVM_FLOAT3, float3(0.0f, 0.0f, 0.0f));




More information about the Bf-blender-cvs mailing list