2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __KERNEL_COMPAT_OPENCL_H__
|
|
|
|
#define __KERNEL_COMPAT_OPENCL_H__
|
|
|
|
|
|
|
|
#define __KERNEL_GPU__
|
|
|
|
#define __KERNEL_OPENCL__
|
|
|
|
|
2011-08-11 12:36:08 +00:00
|
|
|
/* no namespaces in opencl */
|
|
|
|
#define CCL_NAMESPACE_BEGIN
|
|
|
|
#define CCL_NAMESPACE_END
|
2011-12-20 17:36:56 +00:00
|
|
|
|
|
|
|
#ifdef __CL_NOINLINE__
|
2016-02-12 17:33:43 +00:00
|
|
|
# define ccl_noinline __attribute__((noinline))
|
2011-12-20 17:36:56 +00:00
|
|
|
#else
|
2016-02-12 17:33:43 +00:00
|
|
|
# define ccl_noinline
|
2011-12-20 17:36:56 +00:00
|
|
|
#endif
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-08-09 18:53:54 +00:00
|
|
|
/* in opencl all functions are device functions, so leave this empty */
|
2013-11-15 23:17:10 +00:00
|
|
|
#define ccl_device
|
|
|
|
#define ccl_device_inline ccl_device
|
2016-10-02 12:48:39 +00:00
|
|
|
#define ccl_device_forceinline ccl_device
|
2013-11-15 23:17:10 +00:00
|
|
|
#define ccl_device_noinline ccl_device ccl_noinline
|
|
|
|
#define ccl_may_alias
|
2017-10-05 14:41:41 +00:00
|
|
|
#define ccl_static_constant static __constant
|
2013-11-15 23:17:10 +00:00
|
|
|
#define ccl_constant __constant
|
|
|
|
#define ccl_global __global
|
2015-05-09 14:22:16 +00:00
|
|
|
#define ccl_local __local
|
2017-02-22 13:10:02 +00:00
|
|
|
#define ccl_local_param __local
|
2015-05-09 14:22:16 +00:00
|
|
|
#define ccl_private __private
|
2016-07-11 11:53:37 +00:00
|
|
|
#define ccl_restrict restrict
|
2017-08-08 12:34:59 +00:00
|
|
|
#define ccl_ref
|
2016-08-08 23:00:57 +00:00
|
|
|
#define ccl_align(n) __attribute__((aligned(n)))
|
2015-05-09 14:22:16 +00:00
|
|
|
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
#ifdef __SPLIT_KERNEL__
|
2016-02-12 17:33:43 +00:00
|
|
|
# define ccl_addr_space __global
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
#else
|
2016-02-12 17:33:43 +00:00
|
|
|
# define ccl_addr_space
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 14:34:30 +00:00
|
|
|
#endif
|
|
|
|
|
2017-05-24 15:23:54 +00:00
|
|
|
#define ATTR_FALLTHROUGH
|
|
|
|
|
2017-02-22 13:10:02 +00:00
|
|
|
#define ccl_local_id(d) get_local_id(d)
|
|
|
|
#define ccl_global_id(d) get_global_id(d)
|
|
|
|
|
|
|
|
#define ccl_local_size(d) get_local_size(d)
|
|
|
|
#define ccl_global_size(d) get_global_size(d)
|
|
|
|
|
|
|
|
#define ccl_group_id(d) get_group_id(d)
|
|
|
|
#define ccl_num_groups(d) get_num_groups(d)
|
|
|
|
|
2015-05-09 14:22:16 +00:00
|
|
|
/* Selective nodes compilation. */
|
|
|
|
#ifndef __NODES_MAX_GROUP__
|
|
|
|
# define __NODES_MAX_GROUP__ NODE_GROUP_LEVEL_MAX
|
|
|
|
#endif
|
|
|
|
#ifndef __NODES_FEATURES__
|
|
|
|
# define __NODES_FEATURES__ NODE_FEATURE_ALL
|
|
|
|
#endif
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-08-09 18:53:54 +00:00
|
|
|
/* no assert in opencl */
|
2011-05-20 12:26:01 +00:00
|
|
|
#define kernel_assert(cond)
|
|
|
|
|
2011-08-09 18:53:54 +00:00
|
|
|
/* make_type definitions with opencl style element initializers */
|
2011-05-31 16:21:30 +00:00
|
|
|
#ifdef make_float2
|
2016-02-12 17:33:43 +00:00
|
|
|
# undef make_float2
|
2011-05-31 16:21:30 +00:00
|
|
|
#endif
|
|
|
|
#ifdef make_float3
|
2016-02-12 17:33:43 +00:00
|
|
|
# undef make_float3
|
2011-05-31 16:21:30 +00:00
|
|
|
#endif
|
|
|
|
#ifdef make_float4
|
2016-02-12 17:33:43 +00:00
|
|
|
# undef make_float4
|
2011-05-31 16:21:30 +00:00
|
|
|
#endif
|
|
|
|
#ifdef make_int2
|
2016-02-12 17:33:43 +00:00
|
|
|
# undef make_int2
|
2011-05-31 16:21:30 +00:00
|
|
|
#endif
|
|
|
|
#ifdef make_int3
|
2016-02-12 17:33:43 +00:00
|
|
|
# undef make_int3
|
2011-05-31 16:21:30 +00:00
|
|
|
#endif
|
|
|
|
#ifdef make_int4
|
2016-02-12 17:33:43 +00:00
|
|
|
# undef make_int4
|
2011-05-31 16:21:30 +00:00
|
|
|
#endif
|
2014-06-14 23:09:35 +00:00
|
|
|
#ifdef make_uchar4
|
2016-02-12 17:33:43 +00:00
|
|
|
# undef make_uchar4
|
2014-06-14 23:09:35 +00:00
|
|
|
#endif
|
2011-05-31 16:21:30 +00:00
|
|
|
|
2011-05-31 11:31:00 +00:00
|
|
|
#define make_float2(x, y) ((float2)(x, y))
|
2011-08-09 18:53:54 +00:00
|
|
|
#define make_float3(x, y, z) ((float3)(x, y, z))
|
2011-05-31 11:31:00 +00:00
|
|
|
#define make_float4(x, y, z, w) ((float4)(x, y, z, w))
|
|
|
|
#define make_int2(x, y) ((int2)(x, y))
|
2011-08-09 18:53:54 +00:00
|
|
|
#define make_int3(x, y, z) ((int3)(x, y, z))
|
2011-05-31 11:31:00 +00:00
|
|
|
#define make_int4(x, y, z, w) ((int4)(x, y, z, w))
|
2014-06-14 23:09:35 +00:00
|
|
|
#define make_uchar4(x, y, z, w) ((uchar4)(x, y, z, w))
|
2011-05-31 11:31:00 +00:00
|
|
|
|
2011-08-09 18:53:54 +00:00
|
|
|
/* math functions */
|
2011-05-20 12:26:01 +00:00
|
|
|
#define __uint_as_float(x) as_float(x)
|
|
|
|
#define __float_as_uint(x) as_uint(x)
|
|
|
|
#define __int_as_float(x) as_float(x)
|
|
|
|
#define __float_as_int(x) as_int(x)
|
2014-10-07 22:02:46 +00:00
|
|
|
#define powf(x, y) pow(((float)(x)), ((float)(y)))
|
|
|
|
#define fabsf(x) fabs(((float)(x)))
|
|
|
|
#define copysignf(x, y) copysign(((float)(x)), ((float)(y)))
|
|
|
|
#define asinf(x) asin(((float)(x)))
|
|
|
|
#define acosf(x) acos(((float)(x)))
|
|
|
|
#define atanf(x) atan(((float)(x)))
|
|
|
|
#define floorf(x) floor(((float)(x)))
|
|
|
|
#define ceilf(x) ceil(((float)(x)))
|
|
|
|
#define hypotf(x, y) hypot(((float)(x)), ((float)(y)))
|
|
|
|
#define atan2f(x, y) atan2(((float)(x)), ((float)(y)))
|
|
|
|
#define fmaxf(x, y) fmax(((float)(x)), ((float)(y)))
|
|
|
|
#define fminf(x, y) fmin(((float)(x)), ((float)(y)))
|
|
|
|
#define fmodf(x, y) fmod((float)(x), (float)(y))
|
2018-07-18 09:14:43 +00:00
|
|
|
#define sinhf(x) sinh(((float)(x)))
|
2011-08-09 18:53:54 +00:00
|
|
|
|
2019-03-18 15:36:55 +00:00
|
|
|
/* Use native functions with possibly lower precision for performance,
|
|
|
|
* no issues found so far. */
|
|
|
|
#if 1
|
2016-02-12 17:33:43 +00:00
|
|
|
# define sinf(x) native_sin(((float)(x)))
|
|
|
|
# define cosf(x) native_cos(((float)(x)))
|
|
|
|
# define tanf(x) native_tan(((float)(x)))
|
|
|
|
# define expf(x) native_exp(((float)(x)))
|
|
|
|
# define sqrtf(x) native_sqrt(((float)(x)))
|
|
|
|
# define logf(x) native_log(((float)(x)))
|
2017-08-07 18:52:24 +00:00
|
|
|
# define rcp(x) native_recip(x)
|
2014-04-07 12:01:31 +00:00
|
|
|
#else
|
2016-02-12 17:33:43 +00:00
|
|
|
# define sinf(x) sin(((float)(x)))
|
|
|
|
# define cosf(x) cos(((float)(x)))
|
|
|
|
# define tanf(x) tan(((float)(x)))
|
|
|
|
# define expf(x) exp(((float)(x)))
|
|
|
|
# define sqrtf(x) sqrt(((float)(x)))
|
|
|
|
# define logf(x) log(((float)(x)))
|
2019-03-18 15:36:55 +00:00
|
|
|
# define rcp(x) recip(x)
|
2014-04-07 12:01:31 +00:00
|
|
|
#endif
|
|
|
|
|
2011-08-09 18:53:54 +00:00
|
|
|
/* data lookup defines */
|
2011-04-27 11:58:34 +00:00
|
|
|
#define kernel_data (*kg->data)
|
2018-03-10 00:36:09 +00:00
|
|
|
#define kernel_tex_array(tex) ((const ccl_global tex##_t*)(kg->buffers[kg->tex.cl_buffer] + kg->tex.data))
|
|
|
|
#define kernel_tex_fetch(tex, index) kernel_tex_array(tex)[(index)]
|
2011-05-20 12:26:01 +00:00
|
|
|
|
2011-08-09 18:53:54 +00:00
|
|
|
/* define NULL */
|
2011-05-20 12:26:01 +00:00
|
|
|
#define NULL 0
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2018-07-06 09:42:34 +00:00
|
|
|
/* enable extensions */
|
|
|
|
#ifdef __KERNEL_CL_KHR_FP16__
|
|
|
|
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
|
|
|
#endif
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 18:39:14 +00:00
|
|
|
#include "util/util_half.h"
|
|
|
|
#include "util/util_types.h"
|
2011-05-31 11:31:00 +00:00
|
|
|
|
2018-11-09 10:34:54 +00:00
|
|
|
#endif /* __KERNEL_COMPAT_OPENCL_H__ */
|