[Bf-blender-cvs] [0e974d6] object_nodes: Define the base opcode functions for LLVM and use util_ files for types.
Lukas Tönne
noreply at git.blender.org
Thu May 12 19:26:48 CEST 2016
Commit: 0e974d6e917ef2bbf89d26b41eeba69893a74d15
Author: Lukas Tönne
Date: Thu May 12 19:26:03 2016 +0200
Branches: object_nodes
https://developer.blender.org/rB0e974d6e917ef2bbf89d26b41eeba69893a74d15
Define the base opcode functions for LLVM and use util_ files for types.
===================================================================
M source/blender/blenvm/llvm/CMakeLists.txt
M source/blender/blenvm/llvm/llvm_modules.cc
A source/blender/blenvm/modules/mod_base.h
M source/blender/blenvm/modules/mod_color.h
M source/blender/blenvm/modules/mod_math.h
D source/blender/blenvm/modules/mod_value.h
M source/blender/blenvm/modules/modules.cc
M source/blender/blenvm/util/util_data_ptr.h
===================================================================
diff --git a/source/blender/blenvm/llvm/CMakeLists.txt b/source/blender/blenvm/llvm/CMakeLists.txt
index 1e8ecea..035d263 100644
--- a/source/blender/blenvm/llvm/CMakeLists.txt
+++ b/source/blender/blenvm/llvm/CMakeLists.txt
@@ -59,10 +59,10 @@ set(LLVM_SRC
../modules/modules.cc
)
set(LLVM_HEADERS
+ ../modules/mod_base.h
../modules/mod_color.h
../modules/mod_defines.h
../modules/mod_math.h
- ../modules/mod_value.h
)
if(NOT WITH_BLENVM_IRMODULES)
diff --git a/source/blender/blenvm/llvm/llvm_modules.cc b/source/blender/blenvm/llvm/llvm_modules.cc
index f173494..0c7a3b6 100644
--- a/source/blender/blenvm/llvm/llvm_modules.cc
+++ b/source/blender/blenvm/llvm/llvm_modules.cc
@@ -51,9 +51,9 @@ extern "C" {
#include "util_math.h"
#include "util_opcode.h"
+#include "mod_base.h"
#include "mod_color.h"
#include "mod_math.h"
-#include "mod_value.h"
namespace blenvm {
@@ -265,12 +265,7 @@ void llvm_declare_node_functions()
Module *mod = new llvm::Module("nodes", context);
#define TEST_OPCODES \
- DEF_OPCODE(VALUE_FLOAT) \
- DEF_OPCODE(VALUE_FLOAT3) \
- DEF_OPCODE(VALUE_FLOAT4) \
- DEF_OPCODE(VALUE_INT) \
- DEF_OPCODE(VALUE_MATRIX44) \
- DEF_OPCODE(MIX_RGB) \
+ BVM_DEFINE_OPCODES_BASE \
#define DEF_OPCODE(op) \
{ \
diff --git a/source/blender/blenvm/modules/mod_value.h b/source/blender/blenvm/modules/mod_base.h
similarity index 53%
rename from source/blender/blenvm/modules/mod_value.h
rename to source/blender/blenvm/modules/mod_base.h
index d4f9dc6..e1d30e0 100644
--- a/source/blender/blenvm/modules/mod_value.h
+++ b/source/blender/blenvm/modules/mod_base.h
@@ -30,8 +30,21 @@
#include "mod_defines.h"
+#include "util_data_ptr.h"
+#include "util_math.h"
+#include "util_string.h"
+
+extern "C" {
+#include "RNA_access.h"
+}
+
BVM_MOD_NAMESPACE_BEGIN
+BVM_MOD_FUNCTION("NOOP")
+void NOOP(void)
+{
+}
+
BVM_MOD_FUNCTION("VALUE_FLOAT")
void VALUE_FLOAT(float &result, float value)
{
@@ -62,6 +75,68 @@ void VALUE_MATRIX44(matrix44 &result, const matrix44 &value)
result = value;
}
+BVM_MOD_FUNCTION("VALUE_STRING")
+void VALUE_STRING(const char *&result, const char *value)
+{
+ result = value;
+}
+
+BVM_MOD_FUNCTION("VALUE_RNAPOINTER")
+void VALUE_RNAPOINTER(PointerRNA &result, const PointerRNA &value)
+{
+ result = value;
+}
+
+BVM_MOD_FUNCTION("VALUE_MESH")
+void VALUE_MESH(mesh_ptr &result, const mesh_ptr &value)
+{
+ result = value;
+}
+
+BVM_MOD_FUNCTION("VALUE_DUPLIS")
+void VALUE_DUPLIS(duplis_ptr &result, const duplis_ptr &value)
+{
+ result = value;
+}
+
+BVM_MOD_FUNCTION("FLOAT_TO_INT")
+void FLOAT_TO_INT(int &result, float value)
+{
+ result = (int)value;
+}
+
+BVM_MOD_FUNCTION("INT_TO_FLOAT")
+void INT_TO_FLOAT(float &result, int value)
+{
+ result = (float)value;
+}
+
+BVM_MOD_FUNCTION("SET_FLOAT3")
+void SET_FLOAT3(float3 &result, float x, float y, float z)
+{
+ result = float3(x, y, z);
+}
+
+BVM_MOD_FUNCTION("SET_FLOAT4")
+void GET_ELEM_FLOAT3(float &result, const float3 &f, int index)
+{
+ BLI_assert(index >= 0 && index < 3);
+ result = f[index];
+}
+
+BVM_MOD_FUNCTION("SET_FLOAT4")
+void SET_FLOAT4(float4 &result, float x, float y, float z, float w)
+{
+ result = float4(x, y, z, w);
+}
+
+BVM_MOD_FUNCTION("SET_FLOAT4")
+void GET_ELEM_FLOAT4(float &result, const float4 &f, int index)
+{
+ BLI_assert(index >= 0 && index < 4);
+ result = f[index];
+}
+
BVM_MOD_NAMESPACE_END
#endif /* __MOD_VALUE_H__ */
diff --git a/source/blender/blenvm/modules/mod_color.h b/source/blender/blenvm/modules/mod_color.h
index 27a074a..07c8d59 100644
--- a/source/blender/blenvm/modules/mod_color.h
+++ b/source/blender/blenvm/modules/mod_color.h
@@ -28,12 +28,9 @@
#ifndef __MOD_COLOR_H__
#define __MOD_COLOR_H__
-extern "C" {
-#include "BLI_math_color.h"
-}
-
#include "mod_defines.h"
-#include "mod_math.h"
+
+#include "util_math.h"
BVM_MOD_NAMESPACE_BEGIN
diff --git a/source/blender/blenvm/modules/mod_math.h b/source/blender/blenvm/modules/mod_math.h
index 6d197f3..7581918 100644
--- a/source/blender/blenvm/modules/mod_math.h
+++ b/source/blender/blenvm/modules/mod_math.h
@@ -28,135 +28,10 @@
#ifndef __MOD_MATH_H__
#define __MOD_MATH_H__
-extern "C" {
-#include "BLI_math.h"
-}
+#include "util_math.h"
BVM_MOD_NAMESPACE_BEGIN
-struct float3 {
- float3()
- {}
-
- float3(float x, float y, float z) :
- x(x), y(y), z(z)
- {}
-
- float* data() { return &x; }
- const float* data() const { return &x; }
-
- inline static float3 from_data(const float *values)
- {
- float3 f;
- f.x = values[0];
- f.y = values[1];
- f.z = values[2];
- return f;
- }
-
- float& operator[] (int index)
- {
- return ((float*)(&x))[index];
- }
- float operator[] (int index) const
- {
- return ((float*)(&x))[index];
- }
-
- float x;
- float y;
- float z;
-};
-
-struct float4 {
- float4()
- {}
-
- float4(float x, float y, float z, float w) :
- x(x), y(y), z(z), w(w)
- {}
-
- float* data() { return &x; }
- const float* data() const { return &x; }
-
- inline static float4 from_data(const float *values)
- {
- float4 f;
- f.x = values[0];
- f.y = values[1];
- f.z = values[2];
- f.w = values[3];
- return f;
- }
-
- float& operator[] (int index)
- {
- return ((float*)(&x))[index];
- }
- float operator[] (int index) const
- {
- return ((float*)(&x))[index];
- }
-
- float x;
- float y;
- float z;
- float w;
-};
-
-struct matrix44 {
- enum Layout {
- COL_MAJOR,
- ROW_MAJOR,
- };
-
- matrix44()
- {}
-
- matrix44(const float3 &x, const float3 &y, const float3 &z, const float3 &t)
- {
- data[0][0] = x.x; data[1][0] = y.x; data[2][0] = z.x; data[3][0] = t.x;
- data[0][1] = x.y; data[1][1] = y.y; data[2][1] = z.y; data[3][1] = t.y;
- data[0][2] = x.z; data[1][2] = y.z; data[2][2] = z.z; data[3][2] = t.z;
- data[0][3] = 0.0f; data[1][3] = 0.0f; data[2][3] = 0.0f; data[3][3] = 1.0f;
- }
-
- matrix44(const float3 &t)
- {
- data[0][0] = 1.0f; data[1][0] = 0.0f; data[2][0] = 0.0f; data[3][0] = t.x;
- data[0][1] = 0.0f; data[1][1] = 1.0f; data[2][1] = 0.0f; data[3][1] = t.y;
- data[0][2] = 0.0f; data[1][2] = 0.0f; data[2][2] = 1.0f; data[3][2] = t.z;
- data[0][3] = 0.0f; data[1][3] = 0.0f; data[2][3] = 0.0f; data[3][3] = 1.0f;
- }
-
- inline static matrix44 from_data(const float *values, Layout layout = COL_MAJOR) {
- matrix44 m;
- if (layout == COL_MAJOR) {
- m.data[0][0] = values[0]; m.data[1][0] = values[1]; m.data[2][0] = values[2]; m.data[3][0] = values[3];
- m.data[0][1] = values[4]; m.data[1][1] = values[5]; m.data[2][1] = values[6]; m.data[3][1] = values[7];
- m.data[0][2] = values[8]; m.data[1][2] = values[9]; m.data[2][2] = values[10]; m.data[3][2] = values[11];
- m.data[0][3] = values[12]; m.data[1][3] = values[13]; m.data[2][3] = values[14]; m.data[3][3] = values[15];
- }
- else {
- m.data[0][0] = values[0]; m.data[1][0] = values[4]; m.data[2][0] = values[8]; m.data[3][0] = values[12];
- m.data[0][1] = values[1]; m.data[1][1] = values[5]; m.data[2][1] = values[9]; m.data[3][1] = values[13];
- m.data[0][2] = values[2]; m.data[1][2] = values[6]; m.data[2][2] = values[10]; m.data[3][2] = values[14];
- m.data[0][3] = values[3]; m.data[1][3] = values[7]; m.data[2][3] = values[11]; m.data[3][3] = values[15];
- }
- return m;
- }
-
- inline static matrix44 identity()
- {
- return matrix44(float3(1.0f, 0.0f, 0.0f),
- float3(0.0f, 1.0f, 0.0f),
- float3(0.0f, 0.0f, 1.0f),
- float3(0.0f, 0.0f, 0.0f));
- }
-
- float data[4][4];
-};
-
BVM_MOD_NAMESPACE_END
#endif /* __MOD_MATH_H__ */
diff --git a/source/blender/blenvm/modules/modules.cc b/source/blender/blenvm/modules/modules.cc
index 71ee5af..64cb0c7 100644
--- a/source/blender/blenvm/modules/modules.cc
+++ b/source/blender/blenvm/modules/modules.cc
@@ -25,12 +25,13 @@
* ***** END GPL LICENSE BLOCK *****
*/
+#include "mod_base.h"
#include "mod_color.h"
#include "mod_math.h"
-#include "mod_value.h"
BVM_MOD_NAMESPACE_BEGIN
+#if 0
inline int force_linking()
{
int i = 0;
@@ -46,5 +47,6 @@ inline int force_linking()
}
static int f = force_linking();
+#endif
BVM_MOD_NAMESPACE_END
diff --git a/source/blender/blenvm/util/util_data_ptr.h b/source/blender/blenvm/util/util_data_ptr.h
index b9f572b..c3ed90d 100644
--- a/source/blender/blenvm/util/util_data_ptr.h
+++ b/source/blender/blenvm/util/util_data_ptr.h
@@ -33,6 +33,7 @@
#define __BVM_UTIL_DATA_PTR_H__
#include <assert.h>
+#include <vector>
#include "MEM_guardedalloc.h"
More information about the Bf-blender-cvs
mailing list