Cycles OpenCL: fix other build issues when enabling more features.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 9 May 2013 15:28:38 +0000 (15:28 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 9 May 2013 15:28:38 +0000 (15:28 +0000)
intern/cycles/kernel/kernel_bvh.h
intern/cycles/kernel/kernel_bvh_traversal.h
intern/cycles/kernel/kernel_curve.h
intern/cycles/kernel/kernel_light.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/osl/osl_services.cpp

index ef5c9100e5330f2dff5405abcf8982d7255477b6..9e0d4847a1f8ff989b07bb1faa3b8c7d3fc3fd74 100644 (file)
@@ -117,7 +117,7 @@ __device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, cons
 __device_inline void bvh_node_intersect(KernelGlobals *kg,
        bool *traverseChild0, bool *traverseChild1,
        bool *closestChild1, int *nodeAddr0, int *nodeAddr1,
-       float3 P, float3 idir, float t, uint visibility, int nodeAddr, float difl = 0.0f, float extmax = 0.0f)
+       float3 P, float3 idir, float t, uint visibility, int nodeAddr, float difl, float extmax)
 {
        float hdiff = 1.0f + difl;
        float ldiff = 1.0f - difl;
@@ -281,7 +281,7 @@ __device_inline void curvebounds(float *lower, float *upper, float *extremta, fl
 }
 
 __device_inline void bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersection *isect,
-       float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state = NULL, float difl = 0.0f, float extmax = 0.0f)
+       float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state, float difl, float extmax)
 {
        float epsilon = 0.0f;
        int depth = kernel_data.curve_kernel_data.subdivisions;
@@ -305,10 +305,6 @@ __device_inline void bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio
                        dir.z / d, 0, -dir.x /d, 0,
                        -dir.x * dir.y /d, d, -dir.y * dir.z /d, 0,
                        dir.x, dir.y, dir.z, 0,
-                       0, 0, 0, 1) * make_transform(
-                       1, 0, 0, -P.x,
-                       0, 1, 0, -P.y,
-                       0, 0, 1, -P.z,
                        0, 0, 0, 1);
 
                float4 v00 = kernel_tex_fetch(__curves, prim);
@@ -324,10 +320,10 @@ __device_inline void bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio
                float4 P2 = kernel_tex_fetch(__curve_keys, k1);
                float4 P3 = kernel_tex_fetch(__curve_keys, kb);
 
-               float3 p0 = transform_point(&htfm, float4_to_float3(P0));
-               float3 p1 = transform_point(&htfm, float4_to_float3(P1));
-               float3 p2 = transform_point(&htfm, float4_to_float3(P2));
-               float3 p3 = transform_point(&htfm, float4_to_float3(P3));
+               float3 p0 = transform_point(&htfm, float4_to_float3(P0) - P);
+               float3 p1 = transform_point(&htfm, float4_to_float3(P1) - P);
+               float3 p2 = transform_point(&htfm, float4_to_float3(P2) - P);
+               float3 p3 = transform_point(&htfm, float4_to_float3(P3) - P);
 
                float fc = 0.71f;
                curve_coef[0] = p1;
@@ -591,7 +587,7 @@ __device_inline void bvh_cardinal_curve_intersect(KernelGlobals *kg, Intersectio
 }
 
 __device_inline void bvh_curve_intersect(KernelGlobals *kg, Intersection *isect,
-       float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state = NULL, float difl = 0.0f, float extmax = 0.0f)
+       float3 P, float3 idir, uint visibility, int object, int curveAddr, int segment, uint *lcg_state, float difl, float extmax)
 {
        /* curve Intersection check */
        int flags = kernel_data.curve_kernel_data.curveflags;
@@ -865,7 +861,7 @@ __device_inline void bvh_triangle_intersect_subsurface(KernelGlobals *kg, Inters
 
 
 #ifdef __HAIR__ 
-__device_inline bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, Intersection *isect, uint *lcg_state = NULL, float difl = 0.0f, float extmax = 0.0f)
+__device_inline bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, Intersection *isect, uint *lcg_state, float difl, float extmax)
 #else
 __device_inline bool scene_intersect(KernelGlobals *kg, const Ray *ray, const uint visibility, Intersection *isect)
 #endif
index aa05f7e2e37372ede85ce4e6ee72a92338f63640..2d75af32abd0117079c9a2a6218b26ad5eb6f316 100644 (file)
@@ -37,7 +37,7 @@ __device bool BVH_FUNCTION_NAME
 , const uint visibility
 #endif
 #if FEATURE(BVH_HAIR_MINIMUM_WIDTH) && !FEATURE(BVH_SUBSURFACE)
-, uint *lcg_state = NULL, float difl = 0.0f, float extmax = 0.0f
+, uint *lcg_state, float difl, float extmax
 #endif
 )
 {
@@ -87,7 +87,11 @@ __device bool BVH_FUNCTION_NAME
 #else
                                bvh_node_intersect(kg, &traverseChild0, &traverseChild1,
                                        &closestChild1, &nodeAddr, &nodeAddrChild1,
+#ifdef __HAIR__
+                                       P, idir, isect->t, visibility, nodeAddr, 0.0f, 0.0f);
+#else
                                        P, idir, isect->t, visibility, nodeAddr);
