[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39228] branches/cycles/intern/cycles: Cycles: opencl 1.1 compatibility tweaks.

Brecht Van Lommel brechtvanlommel at pandora.be
Tue Aug 9 20:53:54 CEST 2011


Revision: 39228
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39228
Author:   blendix
Date:     2011-08-09 18:53:54 +0000 (Tue, 09 Aug 2011)
Log Message:
-----------
Cycles: opencl 1.1 compatibility tweaks.

Modified Paths:
--------------
    branches/cycles/intern/cycles/kernel/kernel_compat_opencl.h
    branches/cycles/intern/cycles/kernel/kernel_path.h
    branches/cycles/intern/cycles/kernel/kernel_types.h
    branches/cycles/intern/cycles/kernel/svm/svm_light_path.h
    branches/cycles/intern/cycles/util/util_math.h
    branches/cycles/intern/cycles/util/util_types.h

Modified: branches/cycles/intern/cycles/kernel/kernel_compat_opencl.h
===================================================================
--- branches/cycles/intern/cycles/kernel/kernel_compat_opencl.h	2011-08-09 18:26:21 UTC (rev 39227)
+++ branches/cycles/intern/cycles/kernel/kernel_compat_opencl.h	2011-08-09 18:53:54 UTC (rev 39228)
@@ -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 @@
 	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 @@
 #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 @@
 #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"

Modified: branches/cycles/intern/cycles/kernel/kernel_path.h
===================================================================
--- branches/cycles/intern/cycles/kernel/kernel_path.h	2011-08-09 18:26:21 UTC (rev 39227)
+++ branches/cycles/intern/cycles/kernel/kernel_path.h	2011-08-09 18:53:54 UTC (rev 39228)
@@ -129,7 +129,7 @@
 			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;
 		}

Modified: branches/cycles/intern/cycles/kernel/kernel_types.h
===================================================================
--- branches/cycles/intern/cycles/kernel/kernel_types.h	2011-08-09 18:26:21 UTC (rev 39227)
+++ branches/cycles/intern/cycles/kernel/kernel_types.h	2011-08-09 18:53:54 UTC (rev 39228)
@@ -27,6 +27,7 @@
 
 #define OBJECT_SIZE 16
 
+#define __SOBOL__
 #define __INSTANCING__
 #define __DPDU__
 #define __UV__
@@ -34,8 +35,9 @@
 #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 @@
 
 	/* differentials */
 	float3 dx;
+#ifndef WITH_OPENCL
 	float pad1;
+#endif
 	float3 dy;
+#ifndef WITH_OPENCL
 	float pad2;
+#endif
 
 	/* clipping */
 	float nearclip;
@@ -321,7 +327,9 @@
 	/* 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;

Modified: branches/cycles/intern/cycles/kernel/svm/svm_light_path.h
===================================================================
--- branches/cycles/intern/cycles/kernel/svm/svm_light_path.h	2011-08-09 18:26:21 UTC (rev 39227)
+++ branches/cycles/intern/cycles/kernel/svm/svm_light_path.h	2011-08-09 18:53:54 UTC (rev 39228)
@@ -34,7 +34,7 @@
 		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

Modified: branches/cycles/intern/cycles/util/util_math.h
===================================================================
--- branches/cycles/intern/cycles/util/util_math.h	2011-08-09 18:26:21 UTC (rev 39227)
+++ branches/cycles/intern/cycles/util/util_math.h	2011-08-09 18:53:54 UTC (rev 39228)
@@ -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

Modified: branches/cycles/intern/cycles/util/util_types.h
===================================================================
--- branches/cycles/intern/cycles/util/util_types.h	2011-08-09 18:26:21 UTC (rev 39227)
+++ branches/cycles/intern/cycles/util/util_types.h	2011-08-09 18:53:54 UTC (rev 39228)
@@ -70,9 +70,13 @@
 
 /* Shorter Unsigned Names */
 
+#ifndef __KERNEL_OPENCL__
+
 typedef unsigned char uchar;
 typedef unsigned int uint;
 
+#endif
+
 #ifndef __KERNEL_GPU__
 
 /* Fixed Bits Types */




More information about the Bf-blender-cvs mailing list