[Bf-blender-cvs] [66070ec] object_nodes: Split off from the bvm::Function class the basic instruction list functionality.
Lukas Tönne
noreply at git.blender.org
Wed Jan 13 19:36:33 CET 2016
Commit: 66070ec814592f9cbe13f880f1a70627e27ec428
Author: Lukas Tönne
Date: Wed Jan 13 19:26:17 2016 +0100
Branches: object_nodes
https://developer.blender.org/rB66070ec814592f9cbe13f880f1a70627e27ec428
Split off from the bvm::Function class the basic instruction list functionality.
The point of this is to keep type definitions out of the core bvm eval code.
TypeDesc is only used for the outermost layer of bvm::Function in order to
copy arguments to and results from the eval stack. OpCodes themselves are
agnostic to higher type definitions and just work with raw data.
===================================================================
M build_files/cmake/macros.cmake
M source/blender/blenvm/bvm/CMakeLists.txt
M source/blender/blenvm/bvm/bvm_eval.cc
M source/blender/blenvm/bvm/bvm_eval.h
M source/blender/blenvm/bvm/bvm_eval_common.h
D source/blender/blenvm/bvm/bvm_function.cc
D source/blender/blenvm/bvm/bvm_function.h
A source/blender/blenvm/bvm/bvm_instruction_list.cc
A source/blender/blenvm/bvm/bvm_instruction_list.h
M source/blender/blenvm/compile/CMakeLists.txt
M source/blender/blenvm/compile/bvm_codegen.h
A source/blender/blenvm/compile/bvm_function.cc
A source/blender/blenvm/compile/bvm_function.h
M source/blender/blenvm/intern/bvm_api.cc
M source/blender/blenvm/util/bvm_util_data_ptr.h
===================================================================
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 283cdda..532660b 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -571,8 +571,8 @@ function(SETUP_BLENDER_SORTED_LIBS)
bf_gpu
bf_blenkernel
bf_blenvm
- bf_blenvm_bvm
bf_blenvm_compile
+ bf_blenvm_bvm
bf_physics
bf_nodes
bf_rna
diff --git a/source/blender/blenvm/bvm/CMakeLists.txt b/source/blender/blenvm/bvm/CMakeLists.txt
index 31f8b08..fd8add6 100644
--- a/source/blender/blenvm/bvm/CMakeLists.txt
+++ b/source/blender/blenvm/bvm/CMakeLists.txt
@@ -46,8 +46,8 @@ set(SRC
bvm_eval_math.h
bvm_eval_mesh.h
bvm_eval_texture.h
- bvm_function.cc
- bvm_function.h
+ bvm_instruction_list.cc
+ bvm_instruction_list.h
bvm_opcode.h
)
diff --git a/source/blender/blenvm/bvm/bvm_eval.cc b/source/blender/blenvm/bvm/bvm_eval.cc
index 5f08fbf..7a8cdb9 100644
--- a/source/blender/blenvm/bvm/bvm_eval.cc
+++ b/source/blender/blenvm/bvm/bvm_eval.cc
@@ -335,7 +335,7 @@ static void eval_op_duplis_combine(float *stack, StackIndex offset_duplis_a, Sta
stack_store_duplis(stack, offset_duplis, result);
}
-void EvalContext::eval_instructions(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const
+void EvalContext::eval_instructions(const EvalGlobals *globals, const InstructionList *fn, int entry_point, float *stack) const
{
EvalKernelData kd;
kd.context = this;
@@ -1112,32 +1112,7 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const Function *
}
}
-void EvalContext::eval_function(const EvalGlobals *globals, const Function *fn, const void *arguments[], void *results[]) const
-{
- float stack[BVM_STACK_SIZE] = {0};
-
- /* initialize input arguments */
- for (int i = 0; i < fn->num_arguments(); ++i) {
- const Argument &arg = fn->argument(i);
- if (arg.stack_offset != BVM_STACK_INVALID) {
- float *value = &stack[arg.stack_offset];
-
- arg.typedesc.copy_value((void *)value, arguments[i]);
- }
- }
-
- eval_instructions(globals, fn, fn->entry_point(), stack);
-
- /* read out return values */
- for (int i = 0; i < fn->num_return_values(); ++i) {
- const Argument &rval = fn->return_value(i);
- float *value = &stack[rval.stack_offset];
-
- rval.typedesc.copy_value(results[i], (void *)value);
- }
-}
-
-void EvalContext::eval_expression(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const
+void EvalContext::eval_expression(const EvalGlobals *globals, const InstructionList *fn, int entry_point, float *stack) const
{
if (entry_point != BVM_JMP_INVALID)
eval_instructions(globals, fn, entry_point, stack);
diff --git a/source/blender/blenvm/bvm/bvm_eval.h b/source/blender/blenvm/bvm/bvm_eval.h
index ae828b3..85efaa6 100644
--- a/source/blender/blenvm/bvm/bvm_eval.h
+++ b/source/blender/blenvm/bvm/bvm_eval.h
@@ -36,16 +36,19 @@
#include "MEM_guardedalloc.h"
+extern "C" {
+#include "RNA_access.h"
+}
+
#include "bvm_util_map.h"
#include "bvm_util_string.h"
-#include "bvm_util_typedesc.h"
struct ID;
struct Object;
namespace bvm {
-struct Function;
+struct InstructionList;
#define BVM_STACK_SIZE 4095
@@ -67,12 +70,10 @@ struct EvalContext {
EvalContext();
~EvalContext();
- void eval_function(const EvalGlobals *globals, const Function *fn, const void *arguments[], void *results[]) const;
- void eval_expression(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const;
+ void eval_expression(const EvalGlobals *globals, const InstructionList *instr, int entry_point, float *stack) const;
+
+ void eval_instructions(const EvalGlobals *globals, const InstructionList *instr, int entry_point, float *stack) const;
-protected:
- void eval_instructions(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const;
-
MEM_CXX_CLASS_ALLOC_FUNCS("BVM:EvalContext")
};
diff --git a/source/blender/blenvm/bvm/bvm_eval_common.h b/source/blender/blenvm/bvm/bvm_eval_common.h
index 935f25d..5baa686 100644
--- a/source/blender/blenvm/bvm/bvm_eval_common.h
+++ b/source/blender/blenvm/bvm/bvm_eval_common.h
@@ -33,7 +33,7 @@
*/
#include "bvm_eval.h"
-#include "bvm_function.h"
+#include "bvm_instruction_list.h"
namespace bvm {
@@ -41,7 +41,7 @@ struct EvalContext;
struct EvalKernelData {
const EvalContext *context;
- const Function *function;
+ const InstructionList *function;
};
inline static float stack_load_float(float *stack, StackIndex offset)
diff --git a/source/blender/blenvm/bvm/bvm_eval.h b/source/blender/blenvm/bvm/bvm_instruction_list.cc
similarity index 50%
copy from source/blender/blenvm/bvm/bvm_eval.h
copy to source/blender/blenvm/bvm/bvm_instruction_list.cc
index ae828b3..0103952a 100644
--- a/source/blender/blenvm/bvm/bvm_eval.h
+++ b/source/blender/blenvm/bvm/bvm_instruction_list.cc
@@ -25,57 +25,31 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __BVM_EVAL_H__
-#define __BVM_EVAL_H__
-
-/** \file bvm_eval.h
+/** \file bvm_instruction_list.cc
* \ingroup bvm
*/
-#include <vector>
-
-#include "MEM_guardedalloc.h"
-
-#include "bvm_util_map.h"
-#include "bvm_util_string.h"
-#include "bvm_util_typedesc.h"
-
-struct ID;
-struct Object;
+#include "bvm_instruction_list.h"
namespace bvm {
-struct Function;
+InstructionList::InstructionList() :
+ m_entry_point(0)
+{
+}
-#define BVM_STACK_SIZE 4095
+InstructionList::~InstructionList()
+{
+}
-struct EvalGlobals {
- typedef unordered_map<int, Object *> ObjectMap;
-
- static int get_id_key(ID *id);
-
- void add_object(int key, Object *ob);
- PointerRNA lookup_object(int key) const;
-
-private:
- ObjectMap m_objects;
+void InstructionList::add_instruction(Instruction v)
+{
+ m_instructions.push_back(v);
+}
- MEM_CXX_CLASS_ALLOC_FUNCS("BVM:EvalGlobals")
-};
-
-struct EvalContext {
- EvalContext();
- ~EvalContext();
-
- void eval_function(const EvalGlobals *globals, const Function *fn, const void *arguments[], void *results[]) const;
- void eval_expression(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const;
-
-protected:
- void eval_instructions(const EvalGlobals *globals, const Function *fn, int entry_point, float *stack) const;
-
- MEM_CXX_CLASS_ALLOC_FUNCS("BVM:EvalContext")
-};
+void InstructionList::set_entry_point(int entry_point)
+{
+ m_entry_point = entry_point;
+}
} /* namespace bvm */
-
-#endif /* __BVM_EVAL_H__ */
diff --git a/source/blender/blenvm/bvm/bvm_function.h b/source/blender/blenvm/bvm/bvm_instruction_list.h
similarity index 77%
rename from source/blender/blenvm/bvm/bvm_function.h
rename to source/blender/blenvm/bvm/bvm_instruction_list.h
index 4de0705..1e04b3c 100644
--- a/source/blender/blenvm/bvm/bvm_function.h
+++ b/source/blender/blenvm/bvm/bvm_instruction_list.h
@@ -25,10 +25,10 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __BVM_FUNCTION_H__
-#define __BVM_FUNCTION_H__
+#ifndef __BVM_INSTRUCTION_LIST_H__
+#define __BVM_INSTRUCTION_LIST_H__
-/** \file bvm_function.h
+/** \file bvm_instruction_list.h
* \ingroup bvm
*/
@@ -38,9 +38,10 @@
#include "MEM_guardedalloc.h"
#include "bvm_opcode.h"
+#include "bvm_util_data_ptr.h"
+#include "bvm_util_math.h"
#include "bvm_util_string.h"
#include "bvm_util_thread.h"
-#include "bvm_util_typedesc.h"
namespace bvm {
@@ -77,29 +78,11 @@ static inline int instruction_to_int(Instruction i)
return u.v;
}
-struct Argument {
- Argument(const TypeDesc &typedesc, const string &name, StackIndex stack_offset) :
- typedesc(typedesc),
- name(name),
- stack_offset(stack_offset)
- {}
+struct InstructionList {
+ typedef std::vector<Instruction> Instructions;
- TypeDesc typedesc;
- string name;
- StackIndex stack_offset;
-
- MEM_CXX_CLASS_ALLOC_FUNCS("BVM:ReturnValue")
-};
-
-struct Function {
- typedef std::vector<Argument> ArgumentList;
- typedef std::vector<Instruction> InstructionList;
-
- Function();
- ~Function();
-
- static void retain(Function *fn);
- static void release(Function **fn);
+ InstructionList();
+ ~InstructionList();
OpCode read_opcode(int *instr) const
{
@@ -199,30 +182,13 @@ struct Function {
int entry_point() const { return m_entry_point; }
void set_entry_point(int entry_point);
- size_t num_return_values() const;
- const Argument &return_value(size_t index) const;
- const Argument &return_value(const string &name) const;
- size_t num_arguments() const;
- const Argument &argument(size_t index) const;
- const Argument &argument(const string &name) const;
-
- void add_argument(const TypeDesc &typedesc, const string &name, StackIndex stack_offset);
- void add_return_value(const TypeDesc &typedesc, const string &name, StackIndex stack_offset);
-
-private:
- ArgumentList m_arguments;
- ArgumentList m_return_values;
- InstructionList m_instructions;
+protected:
+ Instructions m_instructions;
int m_entry_point;
- int m_users;
-
- static mutex users_mutex;
- static spin_lock users_lock;
-
- MEM_CXX_CLASS_ALLOC_FUNCS("BVM:Function")
+ MEM_CXX_CLASS_ALLOC_FUNCS("BVM:InstructionList")
};
} /* namespace bvm */
-#endif /* __BVM_FUNCTION_H__ */
+#endif /* __BVM_INSTRUCTION_LIST_H__ */
diff --git a/source/blender/blenvm/compile/CMakeLists.txt b/source/blender/blenvm/compile/CMakeLists.txt
index c315b98..2da67e2 100644
--- a/source/blender/blenvm/compile/CMakeLists.txt
+++ b/source/blender/blenvm/compile/CMakeLists.txt
@@ -42,6 +42,8 @@ set(SRC
bvm_codegen.cc
bvm_codegen_debug.cc
bvm_codegen.h
+ bvm_function.h
+ bvm_function.cc
bvm_nodegraph.cc
bvm_nodegraph.h
)
diff --git a/source/blender/blenvm/compile/bvm_codegen.h b/source/blender/blenvm/compile/bvm_codegen.h
index 20196ac..421fb83 100644
--- a/source/blender/blenvm/compile/bvm_codegen.h
+++ b/source/blender/blenvm/compile/bvm_codegen.h
@@ -37,7 +37,7 @@
#include "MEM_guardedalloc.h"
-#include "bvm_function.h"
+#include "bvm_instruction_list.h"
#include "bvm_nodegraph.h"
#include "bvm_opcode.h"
#include "bvm_util_string.h"
diff --git a/source/blender/blenvm/bvm/bvm_function.cc b/source/blender/blenvm/compile/bvm_function.cc
similarity index 78%
rename from source/blender/blenvm/bvm/bvm_function.cc
rename to source/blender/blenvm/
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list