[Bf-blender-cvs] [46ba92729fa] cycles-x: Cycles: Add ccl_constexpr utility macros

Sergey Sharybin noreply at git.blender.org
Tue May 4 15:54:35 CEST 2021


Commit: 46ba92729fa59efb174651c6cb362a4dae056c5f
Author: Sergey Sharybin
Date:   Mon May 3 11:18:22 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB46ba92729fa59efb174651c6cb362a4dae056c5f

Cycles: Add ccl_constexpr utility macros

Allows to give constexpr qualifier on backends and compilers which support this
attribute.

Currently only enabled for CPU. Need to check CUDA and OptiX for support.

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

M	intern/cycles/kernel/device/cuda/compat.h
M	intern/cycles/kernel/device/opencl/compat.h
M	intern/cycles/kernel/device/optix/compat.h
M	intern/cycles/util/util_defines.h

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

diff --git a/intern/cycles/kernel/device/cuda/compat.h b/intern/cycles/kernel/device/cuda/compat.h
index aa5a30e34c3..c8c148d6ee5 100644
--- a/intern/cycles/kernel/device/cuda/compat.h
+++ b/intern/cycles/kernel/device/cuda/compat.h
@@ -82,6 +82,7 @@ __device__ half __float2half(const float f)
 #define ccl_ref
 #define ccl_align(n) __align__(n)
 #define ccl_optional_struct_init
+#define ccl_constexpr
 
 /* TODO(sergey): Should be able to use [[maybe_unused]] once the kernels are compiled with C++17
  * standard support, */
diff --git a/intern/cycles/kernel/device/opencl/compat.h b/intern/cycles/kernel/device/opencl/compat.h
index 5b372085987..3dafe0c7fde 100644
--- a/intern/cycles/kernel/device/opencl/compat.h
+++ b/intern/cycles/kernel/device/opencl/compat.h
@@ -46,6 +46,7 @@
 #define ccl_ref
 #define ccl_align(n) __attribute__((aligned(n)))
 #define ccl_optional_struct_init
+#define ccl_constexpr
 #define ccl_attr_maybe_unused
 
 #if __OPENCL_VERSION__ >= 200 && !defined(__NV_CL_C_VERSION)
diff --git a/intern/cycles/kernel/device/optix/compat.h b/intern/cycles/kernel/device/optix/compat.h
index 3957e657637..5afeabe4fd6 100644
--- a/intern/cycles/kernel/device/optix/compat.h
+++ b/intern/cycles/kernel/device/optix/compat.h
@@ -86,6 +86,8 @@ __device__ half __float2half(const float f)
 // Zero initialize structs to help the compiler figure out scoping
 #define ccl_optional_struct_init = {}
 
+#define ccl_constexpr
+
 #define kernel_data __params.data  // See globals.h
 #define kernel_tex_array(t) __params.t
 #define kernel_tex_fetch(t, index) __params.t[(index)]
diff --git a/intern/cycles/util/util_defines.h b/intern/cycles/util/util_defines.h
index 44e61b2bd40..255b3db3d0a 100644
--- a/intern/cycles/util/util_defines.h
+++ b/intern/cycles/util/util_defines.h
@@ -45,6 +45,7 @@
 #  define ccl_restrict __restrict
 #  define ccl_ref &
 #  define ccl_optional_struct_init
+#  define ccl_constexpr constexpr
 #  define ccl_loop_no_unroll
 #  define ccl_attr_maybe_unused [[maybe_unused]]
 #  define __KERNEL_WITH_SSE_ALIGN__



More information about the Bf-blender-cvs mailing list