[Bf-blender-cvs] [8363204347d] functions: use faster CPPType access

Jacques Lucke noreply at git.blender.org
Fri Feb 14 11:06:06 CET 2020


Commit: 8363204347d6c0525aaed940f0a30435a7f49b49
Author: Jacques Lucke
Date:   Fri Feb 14 11:03:32 2020 +0100
Branches: functions
https://developer.blender.org/rB8363204347d6c0525aaed940f0a30435a7f49b49

use faster CPPType access

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

M	source/blender/functions/FN_cpp_type.h
M	source/blender/functions/intern/multi_functions/constants.cc
M	source/blender/functions/intern/multi_functions/constants.h
M	source/blender/functions/intern/multi_functions/network.cc
M	source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
M	source/blender/simulations/bparticles/c_wrapper.cpp

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

diff --git a/source/blender/functions/FN_cpp_type.h b/source/blender/functions/FN_cpp_type.h
index 957dce1cbf4..364d1def54e 100644
--- a/source/blender/functions/FN_cpp_type.h
+++ b/source/blender/functions/FN_cpp_type.h
@@ -370,7 +370,9 @@ class CPPType {
 
 template<typename T> const CPPType &CPP_TYPE();
 extern const CPPType &CPPType_float;
+extern const CPPType &CPPType_float3;
 extern const CPPType &CPPType_int32;
+extern const CPPType &CPPType_string;
 
 }  // namespace FN
 