+#endif
 #endif
 
                                if(traverseChild0 != traverseChild1) {
index e065717888ca9e51ad8ef28ecb2c21c283ca790d..dd0c0ac10c2ae07cf693208b159785bc0c3e0737 100644 (file)
@@ -102,7 +102,7 @@ __device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
 {
        float r = 0.0f;
 
-       if(sd->segment != ~0) {
+       if(sd->segment != (int)~0) {
                float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
                int k0 = __float_as_int(curvedata.x) + sd->segment;
                int k1 = k0 + 1;
@@ -119,7 +119,7 @@ __device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
 {      
        float3 tgN = make_float3(0.0f,0.0f,0.0f);
 
-       if(sd->segment != ~0) {
+       if(sd->segment != (int)~0) {
                float normalmix = kernel_data.curve_kernel_data.normalmix;
 
                tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu,-sd->I) * normalmix / len_squared(sd->dPdu)));
index 2eab293963a98d123d9592f6717ab6246e463878..88ee0155f5f427324adc083d9f9a066abfa43fa0 100644 (file)
@@ -486,11 +486,11 @@ __device void curve_segment_light_sample(KernelGlobals *kg, int prim, int object
        float4 P1 = kernel_tex_fetch(__curve_keys, k0);
        float4 P2 = kernel_tex_fetch(__curve_keys, k1);
 
-       float l = len(P2 - P1);
+       float l = len(float4_to_float3(P2) - float4_to_float3(P1));
 
        float r1 = P1.w;
        float r2 = P2.w;
-       float3 tg = float4_to_float3(P2 - P1) / l;
+       float3 tg = (float4_to_float3(P2) - float4_to_float3(P1)) / l;
        float3 xc = make_float3(tg.x * tg.z, tg.y * tg.z, -(tg.x * tg.x + tg.y * tg.y));
        if (dot(xc, xc) == 0.0f)
                xc = make_float3(tg.x * tg.y, -(tg.x * tg.x + tg.z * tg.z), tg.z * tg.y);
@@ -561,7 +561,7 @@ __device void light_sample(KernelGlobals *kg, float randt, float randu, float ra
 #endif
 
 #ifdef __HAIR__
-               if (segment != ~0)
+               if (segment != (int)~0)
                        curve_segment_light_sample(kg, prim, object, segment, randu, randv, time, ls);
                else
 #endif
index faf0ac6035cd620d1a6f99296d8aedb58e6b515e..b5a179d0b20d23cf6b8b570b85b3d54f41ab7fb5 100644 (file)
@@ -164,7 +164,11 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
                return false;
        
        Intersection isect;
+#ifdef __HAIR__
+       bool result = scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect, NULL, 0.0f, 0.0f);
+#else
        bool result = scene_intersect(kg, ray, PATH_RAY_SHADOW_OPAQUE, &isect);
+#endif
 
 #ifdef __TRANSPARENT_SHADOWS__
        if(result && kernel_data.integrator.transparent_shadows) {
@@ -198,7 +202,11 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
 #endif
                                }
 
+#ifdef __HAIR__
+                               if(!scene_intersect(kg, ray, PATH_RAY_SHADOW_TRANSPARENT, &isect, NULL, 0.0f, 0.0f)) {
+#else
                                if(!scene_intersect(kg, ray, PATH_RAY_SHADOW_TRANSPARENT, &isect)) {
+#endif
                                        *shadow *= throughput;
                                        return false;
                                }
@@ -528,7 +536,11 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
                /* intersect scene */
                Intersection isect;
                uint visibility = path_state_ray_visibility(kg, &state);
+#ifdef __HAIR__
+               bool hit = scene_intersect(kg, &ray, visibility, &isect, NULL, 0.0f, 0.0f);
+#else
                bool hit = scene_intersect(kg, &ray, visibility, &isect);
+#endif
 
 #ifdef __LAMP_MIS__
                if(kernel_data.integrator.use_lamp_mis && !(state.flag & PATH_RAY_CAMERA)) {
index ee221db426755c21b333f482e4981cfb2ba1a724..535b948998519a610d83a2c5ce19eae269935027 100644 (file)
@@ -72,12 +72,8 @@ CCL_NAMESPACE_BEGIN
 #endif
 
 #ifdef __KERNEL_OPENCL_APPLE__
-//#define __SVM__
-//#define __EMISSION__
-//#define __IMAGE_TEXTURES__
-//#define __HOLDOUT__
-//#define __PROCEDURAL_TEXTURES__
-//#define __EXTRA_NODES__
+#define __KERNEL_SHADING__
+//#define __KERNEL_ADV_SHADING__
 #endif
 
 #ifdef __KERNEL_OPENCL_AMD__
index 7c7248b3b345ed5932a359a6c886b04561b2eacb..7974665900f3f200155a14789bc414b467f0f7f9 100644 (file)
@@ -861,7 +861,7 @@ bool OSLRenderServices::trace(TraceOpt &options, OSL::ShaderGlobals *sg,
        tracedata->init = true;
 
        /* raytrace */
-       return scene_intersect(sd->osl_globals, &ray, ~0, &tracedata->isect);
+       return scene_intersect(sd->osl_globals, &ray, ~0, &tracedata->isect, NULL, 0.0f, 0.0f);
 }