[Bf-blender-cvs] [0f868ea] object_nodes: Include mesh opcode functions in modules.
Lukas Tönne
noreply at git.blender.org
Fri Jun 24 10:24:29 CEST 2016
Commit: 0f868ea6b620cf402de0f099f57e1b19c3c8b509
Author: Lukas Tönne
Date: Fri Jun 24 08:40:08 2016 +0200
Branches: object_nodes
https://developer.blender.org/rB0f868ea6b620cf402de0f099f57e1b19c3c8b509
Include mesh opcode functions in modules.
Modifier functions with variable expression inputs are disabled,
until DerivedMesh handling through LLVM is implemented.
===================================================================
M source/blender/blenvm/CMakeLists.txt
M source/blender/blenvm/bvm/bvm_eval.cc
M source/blender/blenvm/bvm/bvm_eval_mesh.h
M source/blender/blenvm/llvm/llvm_types.h
A source/blender/blenvm/modules/mod_mesh.h
M source/blender/blenvm/modules/modules.h
M source/blender/blenvm/util/util_math.h
M source/blender/blenvm/util/util_opcode.h
===================================================================
diff --git a/source/blender/blenvm/CMakeLists.txt b/source/blender/blenvm/CMakeLists.txt
index aed1bd4..76645c6 100644
--- a/source/blender/blenvm/CMakeLists.txt
+++ b/source/blender/blenvm/CMakeLists.txt
@@ -56,6 +56,7 @@ set(SRC
modules/mod_color.h
modules/mod_image.h
modules/mod_math.h
+ modules/mod_mesh.h
modules/mod_texture.h
util/util_array.h
diff --git a/source/blender/blenvm/bvm/bvm_eval.cc b/source/blender/blenvm/bvm/bvm_eval.cc
index fd053c7..1d68235 100644
--- a/source/blender/blenvm/bvm/bvm_eval.cc
+++ b/source/blender/blenvm/bvm/bvm_eval.cc
@@ -978,7 +978,7 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const Instructio
eval_op_object_transform(stack, offset_object, offset_transform);
break;
}
- case OP_OBJECT_FINAL_MESH: {
+ case OP_MESH_LOAD_OBJECT: {
StackIndex offset_object = fn->read_stack_index(&instr);
StackIndex offset_mesh = fn->read_stack_index(&instr);
eval_op_object_final_mesh(stack, offset_object, offset_mesh);
@@ -1014,6 +1014,7 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const Instructio
eval_op_mesh_combine(&kd, stack, offset_mesh_a, offset_mesh_b, offset_mesh_out);
break;
}
+#if 0
case OP_MESH_ARRAY: {
fn->read_jump_address(&instr);
StackIndex offset_mesh_in = fn->read_stack_index(&instr);
@@ -1057,6 +1058,7 @@ void EvalContext::eval_instructions(const EvalGlobals *globals, const Instructio
offset_threshold, offset_mesh_out);
break;
}
+#endif
case OP_MESH_CLOSEST_POINT: {
StackIndex offset_mesh = fn->read_stack_index(&instr);
StackIndex offset_transform = fn->read_stack_index(&instr);
diff --git a/source/blender/blenvm/bvm/bvm_eval_mesh.h b/source/blender/blenvm/bvm/bvm_eval_mesh.h
index 4a887bb..d64e775 100644
--- a/source/blender/blenvm/bvm/bvm_eval_mesh.h
+++ b/source/blender/blenvm/bvm/bvm_eval_mesh.h
@@ -181,6 +181,7 @@ static void eval_op_mesh_combine(const EvalKernelData */*kernel_data*/, EvalStac
stack_store_mesh(stack, offset_mesh_out, result);
}
+#if 0
static DerivedMesh *do_array(const EvalGlobals *globals, const EvalKernelData *kernel_data, EvalStack *stack,
DerivedMesh *dm, int count,
int fn_transform, StackIndex offset_transform, StackIndex offset_iteration)
@@ -496,6 +497,7 @@ static void eval_op_mesh_boolean(const EvalGlobals *UNUSED(globals),
stack_store_mesh(stack, offset_mesh_out, result);
}
+#endif
static void eval_op_mesh_closest_point(EvalStack *stack,
StackIndex offset_mesh,
diff --git a/source/blender/blenvm/llvm/llvm_types.h b/source/blender/blenvm/llvm/llvm_types.h
index 166161e..555442c 100644
--- a/source/blender/blenvm/llvm/llvm_types.h
+++ b/source/blender/blenvm/llvm/llvm_types.h
@@ -107,34 +107,32 @@ public:
}
};
-template <typename T, bool xcompile>
-class TypeBuilder<blenvm::Dual2<T>, xcompile> {
+template <bool xcompile>
+class TypeBuilder<PointerRNA, xcompile> {
public:
static StructType *get(LLVMContext &context) {
return StructType::get(
- TypeBuilder<T, xcompile>::get(context),
- TypeBuilder<T, xcompile>::get(context),
- TypeBuilder<T, xcompile>::get(context),
+ TypeBuilder<void*, xcompile>::get(context),
+ TypeBuilder<void*, xcompile>::get(context),
+ TypeBuilder<void*, xcompile>::get(context),
NULL);
}
enum Fields {
- FIELD_VALUE = 0,
- FIELD_DX = 1,
- FIELD_DY = 2,
+ FIELD_ID = 0,
+ FIELD_TYPE = 1,
+ FIELD_DATA = 2,
};
};
-#if 0
-/* Specialization to enable TypeBuilder for Dual2<float> */
-template <bool xcompile>
-class TypeBuilder<blenvm::Dual2<float>, xcompile> {
+template <typename T, bool xcompile>
+class TypeBuilder<blenvm::Dual2<T>, xcompile> {
public:
static StructType *get(LLVMContext &context) {
return StructType::get(
- TypeBuilder<types::ieee_float, xcompile>::get(context),
- TypeBuilder<types::ieee_float, xcompile>::get(context),
- TypeBuilder<types::ieee_float, xcompile>::get(context),
+ TypeBuilder<T, xcompile>::get(context),
+ TypeBuilder<T, xcompile>::get(context),
+ TypeBuilder<T, xcompile>::get(context),
NULL);
}
@@ -144,7 +142,6 @@ public:
FIELD_DY = 2,
};
};
-#endif
} /* namespace llvm */
@@ -212,6 +209,24 @@ inline llvm::Constant *make_constant(llvm::LLVMContext &context, const matrix44
data, NULL);
}
+inline llvm::Constant *make_constant(llvm::LLVMContext &UNUSED(context), void *UNUSED(p))
+{
+ using namespace llvm;
+
+ /* Note: pointer constants are not allowed, should never be used */
+ BLI_assert(false);
+ return NULL;
+}
+
+inline llvm::Constant *make_constant(llvm::LLVMContext &UNUSED(context), const PointerRNA &UNUSED(p))
+{
+ using namespace llvm;
+
+ /* Note: pointer constants are not allowed, should never be used */
+ BLI_assert(false);
+ return NULL;
+}
+
template <typename T>
inline llvm::Constant *make_constant(llvm::LLVMContext &context, const Dual2<T> &d)
{
@@ -377,23 +392,31 @@ template <>
struct BVMTypeLLVMTraits<BVM_RNAPOINTER> {
enum { use_dual_value = false };
- typedef int value_type;
+ typedef PointerRNA value_type;
typedef value_type dual2_type;
template <typename BuilderT>
static void copy_value(BuilderT &builder, llvm::Value *ptr, llvm::Value *value)
{
using namespace llvm;
- /* TODO */
- BLI_assert(false);
- UNUSED_VARS(builder, ptr, value);
+
+ Value *src_id = builder.CreateStructGEP(value, 0);
+ Value *src_type = builder.CreateStructGEP(value, 1);
+ Value *src_data = builder.CreateStructGEP(value, 2);
+
+ Value *dst_id = builder.CreateStructGEP(ptr, 0);
+ Value *dst_type = builder.CreateStructGEP(ptr, 1);
+ Value *dst_data = builder.CreateStructGEP(ptr, 2);
+
+ builder.CreateStore(builder.CreateLoad(src_id), dst_id);
+ builder.CreateStore(builder.CreateLoad(src_type), dst_type);
+ builder.CreateStore(builder.CreateLoad(src_data), dst_data);
}
template <typename BuilderT>
static void set_zero(BuilderT &builder, llvm::Value *ptr)
{
using namespace llvm;
- /* TODO */
BLI_assert(false);
UNUSED_VARS(builder, ptr);
}
@@ -403,7 +426,7 @@ template <>
struct BVMTypeLLVMTraits<BVM_MESH> {
enum { use_dual_value = false };
- typedef int value_type;
+ typedef void* value_type;
typedef value_type dual2_type;
template <typename BuilderT>
@@ -419,7 +442,6 @@ struct BVMTypeLLVMTraits<BVM_MESH> {
static void set_zero(BuilderT &builder, llvm::Value *ptr)
{
using namespace llvm;
- /* TODO */
BLI_assert(false);
UNUSED_VARS(builder, ptr);
}
diff --git a/source/blender/blenvm/bvm/bvm_eval_mesh.h b/source/blender/blenvm/modules/mod_mesh.h
similarity index 86%
copy from source/blender/blenvm/bvm/bvm_eval_mesh.h
copy to source/blender/blenvm/modules/mod_mesh.h
index 4a887bb..80a20df 100644
--- a/source/blender/blenvm/bvm/bvm_eval_mesh.h
+++ b/source/blender/blenvm/modules/mod_mesh.h
@@ -25,56 +25,50 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifndef __BVM_EVAL_MESH_H__
-#define __BVM_EVAL_MESH_H__
-
-/** \file bvm_eval_mesh.h
- * \ingroup bvm
- */
+#ifndef __MOD_MESH_H__
+#define __MOD_MESH_H__
extern "C" {
-#include "BLI_math.h"
-
#include "DNA_object_types.h"
-#include "bmesh.h"
-#include "bmesh_tools.h"
-#include "tools/bmesh_intersect.h"
+#include "BKE_DerivedMesh.h"
+
+#include "RNA_access.h"
}
-#include "bvm_eval_common.h"
+#include "mod_defines.h"
-namespace blenvm {
+#include "util_math.h"
+#include "util_data_ptr.h"
-static void eval_op_mesh_load(EvalStack *stack, StackIndex offset_base_mesh, StackIndex offset_mesh)
+BVM_MOD_NAMESPACE_BEGIN
+
+bvm_extern void V__MESH_LOAD(mesh_ptr &mesh, const PointerRNA &mesh_ptr)
{
- PointerRNA ptr = stack_load_rnapointer(stack, offset_base_mesh);
DerivedMesh *dm;
- if (ptr.data && RNA_struct_is_a(&RNA_Mesh, ptr.type)) {
- dm = CDDM_from_mesh((Mesh *)ptr.data);
+ if (mesh_ptr.data && RNA_struct_is_a(&RNA_Mesh, mesh_ptr.type)) {
+ dm = CDDM_from_mesh((Mesh *)mesh_ptr.data);
}
else {
dm = CDDM_new(0, 0, 0, 0, 0);
}
- stack_store_mesh(stack, offset_mesh, dm);
+ mesh.set(dm);
}
+BVM_DECL_FUNCTION_VALUE(MESH_LOAD)
-static void eval_op_object_final_mesh(EvalStack *stack,
- StackIndex offset_object,
- StackIndex offset_mesh)
+bvm_extern void V__MESH_LOAD_OBJECT(mesh_ptr &mesh, const PointerRNA &ob_ptr)
{
- PointerRNA ptr = stack_load_rnapointer(stack, offset_object);
-
DerivedMesh *result = NULL;
- if (ptr.data && RNA_struct_is_a(&RNA_Object, ptr.type)) {
- Object *ob = (Object *)ptr.data;
+ if (ob_ptr.data && RNA_struct_is_a(&RNA_Object, ob_ptr.type)) {
+ Object *ob = (Object *)ob_ptr.data;
result = ob->derivedFinal;
}
if (!result)
result = CDDM_new(0, 0, 0, 0, 0);
- stack_store_mesh(stack, offset_mesh, result);
+ mesh.set(result);
}
+BVM_DECL_FUNCTION_VALUE(MESH_LOAD_OBJECT)
static void dm_insert(
DerivedMesh *result, DerivedMesh *dm,
@@ -152,11 +146,10 @@ static void dm_insert(
}
}
-static void eval_op_mesh_combine(const EvalKernelData */*kernel_data*/, EvalStack *stack,
- StackIndex offset_mesh_a, StackIndex offset_mesh_b, StackIndex offset_mesh_out)
+bvm_extern void V__MESH_COMBINE(mesh_ptr &out, const mesh_ptr &a, const mesh_ptr &b)
{
- DerivedMesh *dm_a = stack_load_mesh(stack, offset_mesh_a);
- DerivedMesh *dm_b = stack_load_mesh(stack, offset_mesh_b);
+ DerivedMesh *dm_a = a.get();
+ DerivedMesh *dm_b = b.get();
int numVertsA = dm_a->getNumVerts(dm_a);
int numEdgesA = dm_a->getNumEdges(dm_a);
@@ -178,9 +171,11 @@ static void eval_op_mesh_combine(const EvalKernelData */*kernel_data*/, EvalStac
dm_insert(result, dm_a, 0, 0, 0, 0);
dm_insert(result, dm_b, numVertsA, numEdgesA, numLoopsA, numPolysA);
- stack_store_mesh(stack, offset_mesh_out, result);
+ out.set(result);
}
+BVM_DECL_FUNCTION_VALUE(MESH_COMBINE)
+#if 0
static DerivedMesh *do_array(const EvalGlobals *globals, const Ev
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list