diff --git a/source/blender/functions/intern/multi_functions/constants.cc b/source/blender/functions/intern/multi_functions/constants.cc
index 051ac8ad7ec..49ecf4f2507 100644
--- a/source/blender/functions/intern/multi_functions/constants.cc
+++ b/source/blender/functions/intern/multi_functions/constants.cc
@@ -6,19 +6,19 @@ void MF_GenericConstantValue::value_to_string(std::stringstream &ss,
                                               const CPPType &type,
                                               const void *value)
 {
-  if (type == CPP_TYPE<float>()) {
+  if (type == CPPType_float) {
     ss << (*(float *)value);
   }
-  else if (type == CPP_TYPE<int>()) {
+  else if (type == CPPType_int32) {
     ss << *(int *)value;
   }
-  else if (type == CPP_TYPE<BLI::float3>()) {
+  else if (type == CPPType_float3) {
     ss << *(BLI::float3 *)value;
   }
   else if (type == CPP_TYPE<bool>()) {
     ss << ((*(bool *)value) ? "true" : "false");
   }
-  else if (type == CPP_TYPE<std::string>()) {
+  else if (type == CPPType_string) {
     ss << "\"" << *(std::string *)value << "\"";
   }
   else {
@@ -34,7 +34,7 @@ MF_GenericConstantValue::MF_GenericConstantValue(const CPPType &type, const void
   MF_GenericConstantValue::value_to_string(ss, type, value);
   signature.single_output(ss.str(), type);
 
-  if (type == CPP_TYPE<float>()) {
+  if (type == CPPType_float) {
     uint32_t hash = BLI_hash_int_2d(*(uint *)value, 0);
     signature.operation_hash(hash);
   }
diff --git a/source/blender/functions/intern/multi_functions/constants.h b/source/blender/functions/intern/multi_functions/constants.h
index 4e8d2194d86..7d3a0264a41 100644
--- a/source/blender/functions/intern/multi_functions/constants.h
+++ b/source/blender/functions/intern/multi_functions/constants.h
@@ -49,15 +49,15 @@ template<typename T> class MF_ConstantValue : public MultiFunction {
     MF_GenericConstantValue::value_to_string(ss, CPP_TYPE<T>(), (const void *)&m_value);
     signature.single_output<T>(ss.str());
 
-    if (CPP_TYPE<T>() == CPP_TYPE<float>()) {
+    if (CPP_TYPE<T>() == CPPType_float) {
       uint32_t hash = BLI_hash_int_2d(*(uint *)&m_value, 0);
       signature.operation_hash(hash);
     }
-    else if (CPP_TYPE<T>() == CPP_TYPE<int>()) {
+    else if (CPP_TYPE<T>() == CPPType_int32) {
       uint32_t hash = BLI_hash_int_2d(*(uint *)&m_value, 1);
       signature.operation_hash(hash);
     }
-    else if (CPP_TYPE<T>() == CPP_TYPE<std::string>()) {
+    else if (CPP_TYPE<T>() == CPPType_string) {
       uint32_t hash = BLI_hash_string(((std::string *)&m_value)->c_str());
       signature.operation_hash(hash);
     }
@@ -66,7 +66,7 @@ template<typename T> class MF_ConstantValue : public MultiFunction {
       uint32_t hash = object_handle.internal_identifier() ^ BLI_RAND_PER_LINE_UINT32;
       signature.operation_hash(hash);
     }
-    else if (CPP_TYPE<T>() == CPP_TYPE<BLI::float3>()) {
+    else if (CPP_TYPE<T>() == CPPType_float3) {
       BLI::float3 vector = *(BLI::float3 *)&value;
       uint32_t hash = BLI_hash_int_2d(*(uint *)&vector.x, 0);
       hash = BLI_hash_int_2d(*(uint *)&vector.y, hash);
diff --git a/source/blender/functions/intern/multi_functions/network.cc b/source/blender/functions/intern/multi_functions/network.cc
index a180aada861..2cc96428164 100644
--- a/source/blender/functions/intern/multi_functions/network.cc
+++ b/source/blender/functions/intern/multi_functions/network.cc
@@ -582,7 +582,7 @@ class NetworkEvaluationStorage {
     }
 
     BLI_assert(false);
-    return GenericVirtualListRef(CPP_TYPE<float>());
+    return GenericVirtualListRef(CPPType_float);
   }
 
   GenericVirtualListRef get_single_input__single(const MFInputSocket &socket)
@@ -609,7 +609,7 @@ class NetworkEvaluationStorage {
     }
 
     BLI_assert(false);
-    return GenericVirtualListRef(CPP_TYPE<float>());
+    return GenericVirtualListRef(CPPType_float);
   }
 
   GenericVirtualListListRef get_vector_input__full(const MFInputSocket &socket)
@@ -639,7 +639,7 @@ class NetworkEvaluationStorage {
     }
 
     BLI_assert(false);
-    return GenericVirtualListListRef::FromSingleArray(CPP_TYPE<float>(), nullptr, 0, 0);
+    return GenericVirtualListListRef::FromSingleArray(CPPType_float, nullptr, 0, 0);
   }
 
   GenericVirtualListListRef get_vector_input__single(const MFInputSocket &socket)
@@ -665,7 +665,7 @@ class NetworkEvaluationStorage {
     }
 
     BLI_assert(false);
-    return GenericVirtualListListRef::FromSingleArray(CPP_TYPE<float>(), nullptr, 0, 0);
+    return GenericVirtualListListRef::FromSingleArray(CPPType_float, nullptr, 0, 0);
   }
 };
 
diff --git a/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc b/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
index bbb52d01df3..6f2eca29253 100644
--- a/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
+++ b/source/blender/modifiers/intern/MOD_functionpoints_cxx.cc
@@ -51,7 +51,7 @@ Mesh *MOD_functionpoints_do(FunctionPointsModifierData *fpmd,
   params_builder.add_readonly_single_input(&fpmd->control1);
   params_builder.add_readonly_single_input(&fpmd->control2);
 
-  FN::GenericVectorArray vector_array{FN::CPP_TYPE<float3>(), 1};
+  FN::GenericVectorArray vector_array{FN::CPPType_float3, 1};
   params_builder.add_vector_output(vector_array);
 
   FN::SceneTimeContext time_context;
diff --git a/source/blender/simulations/bparticles/c_wrapper.cpp b/source/blender/simulations/bparticles/c_wrapper.cpp
index 6e4062946dd..9600a1ac9a6 100644
--- a/source/blender/simulations/bparticles/c_wrapper.cpp
+++ b/source/blender/simulations/bparticles/c_wrapper.cpp
@@ -318,18 +318,18 @@ void BParticles_modifier_cache_state(BParticlesModifierData *bpmd,
     strncpy(position_attribute.name, "Position", sizeof(position_attribute.name));
     position_attribute.values = (float *)MEM_malloc_arrayN(
         cached_type.particle_amount, sizeof(float3), __func__);
-    FN::CPP_TYPE<float3>().copy_to_uninitialized_n(particles.attributes().get("Position").buffer(),
-                                                   position_attribute.values,
-                                                   cached_type.particle_amount);
+    FN::CPPType_float3.copy_to_uninitialized_n(particles.attributes().get("Position").buffer(),
+                                               position_attribute.values,
+                                               cached_type.particle_amount);
 
     BParticlesAttributeCacheFloat &size_attribute = cached_type.attributes_float[1];
     size_attribute.floats_per_particle = 1;
     strncpy(size_attribute.name, "Size", sizeof(size_attribute.name));
     size_attribute.values = (float *)MEM_malloc_arrayN(
         cached_type.particle_amount, sizeof(float), __func__);
-    FN::CPP_TYPE<float>().copy_to_uninitialized_n(particles.attributes().get("Size").buffer(),
-                                                  size_attribute.values,
-                                                  cached_type.particle_amount);
+    FN::CPPType_float.copy_to_uninitialized_n(particles.attributes().get("Size").buffer(),
+                                              size_attribute.values,
+                                              cached_type.particle_amount);
 
     BParticlesAttributeCacheFloat &color_attribute = cached_type.attributes_float[2];
     color_attribute.floats_per_particle = 4;



More information about the Bf-blender-cvs mailing list