[Bf-blender-cvs] [849b5ae] object_nodes: New bf library 'BlenVM' ("Blender Virtual Machine", BVM), as a general purpose runtime node backend.

Lukas Tönne noreply at git.blender.org
Tue Nov 24 09:42:41 CET 2015


Commit: 849b5aec20f79bcfb042a10873faca2c43ae427b
Author: Lukas Tönne
Date:   Fri Sep 11 13:35:51 2015 +0200
Branches: object_nodes
https://developer.blender.org/rB849b5aec20f79bcfb042a10873faca2c43ae427b

New bf library 'BlenVM' ("Blender Virtual Machine", BVM), as a general purpose runtime node backend.

This library provides a way to register modules and functions. Functions are simple
opcode-based descriptions of functionality (programs). They can be evaluated with
a simple interpreter using monolithic kernels, or could be compiled into more
optimized languages via LLVM or OpenCL.

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

M	source/blender/CMakeLists.txt
A	source/blender/blenvm/BVM_function.h
A	source/blender/blenvm/BVM_module.h
A	source/blender/blenvm/CMakeLists.txt
A	source/blender/blenvm/intern/bvm_function.cc
A	source/blender/blenvm/intern/bvm_module.cc

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

diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index e36f9e2..12f27b5 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -103,6 +103,7 @@ add_subdirectory(render)
 add_subdirectory(blenfont)
 add_subdirectory(blentranslation)
 add_subdirectory(blenloader)
+add_subdirectory(blenvm)
 add_subdirectory(depsgraph)
 add_subdirectory(ikplugin)
 add_subdirectory(physics)
diff --git a/source/blender/blenvm/BVM_function.h b/source/blender/blenvm/BVM_function.h
new file mode 100644
index 0000000..f8d657c
--- /dev/null
+++ b/source/blender/blenvm/BVM_function.h
@@ -0,0 +1,41 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BVM_FUNCTION_H__
+#define __BVM_FUNCTION_H__
+
+/** \file BVM_function.h
+ *  \ingroup bvm
+ */
+
+#include "DNA_defs.h"
+
+typedef struct BVMFunction {
+	char name[MAX_NAME];
+} BVMFunction;
+
+#endif /* __BVM_FUNCTION_H__ */
diff --git a/source/blender/blenvm/BVM_module.h b/source/blender/blenvm/BVM_module.h
new file mode 100644
index 0000000..46ccf9a
--- /dev/null
+++ b/source/blender/blenvm/BVM_module.h
@@ -0,0 +1,44 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __BVM_MODULE_H__
+#define __BVM_MODULE_H__
+
+/** \file BVM_module.h
+ *  \ingroup bvm
+ */
+
+struct BVMFunction;
+
+typedef struct BVMModule {
+	struct GHash *functions;
+} BVMModule;
+
+void BVM_module_init(struct BVMModule *lib);
+void BVM_module_free(struct BVMModule *lib);
+
+#endif /* __BVM_MODULE_H__ */
diff --git a/source/blender/blenvm/CMakeLists.txt b/source/blender/blenvm/CMakeLists.txt
new file mode 100644
index 0000000..26a7147
--- /dev/null
+++ b/source/blender/blenvm/CMakeLists.txt
@@ -0,0 +1,44 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2015, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Lukas Toenne.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+	.
+	../blenlib
+	../makesdna
+	../../../intern/guardedalloc
+)
+
+set(INC_SYS
+)
+
+set(SRC
+	intern/bvm_function.cc
+	intern/bvm_module.cc
+
+	BVM_function.h
+	BVM_module.h
+)
+
+blender_add_lib(bf_blenvm "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/blenvm/intern/bvm_function.cc b/source/blender/blenvm/intern/bvm_function.cc
new file mode 100644
index 0000000..7cabc58
--- /dev/null
+++ b/source/blender/blenvm/intern/bvm_function.cc
@@ -0,0 +1,35 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenvm/intern/function.cc
+ *  \ingroup bvm
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BVM_function.h"
+
diff --git a/source/blender/blenvm/intern/bvm_module.cc b/source/blender/blenvm/intern/bvm_module.cc
new file mode 100644
index 0000000..53e496c
--- /dev/null
+++ b/source/blender/blenvm/intern/bvm_module.cc
@@ -0,0 +1,61 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/blenvm/intern/module.cc
+ *  \ingroup bvm
+ */
+
+#include <cstdlib> /* needed for BLI_assert */
+
+extern "C" {
+#include "BLI_utildefines.h"
+#include "BLI_ghash.h"
+}
+
+#include "MEM_guardedalloc.h"
+
+#include "BVM_function.h"
+#include "BVM_module.h"
+
+// forward declaration
+static void ghash_function_free(BVMFunction *fun);
+
+void BVM_module_init(BVMModule *lib)
+{
+	lib->functions = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "BVM library functions");
+}
+
+void BVM_module_free(BVMModule *lib)
+{
+	BLI_assert(lib->functions != NULL);
+	BLI_ghash_free(lib->functions, NULL, (GHashValFreeFP)ghash_function_free);
+}
+
+static void ghash_function_free(BVMFunction *fun)
+{
+	MEM_freeN(fun);
+}




More information about the Bf-blender-cvs mailing list