[Bf-blender-cvs] [c97a25b] object_nodes: LLVM TypeBuilder and copy function for node_counted_ptr.
Lukas Tönne
noreply at git.blender.org
Fri Jun 24 16:19:54 CEST 2016
Commit: c97a25b2064d532deffebaab1d6bab779ece20ef
Author: Lukas Tönne
Date: Fri Jun 24 14:45:53 2016 +0200
Branches: object_nodes
https://developer.blender.org/rBc97a25b2064d532deffebaab1d6bab779ece20ef
LLVM TypeBuilder and copy function for node_counted_ptr.
Using a DerivedMesh directly for mesh data isn't so great because
the lifetime of a DM is not necessarily known at compile time, depending
on branching. node_counted_ptr is basically a simplified shared_ptr variant.
===================================================================
M source/blender/blenvm/llvm/llvm_types.h
===================================================================
diff --git a/source/blender/blenvm/llvm/llvm_types.h b/source/blender/blenvm/llvm/llvm_types.h
index 555442c..5a85aea 100644
--- a/source/blender/blenvm/llvm/llvm_types.h
+++ b/source/blender/blenvm/llvm/llvm_types.h
@@ -126,6 +126,22 @@ public:
};
template <typename T, bool xcompile>
+class TypeBuilder<blenvm::node_counted_ptr<T>, xcompile> {
+public:
+ static StructType *get(LLVMContext &context) {
+ return StructType::get(
+ TypeBuilder<void*, xcompile>::get(context),
+ TypeBuilder<size_t*, xcompile>::get(context),
+ NULL);
+ }
+
+ enum Fields {
+ FIELD_DATA = 0,
+ FIELD_REFS = 1,
+ };
+};
+
+template <typename T, bool xcompile>
class TypeBuilder<blenvm::Dual2<T>, xcompile> {
public:
static StructType *get(LLVMContext &context) {
@@ -426,16 +442,22 @@ template <>
struct BVMTypeLLVMTraits<BVM_MESH> {
enum { use_dual_value = false };
- typedef void* value_type;
+ typedef struct node_counted_ptr<DerivedMesh> 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_data = builder.CreateStructGEP(value, 0);
+ Value *src_refs = builder.CreateStructGEP(value, 1);
+
+ Value *dst_data = builder.CreateStructGEP(ptr, 0);
+ Value *dst_refs = builder.CreateStructGEP(ptr, 1);
+
+ builder.CreateStore(builder.CreateLoad(src_data), dst_data);
+ builder.CreateStore(builder.CreateLoad(src_refs), dst_refs);
}
template <typename BuilderT>
More information about the Bf-blender-cvs
mailing list