diff options
-rw-r--r-- | intern/cycles/kernel/kernel_compat_opencl.h | 43 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 10 | ||||
-rw-r--r-- | intern/cycles/kernel/svm/svm_light_path.h | 2 | ||||
-rw-r--r-- | intern/cycles/util/util_math.h | 4 | ||||
-rw-r--r-- | intern/cycles/util/util_types.h | 4 |
6 files changed, 43 insertions, 22 deletions
diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h index 6ff9340e645..0127093d8ce 100644 --- a/intern/cycles/kernel/kernel_compat_opencl.h +++ b/intern/cycles/kernel/kernel_compat_opencl.h @@ -24,13 +24,14 @@ CCL_NAMESPACE_BEGIN -#pragma OPENCL EXTENSION cl_khr_byte_addressable_store: enable - +/* in opencl all functions are device functions, so leave this empty */ #define __device #define __device_inline +/* no assert in opencl */ #define kernel_assert(cond) +/* manual implementation of interpolated 1D lookup */ __device float kernel_tex_interp_(__global float *data, int width, float x) { x = clamp(x, 0.0f, 1.0f)*width; @@ -42,6 +43,7 @@ __device float kernel_tex_interp_(__global float *data, int width, float x) return (1.0f - t)*data[index] + t*data[nindex]; } +/* make_type definitions with opencl style element initializers */ #ifdef make_float2 #undef make_float2 #endif @@ -62,22 +64,13 @@ __device float kernel_tex_interp_(__global float *data, int width, float x) #endif #define make_float2(x, y) ((float2)(x, y)) -#define make_float3(x, y, z) ((float3)(x, y, z, 0.0f)) +#define make_float3(x, y, z) ((float3)(x, y, z)) #define make_float4(x, y, z, w) ((float4)(x, y, z, w)) #define make_int2(x, y) ((int2)(x, y)) -#define make_int3(x, y, z) ((int3)(x, y, z, 0)) +#define make_int3(x, y, z) ((int3)(x, y, z)) #define make_int4(x, y, z, w) ((int4)(x, y, z, w)) -#ifdef float3 -#undef float3 -#endif -#ifdef int3 -#undef int3 -#endif - -typedef float4 float3; -typedef int4 int3; - +/* math functions */ #define __uint_as_float(x) as_float(x) #define __float_as_uint(x) as_uint(x) #define __int_as_float(x) as_float(x) @@ -88,13 +81,25 @@ typedef int4 int3; #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 cosf(x) cos(((float)x)) +#define asinf(x) asin(((float)x)) +#define acosf(x) acos(((float)x)) +#define atanf(x) atan(((float)x)) +#define tanf(x) tan(((float)x)) +#define logf(x) log(((float)x)) +#define floorf(x) floor(((float)x)) +#define expf(x) exp(((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)) + +/* data lookup defines */ #define kernel_data (*kg->data) -#define kernel_tex_interp(t, x) \ - kernel_tex_interp_(kg->t, kg->t##_width, x) -#define kernel_tex_fetch(t, index) \ - kg->t[index] +#define kernel_tex_interp(t, x) kernel_tex_interp_(kg->t, kg->t##_width, x) +#define kernel_tex_fetch(t, index) kg->t[index] +/* define NULL */ #define NULL 0 #include "util_types.h" diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 15c7e67f101..47aeea4f5c5 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -129,7 +129,7 @@ __device float3 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int pass, Ray L += throughput*shader_eval_background(kg, &sd, path_flag); shader_release(kg, &sd); #else - L += throughputmake_float3(0.8f, 0.8f, 0.8f); + L += make_float3(0.8f, 0.8f, 0.8f); #endif break; } diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index fbe827b1791..992a4d95b54 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -27,6 +27,7 @@ CCL_NAMESPACE_BEGIN #define OBJECT_SIZE 16 +#define __SOBOL__ #define __INSTANCING__ #define __DPDU__ #define __UV__ @@ -34,8 +35,9 @@ CCL_NAMESPACE_BEGIN #define __EMISSION__ #define __CAUSTICS_TRICKS__ #define __SVM__ -#define __SOBOL__ +#ifndef __KERNEL_OPENCL__ #define __TEXTURES__ +#endif #define __RAY_DIFFERENTIALS__ #define __CAMERA_CLIPPING__ #define __INTERSECTION_REFINE__ @@ -286,9 +288,13 @@ typedef struct KernelCamera { /* differentials */ float3 dx; +#ifndef WITH_OPENCL float pad1; +#endif float3 dy; +#ifndef WITH_OPENCL float pad2; +#endif /* clipping */ float nearclip; @@ -321,7 +327,9 @@ typedef struct KernelSunSky { /* sun direction in spherical and cartesian */ float theta, phi, pad3, pad4; float3 dir; +#ifndef WITH_OPENCL float pad; +#endif /* perez function parameters */ float zenith_Y, zenith_x, zenith_y, pad2; diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h index a4a461f9590..d6413d1569e 100644 --- a/intern/cycles/kernel/svm/svm_light_path.h +++ b/intern/cycles/kernel/svm/svm_light_path.h @@ -34,7 +34,7 @@ __device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint case NODE_LP_backfacing: info = (sd->flag & SD_BACKFACING)? 1.0f: 0.0f; break; } - stack_store_float(stack, out_offset, info? 1.0f: 0.0f); + stack_store_float(stack, out_offset, info); } CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 1bb3f5b6097..c435a9e17b8 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -38,12 +38,16 @@ CCL_NAMESPACE_BEGIN +#ifndef __KERNEL_OPENCL__ + #define M_PI_F ((float)3.14159265358979323846264338327950288) #define M_PI_2_F ((float)1.57079632679489661923132169163975144) #define M_PI_4_F ((float)0.785398163397448309615660845819875721) #define M_1_PI_F ((float)0.318309886183790671537767526745028724) #define M_2_PI_F ((float)0.636619772367581343075535053490057448) +#endif + /* Scalar */ #ifdef _WIN32 diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index 02ab59a261f..12ae60f1143 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -70,9 +70,13 @@ CCL_NAMESPACE_BEGIN /* Shorter Unsigned Names */ +#ifndef __KERNEL_OPENCL__ + typedef unsigned char uchar; typedef unsigned int uint; +#endif + #ifndef __KERNEL_GPU__ /* Fixed Bits Types */ |