Commit: fd397a7d28666f1c3ee9cd85de5760825d62d28e
Author: Sergey Sharybin
Date:   Tue Aug 8 14:34:59 2017 +0200
Branches: master

Cycles: Add utility macro ccl_ref

It is defined to & for CPU side compilation, and defined to an empty for any GPU
platform. The idea here is to use this macro instead of #ifdef block with bunch
of duplicated lines just to make it so CPU code is efficient.

Eventually we might switch to references on CUDA as well, but that would require
some intensive testing.


M       intern/cycles/kernel/kernel_compat_cuda.h
M       intern/cycles/kernel/kernel_compat_opencl.h
M       intern/cycles/util/util_defines.h


diff --git a/intern/cycles/kernel/kernel_compat_cuda.h 
index 38708f7ff0b..6d1cf055f2c 100644
--- a/intern/cycles/kernel/kernel_compat_cuda.h
+++ b/intern/cycles/kernel/kernel_compat_cuda.h
@@ -53,6 +53,10 @@
 #define ccl_may_alias
 #define ccl_addr_space
 #define ccl_restrict __restrict__
+/* TODO(sergey): In theory we might use references with CUDA, however
+ * performance impact yet to be investigated.
+ */
+#define ccl_ref
 #define ccl_align(n) __align__(n)
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h 
index 21eba971688..36d6031d042 100644
--- a/intern/cycles/kernel/kernel_compat_opencl.h
+++ b/intern/cycles/kernel/kernel_compat_opencl.h
@@ -42,6 +42,7 @@
 #define ccl_local_param __local
 #define ccl_private __private
 #define ccl_restrict restrict
+#define ccl_ref
 #define ccl_align(n) __attribute__((aligned(n)))
 #ifdef __SPLIT_KERNEL__
diff --git a/intern/cycles/util/util_defines.h 
index d0d87e74332..ae654092c87 100644
--- a/intern/cycles/util/util_defines.h
+++ b/intern/cycles/util/util_defines.h
@@ -35,6 +35,7 @@
 #  define ccl_local_param
 #  define ccl_private
 #  define ccl_restrict __restrict
+#  define ccl_ref &
 #  define __KERNEL_WITH_SSE_ALIGN__
 #  if defined(_WIN32) && !defined(FREE_WINDOWS)

Bf-blender-cvs mailing list

Reply via email to