diff options
author | Brecht Van Lommel <brecht@blender.org> | 2022-07-29 15:40:50 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2022-08-09 17:07:23 +0300 |
commit | 1988665c3c310cbfb66b4e499408fa48c522545c (patch) | |
tree | 5e5771dd13165d9d7ab67fe8837ac088de522eec /intern/cycles/util/types.h | |
parent | 9990792e87238386375c97f431f648c1334bd587 (diff) |
Cleanup: make vector types make/print functions consistent between CPU and GPU
Now all the same ones are available on CPU and GPU, which was previously not
possible due to lack of operator overloadng in OpenCL. Print functions are
no-ops on some GPUs.
Ref D15535
Diffstat (limited to 'intern/cycles/util/types.h')
-rw-r--r-- | intern/cycles/util/types.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/intern/cycles/util/types.h b/intern/cycles/util/types.h index 26031d9e0fd..d0d8c2941d7 100644 --- a/intern/cycles/util/types.h +++ b/intern/cycles/util/types.h @@ -71,6 +71,18 @@ ccl_device_inline bool is_power_of_two(size_t x) CCL_NAMESPACE_END +/* Device side printf only tested on CUDA, may work on more GPU devices. */ +#if !defined(__KERNEL_GPU__) || defined(__KERNEL_CUDA__) +# define __KERNEL_PRINTF__ +#endif + +ccl_device_inline void print_float(ccl_private const char *label, const float a) +{ +#ifdef __KERNEL_PRINTF__ + printf("%s: %.8f\n", label, (double)a); +#endif +} + /* Most GPU APIs matching native vector types, so we only need to implement them for * CPU and oneAPI. */ #if defined(__KERNEL_GPU__) && !defined(__KERNEL_ONEAPI__) |