Cycles: Remove ccl_fetch and SOA
authorMai Lavelle <mai.lavelle@gmail.com>
Thu, 16 Feb 2017 11:24:13 +0000 (06:24 -0500)
committerMai Lavelle <mai.lavelle@gmail.com>
Wed, 8 Mar 2017 05:52:41 +0000 (00:52 -0500)
45 files changed:
intern/cycles/kernel/closure/alloc.h
intern/cycles/kernel/closure/bsdf.h
intern/cycles/kernel/geom/geom_attribute.h
intern/cycles/kernel/geom/geom_curve.h
intern/cycles/kernel/geom/geom_motion_triangle_intersect.h
intern/cycles/kernel/geom/geom_motion_triangle_shader.h
intern/cycles/kernel/geom/geom_object.h
intern/cycles/kernel/geom/geom_patch.h
intern/cycles/kernel/geom/geom_primitive.h
intern/cycles/kernel/geom/geom_subd_triangle.h
intern/cycles/kernel/geom/geom_triangle.h
intern/cycles/kernel/geom/geom_triangle_intersect.h
intern/cycles/kernel/geom/geom_volume.h
intern/cycles/kernel/kernel_camera.h
intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_passes.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_path_branched.h
intern/cycles/kernel/kernel_path_surface.h
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/kernel_shadow.h
intern/cycles/kernel/kernel_subsurface.h
intern/cycles/kernel/kernel_types.h
intern/cycles/kernel/osl/osl_bssrdf.cpp
intern/cycles/kernel/split/kernel_background_buffer_update.h
intern/cycles/kernel/split/kernel_data_init.h
intern/cycles/kernel/split/kernel_direct_lighting.h
intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h
intern/cycles/kernel/split/kernel_lamp_emission.h
intern/cycles/kernel/split/kernel_next_iteration_setup.h
intern/cycles/kernel/split/kernel_shader_eval.h
intern/cycles/kernel/split/kernel_shadow_blocked.h
intern/cycles/kernel/svm/svm.h
intern/cycles/kernel/svm/svm_attribute.h
intern/cycles/kernel/svm/svm_bump.h
intern/cycles/kernel/svm/svm_camera.h
intern/cycles/kernel/svm/svm_closure.h
intern/cycles/kernel/svm/svm_displace.h
intern/cycles/kernel/svm/svm_fresnel.h
intern/cycles/kernel/svm/svm_geometry.h
intern/cycles/kernel/svm/svm_image.h
intern/cycles/kernel/svm/svm_light_path.h
intern/cycles/kernel/svm/svm_tex_coord.h
intern/cycles/kernel/svm/svm_vector_transform.h
intern/cycles/kernel/svm/svm_wireframe.h

index b7abc1ec507536456d46359cd0af5fb1d1624ca5..4894ea58dbaa90de66ee0f68d7b0d46aa857aef6 100644 (file)
@@ -20,17 +20,17 @@ ccl_device ShaderClosure *closure_alloc(ShaderData *sd, int size, ClosureType ty
 {
        kernel_assert(size <= sizeof(ShaderClosure));
 
-       int num_closure = ccl_fetch(sd, num_closure);
-       int num_closure_extra = ccl_fetch(sd, num_closure_extra);
+       int num_closure = sd->num_closure;
+       int num_closure_extra = sd->num_closure_extra;
        if(num_closure + num_closure_extra >= MAX_CLOSURE)
                return NULL;
 
-       ShaderClosure *sc = &ccl_fetch(sd, closure)[num_closure];
+       ShaderClosure *sc = &sd->closure[num_closure];
 
        sc->type = type;
        sc->weight = weight;
 
-       ccl_fetch(sd, num_closure)++;
+       sd->num_closure++;
 
        return sc;
 }
@@ -44,18 +44,18 @@ ccl_device ccl_addr_space void *closure_alloc_extra(ShaderData *sd, int size)
         * This lets us keep the same fast array iteration over closures, as we
         * found linked list iteration and iteration with skipping to be slower. */
        int num_extra = ((size + sizeof(ShaderClosure) - 1) / sizeof(ShaderClosure));
-       int num_closure = ccl_fetch(sd, num_closure);
-       int num_closure_extra = ccl_fetch(sd, num_closure_extra) + num_extra;
+       int num_closure = sd->num_closure;
+       int num_closure_extra = sd->num_closure_extra + num_extra;
 
        if(num_closure + num_closure_extra > MAX_CLOSURE) {
                /* Remove previous closure. */
-               ccl_fetch(sd, num_closure)--;
-               ccl_fetch(sd, num_closure_extra)++;
+               sd->num_closure--;
+               sd->num_closure_extra++;
                return NULL;
        }
 
-       ccl_fetch(sd, num_closure_extra) = num_closure_extra;
-       return (ccl_addr_space void*)(ccl_fetch(sd, closure) + MAX_CLOSURE - num_closure_extra);
+       sd->num_closure_extra = num_closure_extra;
+       return (ccl_addr_space void*)(sd->closure + MAX_CLOSURE - num_closure_extra);
 }
 
 ccl_device_inline ShaderClosure *bsdf_alloc(ShaderData *sd, int size, float3 weight)
index 7e4d5fe2e377838856abfe16c0fc04457e2bc947..a44b9e2d9b9bb0e9f8feef296b14d966cb420c30 100644 (file)
@@ -51,89 +51,89 @@ ccl_device_forceinline int bsdf_sample(KernelGlobals *kg,
        switch(sc->type) {
                case CLOSURE_BSDF_DIFFUSE_ID:
                case CLOSURE_BSDF_BSSRDF_ID:
-                       label = bsdf_diffuse_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_diffuse_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
 #ifdef __SVM__
                case CLOSURE_BSDF_OREN_NAYAR_ID:
-                       label = bsdf_oren_nayar_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_oren_nayar_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
 #ifdef __OSL__
                case CLOSURE_BSDF_PHONG_RAMP_ID:
-                       label = bsdf_phong_ramp_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_phong_ramp_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_DIFFUSE_RAMP_ID:
-                       label = bsdf_diffuse_ramp_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_diffuse_ramp_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
 #endif
                case CLOSURE_BSDF_TRANSLUCENT_ID:
-                       label = bsdf_translucent_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_translucent_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_REFLECTION_ID:
-                       label = bsdf_reflection_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_reflection_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_REFRACTION_ID:
-                       label = bsdf_refraction_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_refraction_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_TRANSPARENT_ID:
-                       label = bsdf_transparent_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_transparent_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_MICROFACET_GGX_ID:
                case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
                case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
-                       label = bsdf_microfacet_ggx_sample(kg, sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_microfacet_ggx_sample(kg, sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
-                       label = bsdf_microfacet_multi_ggx_sample(kg, sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
-                               eval, omega_in,  &domega_in->dx, &domega_in->dy, pdf, &ccl_fetch(sd, lcg_state));
+                       label = bsdf_microfacet_multi_ggx_sample(kg, sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
+                               eval, omega_in,  &domega_in->dx, &domega_in->dy, pdf, &sd->lcg_state);
                        break;
                case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
-                       label = bsdf_microfacet_multi_ggx_glass_sample(kg, sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
-                               eval, omega_in,  &domega_in->dx, &domega_in->dy, pdf, &ccl_fetch(sd, lcg_state));
+                       label = bsdf_microfacet_multi_ggx_glass_sample(kg, sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
+                               eval, omega_in,  &domega_in->dx, &domega_in->dy, pdf, &sd->lcg_state);
                        break;
                case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
                case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
                case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
-                       label = bsdf_microfacet_beckmann_sample(kg, sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_microfacet_beckmann_sample(kg, sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
                case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
-                       label = bsdf_ashikhmin_shirley_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_ashikhmin_shirley_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
-                       label = bsdf_ashikhmin_velvet_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_ashikhmin_velvet_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_DIFFUSE_TOON_ID:
-                       label = bsdf_diffuse_toon_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_diffuse_toon_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_GLOSSY_TOON_ID:
-                       label = bsdf_glossy_toon_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_glossy_toon_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_HAIR_REFLECTION_ID:
-                       label = bsdf_hair_reflection_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_hair_reflection_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
                case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
-                       label = bsdf_hair_transmission_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
+                       label = bsdf_hair_transmission_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
                                eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
 #endif
 #ifdef __VOLUME__
                case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
-                       label = volume_henyey_greenstein_sample(sc, ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
+                       label = volume_henyey_greenstein_sample(sc, sd->I, sd->dI.dx, sd->dI.dy, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
                        break;
 #endif
                default:
@@ -157,75 +157,75 @@ float3 bsdf_eval(KernelGlobals *kg,
 {
        float3 eval;
 
-       if(dot(ccl_fetch(sd, Ng), omega_in) >= 0.0f) {
+       if(dot(sd->Ng, omega_in) >= 0.0f) {
                switch(sc->type) {
                        case CLOSURE_BSDF_DIFFUSE_ID:
                        case CLOSURE_BSDF_BSSRDF_ID:
-                               eval = bsdf_diffuse_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_diffuse_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
 #ifdef __SVM__
                        case CLOSURE_BSDF_OREN_NAYAR_ID:
-                               eval = bsdf_oren_nayar_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_oren_nayar_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
 #ifdef __OSL__
                        case CLOSURE_BSDF_PHONG_RAMP_ID:
-                               eval = bsdf_phong_ramp_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_phong_ramp_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_DIFFUSE_RAMP_ID:
-                               eval = bsdf_diffuse_ramp_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_diffuse_ramp_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
 #endif
                        case CLOSURE_BSDF_TRANSLUCENT_ID:
-                               eval = bsdf_translucent_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_translucent_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_REFLECTION_ID:
-                               eval = bsdf_reflection_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_reflection_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_REFRACTION_ID:
-                               eval = bsdf_refraction_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_refraction_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_TRANSPARENT_ID:
-                               eval = bsdf_transparent_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_transparent_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_MICROFACET_GGX_ID:
                        case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
                        case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
-                               eval = bsdf_microfacet_ggx_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_microfacet_ggx_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
-                               eval = bsdf_microfacet_multi_ggx_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf, &ccl_fetch(sd, lcg_state));
+                               eval = bsdf_microfacet_multi_ggx_eval_reflect(sc, sd->I, omega_in, pdf, &sd->lcg_state);
                                break;
                        case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
-                               eval = bsdf_microfacet_multi_ggx_glass_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf, &ccl_fetch(sd, lcg_state));
+                               eval = bsdf_microfacet_multi_ggx_glass_eval_reflect(sc, sd->I, omega_in, pdf, &sd->lcg_state);
                                break;
                        case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
                        case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
                        case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
-                               eval = bsdf_microfacet_beckmann_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_microfacet_beckmann_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
                        case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
-                               eval = bsdf_ashikhmin_shirley_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_ashikhmin_shirley_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
-                               eval = bsdf_ashikhmin_velvet_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_ashikhmin_velvet_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_DIFFUSE_TOON_ID:
-                               eval = bsdf_diffuse_toon_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_diffuse_toon_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_GLOSSY_TOON_ID:
-                               eval = bsdf_glossy_toon_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_glossy_toon_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_HAIR_REFLECTION_ID:
-                               eval = bsdf_hair_reflection_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_hair_reflection_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
-                               eval = bsdf_hair_transmission_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_hair_transmission_eval_reflect(sc, sd->I, omega_in, pdf);
                                break;
 #endif
 #ifdef __VOLUME__
                        case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
-                               eval = volume_henyey_greenstein_eval_phase(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = volume_henyey_greenstein_eval_phase(sc, sd->I, omega_in, pdf);
                                break;
 #endif
                        default:
@@ -237,63 +237,63 @@ float3 bsdf_eval(KernelGlobals *kg,
                switch(sc->type) {
                        case CLOSURE_BSDF_DIFFUSE_ID:
                        case CLOSURE_BSDF_BSSRDF_ID:
-                               eval = bsdf_diffuse_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_diffuse_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
 #ifdef __SVM__
                        case CLOSURE_BSDF_OREN_NAYAR_ID:
-                               eval = bsdf_oren_nayar_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_oren_nayar_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_TRANSLUCENT_ID:
-                               eval = bsdf_translucent_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_translucent_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_REFLECTION_ID:
-                               eval = bsdf_reflection_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_reflection_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_REFRACTION_ID:
-                               eval = bsdf_refraction_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_refraction_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_TRANSPARENT_ID:
-                               eval = bsdf_transparent_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_transparent_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_MICROFACET_GGX_ID:
                        case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
                        case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
-                               eval = bsdf_microfacet_ggx_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_microfacet_ggx_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
-                               eval = bsdf_microfacet_multi_ggx_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf, &ccl_fetch(sd, lcg_state));
+                               eval = bsdf_microfacet_multi_ggx_eval_transmit(sc, sd->I, omega_in, pdf, &sd->lcg_state);
                                break;
                        case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
-                               eval = bsdf_microfacet_multi_ggx_glass_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf, &ccl_fetch(sd, lcg_state));
+                               eval = bsdf_microfacet_multi_ggx_glass_eval_transmit(sc, sd->I, omega_in, pdf, &sd->lcg_state);
                                break;
                        case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
                        case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
                        case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
-                               eval = bsdf_microfacet_beckmann_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_microfacet_beckmann_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
                        case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
-                               eval = bsdf_ashikhmin_shirley_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_ashikhmin_shirley_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
-                               eval = bsdf_ashikhmin_velvet_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_ashikhmin_velvet_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_DIFFUSE_TOON_ID:
-                               eval = bsdf_diffuse_toon_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_diffuse_toon_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_GLOSSY_TOON_ID:
-                               eval = bsdf_glossy_toon_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_glossy_toon_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_HAIR_REFLECTION_ID:
-                               eval = bsdf_hair_reflection_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_hair_reflection_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
                        case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
-                               eval = bsdf_hair_transmission_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = bsdf_hair_transmission_eval_transmit(sc, sd->I, omega_in, pdf);
                                break;
 #endif
 #ifdef __VOLUME__
                        case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
-                               eval = volume_henyey_greenstein_eval_phase(sc, ccl_fetch(sd, I), omega_in, pdf);
+                               eval = volume_henyey_greenstein_eval_phase(sc, sd->I, omega_in, pdf);
                                break;
 #endif
                        default:
index 08ccee56335a6cd9a5bcca0fb090dff51bc914d9..cc62192ef21ba7361d7133517b4fd0fc82ea0ef6 100644 (file)
@@ -30,7 +30,7 @@ ccl_device_inline uint subd_triangle_patch(KernelGlobals *kg, const ShaderData *
 ccl_device_inline uint attribute_primitive_type(KernelGlobals *kg, const ShaderData *sd)
 {
 #ifdef __HAIR__
-       if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
+       if(sd->type & PRIMITIVE_ALL_CURVE) {
                return ATTR_PRIM_CURVE;
        }
        else
@@ -53,12 +53,12 @@ ccl_device_inline AttributeDescriptor attribute_not_found()
 
 ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id)
 {
-       if(ccl_fetch(sd, object) == PRIM_NONE) {
+       if(sd->object == PRIM_NONE) {
                return attribute_not_found();
        }
 
        /* for SVM, find attribute by unique id */
-       uint attr_offset = ccl_fetch(sd, object)*kernel_data.bvh.attributes_map_stride;
+       uint attr_offset = sd->object*kernel_data.bvh.attributes_map_stride;
        attr_offset += attribute_primitive_type(kg, sd);
        uint4 attr_map = kernel_tex_fetch(__attributes_map, attr_offset);
        
@@ -73,7 +73,7 @@ ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const Sh
        AttributeDescriptor desc;
        desc.element = (AttributeElement)attr_map.y;
        
-       if(ccl_fetch(sd, prim) == PRIM_NONE &&
+       if(sd->prim == PRIM_NONE &&
           desc.element != ATTR_ELEMENT_MESH &&
           desc.element != ATTR_ELEMENT_VOXEL &&
           desc.element != ATTR_ELEMENT_OBJECT)
index 712b67a1b5547b842e7bb889ebf9665fe17e5dc8..7cc840ce78dad4f9adba66743620a16fce41d3bc 100644 (file)
@@ -32,22 +32,22 @@ ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd,
                if(dy) *dy = 0.0f;
 #endif
 
-               return kernel_tex_fetch(__attributes_float, desc.offset + ccl_fetch(sd, prim));
+               return kernel_tex_fetch(__attributes_float, desc.offset + sd->prim);
        }
        else if(desc.element == ATTR_ELEMENT_CURVE_KEY || desc.element == ATTR_ELEMENT_CURVE_KEY_MOTION) {
-               float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
-               int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
+               float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
+               int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
                int k1 = k0 + 1;
 
                float f0 = kernel_tex_fetch(__attributes_float, desc.offset + k0);
                float f1 = kernel_tex_fetch(__attributes_float, desc.offset + k1);
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*(f1 - f0);
+               if(dx) *dx = sd->du.dx*(f1 - f0);
                if(dy) *dy = 0.0f;
 #endif
 
-               return (1.0f - ccl_fetch(sd, u))*f0 + ccl_fetch(sd, u)*f1;
+               return (1.0f - sd->u)*f0 + sd->u*f1;
        }
        else {
 #ifdef __RAY_DIFFERENTIALS__
@@ -71,22 +71,22 @@ ccl_device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd
                if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
 #endif
 
-               return float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + ccl_fetch(sd, prim)));
+               return float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + sd->prim));
        }
        else if(desc.element == ATTR_ELEMENT_CURVE_KEY || desc.element == ATTR_ELEMENT_CURVE_KEY_MOTION) {
-               float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
-               int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
+               float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
+               int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
                int k1 = k0 + 1;
 
                float3 f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + k0));
                float3 f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + k1));
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*(f1 - f0);
+               if(dx) *dx = sd->du.dx*(f1 - f0);
                if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
 #endif
 
-               return (1.0f - ccl_fetch(sd, u))*f0 + ccl_fetch(sd, u)*f1;
+               return (1.0f - sd->u)*f0 + sd->u*f1;
        }
        else {
 #ifdef __RAY_DIFFERENTIALS__
@@ -104,22 +104,22 @@ ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
 {
        float r = 0.0f;
 
-       if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
-               float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
-               int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
+       if(sd->type & PRIMITIVE_ALL_CURVE) {
+               float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
+               int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
                int k1 = k0 + 1;
 
                float4 P_curve[2];
 
-               if(ccl_fetch(sd, type) & PRIMITIVE_CURVE) {
+               if(sd->type & PRIMITIVE_CURVE) {
                        P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
                        P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
                }
                else {
-                       motion_curve_keys(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), k0, k1, P_curve);
+                       motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve);
                }
 
-               r = (P_curve[1].w - P_curve[0].w) * ccl_fetch(sd, u) + P_curve[0].w;
+               r = (P_curve[1].w - P_curve[0].w) * sd->u + P_curve[0].w;
        }
 
        return r*2.0f;
@@ -130,8 +130,8 @@ ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
 
 ccl_device float3 curve_motion_center_location(KernelGlobals *kg, ShaderData *sd)
 {
-       float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
-       int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
+       float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
+       int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
        int k1 = k0 + 1;
 
        float4 P_curve[2];
@@ -139,7 +139,7 @@ ccl_device float3 curve_motion_center_location(KernelGlobals *kg, ShaderData *sd
        P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
        P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
 
-       return float4_to_float3(P_curve[1]) * ccl_fetch(sd, u) + float4_to_float3(P_curve[0]) * (1.0f - ccl_fetch(sd, u));
+       return float4_to_float3(P_curve[1]) * sd->u + float4_to_float3(P_curve[0]) * (1.0f - sd->u);
 }
 
 /* Curve tangent normal */
@@ -148,14 +148,14 @@ ccl_device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
 {      
        float3 tgN = make_float3(0.0f,0.0f,0.0f);
 
-       if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
+       if(sd->type & PRIMITIVE_ALL_CURVE) {
 
-               tgN = -(-ccl_fetch(sd, I) - ccl_fetch(sd, dPdu) * (dot(ccl_fetch(sd, dPdu),-ccl_fetch(sd, I)) / len_squared(ccl_fetch(sd, dPdu))));
+               tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu,-sd->I) / len_squared(sd->dPdu)));
                tgN = normalize(tgN);
 
                /* need to find suitable scaled gd for corrected normal */
 #if 0
-               tgN = normalize(tgN - gd * ccl_fetch(sd, dPdu));
+               tgN = normalize(tgN - gd * sd->dPdu);
 #endif
        }
 
@@ -966,7 +966,7 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
 
        if(isect->object != OBJECT_NONE) {
 #ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_itfm);
+               Transform tfm = sd->ob_itfm;
 #else
                Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
 #endif
@@ -979,7 +979,7 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
        int prim = kernel_tex_fetch(__prim_index, isect->prim);
        float4 v00 = kernel_tex_fetch(__curves, prim);
 
-       int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
+       int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
        int k1 = k0 + 1;
 
        float3 tg;
@@ -990,14 +990,14 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
 
                float4 P_curve[4];
 
-               if(ccl_fetch(sd, type) & PRIMITIVE_CURVE) {
+               if(sd->type & PRIMITIVE_CURVE) {
                        P_curve[0] = kernel_tex_fetch(__curve_keys, ka);
                        P_curve[1] = kernel_tex_fetch(__curve_keys, k0);
                        P_curve[2] = kernel_tex_fetch(__curve_keys, k1);
                        P_curve[3] = kernel_tex_fetch(__curve_keys, kb);
                }
                else {
-                       motion_cardinal_curve_keys(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), ka, k0, k1, kb, P_curve);
+                       motion_cardinal_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve);
                }
 
                float3 p[4];
@@ -1009,43 +1009,43 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
                P = P + D*t;
 
 #ifdef __UV__
-               ccl_fetch(sd, u) = isect->u;
-               ccl_fetch(sd, v) = 0.0f;
+               sd->u = isect->u;
+               sd->v = 0.0f;
 #endif
 
                tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3]));
 
                if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) {
-                       ccl_fetch(sd, Ng) = normalize(-(D - tg * (dot(tg, D))));
+                       sd->Ng = normalize(-(D - tg * (dot(tg, D))));
                }
                else {
                        /* direction from inside to surface of curve */
                        float3 p_curr = curvepoint(isect->u, p[0], p[1], p[2], p[3]);   
-                       ccl_fetch(sd, Ng) = normalize(P - p_curr);
+                       sd->Ng = normalize(P - p_curr);
 
                        /* adjustment for changing radius */
                        float gd = isect->v;
 
                        if(gd != 0.0f) {
-                               ccl_fetch(sd, Ng) = ccl_fetch(sd, Ng) - gd * tg;
-                               ccl_fetch(sd, Ng) = normalize(ccl_fetch(sd, Ng));
+                               sd->Ng = sd->Ng - gd * tg;
+                               sd->Ng = normalize(sd->Ng);
                        }
                }
 
                /* todo: sometimes the normal is still so that this is detected as
                 * backfacing even if cull backfaces is enabled */
 
-               ccl_fetch(sd, N) = ccl_fetch(sd, Ng);
+               sd->N = sd->Ng;
        }
        else {
                float4 P_curve[2];
 
-               if(ccl_fetch(sd, type) & PRIMITIVE_CURVE) {
+               if(sd->type & PRIMITIVE_CURVE) {
                        P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
                        P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
                }
                else {
-                       motion_curve_keys(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), k0, k1, P_curve);
+                       motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve);
                }
 
                float l = 1.0f;
@@ -1056,39 +1056,39 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
                float3 dif = P - float4_to_float3(P_curve[0]);
 
 #ifdef __UV__
-               ccl_fetch(sd, u) = dot(dif,tg)/l;
-               ccl_fetch(sd, v) = 0.0f;
+               sd->u = dot(dif,tg)/l;
+               sd->v = 0.0f;
 #endif
 
                if(flag & CURVE_KN_TRUETANGENTGNORMAL) {
-                       ccl_fetch(sd, Ng) = -(D - tg * dot(tg, D));
-                       ccl_fetch(sd, Ng) = normalize(ccl_fetch(sd, Ng));
+                       sd->Ng = -(D - tg * dot(tg, D));
+                       sd->Ng = normalize(sd->Ng);
                }
                else {
                        float gd = isect->v;
 
                        /* direction from inside to surface of curve */
-                       ccl_fetch(sd, Ng) = (dif - tg * ccl_fetch(sd, u) * l) / (P_curve[0].w + ccl_fetch(sd, u) * l * gd);
+                       sd->Ng = (dif - tg * sd->u * l) / (P_curve[0].w + sd->u * l * gd);
 
                        /* adjustment for changing radius */
                        if(gd != 0.0f) {
-                               ccl_fetch(sd, Ng) = ccl_fetch(sd, Ng) - gd * tg;
-                               ccl_fetch(sd, Ng) = normalize(ccl_fetch(sd, Ng));
+                               sd->Ng = sd->Ng - gd * tg;
+                               sd->Ng = normalize(sd->Ng);
                        }
                }
 
-               ccl_fetch(sd, N) = ccl_fetch(sd, Ng);
+               sd->N = sd->Ng;
        }
 
 #ifdef __DPDU__
        /* dPdu/dPdv */
-       ccl_fetch(sd, dPdu) = tg;
-       ccl_fetch(sd, dPdv) = cross(tg, ccl_fetch(sd, Ng));
+       sd->dPdu = tg;
+       sd->dPdv = cross(tg, sd->Ng);
 #endif
 
        if(isect->object != OBJECT_NONE) {
 #ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_tfm);
+               Transform tfm = sd->ob_tfm;
 #else
                Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
 #endif
index d57d74ea882c1575c278054fe51e6a17a0cf8bc5..2500228281ed17d76f3ccce3021b9171c5b72941 100644 (file)
@@ -48,7 +48,7 @@ ccl_device_inline float3 motion_triangle_refine(KernelGlobals *kg,
                        return P;
                }
 #  ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_itfm);
+               Transform tfm = sd->ob_itfm;
 #  else
                Transform tfm = object_fetch_transform(kg,
                                                       isect->object,
@@ -77,7 +77,7 @@ ccl_device_inline float3 motion_triangle_refine(KernelGlobals *kg,
 
        if(isect->object != OBJECT_NONE) {
 #  ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_tfm);
+               Transform tfm = sd->ob_tfm;
 #  else
                Transform tfm = object_fetch_transform(kg,
                                                       isect->object,
@@ -116,7 +116,7 @@ float3 motion_triangle_refine_subsurface(KernelGlobals *kg,
 #  ifdef __INTERSECTION_REFINE__
        if(isect->object != OBJECT_NONE) {
 #    ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_itfm);
+               Transform tfm = sd->ob_itfm;
 #    else
                Transform tfm = object_fetch_transform(kg,
                                                       isect->object,
@@ -144,7 +144,7 @@ float3 motion_triangle_refine_subsurface(KernelGlobals *kg,
 
        if(isect->object != OBJECT_NONE) {
 #    ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_tfm);
+               Transform tfm = sd->ob_tfm;
 #    else
                Transform tfm = object_fetch_transform(kg,
                                                       isect->object,
index 0e024a05db6700c3c7f6f7bc8c3cd56a04f86e82..cb456056e20d6d1d43e53106409e3cdb7039886a 100644 (file)
@@ -39,26 +39,26 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals *kg,
                                                       bool subsurface)
 {
        /* Get shader. */
-       ccl_fetch(sd, shader) = kernel_tex_fetch(__tri_shader, ccl_fetch(sd, prim));
+       sd->shader = kernel_tex_fetch(__tri_shader, sd->prim);
        /* Get motion info. */
        /* TODO(sergey): This logic is really similar to motion_triangle_vertices(),
         * can we de-duplicate something here?
         */
        int numsteps, numverts;
-       object_motion_info(kg, ccl_fetch(sd, object), &numsteps, &numverts, NULL);
+       object_motion_info(kg, sd->object, &numsteps, &numverts, NULL);
        /* Figure out which steps we need to fetch and their interpolation factor. */
        int maxstep = numsteps*2;
-       int step = min((int)(ccl_fetch(sd, time)*maxstep), maxstep-1);
-       float t = ccl_fetch(sd, time)*maxstep - step;
+       int step = min((int)(sd->time*maxstep), maxstep-1);
+       float t = sd->time*maxstep - step;
        /* Find attribute. */
        AttributeElement elem;
-       int offset = find_attribute_motion(kg, ccl_fetch(sd, object),
+       int offset = find_attribute_motion(kg, sd->object,
                                           ATTR_STD_MOTION_VERTEX_POSITION,
                                           &elem);
        kernel_assert(offset != ATTR_STD_NOT_FOUND);
        /* Fetch vertex coordinates. */
        float3 verts[3], next_verts[3];
-       uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, ccl_fetch(sd, prim));
+       uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
        motion_triangle_verts_for_step(kg, tri_vindex, offset, numverts, numsteps, step, verts);
        motion_triangle_verts_for_step(kg, tri_vindex, offset, numverts, numsteps, step+1, next_verts);
        /* Interpolate between steps. */
@@ -68,7 +68,7 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals *kg,
        /* Compute refined position. */
 #ifdef __SUBSURFACE__
        if(subsurface) {
-               ccl_fetch(sd, P) = motion_triangle_refine_subsurface(kg,
+               sd->P = motion_triangle_refine_subsurface(kg,
                                                                     sd,
                                                                     isect,
                                                                     ray,
@@ -77,29 +77,29 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals *kg,
        else
 #endif  /*  __SUBSURFACE__*/
        {
-               ccl_fetch(sd, P) = motion_triangle_refine(kg, sd, isect, ray, verts);
+               sd->P = motion_triangle_refine(kg, sd, isect, ray, verts);
        }
        /* Compute face normal. */
        float3 Ng;
-       if(ccl_fetch(sd, object_flag) & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
+       if(sd->object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
                Ng = normalize(cross(verts[2] - verts[0], verts[1] - verts[0]));
        }
        else {
                Ng = normalize(cross(verts[1] - verts[0], verts[2] - verts[0]));
        }
-       ccl_fetch(sd, Ng) = Ng;
-       ccl_fetch(sd, N) = Ng;
+       sd->Ng = Ng;
+       sd->N = Ng;
        /* Compute derivatives of P w.r.t. uv. */
 #ifdef __DPDU__
-       ccl_fetch(sd, dPdu) = (verts[0] - verts[2]);
-       ccl_fetch(sd, dPdv) = (verts[1] - verts[2]);
+       sd->dPdu = (verts[0] - verts[2]);
+       sd->dPdv = (verts[1] - verts[2]);
 #endif
        /* Compute smooth normal. */
-       if(ccl_fetch(sd, shader) & SHADER_SMOOTH_NORMAL) {
+       if(sd->shader & SHADER_SMOOTH_NORMAL) {
                /* Find attribute. */
                AttributeElement elem;
                int offset = find_attribute_motion(kg,
-                                                  ccl_fetch(sd, object),
+                                                  sd->object,
                                                   ATTR_STD_MOTION_VERTEX_NORMAL,
                                                   &elem);
                kernel_assert(offset != ATTR_STD_NOT_FOUND);
@@ -112,10 +112,10 @@ ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals *kg,
                normals[1] = (1.0f - t)*normals[1] + t*next_normals[1];
                normals[2] = (1.0f - t)*normals[2] + t*next_normals[2];
                /* Interpolate between vertices. */
-               float u = ccl_fetch(sd, u);
-               float v = ccl_fetch(sd, v);
+               float u = sd->u;
+               float v = sd->v;
                float w = 1.0f - u - v;
-               ccl_fetch(sd, N) = (u*normals[0] + v*normals[1] + w*normals[2]);
+               sd->N = (u*normals[0] + v*normals[1] + w*normals[2]);
        }
 }
 
index f51b2d1865730fa22f3b71ab420e9a5388b30eb3..5a04be8b0bfe6c12b80e2387b1602c94294316ae 100644 (file)
@@ -137,9 +137,9 @@ ccl_device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg
 ccl_device_inline void object_position_transform(KernelGlobals *kg, const ShaderData *sd, float3 *P)
 {
 #ifdef __OBJECT_MOTION__
-       *P = transform_point_auto(&ccl_fetch(sd, ob_tfm), *P);
+       *P = transform_point_auto(&sd->ob_tfm, *P);
 #else
-       Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
+       Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
        *P = transform_point(&tfm, *P);
 #endif
 }
@@ -149,9 +149,9 @@ ccl_device_inline void object_position_transform(KernelGlobals *kg, const Shader
 ccl_device_inline void object_inverse_position_transform(KernelGlobals *kg, const ShaderData *sd, float3 *P)
 {
 #ifdef __OBJECT_MOTION__
-       *P = transform_point_auto(&ccl_fetch(sd, ob_itfm), *P);
+       *P = transform_point_auto(&sd->ob_itfm, *P);
 #else
-       Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
+       Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
        *P = transform_point(&tfm, *P);
 #endif
 }
@@ -161,12 +161,12 @@ ccl_device_inline void object_inverse_position_transform(KernelGlobals *kg, cons
 ccl_device_inline void object_inverse_normal_transform(KernelGlobals *kg, const ShaderData *sd, float3 *N)
 {
 #ifdef __OBJECT_MOTION__
-       if((ccl_fetch(sd, object) != OBJECT_NONE) || (ccl_fetch(sd, type) == PRIMITIVE_LAMP)) {
-               *N = normalize(transform_direction_transposed_auto(&ccl_fetch(sd, ob_tfm), *N));
+       if((sd->object != OBJECT_NONE) || (sd->type == PRIMITIVE_LAMP)) {
+               *N = normalize(transform_direction_transposed_auto(&sd->ob_tfm, *N));
        }
 #else
-       if(ccl_fetch(sd, object) != OBJECT_NONE) {
-               Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
+       if(sd->object != OBJECT_NONE) {
+               Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
                *N = normalize(transform_direction_transposed(&tfm, *N));
        }
 #endif
@@ -177,9 +177,9 @@ ccl_device_inline void object_inverse_normal_transform(KernelGlobals *kg, const
 ccl_device_inline void object_normal_transform(KernelGlobals *kg, const ShaderData *sd, float3 *N)
 {
 #ifdef __OBJECT_MOTION__
-       *N = normalize(transform_direction_transposed_auto(&ccl_fetch(sd, ob_itfm), *N));
+       *N = normalize(transform_direction_transposed_auto(&sd->ob_itfm, *N));
 #else
-       Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
+       Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
        *N = normalize(transform_direction_transposed(&tfm, *N));
 #endif
 }
@@ -189,9 +189,9 @@ ccl_device_inline void object_normal_transform(KernelGlobals *kg, const ShaderDa
 ccl_device_inline void object_dir_transform(KernelGlobals *kg, const ShaderData *sd, float3 *D)
 {
 #ifdef __OBJECT_MOTION__
-       *D = transform_direction_auto(&ccl_fetch(sd, ob_tfm), *D);
+       *D = transform_direction_auto(&sd->ob_tfm, *D);
 #else
-       Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
+       Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
        *D = transform_direction(&tfm, *D);
 #endif
 }
@@ -201,9 +201,9 @@ ccl_device_inline void object_dir_transform(KernelGlobals *kg, const ShaderData
 ccl_device_inline void object_inverse_dir_transform(KernelGlobals *kg, const ShaderData *sd, float3 *D)
 {
 #ifdef __OBJECT_MOTION__
-       *D = transform_direction_auto(&ccl_fetch(sd, ob_itfm), *D);
+       *D = transform_direction_auto(&sd->ob_itfm, *D);
 #else
-       Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
+       Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
        *D = transform_direction(&tfm, *D);
 #endif
 }
@@ -212,13 +212,13 @@ ccl_device_inline void object_inverse_dir_transform(KernelGlobals *kg, const Sha
 
 ccl_device_inline float3 object_location(KernelGlobals *kg, const ShaderData *sd)
 {
-       if(ccl_fetch(sd, object) == OBJECT_NONE)
+       if(sd->object == OBJECT_NONE)
                return make_float3(0.0f, 0.0f, 0.0f);
 
 #ifdef __OBJECT_MOTION__
-       return make_float3(ccl_fetch(sd, ob_tfm).x.w, ccl_fetch(sd, ob_tfm).y.w, ccl_fetch(sd, ob_tfm).z.w);
+       return make_float3(sd->ob_tfm.x.w, sd->ob_tfm.y.w, sd->ob_tfm.z.w);
 #else
-       Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
+       Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
        return make_float3(tfm.x.w, tfm.y.w, tfm.z.w);
 #endif
 }
@@ -326,7 +326,7 @@ ccl_device_inline uint object_patch_map_offset(KernelGlobals *kg, int object)
 
 ccl_device int shader_pass_id(KernelGlobals *kg, const ShaderData *sd)
 {
-       return kernel_tex_fetch(__shader_flag, (ccl_fetch(sd, shader) & SHADER_MASK)*SHADER_SIZE + 1);
+       return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*SHADER_SIZE + 1);
 }
 
 /* Particle data from which object was instanced */
index 6a0ff5a4a04fa032a49c9ed078d76ed1ae455b09..5663b5985086b0d204d38a1505ce8e968d0639a2 100644 (file)
@@ -267,7 +267,7 @@ ccl_device float patch_eval_float(KernelGlobals *kg, const ShaderData *sd, int o
        float weights_du[PATCH_MAX_CONTROL_VERTS];
        float weights_dv[PATCH_MAX_CONTROL_VERTS];
 
-       int num_control = patch_eval_control_verts(kg, ccl_fetch(sd, object), patch, u, v, channel,
+       int num_control = patch_eval_control_verts(kg, sd->object, patch, u, v, channel,
                                                   indices, weights, weights_du, weights_dv);
 
        float val = 0.0f;
@@ -294,7 +294,7 @@ ccl_device float3 patch_eval_float3(KernelGlobals *kg, const ShaderData *sd, int
        float weights_du[PATCH_MAX_CONTROL_VERTS];
        float weights_dv[PATCH_MAX_CONTROL_VERTS];
 
-       int num_control = patch_eval_control_verts(kg, ccl_fetch(sd, object), patch, u, v, channel,
+       int num_control = patch_eval_control_verts(kg, sd->object, patch, u, v, channel,
                                                   indices, weights, weights_du, weights_dv);
 
        float3 val = make_float3(0.0f, 0.0f, 0.0f);
@@ -321,7 +321,7 @@ ccl_device float3 patch_eval_uchar4(KernelGlobals *kg, const ShaderData *sd, int
        float weights_du[PATCH_MAX_CONTROL_VERTS];
        float weights_dv[PATCH_MAX_CONTROL_VERTS];
 
-       int num_control = patch_eval_control_verts(kg, ccl_fetch(sd, object), patch, u, v, channel,
+       int num_control = patch_eval_control_verts(kg, sd->object, patch, u, v, channel,
                                                   indices, weights, weights_du, weights_dv);
 
        float3 val = make_float3(0.0f, 0.0f, 0.0f);
index 8a73bb2f78b1fbdaf807dfb6532e73a04b19ce71..90a9c2147cc7a6871067d9efdbd4e191c6bb6a0d 100644 (file)
@@ -28,19 +28,19 @@ ccl_device_inline float primitive_attribute_float(KernelGlobals *kg,
                                                   const AttributeDescriptor desc,
                                                   float *dx, float *dy)
 {
-       if(ccl_fetch(sd, type) & PRIMITIVE_ALL_TRIANGLE) {
+       if(sd->type & PRIMITIVE_ALL_TRIANGLE) {
                if(subd_triangle_patch(kg, sd) == ~0)
                        return triangle_attribute_float(kg, sd, desc, dx, dy);
                else
                        return subd_triangle_attribute_float(kg, sd, desc, dx, dy);
        }
 #ifdef __HAIR__
-       else if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
+       else if(sd->type & PRIMITIVE_ALL_CURVE) {
                return curve_attribute_float(kg, sd, desc, dx, dy);
        }
 #endif
 #ifdef __VOLUME__
-       else if(ccl_fetch(sd, object) != OBJECT_NONE && desc.element == ATTR_ELEMENT_VOXEL) {
+       else if(sd->object != OBJECT_NONE && desc.element == ATTR_ELEMENT_VOXEL) {
                return volume_attribute_float(kg, sd, desc, dx, dy);
        }
 #endif
@@ -56,19 +56,19 @@ ccl_device_inline float3 primitive_attribute_float3(KernelGlobals *kg,
                                                     const AttributeDescriptor desc,
                                                     float3 *dx, float3 *dy)
 {
-       if(ccl_fetch(sd, type) & PRIMITIVE_ALL_TRIANGLE) {
+       if(sd->type & PRIMITIVE_ALL_TRIANGLE) {
                if(subd_triangle_patch(kg, sd) == ~0)
                        return triangle_attribute_float3(kg, sd, desc, dx, dy);
                else
                        return subd_triangle_attribute_float3(kg, sd, desc, dx, dy);
        }
 #ifdef __HAIR__
-       else if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
+       else if(sd->type & PRIMITIVE_ALL_CURVE) {
                return curve_attribute_float3(kg, sd, desc, dx, dy);
        }
 #endif
 #ifdef __VOLUME__
-       else if(ccl_fetch(sd, object) != OBJECT_NONE && desc.element == ATTR_ELEMENT_VOXEL) {
+       else if(sd->object != OBJECT_NONE && desc.element == ATTR_ELEMENT_VOXEL) {
                return volume_attribute_float3(kg, sd, desc, dx, dy);
        }
 #endif
@@ -118,9 +118,9 @@ ccl_device bool primitive_ptex(KernelGlobals *kg, ShaderData *sd, float2 *uv, in
 ccl_device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd)
 {
 #ifdef __HAIR__
-       if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE)
+       if(sd->type & PRIMITIVE_ALL_CURVE)
 #  ifdef __DPDU__
-               return normalize(ccl_fetch(sd, dPdu));
+               return normalize(sd->dPdu);
 #  else
                return make_float3(0.0f, 0.0f, 0.0f);
 #  endif
@@ -133,12 +133,12 @@ ccl_device float3 primitive_tangent(KernelGlobals *kg, ShaderData *sd)
                float3 data = primitive_attribute_float3(kg, sd, desc, NULL, NULL);
                data = make_float3(-(data.y - 0.5f), (data.x - 0.5f), 0.0f);
                object_normal_transform(kg, sd, &data);
-               return cross(ccl_fetch(sd, N), normalize(cross(data, ccl_fetch(sd, N))));
+               return cross(sd->N, normalize(cross(data, sd->N)));
        }
        else {
                /* otherwise use surface derivatives */
 #ifdef __DPDU__
-               return normalize(ccl_fetch(sd, dPdu));
+               return normalize(sd->dPdu);
 #else
                return make_float3(0.0f, 0.0f, 0.0f);
 #endif
@@ -153,17 +153,17 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *
        float3 center;
 
 #ifdef __HAIR__
-       bool is_curve_primitive = ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE;
+       bool is_curve_primitive = sd->type & PRIMITIVE_ALL_CURVE;
        if(is_curve_primitive) {
                center = curve_motion_center_location(kg, sd);
 
-               if(!(ccl_fetch(sd, object_flag) & SD_OBJECT_TRANSFORM_APPLIED)) {
+               if(!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
                        object_position_transform(kg, sd, &center);
                }
        }
        else
 #endif
-               center = ccl_fetch(sd, P);
+               center = sd->P;
 
        float3 motion_pre = center, motion_post = center;
 
@@ -173,16 +173,16 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *
        if(desc.offset != ATTR_STD_NOT_FOUND) {
                /* get motion info */
                int numverts, numkeys;
-               object_motion_info(kg, ccl_fetch(sd, object), NULL, &numverts, &numkeys);
+               object_motion_info(kg, sd->object, NULL, &numverts, &numkeys);
 
                /* lookup attributes */
                motion_pre = primitive_attribute_float3(kg, sd, desc, NULL, NULL);
 
-               desc.offset += (ccl_fetch(sd, type) & PRIMITIVE_ALL_TRIANGLE)? numverts: numkeys;
+               desc.offset += (sd->type & PRIMITIVE_ALL_TRIANGLE)? numverts: numkeys;
                motion_post = primitive_attribute_float3(kg, sd, desc, NULL, NULL);
 
 #ifdef __HAIR__
-               if(is_curve_primitive && (ccl_fetch(sd, object_flag) & SD_OBJECT_HAS_VERTEX_MOTION) == 0) {
+               if(is_curve_primitive && (sd->object_flag & SD_OBJECT_HAS_VERTEX_MOTION) == 0) {
                        object_position_transform(kg, sd, &motion_pre);
                        object_position_transform(kg, sd, &motion_post);
                }
@@ -193,10 +193,10 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals *kg, ShaderData *
         * transformation was set match the world/object space of motion_pre/post */
        Transform tfm;
        
-       tfm = object_fetch_vector_transform(kg, ccl_fetch(sd, object), OBJECT_VECTOR_MOTION_PRE);
+       tfm = object_fetch_vector_transform(kg, sd->object, OBJECT_VECTOR_MOTION_PRE);
        motion_pre = transform_point(&tfm, motion_pre);
 
-       tfm = object_fetch_vector_transform(kg, ccl_fetch(sd, object), OBJECT_VECTOR_MOTION_POST);
+       tfm = object_fetch_vector_transform(kg, sd->object, OBJECT_VECTOR_MOTION_POST);
        motion_post = transform_point(&tfm, motion_post);
 
        float3 motion_center;
index 647840dc696924bff0859266791a567fa39f84b0..044e82f03d43c070c22258c36ef932516ef606ce 100644 (file)
@@ -22,14 +22,14 @@ CCL_NAMESPACE_BEGIN
 
 ccl_device_inline uint subd_triangle_patch(KernelGlobals *kg, const ShaderData *sd)
 {
-       return (ccl_fetch(sd, prim) != PRIM_NONE) ? kernel_tex_fetch(__tri_patch, ccl_fetch(sd, prim)) : ~0;
+       return (sd->prim != PRIM_NONE) ? kernel_tex_fetch(__tri_patch, sd->prim) : ~0;
 }
 
 /* UV coords of triangle within patch */
 
 ccl_device_inline void subd_triangle_patch_uv(KernelGlobals *kg, const ShaderData *sd, float2 uv[3])
 {
-       uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, ccl_fetch(sd, prim));
+       uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
 
        uv[0] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.x);
        uv[1] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.y);
@@ -110,7 +110,7 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals *kg, const
                float2 dpdv = uv[1] - uv[2];
 
                /* p is [s, t] */
-               float2 p = dpdu * ccl_fetch(sd, u) + dpdv * ccl_fetch(sd, v) + uv[2];
+               float2 p = dpdu * sd->u + dpdv * sd->v + uv[2];
 
                float a, dads, dadt;
                a = patch_eval_float(kg, sd, desc.offset, patch, p.x, p.y, 0, &dads, &dadt);
@@ -123,8 +123,8 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals *kg, const
                        float dtdv = dpdv.y;
 
                        if(dx) {
-                               float dudx = ccl_fetch(sd, du).dx;
-                               float dvdx = ccl_fetch(sd, dv).dx;
+                               float dudx = sd->du.dx;
+                               float dvdx = sd->dv.dx;
 
                                float dsdx = dsdu*dudx + dsdv*dvdx;
                                float dtdx = dtdu*dudx + dtdv*dvdx;
@@ -132,8 +132,8 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals *kg, const
                                *dx = dads*dsdx + dadt*dtdx;
                        }
                        if(dy) {
-                               float dudy = ccl_fetch(sd, du).dy;
-                               float dvdy = ccl_fetch(sd, dv).dy;
+                               float dudy = sd->du.dy;
+                               float dvdy = sd->dv.dy;
 
                                float dsdy = dsdu*dudy + dsdv*dvdy;
                                float dtdy = dtdu*dudy + dtdv*dvdy;
@@ -174,11 +174,11 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals *kg, const
                float c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*a + ccl_fetch(sd, dv).dx*b - (ccl_fetch(sd, du).dx + ccl_fetch(sd, dv).dx)*c;
-               if(dy) *dy = ccl_fetch(sd, du).dy*a + ccl_fetch(sd, dv).dy*b - (ccl_fetch(sd, du).dy + ccl_fetch(sd, dv).dy)*c;
+               if(dx) *dx = sd->du.dx*a + sd->dv.dx*b - (sd->du.dx + sd->dv.dx)*c;
+               if(dy) *dy = sd->du.dy*a + sd->dv.dy*b - (sd->du.dy + sd->dv.dy)*c;
 #endif
 
-               return ccl_fetch(sd, u)*a + ccl_fetch(sd, v)*b + (1.0f - ccl_fetch(sd, u) - ccl_fetch(sd, v))*c;
+               return sd->u*a + sd->v*b + (1.0f - sd->u - sd->v)*c;
        }
        else if(desc.element == ATTR_ELEMENT_CORNER) {
                float2 uv[3];
@@ -202,11 +202,11 @@ ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals *kg, const
                float c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*a + ccl_fetch(sd, dv).dx*b - (ccl_fetch(sd, du).dx + ccl_fetch(sd, dv).dx)*c;
-               if(dy) *dy = ccl_fetch(sd, du).dy*a + ccl_fetch(sd, dv).dy*b - (ccl_fetch(sd, du).dy + ccl_fetch(sd, dv).dy)*c;
+               if(dx) *dx = sd->du.dx*a + sd->dv.dx*b - (sd->du.dx + sd->dv.dx)*c;
+               if(dy) *dy = sd->du.dy*a + sd->dv.dy*b - (sd->du.dy + sd->dv.dy)*c;
 #endif
 
-               return ccl_fetch(sd, u)*a + ccl_fetch(sd, v)*b + (1.0f - ccl_fetch(sd, u) - ccl_fetch(sd, v))*c;
+               return sd->u*a + sd->v*b + (1.0f - sd->u - sd->v)*c;
        }
        else {
                if(dx) *dx = 0.0f;
@@ -229,7 +229,7 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con
                float2 dpdv = uv[1] - uv[2];
 
                /* p is [s, t] */
-               float2 p = dpdu * ccl_fetch(sd, u) + dpdv * ccl_fetch(sd, v) + uv[2];
+               float2 p = dpdu * sd->u + dpdv * sd->v + uv[2];
 
                float3 a, dads, dadt;
 
@@ -248,8 +248,8 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con
                        float dtdv = dpdv.y;
 
                        if(dx) {
-                               float dudx = ccl_fetch(sd, du).dx;
-                               float dvdx = ccl_fetch(sd, dv).dx;
+                               float dudx = sd->du.dx;
+                               float dvdx = sd->dv.dx;
 
                                float dsdx = dsdu*dudx + dsdv*dvdx;
                                float dtdx = dtdu*dudx + dtdv*dvdx;
@@ -257,8 +257,8 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con
                                *dx = dads*dsdx + dadt*dtdx;
                        }
                        if(dy) {
-                               float dudy = ccl_fetch(sd, du).dy;
-                               float dvdy = ccl_fetch(sd, dv).dy;
+                               float dudy = sd->du.dy;
+                               float dvdy = sd->dv.dy;
 
                                float dsdy = dsdu*dudy + dsdv*dvdy;
                                float dtdy = dtdu*dudy + dtdv*dvdy;
@@ -299,11 +299,11 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con
                float3 c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*a + ccl_fetch(sd, dv).dx*b - (ccl_fetch(sd, du).dx + ccl_fetch(sd, dv).dx)*c;
-               if(dy) *dy = ccl_fetch(sd, du).dy*a + ccl_fetch(sd, dv).dy*b - (ccl_fetch(sd, du).dy + ccl_fetch(sd, dv).dy)*c;
+               if(dx) *dx = sd->du.dx*a + sd->dv.dx*b - (sd->du.dx + sd->dv.dx)*c;
+               if(dy) *dy = sd->du.dy*a + sd->dv.dy*b - (sd->du.dy + sd->dv.dy)*c;
 #endif
 
-               return ccl_fetch(sd, u)*a + ccl_fetch(sd, v)*b + (1.0f - ccl_fetch(sd, u) - ccl_fetch(sd, v))*c;
+               return sd->u*a + sd->v*b + (1.0f - sd->u - sd->v)*c;
        }
        else if(desc.element == ATTR_ELEMENT_CORNER || desc.element == ATTR_ELEMENT_CORNER_BYTE) {
                float2 uv[3];
@@ -337,11 +337,11 @@ ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg, con
                float3 c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*a + ccl_fetch(sd, dv).dx*b - (ccl_fetch(sd, du).dx + ccl_fetch(sd, dv).dx)*c;
-               if(dy) *dy = ccl_fetch(sd, du).dy*a + ccl_fetch(sd, dv).dy*b - (ccl_fetch(sd, du).dy + ccl_fetch(sd, dv).dy)*c;
+               if(dx) *dx = sd->du.dx*a + sd->dv.dx*b - (sd->du.dx + sd->dv.dx)*c;
+               if(dy) *dy = sd->du.dy*a + sd->dv.dy*b - (sd->du.dy + sd->dv.dy)*c;
 #endif
 
-               return ccl_fetch(sd, u)*a + ccl_fetch(sd, v)*b + (1.0f - ccl_fetch(sd, u) - ccl_fetch(sd, v))*c;
+               return sd->u*a + sd->v*b + (1.0f - sd->u - sd->v)*c;
        }
        else {
                if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f);
index 3229091bbb05a030f0fced9c002e30ad5d3a217c..47778553b94438070e3ab159de1e29ff89d1cdfe 100644 (file)
@@ -26,13 +26,13 @@ CCL_NAMESPACE_BEGIN
 ccl_device_inline float3 triangle_normal(KernelGlobals *kg, ShaderData *sd)
 {
        /* load triangle vertices */
-       const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, ccl_fetch(sd, prim));
+       const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
        const float3 v0 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w+0));
        const float3 v1 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w+1));
        const float3 v2 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w+2));
 
        /* return normal */
-       if(ccl_fetch(sd, object_flag) & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
+       if(sd->object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
                return normalize(cross(v2 - v0, v1 - v0));
        }
        else {
@@ -110,34 +110,34 @@ ccl_device float triangle_attribute_float(KernelGlobals *kg, const ShaderData *s
                if(dx) *dx = 0.0f;
                if(dy) *dy = 0.0f;
 
-               return kernel_tex_fetch(__attributes_float, desc.offset + ccl_fetch(sd, prim));
+               return kernel_tex_fetch(__attributes_float, desc.offset + sd->prim);
        }
        else if(desc.element == ATTR_ELEMENT_VERTEX || desc.element == ATTR_ELEMENT_VERTEX_MOTION) {
-               uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, ccl_fetch(sd, prim));
+               uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
 
                float f0 = kernel_tex_fetch(__attributes_float, desc.offset + tri_vindex.x);
                float f1 = kernel_tex_fetch(__attributes_float, desc.offset + tri_vindex.y);
                float f2 = kernel_tex_fetch(__attributes_float, desc.offset + tri_vindex.z);
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*f0 + ccl_fetch(sd, dv).dx*f1 - (ccl_fetch(sd, du).dx + ccl_fetch(sd, dv).dx)*f2;
-               if(dy) *dy = ccl_fetch(sd, du).dy*f0 + ccl_fetch(sd, dv).dy*f1 - (ccl_fetch(sd, du).dy + ccl_fetch(sd, dv).dy)*f2;
+               if(dx) *dx = sd->du.dx*f0 + sd->dv.dx*f1 - (sd->du.dx + sd->dv.dx)*f2;
+               if(dy) *dy = sd->du.dy*f0 + sd->dv.dy*f1 - (sd->du.dy + sd->dv.dy)*f2;
 #endif
 
-               return ccl_fetch(sd, u)*f0 + ccl_fetch(sd, v)*f1 + (1.0f - ccl_fetch(sd, u) - ccl_fetch(sd, v))*f2;
+               return sd->u*f0 + sd->v*f1 + (1.0f - sd->u - sd->v)*f2;
        }
        else if(desc.element == ATTR_ELEMENT_CORNER) {
-               int tri = desc.offset + ccl_fetch(sd, prim)*3;
+               int tri = desc.offset + sd->prim*3;
                float f0 = kernel_tex_fetch(__attributes_float, tri + 0);
                float f1 = kernel_tex_fetch(__attributes_float, tri + 1);
                float f2 = kernel_tex_fetch(__attributes_float, tri + 2);
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*f0 + ccl_fetch(sd, dv).dx*f1 - (ccl_fetch(sd, du).dx + ccl_fetch(sd, dv).dx)*f2;
-               if(dy) *dy = ccl_fetch(sd, du).dy*f0 + ccl_fetch(sd, dv).dy*f1 - (ccl_fetch(sd, du).dy + ccl_fetch(sd, dv).dy)*f2;
+               if(dx) *dx = sd->du.dx*f0 + sd->dv.dx*f1 - (sd->du.dx + sd->dv.dx)*f2;
+               if(dy) *dy = sd->du.dy*f0 + sd->dv.dy*f1 - (sd->du.dy + sd->dv.dy)*f2;
 #endif
 
-               return ccl_fetch(sd, u)*f0 + ccl_fetch(sd, v)*f1 + (1.0f - ccl_fetch(sd, u) - ccl_fetch(sd, v))*f2;
+               return sd->u*f0 + sd->v*f1 + (1.0f - sd->u - sd->v)*f2;
        }
        else {
                if(dx) *dx = 0.0f;
@@ -153,24 +153,24 @@ ccl_device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData
                if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f);
                if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
 
-               return float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + ccl_fetch(sd, prim)));
+               return float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + sd->prim));
        }
        else if(desc.element == ATTR_ELEMENT_VERTEX || desc.element == ATTR_ELEMENT_VERTEX_MOTION) {
-               uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, ccl_fetch(sd, prim));
+               uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
 
                float3 f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + tri_vindex.x));
                float3 f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + tri_vindex.y));
                float3 f2 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + tri_vindex.z));
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*f0 + ccl_fetch(sd, dv).dx*f1 - (ccl_fetch(sd, du).dx + ccl_fetch(sd, dv).dx)*f2;
-               if(dy) *dy = ccl_fetch(sd, du).dy*f0 + ccl_fetch(sd, dv).dy*f1 - (ccl_fetch(sd, du).dy + ccl_fetch(sd, dv).dy)*f2;
+               if(dx) *dx = sd->du.dx*f0 + sd->dv.dx*f1 - (sd->du.dx + sd->dv.dx)*f2;
+               if(dy) *dy = sd->du.dy*f0 + sd->dv.dy*f1 - (sd->du.dy + sd->dv.dy)*f2;
 #endif
 
-               return ccl_fetch(sd, u)*f0 + ccl_fetch(sd, v)*f1 + (1.0f - ccl_fetch(sd, u) - ccl_fetch(sd, v))*f2;
+               return sd->u*f0 + sd->v*f1 + (1.0f - sd->u - sd->v)*f2;
        }
        else if(desc.element == ATTR_ELEMENT_CORNER || desc.element == ATTR_ELEMENT_CORNER_BYTE) {
-               int tri = desc.offset + ccl_fetch(sd, prim)*3;
+               int tri = desc.offset + sd->prim*3;
                float3 f0, f1, f2;
 
                if(desc.element == ATTR_ELEMENT_CORNER) {
@@ -185,11 +185,11 @@ ccl_device float3 triangle_attribute_float3(KernelGlobals *kg, const ShaderData
                }
 
 #ifdef __RAY_DIFFERENTIALS__
-               if(dx) *dx = ccl_fetch(sd, du).dx*f0 + ccl_fetch(sd, dv).dx*f1 - (ccl_fetch(sd, du).dx + ccl_fetch(sd, dv).dx)*f2;
-               if(dy) *dy = ccl_fetch(sd, du).dy*f0 + ccl_fetch(sd, dv).dy*f1 - (ccl_fetch(sd, du).dy + ccl_fetch(sd, dv).dy)*f2;
+               if(dx) *dx = sd->du.dx*f0 + sd->dv.dx*f1 - (sd->du.dx + sd->dv.dx)*f2;
+               if(dy) *dy = sd->du.dy*f0 + sd->dv.dy*f1 - (sd->du.dy + sd->dv.dy)*f2;
 #endif
 
-               return ccl_fetch(sd, u)*f0 + ccl_fetch(sd, v)*f1 + (1.0f - ccl_fetch(sd, u) - ccl_fetch(sd, v))*f2;
+               return sd->u*f0 + sd->v*f1 + (1.0f - sd->u - sd->v)*f2;
        }
        else {
                if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f);
index 4db121d94f41092a0729c3ebc1f1ec9805f3fb6c..4d234dd62bdef4bde4610a7e07698fcc5337d791 100644 (file)
@@ -457,7 +457,7 @@ ccl_device_inline float3 triangle_refine(KernelGlobals *kg,
                        return P;
                }
 #  ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_itfm);
+               Transform tfm = sd->ob_itfm;
 #  else
                Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
 #  endif
@@ -491,7 +491,7 @@ ccl_device_inline float3 triangle_refine(KernelGlobals *kg,
 
        if(isect->object != OBJECT_NONE) {
 #  ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_tfm);
+               Transform tfm = sd->ob_tfm;
 #  else
                Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
 #  endif
@@ -519,7 +519,7 @@ ccl_device_inline float3 triangle_refine_subsurface(KernelGlobals *kg,
 
        if(isect->object != OBJECT_NONE) {
 #ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_itfm);
+               Transform tfm = sd->ob_itfm;
 #else
                Transform tfm = object_fetch_transform(kg,
                                                       isect->object,
@@ -557,7 +557,7 @@ ccl_device_inline float3 triangle_refine_subsurface(KernelGlobals *kg,
 
        if(isect->object != OBJECT_NONE) {
 #ifdef __OBJECT_MOTION__
-               Transform tfm = ccl_fetch(sd, ob_tfm);
+               Transform tfm = sd->ob_tfm;
 #else
                Transform tfm = object_fetch_transform(kg,
                                                       isect->object,
index 03724c955beda09f884fb8d70691dae303f5e30d..1e0ef5201c92f724fbccb4353af36a8e955c0882 100644 (file)
@@ -64,7 +64,7 @@ ccl_device_inline float3 volume_normalized_position(KernelGlobals *kg,
 
 ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy)
 {
-       float3 P = volume_normalized_position(kg, sd, ccl_fetch(sd, P));
+       float3 P = volume_normalized_position(kg, sd, sd->P);
 #ifdef __KERNEL_CUDA__
 #  if __CUDA_ARCH__ >= 300
        CUtexObject tex = kernel_tex_fetch(__bindless_mapping, desc.offset);
@@ -91,7 +91,7 @@ ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd,
 
 ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float3 *dx, float3 *dy)
 {
-       float3 P = volume_normalized_position(kg, sd, ccl_fetch(sd, P));
+       float3 P = volume_normalized_position(kg, sd, sd->P);
 #ifdef __KERNEL_CUDA__
 #  if __CUDA_ARCH__ >= 300
        CUtexObject tex = kernel_tex_fetch(__bindless_mapping, desc.offset);
index dedac6b146508274cae22640de18f9fc5e1653d7..0df5217d97a3fecbe66572ebaf6c7c127ab32989 100644 (file)
@@ -457,7 +457,7 @@ ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd,
 {
        if(kernel_data.cam.type != CAMERA_PANORAMA) {
                /* perspective / ortho */
-               if(ccl_fetch(sd, object) == PRIM_NONE && kernel_data.cam.type == CAMERA_PERSPECTIVE)
+               if(sd->object == PRIM_NONE && kernel_data.cam.type == CAMERA_PERSPECTIVE)
                        P += camera_position(kg);
 
                Transform tfm = kernel_data.cam.worldtondc;
@@ -467,7 +467,7 @@ ccl_device_inline float3 camera_world_to_ndc(KernelGlobals *kg, ShaderData *sd,
                /* panorama */
                Transform tfm = kernel_data.cam.worldtocamera;
 
-               if(ccl_fetch(sd, object) != OBJECT_NONE)
+               if(sd->object != OBJECT_NONE)
                        P = normalize(transform_point(&tfm, P));
                else
                        P = normalize(transform_direction(&tfm, P));
index 8c7c651a053a1a9e7cfe75dbe39f46e9cdfc276b..bc2d96041220a565a0c2baa2c08f0ceef080f51c 100644 (file)
@@ -67,7 +67,7 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
                                         ls->shader, ls->object, ls->prim,
                                         ls->u, ls->v, t, time, false, ls->lamp);
 
-               ls->Ng = ccl_fetch(emission_sd, Ng);
+               ls->Ng = emission_sd->Ng;
 
                /* no path flag, we're evaluating this for all closures. that's weak but
                 * we'd have to do multiple evaluations otherwise */
@@ -76,7 +76,7 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
                path_state_modify_bounce(state, false);
 
                /* evaluate emissive closure */
-               if(ccl_fetch(emission_sd, flag) & SD_EMISSION)
+               if(emission_sd->flag & SD_EMISSION)
                        eval = shader_emissive_eval(kg, emission_sd);
                else
                        eval = make_float3(0.0f, 0.0f, 0.0f);
@@ -112,7 +112,7 @@ ccl_device_noinline bool direct_emission(KernelGlobals *kg,
                                                 -ls->D,
                                                 dD,
                                                 ls->t,
-                                                ccl_fetch(sd, time));
+                                                sd->time);
 
        if(is_zero(light_eval))
                return false;
@@ -120,7 +120,7 @@ ccl_device_noinline bool direct_emission(KernelGlobals *kg,
        /* evaluate BSDF at shading point */
 
 #ifdef __VOLUME__
-       if(ccl_fetch(sd, prim) != PRIM_NONE)
+       if(sd->prim != PRIM_NONE)
                shader_bsdf_eval(kg, sd, ls->D, eval, ls->pdf, ls->shader & SHADER_USE_MIS);
        else {
                float bsdf_pdf;
@@ -168,8 +168,8 @@ ccl_device_noinline bool direct_emission(KernelGlobals *kg,
 
        if(ls->shader & SHADER_CAST_SHADOW) {
                /* setup ray */
-               bool transmit = (dot(ccl_fetch(sd, Ng), ls->D) < 0.0f);
-               ray->P = ray_offset(ccl_fetch(sd, P), (transmit)? -ccl_fetch(sd, Ng): ccl_fetch(sd, Ng));
+               bool transmit = (dot(sd->Ng, ls->D) < 0.0f);
+               ray->P = ray_offset(sd->P, (transmit)? -sd->Ng: sd->Ng);
 
                if(ls->t == FLT_MAX) {
                        /* distant light */
@@ -182,7 +182,7 @@ ccl_device_noinline bool direct_emission(KernelGlobals *kg,
                        ray->D = normalize_len(ray->D, &ray->t);
                }
 
-               ray->dP = ccl_fetch(sd, dP);
+               ray->dP = sd->dP;
                ray->dD = differential3_zero();
        }
        else {
@@ -204,14 +204,14 @@ ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, Shader
        float3 L = shader_emissive_eval(kg, sd);
 
 #ifdef __HAIR__
-       if(!(path_flag & PATH_RAY_MIS_SKIP) && (ccl_fetch(sd, flag) & SD_USE_MIS) && (ccl_fetch(sd, type) & PRIMITIVE_ALL_TRIANGLE))
+       if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_USE_MIS) && (sd->type & PRIMITIVE_ALL_TRIANGLE))
 #else
-       if(!(path_flag & PATH_RAY_MIS_SKIP) && (ccl_fetch(sd, flag) & SD_USE_MIS))
+       if(!(path_flag & PATH_RAY_MIS_SKIP) && (sd->flag & SD_USE_MIS))
 #endif
        {
                /* multiple importance sampling, get triangle light pdf,
                 * and compute weight with respect to BSDF pdf */
-               float pdf = triangle_light_pdf(kg, ccl_fetch(sd, Ng), ccl_fetch(sd, I), t);
+               float pdf = triangle_light_pdf(kg, sd->Ng, sd->I, t);
                float mis_weight = power_heuristic(bsdf_pdf, pdf);
 
                return L*mis_weight;
index 7790cce067b68673a3832b616ed5f0770678c83b..ed52369657109a1e7b1fa3c0207252b938cc9ca5 100644 (file)
@@ -75,18 +75,18 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl
                return;
        
        if(!(path_flag & PATH_RAY_SINGLE_PASS_DONE)) {
-               if(!(ccl_fetch(sd, flag) & SD_TRANSPARENT) ||
+               if(!(sd->flag & SD_TRANSPARENT) ||
                   kernel_data.film.pass_alpha_threshold == 0.0f ||
                   average(shader_bsdf_alpha(kg, sd)) >= kernel_data.film.pass_alpha_threshold)
                {
 
                        if(sample == 0) {
                                if(flag & PASS_DEPTH) {
-                                       float depth = camera_distance(kg, ccl_fetch(sd, P));
+                                       float depth = camera_distance(kg, sd->P);
                                        kernel_write_pass_float(buffer + kernel_data.film.pass_depth, sample, depth);
                                }
                                if(flag & PASS_OBJECT_ID) {
-                                       float id = object_pass_id(kg, ccl_fetch(sd, object));
+                                       float id = object_pass_id(kg, sd->object);
                                        kernel_write_pass_float(buffer + kernel_data.film.pass_object_id, sample, id);
                                }
                                if(flag & PASS_MATERIAL_ID) {
@@ -96,7 +96,7 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl
                        }
 
                        if(flag & PASS_NORMAL) {
-                               float3 normal = ccl_fetch(sd, N);
+                               float3 normal = sd->N;
                                kernel_write_pass_float3(buffer + kernel_data.film.pass_normal, sample, normal);
                        }
                        if(flag & PASS_UV) {
@@ -127,7 +127,7 @@ ccl_device_inline void kernel_write_data_passes(KernelGlobals *kg, ccl_global fl
                float mist_start = kernel_data.film.mist_start;
                float mist_inv_depth = kernel_data.film.mist_inv_depth;
 
-               float depth = camera_distance(kg, ccl_fetch(sd, P));
+               float depth = camera_distance(kg, sd->P);
                float mist = saturate((depth - mist_start)*mist_inv_depth);
 
                /* falloff */
index f90701a8260b9b2a4e974f6bf7d0ce7fdacee667..95c27850513f5ce315bbcebbd1b6071cccdee360 100644 (file)
@@ -75,17 +75,17 @@ ccl_device_noinline void kernel_path_ao(KernelGlobals *kg,
 
        sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
 
-       if(dot(ccl_fetch(sd, Ng), ao_D) > 0.0f && ao_pdf != 0.0f) {
+       if(dot(sd->Ng, ao_D) > 0.0f && ao_pdf != 0.0f) {
                Ray light_ray;
                float3 ao_shadow;
 
-               light_ray.P = ray_offset(ccl_fetch(sd, P), ccl_fetch(sd, Ng));
+               light_ray.P = ray_offset(sd->P, sd->Ng);
                light_ray.D = ao_D;
                light_ray.t = kernel_data.background.ao_distance;
 #ifdef __OBJECT_MOTION__
-               light_ray.time = ccl_fetch(sd, time);
+               light_ray.time = sd->time;
 #endif  /* __OBJECT_MOTION__ */
-               light_ray.dP = ccl_fetch(sd, dP);
+               light_ray.dP = sd->dP;
                light_ray.dD = differential3_zero();
 
                if(!shadow_blocked(kg, emission_sd, state, &light_ray, &ao_shadow)) {
@@ -459,7 +459,7 @@ bool kernel_path_subsurface_scatter(
 #  ifdef __VOLUME__
                ss_indirect->need_update_volume_stack =
                        kernel_data.integrator.use_volumes &&
-                       ccl_fetch(sd, object_flag) & SD_OBJECT_INTERSECTS_VOLUME;
+                       sd->object_flag & SD_OBJECT_INTERSECTS_VOLUME;
 #  endif  /* __VOLUME__ */
 
                /* compute lighting with the BSDF closure */
index ff2b828795de8c64e848ec8eb500d9827226ae75..d58960cae4eb36c75c54d8f60ff7d58460be5f35 100644 (file)
@@ -42,17 +42,17 @@ ccl_device_inline void kernel_branched_path_ao(KernelGlobals *kg,
 
                sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
 
-               if(dot(ccl_fetch(sd, Ng), ao_D) > 0.0f && ao_pdf != 0.0f) {
+               if(dot(sd->Ng, ao_D) > 0.0f && ao_pdf != 0.0f) {
                        Ray light_ray;
                        float3 ao_shadow;
 
-                       light_ray.P = ray_offset(ccl_fetch(sd, P), ccl_fetch(sd, Ng));
+                       light_ray.P = ray_offset(sd->P, sd->Ng);
                        light_ray.D = ao_D;
                        light_ray.t = kernel_data.background.ao_distance;
 #ifdef __OBJECT_MOTION__
-                       light_ray.time = ccl_fetch(sd, time);
+                       light_ray.time = sd->time;
 #endif  /* __OBJECT_MOTION__ */
-                       light_ray.dP = ccl_fetch(sd, dP);
+                       light_ray.dP = sd->dP;
                        light_ray.dD = differential3_zero();
 
                        if(!shadow_blocked(kg, emission_sd, state, &light_ray, &ao_shadow))
@@ -67,8 +67,8 @@ ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGloba
        RNG *rng, ShaderData *sd, ShaderData *indirect_sd, ShaderData *emission_sd,
        float3 throughput, float num_samples_adjust, PathState *state, PathRadiance *L)
 {
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               const ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
+       for(int i = 0; i < sd->num_closure; i++) {
+               const ShaderClosure *sc = &sd->closure[i];
 
                if(!CLOSURE_IS_BSDF(sc->type))
                        continue;
@@ -140,8 +140,8 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
                                                         Ray *ray,
                                                         float3 throughput)
 {
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(!CLOSURE_IS_BSSRDF(sc->type))
                        continue;
@@ -169,7 +169,7 @@ ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
                        Ray volume_ray = *ray;
                        bool need_update_volume_stack =
                                kernel_data.integrator.use_volumes &&
-                               ccl_fetch(sd, object_flag) & SD_OBJECT_INTERSECTS_VOLUME;
+                               sd->object_flag & SD_OBJECT_INTERSECTS_VOLUME;
 #endif  /* __VOLUME__ */
 
                        /* compute lighting with the BSDF closure */
index fea503d06e5081a07ed3cbcd15875ea122233597..34a78552c1da8cea5f32ad26bbbc9047663886e4 100644 (file)
@@ -25,7 +25,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(KernelGlobal
 {
 #ifdef __EMISSION__
        /* sample illumination from lights to find path contribution */
-       if(!(ccl_fetch(sd, flag) & SD_BSDF_HAS_EVAL))
+       if(!(sd->flag & SD_BSDF_HAS_EVAL))
                return;
 
        Ray light_ray;
@@ -33,7 +33,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(KernelGlobal
        bool is_lamp;
 
 #  ifdef __OBJECT_MOTION__
-       light_ray.time = ccl_fetch(sd, time);
+       light_ray.time = sd->time;
 #  endif
 
        if(sample_all_lights) {
@@ -52,7 +52,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(KernelGlobal
                                float terminate = path_branched_rng_light_termination(kg, &lamp_rng, state, j, num_samples);
 
                                LightSample ls;
-                               if(lamp_light_sample(kg, i, light_u, light_v, ccl_fetch(sd, P), &ls)) {
+                               if(lamp_light_sample(kg, i, light_u, light_v, sd->P, &ls)) {
                                        /* The sampling probability returned by lamp_light_sample assumes that all lights were sampled.
                                         * However, this code only samples lamps, so if the scene also had mesh lights, the real probability is twice as high. */
                                        if(kernel_data.integrator.pdf_triangles != 0.0f)
@@ -87,7 +87,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(KernelGlobal
                                        light_t = 0.5f*light_t;
 
                                LightSample ls;
-                               if(light_sample(kg, light_t, light_u, light_v, ccl_fetch(sd, time), ccl_fetch(sd, P), state->bounce, &ls)) {
+                               if(light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
                                        /* Same as above, probability needs to be corrected since the sampling was forced to select a mesh light. */
                                        if(kernel_data.integrator.num_all_lights)
                                                ls.pdf *= 2.0f;
@@ -113,7 +113,7 @@ ccl_device_noinline void kernel_branched_path_surface_connect_light(KernelGlobal
                float terminate = path_state_rng_light_termination(kg, rng, state);
 
                LightSample ls;
-               if(light_sample(kg, light_t, light_u, light_v, ccl_fetch(sd, time), ccl_fetch(sd, P), state->bounce, &ls)) {
+               if(light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
                        /* sample random light */
                        if(direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
                                /* trace shadow ray */
@@ -156,15 +156,15 @@ ccl_device bool kernel_branched_path_surface_bounce(KernelGlobals *kg, RNG *rng,
        path_state_next(kg, state, label);
 
        /* setup ray */
-       ray->P = ray_offset(ccl_fetch(sd, P), (label & LABEL_TRANSMIT)? -ccl_fetch(sd, Ng): ccl_fetch(sd, Ng));
+       ray->P = ray_offset(sd->P, (label & LABEL_TRANSMIT)? -sd->Ng: sd->Ng);
        ray->D = normalize(bsdf_omega_in);
        ray->t = FLT_MAX;
 #ifdef __RAY_DIFFERENTIALS__
-       ray->dP = ccl_fetch(sd, dP);
+       ray->dP = sd->dP;
        ray->dD = bsdf_domega_in;
 #endif
 #ifdef __OBJECT_MOTION__
-       ray->time = ccl_fetch(sd, time);
+       ray->time = sd->time;
 #endif
 
 #ifdef __VOLUME__
@@ -195,7 +195,7 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg, ccl_
        PathRadiance *L)
 {
 #ifdef __EMISSION__
-       if(!(kernel_data.integrator.use_direct_light && (ccl_fetch(sd, flag) & SD_BSDF_HAS_EVAL)))
+       if(!(kernel_data.integrator.use_direct_light && (sd->flag & SD_BSDF_HAS_EVAL)))
                return;
 
        /* sample illumination from lights to find path contribution */
@@ -208,11 +208,11 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg, ccl_
        bool is_lamp;
 
 #ifdef __OBJECT_MOTION__
-       light_ray.time = ccl_fetch(sd, time);
+       light_ray.time = sd->time;
 #endif
 
        LightSample ls;
-       if(light_sample(kg, light_t, light_u, light_v, ccl_fetch(sd, time), ccl_fetch(sd, P), state->bounce, &ls)) {
+       if(light_sample(kg, light_t, light_u, light_v, sd->time, sd->P, state->bounce, &ls)) {
                float terminate = path_state_rng_light_termination(kg, rng, state);
                if(direct_emission(kg, sd, emission_sd, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
                        /* trace shadow ray */
@@ -238,7 +238,7 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
                                            ccl_addr_space Ray *ray)
 {
        /* no BSDF? we can stop here */
-       if(ccl_fetch(sd, flag) & SD_BSDF) {
+       if(sd->flag & SD_BSDF) {
                /* sample BSDF */
                float bsdf_pdf;
                BsdfEval bsdf_eval;
@@ -270,16 +270,16 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
                path_state_next(kg, state, label);
 
                /* setup ray */
-               ray->P = ray_offset(ccl_fetch(sd, P), (label & LABEL_TRANSMIT)? -ccl_fetch(sd, Ng): ccl_fetch(sd, Ng));
+               ray->P = ray_offset(sd->P, (label & LABEL_TRANSMIT)? -sd->Ng: sd->Ng);
                ray->D = normalize(bsdf_omega_in);
 
                if(state->bounce == 0)
-                       ray->t -= ccl_fetch(sd, ray_length); /* clipping works through transparent */
+                       ray->t -= sd->ray_length; /* clipping works through transparent */
                else
                        ray->t = FLT_MAX;
 
 #ifdef __RAY_DIFFERENTIALS__
-               ray->dP = ccl_fetch(sd, dP);
+               ray->dP = sd->dP;
                ray->dD = bsdf_domega_in;
 #endif
 
@@ -291,21 +291,21 @@ ccl_device bool kernel_path_surface_bounce(KernelGlobals *kg,
                return true;
        }
 #ifdef __VOLUME__
-       else if(ccl_fetch(sd, flag) & SD_HAS_ONLY_VOLUME) {
+       else if(sd->flag & SD_HAS_ONLY_VOLUME) {
                /* no surface shader but have a volume shader? act transparent */
 
                /* update path state, count as transparent */
                path_state_next(kg, state, LABEL_TRANSPARENT);
 
                if(state->bounce == 0)
-                       ray->t -= ccl_fetch(sd, ray_length); /* clipping works through transparent */
+                       ray->t -= sd->ray_length; /* clipping works through transparent */
                else
                        ray->t = FLT_MAX;
 
                /* setup ray position, direction stays unchanged */
-               ray->P = ray_offset(ccl_fetch(sd, P), -ccl_fetch(sd, Ng));
+               ray->P = ray_offset(sd->P, -sd->Ng);
 #ifdef __RAY_DIFFERENTIALS__
-               ray->dP = ccl_fetch(sd, dP);
+               ray->dP = sd->dP;
 #endif
 
                /* enter/exit volume */
index 59c1331a63ca64f2f7fde502484258dad1c0b6a0..a2ab96b35e23206904b23b1cd50837143ef78285 100644 (file)
@@ -38,13 +38,13 @@ CCL_NAMESPACE_BEGIN
 #ifdef __OBJECT_MOTION__
 ccl_device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, float time)
 {
-       if(ccl_fetch(sd, object_flag) & SD_OBJECT_MOTION) {
-               ccl_fetch(sd, ob_tfm) = object_fetch_transform_motion(kg, ccl_fetch(sd, object), time);
-               ccl_fetch(sd, ob_itfm) = transform_quick_inverse(ccl_fetch(sd, ob_tfm));
+       if(sd->object_flag & SD_OBJECT_MOTION) {
+               sd->ob_tfm = object_fetch_transform_motion(kg, sd->object, time);
+               sd->ob_itfm = transform_quick_inverse(sd->ob_tfm);
        }
        else {
-               ccl_fetch(sd, ob_tfm) = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
-               ccl_fetch(sd, ob_itfm) = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
+               sd->ob_tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
+               sd->ob_itfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
        }
 }
 #endif
@@ -55,55 +55,55 @@ ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg,
                                                const Ray *ray)
 {
 #ifdef __INSTANCING__
-       ccl_fetch(sd, object) = (isect->object == PRIM_NONE)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
+       sd->object = (isect->object == PRIM_NONE)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
 #endif
 
-       ccl_fetch(sd, type) = isect->type;
-       ccl_fetch(sd, flag) = 0;
-       ccl_fetch(sd, object_flag) = kernel_tex_fetch(__object_flag,
-                                                     ccl_fetch(sd, object));
+       sd->type = isect->type;
+       sd->flag = 0;
+       sd->object_flag = kernel_tex_fetch(__object_flag,
+                                                     sd->object);
 
        /* matrices and time */
 #ifdef __OBJECT_MOTION__
        shader_setup_object_transforms(kg, sd, ray->time);
-       ccl_fetch(sd, time) = ray->time;
+       sd->time = ray->time;
 #endif
 
-       ccl_fetch(sd, prim) = kernel_tex_fetch(__prim_index, isect->prim);
-       ccl_fetch(sd, ray_length) = isect->t;
+       sd->prim = kernel_tex_fetch(__prim_index, isect->prim);
+       sd->ray_length = isect->t;
 
 #ifdef __UV__
-       ccl_fetch(sd, u) = isect->u;
-       ccl_fetch(sd, v) = isect->v;
+       sd->u = isect->u;
+       sd->v = isect->v;
 #endif
 
 #ifdef __HAIR__
-       if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
+       if(sd->type & PRIMITIVE_ALL_CURVE) {
                /* curve */
-               float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
+               float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
 
-               ccl_fetch(sd, shader) = __float_as_int(curvedata.z);
-               ccl_fetch(sd, P) = bvh_curve_refine(kg, sd, isect, ray);
+               sd->shader = __float_as_int(curvedata.z);
+               sd->P = bvh_curve_refine(kg, sd, isect, ray);
        }
        else
 #endif
-       if(ccl_fetch(sd, type) & PRIMITIVE_TRIANGLE) {
+       if(sd->type & PRIMITIVE_TRIANGLE) {
                /* static triangle */
                float3 Ng = triangle_normal(kg, sd);
-               ccl_fetch(sd, shader) = kernel_tex_fetch(__tri_shader, ccl_fetch(sd, prim));
+               sd->shader = kernel_tex_fetch(__tri_shader, sd->prim);
 
                /* vectors */
-               ccl_fetch(sd, P) = triangle_refine(kg, sd, isect, ray);
-               ccl_fetch(sd, Ng) = Ng;
-               ccl_fetch(sd, N) = Ng;
+               sd->P = triangle_refine(kg, sd, isect, ray);
+               sd->Ng = Ng;
+               sd->N = Ng;
                
                /* smooth normal */
-               if(ccl_fetch(sd, shader) & SHADER_SMOOTH_NORMAL)
-                       ccl_fetch(sd, N) = triangle_smooth_normal(kg, ccl_fetch(sd, prim), ccl_fetch(sd, u), ccl_fetch(sd, v));
+               if(sd->shader & SHADER_SMOOTH_NORMAL)
+                       sd->N = triangle_smooth_normal(kg, sd->prim, sd->u, sd->v);
 
 #ifdef __DPDU__
                /* dPdu/dPdv */
-               triangle_dPdudv(kg, ccl_fetch(sd, prim), &ccl_fetch(sd, dPdu), &ccl_fetch(sd, dPdv));
+               triangle_dPdudv(kg, sd->prim, &sd->dPdu, &sd->dPdv);
 #endif
        }
        else {
@@ -111,40 +111,40 @@ ccl_device_noinline void shader_setup_from_ray(KernelGlobals *kg,
                motion_triangle_shader_setup(kg, sd, isect, ray, false);
        }
 
-       ccl_fetch(sd, I) = -ray->D;
+       sd->I = -ray->D;
 
-       ccl_fetch(sd, flag) |= kernel_tex_fetch(__shader_flag, (ccl_fetch(sd, shader) & SHADER_MASK)*SHADER_SIZE);
+       sd->flag |= kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*SHADER_SIZE);
 
 #ifdef __INSTANCING__
        if(isect->object != OBJECT_NONE) {
                /* instance transform */
-               object_normal_transform_auto(kg, sd, &ccl_fetch(sd, N));
-               object_normal_transform_auto(kg, sd, &ccl_fetch(sd, Ng));
+               object_normal_transform_auto(kg, sd, &sd->N);
+               object_normal_transform_auto(kg, sd, &sd->Ng);
 #  ifdef __DPDU__
-               object_dir_transform_auto(kg, sd, &ccl_fetch(sd, dPdu));
-               object_dir_transform_auto(kg, sd, &ccl_fetch(sd, dPdv));
+               object_dir_transform_auto(kg, sd, &sd->dPdu);
+               object_dir_transform_auto(kg, sd, &sd->dPdv);
 #  endif
        }
 #endif
 
        /* backfacing test */
-       bool backfacing = (dot(ccl_fetch(sd, Ng), ccl_fetch(sd, I)) < 0.0f);
+       bool backfacing = (dot(sd->Ng, sd->I) < 0.0f);
 
        if(backfacing) {
-               ccl_fetch(sd, flag) |= SD_BACKFACING;
-               ccl_fetch(sd, Ng) = -ccl_fetch(sd, Ng);
-               ccl_fetch(sd, N) = -ccl_fetch(sd, N);
+               sd->flag |= SD_BACKFACING;
+               sd->Ng = -sd->Ng;
+               sd->N = -sd->N;
 #ifdef __DPDU__
-               ccl_fetch(sd, dPdu) = -ccl_fetch(sd, dPdu);
-               ccl_fetch(sd, dPdv) = -ccl_fetch(sd, dPdv);
+               sd->dPdu = -sd->dPdu;
+               sd->dPdv = -sd->dPdv;
 #endif
        }
 
 #ifdef __RAY_DIFFERENTIALS__
        /* differentials */
-       differential_transfer(&ccl_fetch(sd, dP), ray->dP, ray->D, ray->dD, ccl_fetch(sd, Ng), isect->t);
-       differential_incoming(&ccl_fetch(sd, dI), ray->dD);
-       differential_dudv(&ccl_fetch(sd, du), &ccl_fetch(sd, dv), ccl_fetch(sd, dPdu), ccl_fetch(sd, dPdv), ccl_fetch(sd, dP), ccl_fetch(sd, Ng));
+       differential_transfer(&sd->dP, ray->dP, ray->D, ray->dD, sd->Ng, isect->t);
+       differential_incoming(&sd->dI, ray->dD);
+       differential_dudv(&sd->du, &sd->dv, sd->dPdu, sd->dPdv, sd->dP, sd->Ng);
 #endif
 }
 
@@ -249,106 +249,106 @@ ccl_device_inline void shader_setup_from_sample(KernelGlobals *kg,
                                                 int lamp)
 {
        /* vectors */
-       ccl_fetch(sd, P) = P;
-       ccl_fetch(sd, N) = Ng;
-       ccl_fetch(sd, Ng) = Ng;
-       ccl_fetch(sd, I) = I;
-       ccl_fetch(sd, shader) = shader;
+       sd->P = P;
+       sd->N = Ng;
+       sd->Ng = Ng;
+       sd->I = I;
+       sd->shader = shader;
        if(prim != PRIM_NONE)
-               ccl_fetch(sd, type) = PRIMITIVE_TRIANGLE;
+               sd->type = PRIMITIVE_TRIANGLE;
        else if(lamp != LAMP_NONE)
-               ccl_fetch(sd, type) = PRIMITIVE_LAMP;
+               sd->type = PRIMITIVE_LAMP;
        else
-               ccl_fetch(sd, type) = PRIMITIVE_NONE;
+               sd->type = PRIMITIVE_NONE;
 
        /* primitive */
 #ifdef __INSTANCING__
-       ccl_fetch(sd, object) = object;
+       sd->object = object;
 #endif
        /* currently no access to bvh prim index for strand sd->prim*/
-       ccl_fetch(sd, prim) = prim;
+       sd->prim = prim;
 #ifdef __UV__
-       ccl_fetch(sd, u) = u;
-       ccl_fetch(sd, v) = v;
+       sd->u = u;
+       sd->v = v;
 #endif
-       ccl_fetch(sd, ray_length) = t;
+       sd->ray_length = t;
 
-       ccl_fetch(sd, flag) = kernel_tex_fetch(__shader_flag, (ccl_fetch(sd, shader) & SHADER_MASK)*SHADER_SIZE);
-       ccl_fetch(sd, object_flag) = 0;
-       if(ccl_fetch(sd, object) != OBJECT_NONE) {
-               ccl_fetch(sd, object_flag) |= kernel_tex_fetch(__object_flag,
-                                                              ccl_fetch(sd, object));
+       sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*SHADER_SIZE);
+       sd->object_flag = 0;
+       if(sd->object != OBJECT_NONE) {
+               sd->object_flag |= kernel_tex_fetch(__object_flag,
+                                                              sd->object);
 
 #ifdef __OBJECT_MOTION__
                shader_setup_object_transforms(kg, sd, time);
-               ccl_fetch(sd, time) = time;
+               sd->time = time;
        }
        else if(lamp != LAMP_NONE) {
-               ccl_fetch(sd, ob_tfm)  = lamp_fetch_transform(kg, lamp, false);
-               ccl_fetch(sd, ob_itfm) = lamp_fetch_transform(kg, lamp, true);
+               sd->ob_tfm  = lamp_fetch_transform(kg, lamp, false);
+               sd->ob_itfm = lamp_fetch_transform(kg, lamp, true);
 #endif
        }
 
        /* transform into world space */
        if(object_space) {
-               object_position_transform_auto(kg, sd, &ccl_fetch(sd, P));
-               object_normal_transform_auto(kg, sd, &ccl_fetch(sd, Ng));
-               ccl_fetch(sd, N) = ccl_fetch(sd, Ng);
-               object_dir_transform_auto(kg, sd, &ccl_fetch(sd, I));
+               object_position_transform_auto(kg, sd, &sd->P);
+               object_normal_transform_auto(kg, sd, &sd->Ng);
+               sd->N = sd->Ng;
+               object_dir_transform_auto(kg, sd, &sd->I);
        }
 
-       if(ccl_fetch(sd, type) & PRIMITIVE_TRIANGLE) {
+       if(sd->type & PRIMITIVE_TRIANGLE) {
                /* smooth normal */
-               if(ccl_fetch(sd, shader) & SHADER_SMOOTH_NORMAL) {
-                       ccl_fetch(sd, N) = triangle_smooth_normal(kg, ccl_fetch(sd, prim), ccl_fetch(sd, u), ccl_fetch(sd, v));
+               if(sd->shader & SHADER_SMOOTH_NORMAL) {
+                       sd->N = triangle_smooth_normal(kg, sd->prim, sd->u, sd->v);
 
 #ifdef __INSTANCING__
-                       if(!(ccl_fetch(sd, object_flag) & SD_OBJECT_TRANSFORM_APPLIED)) {
-                               object_normal_transform_auto(kg, sd, &ccl_fetch(sd, N));
+                       if(!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
+                               object_normal_transform_auto(kg, sd, &sd->N);
                        }
 #endif
                }
 
                /* dPdu/dPdv */
 #ifdef __DPDU__
-               triangle_dPdudv(kg, ccl_fetch(sd, prim), &ccl_fetch(sd, dPdu), &ccl_fetch(sd, dPdv));
+               triangle_dPdudv(kg, sd->prim, &sd->dPdu, &sd->dPdv);
 
 #  ifdef __INSTANCING__
-               if(!(ccl_fetch(sd, object_flag) & SD_OBJECT_TRANSFORM_APPLIED)) {
-                       object_dir_transform_auto(kg, sd, &ccl_fetch(sd, dPdu));
-                       object_dir_transform_auto(kg, sd, &ccl_fetch(sd, dPdv));
+               if(!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
+                       object_dir_transform_auto(kg, sd, &sd->dPdu);
+                       object_dir_transform_auto(kg, sd, &sd->dPdv);
                }
 #  endif
 #endif
        }
        else {
 #ifdef __DPDU__
-               ccl_fetch(sd, dPdu) = make_float3(0.0f, 0.0f, 0.0f);
-               ccl_fetch(sd, dPdv) = make_float3(0.0f, 0.0f, 0.0f);
+               sd->dPdu = make_float3(0.0f, 0.0f, 0.0f);
+               sd->dPdv = make_float3(0.0f, 0.0f, 0.0f);
 #endif
        }
 
        /* backfacing test */
-       if(ccl_fetch(sd, prim) != PRIM_NONE) {
-               bool backfacing = (dot(ccl_fetch(sd, Ng), ccl_fetch(sd, I)) < 0.0f);
+       if(sd->prim != PRIM_NONE) {
+               bool backfacing = (dot(sd->Ng, sd->I) < 0.0f);
 
                if(backfacing) {
-                       ccl_fetch(sd, flag) |= SD_BACKFACING;
-                       ccl_fetch(sd, Ng) = -ccl_fetch(sd, Ng);
-                       ccl_fetch(sd, N) = -ccl_fetch(sd, N);
+                       sd->flag |= SD_BACKFACING;
+                       sd->Ng = -sd->Ng;
+                       sd->N = -sd->N;
 #ifdef __DPDU__
-                       ccl_fetch(sd, dPdu) = -ccl_fetch(sd, dPdu);
-                       ccl_fetch(sd, dPdv) = -ccl_fetch(sd, dPdv);
+                       sd->dPdu = -sd->dPdu;
+                       sd->dPdv = -sd->dPdv;
 #endif
                }
        }
 
 #ifdef __RAY_DIFFERENTIALS__
        /* no ray differentials here yet */
-       ccl_fetch(sd, dP) = differential3_zero();
-       ccl_fetch(sd, dI) = differential3_zero();
-       ccl_fetch(sd, du) = differential_zero();
-       ccl_fetch(sd, dv) = differential_zero();
+       sd->dP = differential3_zero();
+       sd->dI = differential3_zero();
+       sd->du = differential_zero();
+       sd->dv = differential_zero();
 #endif
 }
 
@@ -378,39 +378,39 @@ ccl_device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
 ccl_device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray)
 {
        /* vectors */
-       ccl_fetch(sd, P) = ray->D;
-       ccl_fetch(sd, N) = -ray->D;
-       ccl_fetch(sd, Ng) = -ray->D;
-       ccl_fetch(sd, I) = -ray->D;
-       ccl_fetch(sd, shader) = kernel_data.background.surface_shader;
-       ccl_fetch(sd, flag) = kernel_tex_fetch(__shader_flag, (ccl_fetch(sd, shader) & SHADER_MASK)*SHADER_SIZE);
-       ccl_fetch(sd, object_flag) = 0;
+       sd->P = ray->D;
+       sd->N = -ray->D;
+       sd->Ng = -ray->D;
+       sd->I = -ray->D;
+       sd->shader = kernel_data.background.surface_shader;
+       sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*SHADER_SIZE);
+       sd->object_flag = 0;
 #ifdef __OBJECT_MOTION__
-       ccl_fetch(sd, time) = ray->time;
+       sd->time = ray->time;
 #endif
-       ccl_fetch(sd, ray_length) = 0.0f;
+       sd->ray_length = 0.0f;
 
 #ifdef __INSTANCING__
-       ccl_fetch(sd, object) = PRIM_NONE;
+       sd->object = PRIM_NONE;
 #endif
-       ccl_fetch(sd, prim) = PRIM_NONE;
+       sd->prim = PRIM_NONE;
 #ifdef __UV__
-       ccl_fetch(sd, u) = 0.0f;
-       ccl_fetch(sd, v) = 0.0f;
+       sd->u = 0.0f;
+       sd->v = 0.0f;
 #endif
 
 #ifdef __DPDU__
        /* dPdu/dPdv */
-       ccl_fetch(sd, dPdu) = make_float3(0.0f, 0.0f, 0.0f);
-       ccl_fetch(sd, dPdv) = make_float3(0.0f, 0.0f, 0.0f);
+       sd->dPdu = make_float3(0.0f, 0.0f, 0.0f);
+       sd->dPdv = make_float3(0.0f, 0.0f, 0.0f);
 #endif
 
 #ifdef __RAY_DIFFERENTIALS__
        /* differentials */
-       ccl_fetch(sd, dP) = ray->dD;
-       differential_incoming(&ccl_fetch(sd, dI), ccl_fetch(sd, dP));
-       ccl_fetch(sd, du) = differential_zero();
-       ccl_fetch(sd, dv) = differential_zero();
+       sd->dP = ray->dD;
+       differential_incoming(&sd->dI, sd->dP);
+       sd->du = differential_zero();
+       sd->dv = differential_zero();
 #endif
 }
 
@@ -505,11 +505,11 @@ ccl_device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, ShaderData *sd
 {
        /* this is the veach one-sample model with balance heuristic, some pdf
         * factors drop out when using balance heuristic weighting */
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
+       for(int i = 0; i < sd->num_closure; i++) {
                if(i == skip_bsdf)
                        continue;
 
-               const ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+               const ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_BSDF(sc->type)) {
                        float bsdf_pdf = 0.0f;
@@ -535,8 +535,8 @@ ccl_device_inline void _shader_bsdf_multi_eval_branched(KernelGlobals *kg,
                                                         float light_pdf,
                                                         bool use_mis)
 {
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               const ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               const ShaderClosure *sc = &sd->closure[i];
                if(CLOSURE_IS_BSDF(sc->type)) {
                        float bsdf_pdf = 0.0f;
                        float3 eval = bsdf_eval(kg, sd, sc, omega_in, &bsdf_pdf);
@@ -591,22 +591,22 @@ ccl_device_inline int shader_bsdf_sample(KernelGlobals *kg,
 {
        int sampled = 0;
 
-       if(ccl_fetch(sd, num_closure) > 1) {
+       if(sd->num_closure > 1) {
                /* pick a BSDF closure based on sample weights */
                float sum = 0.0f;
 
-               for(sampled = 0; sampled < ccl_fetch(sd, num_closure); sampled++) {
-                       const ShaderClosure *sc = ccl_fetch_array(sd, closure, sampled);
+               for(sampled = 0; sampled < sd->num_closure; sampled++) {
+                       const ShaderClosure *sc = &sd->closure[sampled];
                        
                        if(CLOSURE_IS_BSDF(sc->type))
                                sum += sc->sample_weight;
                }
 
-               float r = ccl_fetch(sd, randb_closure)*sum;
+               float r = sd->randb_closure*sum;
                sum = 0.0f;
 
-               for(sampled = 0; sampled < ccl_fetch(sd, num_closure); sampled++) {
-                       const ShaderClosure *sc = ccl_fetch_array(sd, closure, sampled);
+               for(sampled = 0; sampled < sd->num_closure; sampled++) {
+                       const ShaderClosure *sc = &sd->closure[sampled];
                        
                        if(CLOSURE_IS_BSDF(sc->type)) {
                                sum += sc->sample_weight;
@@ -616,13 +616,13 @@ ccl_device_inline int shader_bsdf_sample(KernelGlobals *kg,
                        }
                }
 
-               if(sampled == ccl_fetch(sd, num_closure)) {
+               if(sampled == sd->num_closure) {
                        *pdf = 0.0f;
                        return LABEL_NONE;
                }
        }
 
-       const ShaderClosure *sc = ccl_fetch_array(sd, closure, sampled);
+       const ShaderClosure *sc = &sd->closure[sampled];
 
        int label;
        float3 eval;
@@ -633,7 +633,7 @@ ccl_device_inline int shader_bsdf_sample(KernelGlobals *kg,
        if(*pdf != 0.0f) {
                bsdf_eval_init(bsdf_eval, sc->type, eval*sc->weight, kernel_data.film.use_light_pass);
 
-               if(ccl_fetch(sd, num_closure) > 1) {
+               if(sd->num_closure > 1) {
                        float sweight = sc->sample_weight;
                        _shader_bsdf_multi_eval(kg, sd, *omega_in, pdf, sampled, bsdf_eval, *pdf*sweight, sweight);
                }
@@ -660,8 +660,8 @@ ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, ShaderData *sd,
 
 ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness)
 {
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_BSDF(sc->type))
                        bsdf_blur(kg, sc, roughness);
@@ -670,13 +670,13 @@ ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughn
 
 ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
 {
-       if(ccl_fetch(sd, flag) & SD_HAS_ONLY_VOLUME)
+       if(sd->flag & SD_HAS_ONLY_VOLUME)
                return make_float3(1.0f, 1.0f, 1.0f);
 
        float3 eval = make_float3(0.0f, 0.0f, 0.0f);
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID) // todo: make this work for osl
                        eval += sc->weight;
@@ -687,8 +687,8 @@ ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
 
 ccl_device void shader_bsdf_disable_transparency(KernelGlobals *kg, ShaderData *sd)
 {
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID) {
                        sc->sample_weight = 0.0f;
@@ -711,8 +711,8 @@ ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
 {
        float3 eval = make_float3(0.0f, 0.0f, 0.0f);
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
                        eval += sc->weight;
@@ -725,8 +725,8 @@ ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
 {
        float3 eval = make_float3(0.0f, 0.0f, 0.0f);
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
                        eval += sc->weight;
@@ -739,8 +739,8 @@ ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
 {
        float3 eval = make_float3(0.0f, 0.0f, 0.0f);
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_BSDF_TRANSMISSION(sc->type))
                        eval += sc->weight;
@@ -753,8 +753,8 @@ ccl_device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
 {
        float3 eval = make_float3(0.0f, 0.0f, 0.0f);
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_BSSRDF(sc->type) || CLOSURE_IS_BSDF_BSSRDF(sc->type))
                        eval += sc->weight;
@@ -768,8 +768,8 @@ ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_fac
        float3 eval = make_float3(0.0f, 0.0f, 0.0f);
        float3 N = make_float3(0.0f, 0.0f, 0.0f);
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
                        const DiffuseBsdf *bsdf = (const DiffuseBsdf*)sc;
@@ -778,12 +778,12 @@ ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_fac
                }
                else if(CLOSURE_IS_AMBIENT_OCCLUSION(sc->type)) {
                        eval += sc->weight;
-                       N += ccl_fetch(sd, N)*average(sc->weight);
+                       N += sd->N*average(sc->weight);
                }
        }
 
        if(is_zero(N))
-               N = ccl_fetch(sd, N);
+               N = sd->N;
        else
                N = normalize(N);
 
@@ -798,8 +798,8 @@ ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_b
        float3 N = make_float3(0.0f, 0.0f, 0.0f);
        float texture_blur = 0.0f, weight_sum = 0.0f;
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_BSSRDF(sc->type)) {
                        const Bssrdf *bssrdf = (const Bssrdf*)sc;
@@ -813,7 +813,7 @@ ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_b
        }
 
        if(N_)
-               *N_ = (is_zero(N))? ccl_fetch(sd, N): normalize(N);
+               *N_ = (is_zero(N))? sd->N: normalize(N);
 
        if(texture_blur_)
                *texture_blur_ = texture_blur/weight_sum;
@@ -826,7 +826,7 @@ ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_b
 
 ccl_device float3 emissive_eval(KernelGlobals *kg, ShaderData *sd, ShaderClosure *sc)
 {
-       return emissive_simple_eval(ccl_fetch(sd, Ng), ccl_fetch(sd, I));
+       return emissive_simple_eval(sd->Ng, sd->I);
 }
 
 ccl_device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
@@ -834,8 +834,8 @@ ccl_device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
        float3 eval;
        eval = make_float3(0.0f, 0.0f, 0.0f);
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_EMISSION(sc->type))
                        eval += emissive_eval(kg, sd, sc)*sc->weight;
@@ -850,8 +850,8 @@ ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
 {
        float3 weight = make_float3(0.0f, 0.0f, 0.0f);
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_HOLDOUT(sc->type))
                        weight += sc->weight;
@@ -865,9 +865,9 @@ ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
 ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, ccl_addr_space RNG *rng,
        ccl_addr_space PathState *state, float randb, int path_flag, ShaderContext ctx)
 {
-       ccl_fetch(sd, num_closure) = 0;
-       ccl_fetch(sd, num_closure_extra) = 0;
-       ccl_fetch(sd, randb_closure) = randb;
+       sd->num_closure = 0;
+       sd->num_closure_extra = 0;
+       sd->randb_closure = randb;
 
 #ifdef __OSL__
        if(kg->osl)
@@ -881,13 +881,13 @@ ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, ccl_addr_
                DiffuseBsdf *bsdf = (DiffuseBsdf*)bsdf_alloc(sd,
                                                             sizeof(DiffuseBsdf),
                                                             make_float3(0.8f, 0.8f, 0.8f));
-               bsdf->N = ccl_fetch(sd, N);
-               ccl_fetch(sd, flag) |= bsdf_diffuse_setup(bsdf);
+               bsdf->N = sd->N;
+               sd->flag |= bsdf_diffuse_setup(bsdf);
 #endif
        }
 
-       if(rng && (ccl_fetch(sd, flag) & SD_BSDF_NEEDS_LCG)) {
-               ccl_fetch(sd, lcg_state) = lcg_state_init_addrspace(rng, state, 0xb4bc3953);
+       if(rng && (sd->flag & SD_BSDF_NEEDS_LCG)) {
+               sd->lcg_state = lcg_state_init_addrspace(rng, state, 0xb4bc3953);
        }
 }
 
@@ -896,9 +896,9 @@ ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, ccl_addr_
 ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd,
        ccl_addr_space PathState *state, int path_flag, ShaderContext ctx)
 {
-       ccl_fetch(sd, num_closure) = 0;
-       ccl_fetch(sd, num_closure_extra) = 0;
-       ccl_fetch(sd, randb_closure) = 0.0f;
+       sd->num_closure = 0;
+       sd->num_closure_extra = 0;
+       sd->randb_closure = 0.0f;
 
 #ifdef __SVM__
 #ifdef __OSL__
@@ -913,8 +913,8 @@ ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd,
 
        float3 eval = make_float3(0.0f, 0.0f, 0.0f);
 
-       for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
-               const ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
+       for(int i = 0; i < sd->num_closure; i++) {
+               const ShaderClosure *sc = &sd->closure[i];
 
                if(CLOSURE_IS_BACKGROUND(sc->type))
                        eval += sc->weight;
@@ -1093,9 +1093,9 @@ ccl_device_inline void shader_eval_volume(KernelGlobals *kg,
 
 ccl_device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd, ccl_addr_space PathState *state, ShaderContext ctx)
 {
-       ccl_fetch(sd, num_closure) = 0;
-       ccl_fetch(sd, num_closure_extra) = 0;
-       ccl_fetch(sd, randb_closure) = 0.0f;
+       sd->num_closure = 0;
+       sd->num_closure_extra = 0;
+       sd->randb_closure = 0.0f;
 
        /* this will modify sd->P */
 #ifdef __SVM__
index 6abfa9c387302b72e0855d1649b89c60cfc00eb5..2483c5f9ae121d155cd48499aeb4986373c0eca5 100644 (file)
@@ -45,7 +45,7 @@ ccl_device_forceinline bool shadow_handle_transparent_isect(
        /* Setup shader data at surface. */
        shader_setup_from_ray(kg, shadow_sd, isect, ray);
        /* Attenuation from transparent surface. */
-       if(!(ccl_fetch(shadow_sd, flag) & SD_HAS_ONLY_VOLUME)) {
+       if(!(shadow_sd->flag & SD_HAS_ONLY_VOLUME)) {
                path_state_modify_bounce(state, true);
                shader_eval_surface(kg,
                                    shadow_sd,
@@ -180,7 +180,7 @@ ccl_device bool shadow_blocked_transparent_all_loop(KernelGlobals *kg,
                                return true;
                        }
                        /* Move ray forward. */
-                       ray->P = ccl_fetch(shadow_sd, P);
+                       ray->P = shadow_sd->P;
                        if(ray->t != FLT_MAX) {
                                ray->D = normalize_len(Pend - ray->P, &ray->t);
                        }
@@ -308,7 +308,7 @@ ccl_device bool shadow_blocked_transparent_stepped_loop(
                                return true;
                        }
                        /* Move ray forward. */
-                       ray->P = ray_offset(ccl_fetch(shadow_sd, P), -ccl_fetch(shadow_sd, Ng));
+                       ray->P = ray_offset(shadow_sd->P, -shadow_sd->Ng);
                        if(ray->t != FLT_MAX) {
                                ray->D = normalize_len(Pend - ray->P, &ray->t);
                        }
@@ -374,7 +374,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg,
 #ifdef __SPLIT_KERNEL__
        Ray private_ray = *ray_input;
        Ray *ray = &private_ray;
-       Intersection *isect = &kernel_split_state.isect_shadow[SD_THREAD];
+       Intersection *isect = &kernel_split_state.isect_shadow[ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0)];
 #else  /* __SPLIT_KERNEL__ */
        Ray *ray = ray_input;
        Intersection isect_object;
index 52c05b85aee356dd245ab7d944efbf74b87a6def..a8fa64325426a3aa672b3765572b33452ba949db 100644 (file)
@@ -298,20 +298,20 @@ ccl_device_inline int subsurface_scatter_multi_intersect(
        for(int hit = 0; hit < num_eval_hits; hit++) {
                /* Quickly retrieve P and Ng without setting up ShaderData. */
                float3 hit_P;
-               if(ccl_fetch(sd, type) & PRIMITIVE_TRIANGLE) {
+               if(sd->type & PRIMITIVE_TRIANGLE) {
                        hit_P = triangle_refine_subsurface(kg,
                                                           sd,
                                                           &ss_isect->hits[hit],
                                                           ray);
                }
 #ifdef __OBJECT_MOTION__
-               else  if(ccl_fetch(sd, type) & PRIMITIVE_MOTION_TRIANGLE) {
+               else  if(sd->type & PRIMITIVE_MOTION_TRIANGLE) {
                        float3 verts[3];
                        motion_triangle_vertices(
                                kg,
-                               ccl_fetch(sd, object),
+                               sd->object,
                                kernel_tex_fetch(__prim_index, ss_isect->hits[hit].prim),
-                               ccl_fetch(sd, time),
+                               sd->time,
                                verts);
                        hit_P = motion_triangle_refine_subsurface(kg,
                                                                  sd,
index 5a80cdd658533f8652c282fd0004d6818c10065e..279cd6dedabf09fb939f672bc6686a57e66962d4 100644 (file)
@@ -800,99 +800,77 @@ enum ShaderDataObjectFlag {
                           SD_OBJECT_INTERSECTS_VOLUME)
 };
 
-#ifdef __SPLIT_KERNEL__
-#  define SD_THREAD (ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0))
-#  if !defined(__SPLIT_KERNEL_SOA__)
-     /* ShaderData is stored as an Array-of-Structures */
-#    define ccl_soa_member(type, name) type soa_##name
-#    define ccl_fetch(s, t) (s[SD_THREAD].soa_##t)
-#    define ccl_fetch_array(s, t, index) (&s[SD_THREAD].soa_##t[index])
-#  else
-     /* ShaderData is stored as an Structure-of-Arrays */
-#    define SD_GLOBAL_SIZE (ccl_global_size(0) * ccl_global_size(1))
-#    define SD_FIELD_SIZE(t) sizeof(((struct ShaderData*)0)->t)
-#    define SD_OFFSETOF(t) ((char*)(&((struct ShaderData*)0)->t) - (char*)0)
-#    define ccl_soa_member(type, name) type soa_##name
-#    define ccl_fetch(s, t) (((ShaderData*)((ccl_addr_space char*)s + SD_GLOBAL_SIZE * SD_OFFSETOF(soa_##t) +  SD_FIELD_SIZE(soa_##t) * SD_THREAD - SD_OFFSETOF(soa_##t)))->soa_##t)
-#    define ccl_fetch_array(s, t, index) (&ccl_fetch(s, t)[index])
-#  endif
-#else
-#  define ccl_soa_member(type, name) type name
-#  define ccl_fetch(s, t) (s->t)
-#  define ccl_fetch_array(s, t, index) (&s->t[index])
-#endif
-
 typedef ccl_addr_space struct ShaderData {
        /* position */
-       ccl_soa_member(float3, P);
+       float3 P;
        /* smooth normal for shading */
-       ccl_soa_member(float3, N);
+       float3 N;
        /* true geometric normal */
-       ccl_soa_member(float3, Ng);
+       float3 Ng;
        /* view/incoming direction */
-       ccl_soa_member(float3, I);
+       float3 I;
        /* shader id */
-       ccl_soa_member(int, shader);
+       int shader;
        /* booleans describing shader, see ShaderDataFlag */
-       ccl_soa_member(int, flag);
+       int flag;
        /* booleans describing object of the shader, see ShaderDataObjectFlag */
-       ccl_soa_member(int, object_flag);
+       int object_flag;
 
        /* primitive id if there is one, ~0 otherwise */
-       ccl_soa_member(int, prim);
+       int prim;
 
        /* combined type and curve segment for hair */
-       ccl_soa_member(int, type);
+       int type;
 
        /* parametric coordinates
         * - barycentric weights for triangles */
-       ccl_soa_member(float, u);
-       ccl_soa_member(float, v);
+       float u;
+       float v;
        /* object id if there is one, ~0 otherwise */
-       ccl_soa_member(int, object);
+       int object;
 
        /* motion blur sample time */
-       ccl_soa_member(float, time);
+       float time;
 
        /* length of the ray being shaded */
-       ccl_soa_member(float, ray_length);
+       float ray_length;
 
 #ifdef __RAY_DIFFERENTIALS__
        /* differential of P. these are orthogonal to Ng, not N */
-       ccl_soa_member(differential3, dP);
+       differential3 dP;
        /* differential of I */
-       ccl_soa_member(differential3, dI);
+       differential3 dI;
        /* differential of u, v */
-       ccl_soa_member(differential, du);
-       ccl_soa_member(differential, dv);
+       differential du;
+       differential dv;
 #endif
 #ifdef __DPDU__
        /* differential of P w.r.t. parametric coordinates. note that dPdu is
         * not readily suitable as a tangent for shading on triangles. */
-       ccl_soa_member(float3, dPdu);
-       ccl_soa_member(float3, dPdv);
+       float3 dPdu;
+       float3 dPdv;
 #endif
 
 #ifdef __OBJECT_MOTION__
        /* object <-> world space transformations, cached to avoid
         * re-interpolating them constantly for shading */
-       ccl_soa_member(Transform, ob_tfm);
-       ccl_soa_member(Transform, ob_itfm);
+       Transform ob_tfm;
+       Transform ob_itfm;
 #endif
 
        /* Closure data, we store a fixed array of closures */
-       ccl_soa_member(struct ShaderClosure, closure[MAX_CLOSURE]);
-       ccl_soa_member(int, num_closure);
-       ccl_soa_member(int, num_closure_extra);
-       ccl_soa_member(float, randb_closure);
-       ccl_soa_member(float3, svm_closure_weight);
+       struct ShaderClosure closure[MAX_CLOSURE];
+       int num_closure;
+       int num_closure_extra;
+       float randb_closure;
+       float3 svm_closure_weight;
 
        /* LCG state for closures that require additional random numbers. */
-       ccl_soa_member(uint, lcg_state);
+       uint lcg_state;
 
        /* ray start position, only set for backgrounds */
-       ccl_soa_member(float3, ray_P);
-       ccl_soa_member(differential3, ray_dP);
+       float3 ray_P;
+       differential3 ray_dP;
 
 #ifdef __OSL__
        struct KernelGlobals *osl_globals;
index 3614717e28c76a621c8a9bcd1b95681e3271642f..d3a69d3959751bc3fd500342abd568e41fa514c2 100644 (file)
@@ -78,7 +78,7 @@ public:
                                bssrdf->albedo = albedo.x;
                                bssrdf->sharpness = sharpness;
                                bssrdf->N = params.N;
-                               ccl_fetch(sd, flag) |= bssrdf_setup(bssrdf, (ClosureType)type);
+                               sd->flag |= bssrdf_setup(bssrdf, (ClosureType)type);
                        }
 
                        bssrdf = bssrdf_alloc(sd, make_float3(0.0f, weight.y, 0.0f));
@@ -89,7 +89,7 @@ public:
                                bssrdf->albedo = albedo.y;
                                bssrdf->sharpness = sharpness;
                                bssrdf->N = params.N;
-                               ccl_fetch(sd, flag) |= bssrdf_setup(bssrdf, (ClosureType)type);
+                               sd->flag |= bssrdf_setup(bssrdf, (ClosureType)type);
                        }
 
                        bssrdf = bssrdf_alloc(sd, make_float3(0.0f, 0.0f, weight.z));
@@ -100,7 +100,7 @@ public:
                                bssrdf->albedo = albedo.z;
                                bssrdf->sharpness = sharpness;
                                bssrdf->N = params.N;
-                               ccl_fetch(sd, flag) |= bssrdf_setup(bssrdf, (ClosureType)type);
+                               sd->flag |= bssrdf_setup(bssrdf, (ClosureType)type);
                        }
                }
        }
index 6d48856eb44bac3d7d612b97a69fffef1410d479..07e5522c83020223f5f3f0e1a376eedbef87aaac 100644 (file)
@@ -156,7 +156,7 @@ ccl_device void kernel_background_buffer_update(KernelGlobals *kg)
                if(IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND)) {
 #ifdef __BACKGROUND__
                        /* sample background shader */
-                       float3 L_background = indirect_background(kg, kernel_split_state.sd_DL_shadow, state, ray);
+                       float3 L_background = indirect_background(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, ray);
                        path_radiance_accum_background(L, (*throughput), L_background, state->bounce);
 #endif
                        ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
@@ -210,7 +210,7 @@ ccl_device void kernel_background_buffer_update(KernelGlobals *kg)
                                *throughput = make_float3(1.0f, 1.0f, 1.0f);
                                *L_transparent = 0.0f;
                                path_radiance_init(L, kernel_data.film.use_light_pass);
-                               path_state_init(kg, kernel_split_state.sd_DL_shadow, state, rng, sample, ray);
+                               path_state_init(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, rng, sample, ray);
 #ifdef __KERNEL_DEBUG__
                                debug_data_init(debug_data);
 #endif
index eeeb5294fdcdcbf0c968c756e33d3766f55527cb..3251c091468ff306d8c2add6f7ea3df73788014d 100644 (file)
@@ -190,7 +190,7 @@ ccl_device void kernel_data_init(
                kernel_split_state.L_transparent[ray_index] = 0.0f;
                path_radiance_init(&kernel_split_state.path_radiance[ray_index], kernel_data.film.use_light_pass);
                path_state_init(kg,
-                               kernel_split_state.sd_DL_shadow,
+                               &kernel_split_state.sd_DL_shadow[ray_index],
                                &kernel_split_state.path_state[ray_index],
                                &kernel_split_state.rng[ray_index],
                                my_sample,
index 43b943710a1d4cab8db88f3e2a69d36390f63243..5163b8edc044946e9c1e4f1e9b05438146d1d2a0 100644 (file)
@@ -82,12 +82,12 @@ ccl_device void kernel_direct_lighting(KernelGlobals *kg)
 
        if(IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE)) {
                ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
-               ShaderData *sd = kernel_split_state.sd;
+               ShaderData *sd = &kernel_split_state.sd[ray_index];
 
                /* direct lighting */
 #ifdef __EMISSION__
                if((kernel_data.integrator.use_direct_light &&
-                   (ccl_fetch(sd, flag) & SD_BSDF_HAS_EVAL)))
+                   (sd->flag & SD_BSDF_HAS_EVAL)))
                {
                        /* Sample illumination from lights to find path contribution. */
                        ccl_global RNG* rng = &kernel_split_state.rng[ray_index];
@@ -99,19 +99,19 @@ ccl_device void kernel_direct_lighting(KernelGlobals *kg)
                        LightSample ls;
                        if(light_sample(kg,
                                        light_t, light_u, light_v,
-                                       ccl_fetch(sd, time),
-                                       ccl_fetch(sd, P),
+                                       sd->time,
+                                       sd->P,
                                        state->bounce,
                                        &ls)) {
 
                                Ray light_ray;
 #ifdef __OBJECT_MOTION__
-                               light_ray.time = ccl_fetch(sd, time);
+                               light_ray.time = sd->time;
 #endif
 
                                BsdfEval L_light;
                                bool is_lamp;
-                               if(direct_emission(kg, sd, kernel_split_state.sd_DL_shadow, &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
+                               if(direct_emission(kg, sd, &kernel_split_state.sd_DL_shadow[ray_index], &ls, state, &light_ray, &L_light, &is_lamp, terminate)) {
                                        /* Write intermediate data to global memory to access from
                                         * the next kernel.
                                         */
index 3a7f1629e66551b828af28e255be9211f6a7c89c..ee9c4280b2233401992e8b5a692384aa2aa335f1 100644 (file)
@@ -122,7 +122,7 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(KernelGlobal
        float3 throughput;
 
        ccl_global char *ray_state = kernel_split_state.ray_state;
-       ShaderData *sd = kernel_split_state.sd;
+       ShaderData *sd = &kernel_split_state.sd[ray_index];
        ccl_global float *per_sample_output_buffers = kernel_split_state.per_sample_output_buffers;
 
        if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
@@ -145,13 +145,13 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(KernelGlobal
 
                /* holdout */
 #ifdef __HOLDOUT__
-               if(((ccl_fetch(sd, flag) & SD_HOLDOUT) ||
-                   (ccl_fetch(sd, object_flag) & SD_OBJECT_HOLDOUT_MASK)) &&
+               if(((sd->flag & SD_HOLDOUT) ||
+                   (sd->object_flag & SD_OBJECT_HOLDOUT_MASK)) &&
                   (state->flag & PATH_RAY_CAMERA))
                {
                        if(kernel_data.background.transparent) {
                                float3 holdout_weight;
-                               if(ccl_fetch(sd, object_flag) & SD_OBJECT_HOLDOUT_MASK) {
+                               if(sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
                                        holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
                                }
                                else {
@@ -160,7 +160,7 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(KernelGlobal
                                /* any throughput is ok, should all be identical here */
                                kernel_split_state.L_transparent[ray_index] += average(holdout_weight*throughput);
                        }
-                       if(ccl_fetch(sd, object_flag) & SD_OBJECT_HOLDOUT_MASK) {
+                       if(sd->object_flag & SD_OBJECT_HOLDOUT_MASK) {
                                ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
                                enqueue_flag = 1;
                        }
@@ -191,7 +191,7 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(KernelGlobal
 
 #ifdef __EMISSION__
                /* emission */
-               if(ccl_fetch(sd, flag) & SD_EMISSION) {
+               if(sd->flag & SD_EMISSION) {
                        /* TODO(sergey): is isect.t wrong here for transparent surfaces? */
                        float3 emission = indirect_primitive_emission(
                                kg,
@@ -232,7 +232,7 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(KernelGlobal
        if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
                /* ambient occlusion */
                if(kernel_data.integrator.use_ambient_occlusion ||
-                  (ccl_fetch(sd, flag) & SD_AO))
+                  (sd->flag & SD_AO))
                {
                        /* todo: solve correlation */
                        float bsdf_u, bsdf_v;
@@ -247,15 +247,15 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(KernelGlobal
                        float ao_pdf;
                        sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
 
-                       if(dot(ccl_fetch(sd, Ng), ao_D) > 0.0f && ao_pdf != 0.0f) {
+                       if(dot(sd->Ng, ao_D) > 0.0f && ao_pdf != 0.0f) {
                                Ray _ray;
-                               _ray.P = ray_offset(ccl_fetch(sd, P), ccl_fetch(sd, Ng));
+                               _ray.P = ray_offset(sd->P, sd->Ng);
                                _ray.D = ao_D;
                                _ray.t = kernel_data.background.ao_distance;
 #ifdef __OBJECT_MOTION__
-                               _ray.time = ccl_fetch(sd, time);
+                               _ray.time = sd->time;
 #endif
-                               _ray.dP = ccl_fetch(sd, dP);
+                               _ray.dP = sd->dP;
                                _ray.dD = differential3_zero();
                                kernel_split_state.ao_light_ray[ray_index] = _ray;
 
index a9820af30010f931d7d965999b09018aa6cf9948..261625da31df6d2107e7c0d3aa78e4720fa464ca 100644 (file)
@@ -85,7 +85,7 @@ ccl_device void kernel_lamp_emission(KernelGlobals *kg)
                        /* intersect with lamp */
                        float3 emission;
 
-                       if(indirect_lamp_emission(kg, kernel_split_state.sd_DL_shadow, state, &light_ray, &emission)) {
+                       if(indirect_lamp_emission(kg, &kernel_split_state.sd_DL_shadow[ray_index], state, &light_ray, &emission)) {
                                path_radiance_accum_emission(L, throughput, emission, state->bounce);
                        }
                }
index 0ff8286e59bbd841dffe7bfdf24936253997cfc9..a6f2627811657d5f312013151158224196632d78 100644 (file)
@@ -161,7 +161,7 @@ ccl_device void kernel_next_iteration_setup(KernelGlobals *kg)
                L = &kernel_split_state.path_radiance[ray_index];
 
                /* Compute direct lighting and next bounce. */
-               if(!kernel_path_surface_bounce(kg, rng, kernel_split_state.sd, throughput, state, L, ray)) {
+               if(!kernel_path_surface_bounce(kg, rng, &kernel_split_state.sd[ray_index], throughput, state, L, ray)) {
                        ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
                        enqueue_flag = 1;
                }
index 8328f60af3944c3c119ba24f239110deb628067d..35ee19ddf1bcbcde9f6649d2c66a74fc3ec0a73c 100644 (file)
@@ -82,11 +82,11 @@ ccl_device void kernel_shader_eval(KernelGlobals *kg)
                Ray ray = kernel_split_state.ray[ray_index];
 
                shader_setup_from_ray(kg,
-                                     kernel_split_state.sd,
+                                     &kernel_split_state.sd[ray_index],
                                      isect,
                                      &ray);
                float rbsdf = path_state_rng_1D_for_decision(kg, rng, state, PRNG_BSDF);
-               shader_eval_surface(kg, kernel_split_state.sd, rng, state, rbsdf, state->flag, SHADER_CONTEXT_MAIN);
+               shader_eval_surface(kg, &kernel_split_state.sd[ray_index], rng, state, rbsdf, state->flag, SHADER_CONTEXT_MAIN);
        }
 }
 
index f862c37ea6457b68e70e819ac21c54217b4df763..d532c7cf55ba36128a6038b2ccfbe8a50b5b9c8d 100644 (file)
@@ -94,7 +94,7 @@ ccl_device void kernel_shadow_blocked(KernelGlobals *kg)
 
                float3 shadow;
                update_path_radiance = !(shadow_blocked(kg,
-                                                       kernel_split_state.sd_DL_shadow,
+                                                       &kernel_split_state.sd_DL_shadow[thread_index],
                                                        state,
                                                        light_ray_global,
                                                        &shadow));
index 88ec7fe6fcc6810ebfd370baa10fc537a7729f0e..57ec9f94a3d8972bbe0c08e8319f52f50957adbb 100644 (file)
@@ -192,7 +192,7 @@ CCL_NAMESPACE_BEGIN
 ccl_device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ccl_addr_space PathState *state, ShaderType type, int path_flag)
 {
        float stack[SVM_STACK_SIZE];
-       int offset = ccl_fetch(sd, shader) & SHADER_MASK;
+       int offset = sd->shader & SHADER_MASK;
 
        while(1) {
                uint4 node = read_node(kg, &offset);
index 0e55c99ae971a5320ee5ea28f11e539a67a676ee..229a3f204211f9a04b722492d8a1b3c7a7ea0f05 100644 (file)
@@ -27,7 +27,7 @@ ccl_device AttributeDescriptor svm_node_attr_init(KernelGlobals *kg, ShaderData
 
        AttributeDescriptor desc;
 
-       if(ccl_fetch(sd, object) != OBJECT_NONE) {
+       if(sd->object != OBJECT_NONE) {
                desc = find_attribute(kg, sd, node.y);
                if(desc.offset == ATTR_STD_NOT_FOUND) {
                        desc = attribute_not_found();
index 04a8c7b64e5c1e06a8a045f9caa3c52b02134c31..610d9af9e1f3911f7390e29f7b7373003a2bb159 100644 (file)
@@ -21,9 +21,9 @@ CCL_NAMESPACE_BEGIN
 ccl_device void svm_node_enter_bump_eval(KernelGlobals *kg, ShaderData *sd, float *stack, uint offset)
 {
        /* save state */
-       stack_store_float3(stack, offset+0, ccl_fetch(sd, P));
-       stack_store_float3(stack, offset+3, ccl_fetch(sd, dP).dx);
-       stack_store_float3(stack, offset+6, ccl_fetch(sd, dP).dy);
+       stack_store_float3(stack, offset+0, sd->P);
+       stack_store_float3(stack, offset+3, sd->dP.dx);
+       stack_store_float3(stack, offset+6, sd->dP.dy);
 
        /* set state as if undisplaced */
        const AttributeDescriptor desc = find_attribute(kg, sd, ATTR_STD_POSITION_UNDISPLACED);
@@ -36,18 +36,18 @@ ccl_device void svm_node_enter_bump_eval(KernelGlobals *kg, ShaderData *sd, floa
                object_dir_transform(kg, sd, &dPdx);
                object_dir_transform(kg, sd, &dPdy);
 
-               ccl_fetch(sd, P) = P;
-               ccl_fetch(sd, dP).dx = dPdx;
-               ccl_fetch(sd, dP).dy = dPdy;
+               sd->P = P;
+               sd->dP.dx = dPdx;
+               sd->dP.dy = dPdy;
        }
 }
 
 ccl_device void svm_node_leave_bump_eval(KernelGlobals *kg, ShaderData *sd, float *stack, uint offset)
 {
        /* restore state */
-       ccl_fetch(sd, P) = stack_load_float3(stack, offset+0);
-       ccl_fetch(sd, dP).dx = stack_load_float3(stack, offset+3);
-       ccl_fetch(sd, dP).dy = stack_load_float3(stack, offset+6);
+       sd->P = stack_load_float3(stack, offset+0);
+       sd->dP.dx = stack_load_float3(stack, offset+3);
+       sd->dP.dy = stack_load_float3(stack, offset+6);
 }
 
 CCL_NAMESPACE_END
index 00678a49d7061e923f0ce13a045e5bf95d1ddb2f..90249dfd978d01963eba8464b6fcf0859349a5b7 100644 (file)
@@ -23,7 +23,7 @@ ccl_device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack,
        float3 vector;
 
        Transform tfm = kernel_data.cam.worldtocamera;
-       vector = transform_point(&tfm, ccl_fetch(sd, P));
+       vector = transform_point(&tfm, sd->P);
        zdepth = vector.z;
        distance = len(vector);
 
index 017d697f9f8b7404be1ec29ba04545629f9845b6..1885e1af85195aaedfcf108c4df0d84e6219b021 100644 (file)
@@ -25,13 +25,13 @@ ccl_device void svm_node_glass_setup(ShaderData *sd, MicrofacetBsdf *bsdf, int t
                        bsdf->alpha_y = 0.0f;
                        bsdf->alpha_x = 0.0f;
                        bsdf->ior = eta;
-                       ccl_fetch(sd, flag) |= bsdf_refraction_setup(bsdf);
+                       sd->flag |= bsdf_refraction_setup(bsdf);
                }
                else {
                        bsdf->alpha_y = 0.0f;
                        bsdf->alpha_x = 0.0f;
                        bsdf->ior = 0.0f;
-                       ccl_fetch(sd, flag) |= bsdf_reflection_setup(bsdf);
+                       sd->flag |= bsdf_reflection_setup(bsdf);
                }
        }
        else if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID) {
@@ -40,9 +40,9 @@ ccl_device void svm_node_glass_setup(ShaderData *sd, MicrofacetBsdf *bsdf, int t
                bsdf->ior = eta;
 
                if(refract)
-                       ccl_fetch(sd, flag) |= bsdf_microfacet_beckmann_refraction_setup(bsdf);
+                       sd->flag |= bsdf_microfacet_beckmann_refraction_setup(bsdf);
                else
-                       ccl_fetch(sd, flag) |= bsdf_microfacet_beckmann_setup(bsdf);
+                       sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
        }
        else {
                bsdf->alpha_x = roughness;
@@ -50,9 +50,9 @@ ccl_device void svm_node_glass_setup(ShaderData *sd, MicrofacetBsdf *bsdf, int t
                bsdf->ior = eta;
 
                if(refract)
-                       ccl_fetch(sd, flag) |= bsdf_microfacet_ggx_refraction_setup(bsdf);
+                       sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
                else
-                       ccl_fetch(sd, flag) |= bsdf_microfacet_ggx_setup(bsdf);
+                       sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
        }
 }
 
@@ -70,14 +70,14 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
        if(mix_weight == 0.0f)
                return;
 
-       float3 N = stack_valid(data_node.x)? stack_load_float3(stack, data_node.x): ccl_fetch(sd, N);
+       float3 N = stack_valid(data_node.x)? stack_load_float3(stack, data_node.x): sd->N;
 
        float param1 = (stack_valid(param1_offset))? stack_load_float(stack, param1_offset): __uint_as_float(node.z);
        float param2 = (stack_valid(param2_offset))? stack_load_float(stack, param2_offset): __uint_as_float(node.w);
 
        switch(type) {
                case CLOSURE_BSDF_DIFFUSE_ID: {
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        OrenNayarBsdf *bsdf = (OrenNayarBsdf*)bsdf_alloc(sd, sizeof(OrenNayarBsdf), weight);
 
                        if(bsdf) {
@@ -86,31 +86,31 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                float roughness = param1;
 
                                if(roughness == 0.0f) {
-                                       ccl_fetch(sd, flag) |= bsdf_diffuse_setup((DiffuseBsdf*)bsdf);
+                                       sd->flag |= bsdf_diffuse_setup((DiffuseBsdf*)bsdf);
                                }
                                else {
                                        bsdf->roughness = roughness;
-                                       ccl_fetch(sd, flag) |= bsdf_oren_nayar_setup(bsdf);
+                                       sd->flag |= bsdf_oren_nayar_setup(bsdf);
                                }
                        }
                        break;
                }
                case CLOSURE_BSDF_TRANSLUCENT_ID: {
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        DiffuseBsdf *bsdf = (DiffuseBsdf*)bsdf_alloc(sd, sizeof(DiffuseBsdf), weight);
 
                        if(bsdf) {
                                bsdf->N = N;
-                               ccl_fetch(sd, flag) |= bsdf_translucent_setup(bsdf);
+                               sd->flag |= bsdf_translucent_setup(bsdf);
                        }
                        break;
                }
                case CLOSURE_BSDF_TRANSPARENT_ID: {
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        ShaderClosure *bsdf = bsdf_alloc(sd, sizeof(ShaderClosure), weight);
 
                        if(bsdf) {
-                               ccl_fetch(sd, flag) |= bsdf_transparent_setup(bsdf);
+                               sd->flag |= bsdf_transparent_setup(bsdf);
                        }
                        break;
                }
@@ -123,7 +123,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                        if(!kernel_data.integrator.caustics_reflective && (path_flag & PATH_RAY_DIFFUSE))
                                break;
 #endif
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), weight);
 
                        if(bsdf) {
@@ -135,21 +135,21 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 
                                /* setup bsdf */
                                if(type == CLOSURE_BSDF_REFLECTION_ID)
-                                       ccl_fetch(sd, flag) |= bsdf_reflection_setup(bsdf);
+                                       sd->flag |= bsdf_reflection_setup(bsdf);
                                else if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_ID)
-                                       ccl_fetch(sd, flag) |= bsdf_microfacet_beckmann_setup(bsdf);
+                                       sd->flag |= bsdf_microfacet_beckmann_setup(bsdf);
                                else if(type == CLOSURE_BSDF_MICROFACET_GGX_ID)
-                                       ccl_fetch(sd, flag) |= bsdf_microfacet_ggx_setup(bsdf);
+                                       sd->flag |= bsdf_microfacet_ggx_setup(bsdf);
                                else if(type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID) {
                                        kernel_assert(stack_valid(data_node.z));
                                        bsdf->extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
                                        if(bsdf->extra) {
                                                bsdf->extra->color = stack_load_float3(stack, data_node.z);
-                                               ccl_fetch(sd, flag) |= bsdf_microfacet_multi_ggx_setup(bsdf);
+                                               sd->flag |= bsdf_microfacet_multi_ggx_setup(bsdf);
                                        }
                                }
                                else
-                                       ccl_fetch(sd, flag) |= bsdf_ashikhmin_shirley_setup(bsdf);
+                                       sd->flag |= bsdf_ashikhmin_shirley_setup(bsdf);
                        }
 
                        break;
@@ -161,7 +161,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                        if(!kernel_data.integrator.caustics_refractive && (path_flag & PATH_RAY_DIFFUSE))
                                break;
 #endif
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), weight);
 
                        if(bsdf) {
@@ -169,7 +169,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                bsdf->extra = NULL;
 
                                float eta = fmaxf(param2, 1e-5f);
-                               eta = (ccl_fetch(sd, flag) & SD_BACKFACING)? 1.0f/eta: eta;
+                               eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
 
                                /* setup bsdf */
                                if(type == CLOSURE_BSDF_REFRACTION_ID) {
@@ -177,7 +177,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                        bsdf->alpha_y = 0.0f;
                                        bsdf->ior = eta;
 
-                                       ccl_fetch(sd, flag) |= bsdf_refraction_setup(bsdf);
+                                       sd->flag |= bsdf_refraction_setup(bsdf);
                                }
                                else {
                                        bsdf->alpha_x = param1;
@@ -185,9 +185,9 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                        bsdf->ior = eta;
 
                                        if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID)
-                                               ccl_fetch(sd, flag) |= bsdf_microfacet_beckmann_refraction_setup(bsdf);
+                                               sd->flag |= bsdf_microfacet_beckmann_refraction_setup(bsdf);
                                        else
-                                               ccl_fetch(sd, flag) |= bsdf_microfacet_ggx_refraction_setup(bsdf);
+                                               sd->flag |= bsdf_microfacet_ggx_refraction_setup(bsdf);
                                }
                        }
 
@@ -203,14 +203,14 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                break;
                        }
 #endif
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
 
                        /* index of refraction */
                        float eta = fmaxf(param2, 1e-5f);
-                       eta = (ccl_fetch(sd, flag) & SD_BACKFACING)? 1.0f/eta: eta;
+                       eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
 
                        /* fresnel */
-                       float cosNO = dot(N, ccl_fetch(sd, I));
+                       float cosNO = dot(N, sd->I);
                        float fresnel = fresnel_dielectric_cos(cosNO, eta);
                        float roughness = param1;
 
@@ -249,7 +249,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                        if(!kernel_data.integrator.caustics_reflective && !kernel_data.integrator.caustics_refractive && (path_flag & PATH_RAY_DIFFUSE))
                                break;
 #endif
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), weight);
                        MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
 
@@ -261,13 +261,13 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                bsdf->alpha_x = param1;
                                bsdf->alpha_y = param1;
                                float eta = fmaxf(param2, 1e-5f);
-                               bsdf->ior = (ccl_fetch(sd, flag) & SD_BACKFACING)? 1.0f/eta: eta;
+                               bsdf->ior = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
 
                                kernel_assert(stack_valid(data_node.z));
                                bsdf->extra->color = stack_load_float3(stack, data_node.z);
 
                                /* setup bsdf */
-                               ccl_fetch(sd, flag) |= bsdf_microfacet_multi_ggx_glass_setup(bsdf);
+                               sd->flag |= bsdf_microfacet_multi_ggx_glass_setup(bsdf);
                        }
 
                        break;
@@ -280,7 +280,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                        if(!kernel_data.integrator.caustics_reflective && (path_flag & PATH_RAY_DIFFUSE))
                                break;
 #endif
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc(sd, sizeof(MicrofacetBsdf), weight);
 
                        if(bsdf) {
@@ -310,33 +310,33 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                bsdf->ior = 0.0f;
 
                                if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID) {
-                                       ccl_fetch(sd, flag) |= bsdf_microfacet_beckmann_aniso_setup(bsdf);
+                                       sd->flag |= bsdf_microfacet_beckmann_aniso_setup(bsdf);
                                }
                                else if(type == CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID) {
-                                       ccl_fetch(sd, flag) |= bsdf_microfacet_ggx_aniso_setup(bsdf);
+                                       sd->flag |= bsdf_microfacet_ggx_aniso_setup(bsdf);
                                }
                                else if(type == CLOSURE_BSDF_MICROFACET_MULTI_GGX_ANISO_ID) {
                                        kernel_assert(stack_valid(data_node.w));
                                        bsdf->extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
                                        if(bsdf->extra) {
                                                bsdf->extra->color = stack_load_float3(stack, data_node.w);
-                                               ccl_fetch(sd, flag) |= bsdf_microfacet_multi_ggx_aniso_setup(bsdf);
+                                               sd->flag |= bsdf_microfacet_multi_ggx_aniso_setup(bsdf);
                                        }
                                }
                                else
-                                       ccl_fetch(sd, flag) |= bsdf_ashikhmin_shirley_aniso_setup(bsdf);
+                                       sd->flag |= bsdf_ashikhmin_shirley_aniso_setup(bsdf);
                        }
                        break;
                }
                case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID: {
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        VelvetBsdf *bsdf = (VelvetBsdf*)bsdf_alloc(sd, sizeof(VelvetBsdf), weight);
 
                        if(bsdf) {
                                bsdf->N = N;
 
                                bsdf->sigma = saturate(param1);
-                               ccl_fetch(sd, flag) |= bsdf_ashikhmin_velvet_setup(bsdf);
+                               sd->flag |= bsdf_ashikhmin_velvet_setup(bsdf);
                        }
                        break;
                }
@@ -346,7 +346,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                break;
 #endif
                case CLOSURE_BSDF_DIFFUSE_TOON_ID: {
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        ToonBsdf *bsdf = (ToonBsdf*)bsdf_alloc(sd, sizeof(ToonBsdf), weight);
 
                        if(bsdf) {
@@ -355,18 +355,18 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                bsdf->smooth = param2;
                                
                                if(type == CLOSURE_BSDF_DIFFUSE_TOON_ID)
-                                       ccl_fetch(sd, flag) |= bsdf_diffuse_toon_setup(bsdf);
+                                       sd->flag |= bsdf_diffuse_toon_setup(bsdf);
                                else
-                                       ccl_fetch(sd, flag) |= bsdf_glossy_toon_setup(bsdf);
+                                       sd->flag |= bsdf_glossy_toon_setup(bsdf);
                        }
                        break;
                }
 #ifdef __HAIR__
                case CLOSURE_BSDF_HAIR_REFLECTION_ID:
                case CLOSURE_BSDF_HAIR_TRANSMISSION_ID: {
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        
-                       if(ccl_fetch(sd, flag) & SD_BACKFACING && ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
+                       if(sd->flag & SD_BACKFACING && sd->type & PRIMITIVE_ALL_CURVE) {
                                ShaderClosure *bsdf = bsdf_alloc(sd, sizeof(ShaderClosure), weight);
 
                                if(bsdf) {
@@ -376,7 +376,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                         * better figure out a way to skip backfaces from rays
                                         * spawned by transmission from the front */
                                        bsdf->weight = make_float3(1.0f, 1.0f, 1.0f);
-                                       ccl_fetch(sd, flag) |= bsdf_transparent_setup(bsdf);
+                                       sd->flag |= bsdf_transparent_setup(bsdf);
                                }
                        }
                        else {
@@ -390,18 +390,18 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                        if(stack_valid(data_node.y)) {
                                                bsdf->T = normalize(stack_load_float3(stack, data_node.y));
                                        }
-                                       else if(!(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE)) {
-                                               bsdf->T = normalize(ccl_fetch(sd, dPdv));
+                                       else if(!(sd->type & PRIMITIVE_ALL_CURVE)) {
+                                               bsdf->T = normalize(sd->dPdv);
                                                bsdf->offset = 0.0f;
                                        }
                                        else
-                                               bsdf->T = normalize(ccl_fetch(sd, dPdu));
+                                               bsdf->T = normalize(sd->dPdu);
 
                                        if(type == CLOSURE_BSDF_HAIR_REFLECTION_ID) {
-                                               ccl_fetch(sd, flag) |= bsdf_hair_reflection_setup(bsdf);
+                                               sd->flag |= bsdf_hair_reflection_setup(bsdf);
                                        }
                                        else {
-                                               ccl_fetch(sd, flag) |= bsdf_hair_transmission_setup(bsdf);
+                                               sd->flag |= bsdf_hair_transmission_setup(bsdf);
                                        }
                                }
                        }
@@ -414,8 +414,8 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                case CLOSURE_BSSRDF_CUBIC_ID:
                case CLOSURE_BSSRDF_GAUSSIAN_ID:
                case CLOSURE_BSSRDF_BURLEY_ID: {
-                       float3 albedo = ccl_fetch(sd, svm_closure_weight);
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight;
+                       float3 albedo = sd->svm_closure_weight;
+                       float3 weight = sd->svm_closure_weight * mix_weight;
                        float sample_weight = fabsf(average(weight));
                        
                        /* disable in case of diffuse ancestor, can't see it well then and
@@ -441,7 +441,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                        bssrdf->albedo = albedo.x;
                                        bssrdf->sharpness = sharpness;
                                        bssrdf->N = N;
-                                       ccl_fetch(sd, flag) |= bssrdf_setup(bssrdf, (ClosureType)type);
+                                       sd->flag |= bssrdf_setup(bssrdf, (ClosureType)type);
                                }
 
                                bssrdf = bssrdf_alloc(sd, make_float3(0.0f, weight.y, 0.0f));
@@ -452,7 +452,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                        bssrdf->albedo = albedo.y;
                                        bssrdf->sharpness = sharpness;
                                        bssrdf->N = N;
-                                       ccl_fetch(sd, flag) |= bssrdf_setup(bssrdf, (ClosureType)type);
+                                       sd->flag |= bssrdf_setup(bssrdf, (ClosureType)type);
                                }
 
                                bssrdf = bssrdf_alloc(sd, make_float3(0.0f, 0.0f, weight.z));
@@ -463,7 +463,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                                        bssrdf->albedo = albedo.z;
                                        bssrdf->sharpness = sharpness;
                                        bssrdf->N = N;
-                                       ccl_fetch(sd, flag) |= bssrdf_setup(bssrdf, (ClosureType)type);
+                                       sd->flag |= bssrdf_setup(bssrdf, (ClosureType)type);
                                }
                        }
 
@@ -493,21 +493,21 @@ ccl_device void svm_node_closure_volume(KernelGlobals *kg, ShaderData *sd, float
 
        switch(type) {
                case CLOSURE_VOLUME_ABSORPTION_ID: {
-                       float3 weight = (make_float3(1.0f, 1.0f, 1.0f) - ccl_fetch(sd, svm_closure_weight)) * mix_weight * density;
+                       float3 weight = (make_float3(1.0f, 1.0f, 1.0f) - sd->svm_closure_weight) * mix_weight * density;
                        ShaderClosure *sc = closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_NONE_ID, weight);
 
                        if(sc) {
-                               ccl_fetch(sd, flag) |= volume_absorption_setup(sc);
+                               sd->flag |= volume_absorption_setup(sc);
                        }
                        break;
                }
                case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID: {
-                       float3 weight = ccl_fetch(sd, svm_closure_weight) * mix_weight * density;
+                       float3 weight = sd->svm_closure_weight * mix_weight * density;
                        HenyeyGreensteinVolume *volume = (HenyeyGreensteinVolume*)bsdf_alloc(sd, sizeof(HenyeyGreensteinVolume), weight);
 
                        if(volume) {
                                volume->g = param2; /* g */
-                               ccl_fetch(sd, flag) |= volume_henyey_greenstein_setup(volume);
+                               sd->flag |= volume_henyey_greenstein_setup(volume);
                        }
                        break;
                }
@@ -527,12 +527,12 @@ ccl_device void svm_node_closure_emission(ShaderData *sd, float *stack, uint4 no
                if(mix_weight == 0.0f)
                        return;
 
-               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_EMISSION_ID, ccl_fetch(sd, svm_closure_weight) * mix_weight);
+               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_EMISSION_ID, sd->svm_closure_weight * mix_weight);
        }
        else
-               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_EMISSION_ID, ccl_fetch(sd, svm_closure_weight));
+               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_EMISSION_ID, sd->svm_closure_weight);
 
-       ccl_fetch(sd, flag) |= SD_EMISSION;
+       sd->flag |= SD_EMISSION;
 }
 
 ccl_device void svm_node_closure_background(ShaderData *sd, float *stack, uint4 node)
@@ -545,10 +545,10 @@ ccl_device void svm_node_closure_background(ShaderData *sd, float *stack, uint4
                if(mix_weight == 0.0f)
                        return;
 
-               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_BACKGROUND_ID, ccl_fetch(sd, svm_closure_weight) * mix_weight);
+               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_BACKGROUND_ID, sd->svm_closure_weight * mix_weight);
        }
        else
-               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_BACKGROUND_ID, ccl_fetch(sd, svm_closure_weight));
+               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_BACKGROUND_ID, sd->svm_closure_weight);
 }
 
 ccl_device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 node)
@@ -561,12 +561,12 @@ ccl_device void svm_node_closure_holdout(ShaderData *sd, float *stack, uint4 nod
                if(mix_weight == 0.0f)
                        return;
 
-               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_HOLDOUT_ID, ccl_fetch(sd, svm_closure_weight) * mix_weight);
+               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_HOLDOUT_ID, sd->svm_closure_weight * mix_weight);
        }
        else
-               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_HOLDOUT_ID, ccl_fetch(sd, svm_closure_weight));
+               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_HOLDOUT_ID, sd->svm_closure_weight);
 
-       ccl_fetch(sd, flag) |= SD_HOLDOUT;
+       sd->flag |= SD_HOLDOUT;
 }
 
 ccl_device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack, uint4 node)
@@ -579,19 +579,19 @@ ccl_device void svm_node_closure_ambient_occlusion(ShaderData *sd, float *stack,
                if(mix_weight == 0.0f)
                        return;
 
-               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_AMBIENT_OCCLUSION_ID, ccl_fetch(sd, svm_closure_weight) * mix_weight);
+               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_AMBIENT_OCCLUSION_ID, sd->svm_closure_weight * mix_weight);
        }
        else
-               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_AMBIENT_OCCLUSION_ID, ccl_fetch(sd, svm_closure_weight));
+               closure_alloc(sd, sizeof(ShaderClosure), CLOSURE_AMBIENT_OCCLUSION_ID, sd->svm_closure_weight);
 
-       ccl_fetch(sd, flag) |= SD_AO;
+       sd->flag |= SD_AO;
 }
 
 /* Closure Nodes */
 
 ccl_device_inline void svm_node_closure_store_weight(ShaderData *sd, float3 weight)
 {
-       ccl_fetch(sd, svm_closure_weight) = weight;
+       sd->svm_closure_weight = weight;
 }
 
 ccl_device void svm_node_closure_set_weight(ShaderData *sd, uint r, uint g, uint b)
@@ -641,7 +641,7 @@ ccl_device void svm_node_mix_closure(ShaderData *sd, float *stack, uint4 node)
 ccl_device void svm_node_set_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_direction, uint out_normal)
 {
        float3 normal = stack_load_float3(stack, in_direction);
-       ccl_fetch(sd, N) = normal;
+       sd->N = normal;
        stack_store_float3(stack, out_normal, normal);
 }
 
index 890ab41aaaa77ea497d05bb14a492681ced75f62..c94fa130af7560012efa1cc30ccd56e30855b411 100644 (file)
@@ -25,10 +25,10 @@ ccl_device void svm_node_set_bump(KernelGlobals *kg, ShaderData *sd, float *stac
        uint normal_offset, distance_offset, invert, use_object_space;
        decode_node_uchar4(node.y, &normal_offset, &distance_offset, &invert, &use_object_space);
 
-       float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): ccl_fetch(sd, N);
+       float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N;
 
-       float3 dPdx = ccl_fetch(sd, dP).dx;
-       float3 dPdy = ccl_fetch(sd, dP).dy;
+       float3 dPdx = sd->dP.dx;
+       float3 dPdy = sd->dP.dy;
 
        if(use_object_space) {
                object_inverse_normal_transform(kg, sd, &normal_in);
@@ -80,14 +80,14 @@ ccl_device void svm_node_set_displacement(KernelGlobals *kg, ShaderData *sd, flo
 {
        float d = stack_load_float(stack, fac_offset);
 
-       float3 dP = ccl_fetch(sd, N);
+       float3 dP = sd->N;
        object_inverse_normal_transform(kg, sd, &dP);
 
        dP *= d*0.1f; /* todo: get rid of this factor */
 
        object_dir_transform(kg, sd, &dP);
 
-       ccl_fetch(sd, P) += dP;
+       sd->P += dP;
 }
 
 CCL_NAMESPACE_END
index 23c97d80cb03922fc784d3408eb5bb064119af0e..3703ec5501537e84d3e03cf385cd2d7e0c595598 100644 (file)
@@ -23,12 +23,12 @@ ccl_device void svm_node_fresnel(ShaderData *sd, float *stack, uint ior_offset,
        uint normal_offset, out_offset;
        decode_node_uchar4(node, &normal_offset, &out_offset, NULL, NULL);
        float eta = (stack_valid(ior_offset))? stack_load_float(stack, ior_offset): __uint_as_float(ior_value);
-       float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): ccl_fetch(sd, N);
+       float3 normal_in = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N;
        
        eta = fmaxf(eta, 1e-5f);
-       eta = (ccl_fetch(sd, flag) & SD_BACKFACING)? 1.0f/eta: eta;
+       eta = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
 
-       float f = fresnel_dielectric_cos(dot(ccl_fetch(sd, I), normal_in), eta);
+       float f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta);
 
        stack_store_float(stack, out_offset, f);
 }
@@ -44,18 +44,18 @@ ccl_device void svm_node_layer_weight(ShaderData *sd, float *stack, uint4 node)
        decode_node_uchar4(node.w, &type, &normal_offset, &out_offset, NULL);
 
        float blend = (stack_valid(blend_offset))? stack_load_float(stack, blend_offset): __uint_as_float(blend_value);
-       float3 normal_in = (stack_valid(normal_offset))? stack_load_float3(stack, normal_offset): ccl_fetch(sd, N);
+       float3 normal_in = (stack_valid(normal_offset))? stack_load_float3(stack, normal_offset): sd->N;
 
        float f;
 
        if(type == NODE_LAYER_WEIGHT_FRESNEL) {
                float eta = fmaxf(1.0f - blend, 1e-5f);
-               eta = (ccl_fetch(sd, flag) & SD_BACKFACING)? eta: 1.0f/eta;
+               eta = (sd->flag & SD_BACKFACING)? eta: 1.0f/eta;
 
-               f = fresnel_dielectric_cos(dot(ccl_fetch(sd, I), normal_in), eta);
+               f = fresnel_dielectric_cos(dot(sd->I, normal_in), eta);
        }
        else {
-               f = fabsf(dot(ccl_fetch(sd, I), normal_in));
+               f = fabsf(dot(sd->I, normal_in));
 
                if(blend != 0.5f) {
                        blend = clamp(blend, 0.0f, 1.0f-1e-5f);
index 7d512f7ff4ddac213514d1a8bb91fb7af2a6df18..4a09d9f6653a81d61ccfe2c269a1fec6efe3d6a3 100644 (file)
@@ -27,15 +27,15 @@ ccl_device_inline void svm_node_geometry(KernelGlobals *kg,
        float3 data;
 
        switch(type) {
-               case NODE_GEOM_P: data = ccl_fetch(sd, P); break;
-               case NODE_GEOM_N: data = ccl_fetch(sd, N); break;
+               case NODE_GEOM_P: data = sd->P; break;
+               case NODE_GEOM_N: data = sd->N; break;
 #ifdef __DPDU__
                case NODE_GEOM_T: data = primitive_tangent(kg, sd); break;
 #endif
-               case NODE_GEOM_I: data = ccl_fetch(sd, I); break;
-               case NODE_GEOM_Ng: data = ccl_fetch(sd, Ng); break;
+               case NODE_GEOM_I: data = sd->I; break;
+               case NODE_GEOM_Ng: data = sd->Ng; break;
 #ifdef __UV__
-               case NODE_GEOM_uv: data = make_float3(ccl_fetch(sd, u), ccl_fetch(sd, v), 0.0f); break;
+               case NODE_GEOM_uv: data = make_float3(sd->u, sd->v, 0.0f); break;
 #endif
        }
 
@@ -48,8 +48,8 @@ ccl_device void svm_node_geometry_bump_dx(KernelGlobals *kg, ShaderData *sd, flo
        float3 data;
 
        switch(type) {
-               case NODE_GEOM_P: data = ccl_fetch(sd, P) + ccl_fetch(sd, dP).dx; break;
-               case NODE_GEOM_uv: data = make_float3(ccl_fetch(sd, u) + ccl_fetch(sd, du).dx, ccl_fetch(sd, v) + ccl_fetch(sd, dv).dx, 0.0f); break;
+               case NODE_GEOM_P: data = sd->P + sd->dP.dx; break;
+               case NODE_GEOM_uv: data = make_float3(sd->u + sd->du.dx, sd->v + sd->dv.dx, 0.0f); break;
                default: svm_node_geometry(kg, sd, stack, type, out_offset); return;
        }
 
@@ -65,8 +65,8 @@ ccl_device void svm_node_geometry_bump_dy(KernelGlobals *kg, ShaderData *sd, flo
        float3 data;
 
        switch(type) {
-               case NODE_GEOM_P: data = ccl_fetch(sd, P) + ccl_fetch(sd, dP).dy; break;
-               case NODE_GEOM_uv: data = make_float3(ccl_fetch(sd, u) + ccl_fetch(sd, du).dy, ccl_fetch(sd, v) + ccl_fetch(sd, dv).dy, 0.0f); break;
+               case NODE_GEOM_P: data = sd->P + sd->dP.dy; break;
+               case NODE_GEOM_uv: data = make_float3(sd->u + sd->du.dy, sd->v + sd->dv.dy, 0.0f); break;
                default: svm_node_geometry(kg, sd, stack, type, out_offset); return;
        }
 
@@ -87,9 +87,9 @@ ccl_device void svm_node_object_info(KernelGlobals *kg, ShaderData *sd, float *s
                        stack_store_float3(stack, out_offset, object_location(kg, sd));
                        return;
                }
-               case NODE_INFO_OB_INDEX: data = object_pass_id(kg, ccl_fetch(sd, object)); break;
+               case NODE_INFO_OB_INDEX: data = object_pass_id(kg, sd->object); break;
                case NODE_INFO_MAT_INDEX: data = shader_pass_id(kg, sd); break;
-               case NODE_INFO_OB_RANDOM: data = object_random_number(kg, ccl_fetch(sd, object)); break;
+               case NODE_INFO_OB_RANDOM: data = object_random_number(kg, sd->object); break;
                default: data = 0.0f; break;
        }
 
@@ -106,44 +106,44 @@ ccl_device void svm_node_particle_info(KernelGlobals *kg,
 {
        switch(type) {
                case NODE_INFO_PAR_INDEX: {
-                       int particle_id = object_particle_id(kg, ccl_fetch(sd, object));
+                       int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float(stack, out_offset, particle_index(kg, particle_id));
                        break;
                }
                case NODE_INFO_PAR_AGE: {
-                       int particle_id = object_particle_id(kg, ccl_fetch(sd, object));
+                       int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float(stack, out_offset, particle_age(kg, particle_id));
                        break;
                }
                case NODE_INFO_PAR_LIFETIME: {
-                       int particle_id = object_particle_id(kg, ccl_fetch(sd, object));
+                       int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float(stack, out_offset, particle_lifetime(kg, particle_id));
                        break;
                }
                case NODE_INFO_PAR_LOCATION: {
-                       int particle_id = object_particle_id(kg, ccl_fetch(sd, object));
+                       int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float3(stack, out_offset, particle_location(kg, particle_id));
                        break;
                }
 #if 0  /* XXX float4 currently not supported in SVM stack */
                case NODE_INFO_PAR_ROTATION: {
-                       int particle_id = object_particle_id(kg, ccl_fetch(sd, object));
+                       int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float4(stack, out_offset, particle_rotation(kg, particle_id));
                        break;
                }
 #endif
                case NODE_INFO_PAR_SIZE: {
-                       int particle_id = object_particle_id(kg, ccl_fetch(sd, object));
+                       int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float(stack, out_offset, particle_size(kg, particle_id));
                        break;
                }
                case NODE_INFO_PAR_VELOCITY: {
-                       int particle_id = object_particle_id(kg, ccl_fetch(sd, object));
+                       int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float3(stack, out_offset, particle_velocity(kg, particle_id));
                        break;
                }
                case NODE_INFO_PAR_ANGULAR_VELOCITY: {
-                       int particle_id = object_particle_id(kg, ccl_fetch(sd, object));
+                       int particle_id = object_particle_id(kg, sd->object);
                        stack_store_float3(stack, out_offset, particle_angular_velocity(kg, particle_id));
                        break;
                }
@@ -165,7 +165,7 @@ ccl_device void svm_node_hair_info(KernelGlobals *kg,
 
        switch(type) {
                case NODE_INFO_CURVE_IS_STRAND: {
-                       data = (ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) != 0;
+                       data = (sd->type & PRIMITIVE_ALL_CURVE) != 0;
                        stack_store_float(stack, out_offset, data);
                        break;
                }
@@ -177,7 +177,7 @@ ccl_device void svm_node_hair_info(KernelGlobals *kg,
                        break;
                }
                /*case NODE_INFO_CURVE_FADE: {
-                       data = ccl_fetch(sd, curve_transparency);
+                       data = sd->curve_transparency;
                        stack_store_float(stack, out_offset, data);
                        break;
                }*/
index 0d6efb47223037834cc53d55650330e95284b83b..76acc9253a15a19df93fb1546504414b1b7cfcfa 100644 (file)
@@ -237,9 +237,9 @@ ccl_device void svm_node_tex_image(KernelGlobals *kg, ShaderData *sd, float *sta
 ccl_device void svm_node_tex_image_box(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node)
 {
        /* get object space normal */
-       float3 N = ccl_fetch(sd, N);
+       float3 N = sd->N;
 
-       N = ccl_fetch(sd, N);
+       N = sd->N;
        object_inverse_normal_transform(kg, sd, &N);
 
        /* project from direction vector to barycentric coordinates in triangles */
index 04f6f623f188667be161ea78f2b67108c4bf50bb..1492e3586087b49d5082b697464cfbe7fb096b2a 100644 (file)
@@ -31,8 +31,8 @@ ccl_device void svm_node_light_path(ShaderData *sd, ccl_addr_space PathState *st
                case NODE_LP_reflection: info = (path_flag & PATH_RAY_REFLECT)? 1.0f: 0.0f; break;
                case NODE_LP_transmission: info = (path_flag & PATH_RAY_TRANSMIT)? 1.0f: 0.0f; break;
                case NODE_LP_volume_scatter: info = (path_flag & PATH_RAY_VOLUME_SCATTER)? 1.0f: 0.0f; break;
-               case NODE_LP_backfacing: info = (ccl_fetch(sd, flag) & SD_BACKFACING)? 1.0f: 0.0f; break;
-               case NODE_LP_ray_length: info = ccl_fetch(sd, ray_length); break;
+               case NODE_LP_backfacing: info = (sd->flag & SD_BACKFACING)? 1.0f: 0.0f; break;
+               case NODE_LP_ray_length: info = sd->ray_length; break;
                case NODE_LP_ray_depth: info = (float)state->bounce; break;
                case NODE_LP_ray_diffuse: info = (float)state->diffuse_bounce; break;
                case NODE_LP_ray_glossy: info = (float)state->glossy_bounce; break;
@@ -56,14 +56,14 @@ ccl_device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node)
 
        switch(type) {
                case NODE_LIGHT_FALLOFF_QUADRATIC: break;
-               case NODE_LIGHT_FALLOFF_LINEAR: strength *= ccl_fetch(sd, ray_length); break;
-               case NODE_LIGHT_FALLOFF_CONSTANT: strength *= ccl_fetch(sd, ray_length)*ccl_fetch(sd, ray_length); break;
+               case NODE_LIGHT_FALLOFF_LINEAR: strength *= sd->ray_length; break;
+               case NODE_LIGHT_FALLOFF_CONSTANT: strength *= sd->ray_length*sd->ray_length; break;
        }
 
        float smooth = stack_load_float(stack, smooth_offset);
 
        if(smooth > 0.0f) {
-               float squared = ccl_fetch(sd, ray_length)*ccl_fetch(sd, ray_length);
+               float squared = sd->ray_length*sd->ray_length;
                /* Distant lamps set the ray length to FLT_MAX, which causes squared to overflow. */
                if(isfinite(squared)) {
                        strength *= squared/(smooth + squared);
index c0b01262212ed9480c9a381f0f41e7d7b73aa821..c94327401f52c8a65d64819874c79c2cfa54ae5a 100644 (file)
@@ -31,9 +31,9 @@ ccl_device void svm_node_tex_coord(KernelGlobals *kg,
 
        switch(type) {
                case NODE_TEXCO_OBJECT: {
-                       data = ccl_fetch(sd, P);
+                       data = sd->P;
                        if(node.w == 0) {
-                               if(ccl_fetch(sd, object) != OBJECT_NONE) {
+                               if(sd->object != OBJECT_NONE) {
                                        object_inverse_position_transform(kg, sd, &data);
                                }
                        }
@@ -48,47 +48,47 @@ ccl_device void svm_node_tex_coord(KernelGlobals *kg,
                        break;
                }
                case NODE_TEXCO_NORMAL: {
-                       data = ccl_fetch(sd, N);
+                       data = sd->N;
                        object_inverse_normal_transform(kg, sd, &data);
                        break;
                }
                case NODE_TEXCO_CAMERA: {
                        Transform tfm = kernel_data.cam.worldtocamera;
 
-                       if(ccl_fetch(sd, object) != OBJECT_NONE)
-                               data = transform_point(&tfm, ccl_fetch(sd, P));
+                       if(sd->object != OBJECT_NONE)
+                               data = transform_point(&tfm, sd->P);
                        else
-                               data = transform_point(&tfm, ccl_fetch(sd, P) + camera_position(kg));
+                               data = transform_point(&tfm, sd->P + camera_position(kg));
                        break;
                }
                case NODE_TEXCO_WINDOW: {
-                       if((path_flag & PATH_RAY_CAMERA) && ccl_fetch(sd, object) == OBJECT_NONE && kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
-                               data = camera_world_to_ndc(kg, sd, ccl_fetch(sd, ray_P));
+                       if((path_flag & PATH_RAY_CAMERA) && sd->object == OBJECT_NONE && kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
+                               data = camera_world_to_ndc(kg, sd, sd->ray_P);
                        else
-                               data = camera_world_to_ndc(kg, sd, ccl_fetch(sd, P));
+                               data = camera_world_to_ndc(kg, sd, sd->P);
                        data.z = 0.0f;
                        break;
                }
                case NODE_TEXCO_REFLECTION: {
-                       if(ccl_fetch(sd, object) != OBJECT_NONE)
-                               data = 2.0f*dot(ccl_fetch(sd, N), ccl_fetch(sd, I))*ccl_fetch(sd, N) - ccl_fetch(sd, I);
+                       if(sd->object != OBJECT_NONE)
+                               data = 2.0f*dot(sd->N, sd->I)*sd->N - sd->I;
                        else
-                               data = ccl_fetch(sd, I);
+                               data = sd->I;
                        break;
                }
                case NODE_TEXCO_DUPLI_GENERATED: {
-                       data = object_dupli_generated(kg, ccl_fetch(sd, object));
+                       data = object_dupli_generated(kg, sd->object);
                        break;
                }
                case NODE_TEXCO_DUPLI_UV: {
-                       data = object_dupli_uv(kg, ccl_fetch(sd, object));
+                       data = object_dupli_uv(kg, sd->object);
                        break;
                }
                case NODE_TEXCO_VOLUME_GENERATED: {
-                       data = ccl_fetch(sd, P);
+                       data = sd->P;
 
 #ifdef __VOLUME__
-                       if(ccl_fetch(sd, object) != OBJECT_NONE)
+                       if(sd->object != OBJECT_NONE)
                                data = volume_normalized_position(kg, sd, data);
 #endif
                        break;
@@ -112,9 +112,9 @@ ccl_device void svm_node_tex_coord_bump_dx(KernelGlobals *kg,
 
        switch(type) {
                case NODE_TEXCO_OBJECT: {
-                       data = ccl_fetch(sd, P) + ccl_fetch(sd, dP).dx;
+                       data = sd->P + sd->dP.dx;
                        if(node.w == 0) {
-                               if(ccl_fetch(sd, object) != OBJECT_NONE) {
+                               if(sd->object != OBJECT_NONE) {
                                        object_inverse_position_transform(kg, sd, &data);
                                }
                        }
@@ -129,47 +129,47 @@ ccl_device void svm_node_tex_coord_bump_dx(KernelGlobals *kg,
                        break;
                }
                case NODE_TEXCO_NORMAL: {
-                       data = ccl_fetch(sd, N);
+                       data = sd->N;
                        object_inverse_normal_transform(kg, sd, &data);
                        break;
                }
                case NODE_TEXCO_CAMERA: {
                        Transform tfm = kernel_data.cam.worldtocamera;
 
-                       if(ccl_fetch(sd, object) != OBJECT_NONE)
-                               data = transform_point(&tfm, ccl_fetch(sd, P) + ccl_fetch(sd, dP).dx);
+                       if(sd->object != OBJECT_NONE)
+                               data = transform_point(&tfm, sd->P + sd->dP.dx);
                        else
-                               data = transform_point(&tfm, ccl_fetch(sd, P) + ccl_fetch(sd, dP).dx + camera_position(kg));
+                               data = transform_point(&tfm, sd->P + sd->dP.dx + camera_position(kg));
                        break;
                }
                case NODE_TEXCO_WINDOW: {
-                       if((path_flag & PATH_RAY_CAMERA) && ccl_fetch(sd, object) == OBJECT_NONE && kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
-                               data = camera_world_to_ndc(kg, sd, ccl_fetch(sd, ray_P) + ccl_fetch(sd, ray_dP).dx);
+                       if((path_flag & PATH_RAY_CAMERA) && sd->object == OBJECT_NONE && kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
+                               data = camera_world_to_ndc(kg, sd, sd->ray_P + sd->ray_dP.dx);
                        else
-                               data = camera_world_to_ndc(kg, sd, ccl_fetch(sd, P) + ccl_fetch(sd, dP).dx);
+                               data = camera_world_to_ndc(kg, sd, sd->P + sd->dP.dx);
                        data.z = 0.0f;
                        break;
                }
                case NODE_TEXCO_REFLECTION: {
-                       if(ccl_fetch(sd, object) != OBJECT_NONE)
-                               data = 2.0f*dot(ccl_fetch(sd, N), ccl_fetch(sd, I))*ccl_fetch(sd, N) - ccl_fetch(sd, I);
+                       if(sd->object != OBJECT_NONE)
+                               data = 2.0f*dot(sd->N, sd->I)*sd->N - sd->I;
                        else
-                               data = ccl_fetch(sd, I);
+                               data = sd->I;
                        break;
                }
                case NODE_TEXCO_DUPLI_GENERATED: {
-                       data = object_dupli_generated(kg, ccl_fetch(sd, object));
+                       data = object_dupli_generated(kg, sd->object);
                        break;
                }
                case NODE_TEXCO_DUPLI_UV: {
-                       data = object_dupli_uv(kg, ccl_fetch(sd, object));
+                       data = object_dupli_uv(kg, sd->object);
                        break;
                }
                case NODE_TEXCO_VOLUME_GENERATED: {
-                       data = ccl_fetch(sd, P) + ccl_fetch(sd, dP).dx;
+                       data = sd->P + sd->dP.dx;
 
 #ifdef __VOLUME__
-                       if(ccl_fetch(sd, object) != OBJECT_NONE)
+                       if(sd->object != OBJECT_NONE)
                                data = volume_normalized_position(kg, sd, data);
 #endif
                        break;
@@ -196,9 +196,9 @@ ccl_device void svm_node_tex_coord_bump_dy(KernelGlobals *kg,
 
        switch(type) {
                case NODE_TEXCO_OBJECT: {
-                       data = ccl_fetch(sd, P) + ccl_fetch(sd, dP).dy;
+                       data = sd->P + sd->dP.dy;
                        if(node.w == 0) {
-                               if(ccl_fetch(sd, object) != OBJECT_NONE) {
+                               if(sd->object != OBJECT_NONE) {
                                        object_inverse_position_transform(kg, sd, &data);
                                }
                        }
@@ -213,47 +213,47 @@ ccl_device void svm_node_tex_coord_bump_dy(KernelGlobals *kg,
                        break;
                }
                case NODE_TEXCO_NORMAL: {
-                       data = ccl_fetch(sd, N);
+                       data = sd->N;
                        object_inverse_normal_transform(kg, sd, &data);
                        break;
                }
                case NODE_TEXCO_CAMERA: {
                        Transform tfm = kernel_data.cam.worldtocamera;
 
-                       if(ccl_fetch(sd, object) != OBJECT_NONE)
-                               data = transform_point(&tfm, ccl_fetch(sd, P) + ccl_fetch(sd, dP).dy);
+                       if(sd->object != OBJECT_NONE)
+                               data = transform_point(&tfm, sd->P + sd->dP.dy);
                        else
-                               data = transform_point(&tfm, ccl_fetch(sd, P) + ccl_fetch(sd, dP).dy + camera_position(kg));
+                               data = transform_point(&tfm, sd->P + sd->dP.dy + camera_position(kg));
                        break;
                }
                case NODE_TEXCO_WINDOW: {
-                       if((path_flag & PATH_RAY_CAMERA) && ccl_fetch(sd, object) == OBJECT_NONE && kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
-                               data = camera_world_to_ndc(kg, sd, ccl_fetch(sd, ray_P) + ccl_fetch(sd, ray_dP).dy);
+                       if((path_flag & PATH_RAY_CAMERA) && sd->object == OBJECT_NONE && kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
+                               data = camera_world_to_ndc(kg, sd, sd->ray_P + sd->ray_dP.dy);
                        else
-                               data = camera_world_to_ndc(kg, sd, ccl_fetch(sd, P) + ccl_fetch(sd, dP).dy);
+                               data = camera_world_to_ndc(kg, sd, sd->P + sd->dP.dy);
                        data.z = 0.0f;
                        break;
                }
                case NODE_TEXCO_REFLECTION: {
-                       if(ccl_fetch(sd, object) != OBJECT_NONE)
-                               data = 2.0f*dot(ccl_fetch(sd, N), ccl_fetch(sd, I))*ccl_fetch(sd, N) - ccl_fetch(sd, I);
+                       if(sd->object != OBJECT_NONE)
+                               data = 2.0f*dot(sd->N, sd->I)*sd->N - sd->I;
                        else
-                               data = ccl_fetch(sd, I);
+                               data = sd->I;
                        break;
                }
                case NODE_TEXCO_DUPLI_GENERATED: {
-                       data = object_dupli_generated(kg, ccl_fetch(sd, object));
+                       data = object_dupli_generated(kg, sd->object);
                        break;
                }
                case NODE_TEXCO_DUPLI_UV: {
-                       data = object_dupli_uv(kg, ccl_fetch(sd, object));
+                       data = object_dupli_uv(kg, sd->object);
                        break;
                }
                case NODE_TEXCO_VOLUME_GENERATED: {
-                       data = ccl_fetch(sd, P) + ccl_fetch(sd, dP).dy;
+                       data = sd->P + sd->dP.dy;
 
 #ifdef __VOLUME__
-                       if(ccl_fetch(sd, object) != OBJECT_NONE)
+                       if(sd->object != OBJECT_NONE)
                                data = volume_normalized_position(kg, sd, data);
 #endif
                        break;
@@ -274,12 +274,12 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
        float3 color = stack_load_float3(stack, color_offset);
        color = 2.0f*make_float3(color.x - 0.5f, color.y - 0.5f, color.z - 0.5f);
 
-       bool is_backfacing = (ccl_fetch(sd, flag) & SD_BACKFACING) != 0;
+       bool is_backfacing = (sd->flag & SD_BACKFACING) != 0;
        float3 N;
 
        if(space == NODE_NORMAL_MAP_TANGENT) {
                /* tangent space */
-               if(ccl_fetch(sd, object) == OBJECT_NONE) {
+               if(sd->object == OBJECT_NONE) {
                        stack_store_float3(stack, normal_offset, make_float3(0.0f, 0.0f, 0.0f));
                        return;
                }
@@ -299,11 +299,11 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
                float sign = primitive_attribute_float(kg, sd, attr_sign, NULL, NULL);
                float3 normal;
 
-               if(ccl_fetch(sd, shader) & SHADER_SMOOTH_NORMAL) {
+               if(sd->shader & SHADER_SMOOTH_NORMAL) {
                        normal = primitive_attribute_float3(kg, sd, attr_normal, NULL, NULL);
                }
                else {
-                       normal = ccl_fetch(sd, Ng);
+                       normal = sd->Ng;
 
                        /* the normal is already inverted, which is too soon for the math here */
                        if(is_backfacing) {
@@ -345,11 +345,11 @@ ccl_device void svm_node_normal_map(KernelGlobals *kg, ShaderData *sd, float *st
 
        if(strength != 1.0f) {
                strength = max(strength, 0.0f);
-               N = safe_normalize(ccl_fetch(sd, N) + (N - ccl_fetch(sd, N))*strength);
+               N = safe_normalize(sd->N + (N - sd->N)*strength);
        }
 
        if(is_zero(N)) {
-               N = ccl_fetch(sd, N);
+               N = sd->N;
        }
 
        stack_store_float3(stack, normal_offset, N);
@@ -377,7 +377,7 @@ ccl_device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack
                float3 generated;
 
                if(desc.offset == ATTR_STD_NOT_FOUND)
-                       generated = ccl_fetch(sd, P);
+                       generated = sd->P;
                else
                        generated = primitive_attribute_float3(kg, sd, desc, NULL, NULL);
 
@@ -390,7 +390,7 @@ ccl_device void svm_node_tangent(KernelGlobals *kg, ShaderData *sd, float *stack
        }
 
        object_normal_transform(kg, sd, &tangent);
-       tangent = cross(ccl_fetch(sd, N), normalize(cross(tangent, ccl_fetch(sd, N))));
+       tangent = cross(sd->N, normalize(cross(tangent, sd->N)));
        stack_store_float3(stack, tangent_offset, tangent);
 }
 
index 4c32130d06d2d8cbfc1b5a6a5c92a85034e9d224..4e92f27acdb9910c727f3accd584ae2f296f934c 100644 (file)
@@ -33,7 +33,7 @@ ccl_device void svm_node_vector_transform(KernelGlobals *kg, ShaderData *sd, flo
        NodeVectorTransformConvertSpace to = (NodeVectorTransformConvertSpace)ito;
        
        Transform tfm;
-       bool is_object = (ccl_fetch(sd, object) != OBJECT_NONE);
+       bool is_object = (sd->object != OBJECT_NONE);
        bool is_direction = (type == NODE_VECTOR_TRANSFORM_TYPE_VECTOR || type == NODE_VECTOR_TRANSFORM_TYPE_NORMAL);
        
        /* From world */
index 87e40791333b4a130115efe9c05f764afb729f1e..3c6353c800140e3ca77d4abe42c7ef0a5a52d9e2 100644 (file)
@@ -41,9 +41,9 @@ ccl_device_inline float wireframe(KernelGlobals *kg,
                                   float3 *P)
 {
 #ifdef __HAIR__
-       if(ccl_fetch(sd, prim) != PRIM_NONE && ccl_fetch(sd, type) & PRIMITIVE_ALL_TRIANGLE)
+       if(sd->prim != PRIM_NONE && sd->type & PRIMITIVE_ALL_TRIANGLE)
 #else
-       if(ccl_fetch(sd, prim) != PRIM_NONE)
+       if(sd->prim != PRIM_NONE)
 #endif
        {
                float3 Co[3];
@@ -52,12 +52,12 @@ ccl_device_inline float wireframe(KernelGlobals *kg,
                /* Triangles */
                int np = 3;
 
-               if(ccl_fetch(sd, type) & PRIMITIVE_TRIANGLE)
-                       triangle_vertices(kg, ccl_fetch(sd, prim), Co);
+               if(sd->type & PRIMITIVE_TRIANGLE)
+                       triangle_vertices(kg, sd->prim, Co);
                else
-                       motion_triangle_vertices(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), Co);
+                       motion_triangle_vertices(kg, sd->object, sd->prim, sd->time, Co);
 
-               if(!(ccl_fetch(sd, object_flag) & SD_OBJECT_TRANSFORM_APPLIED)) {
+               if(!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
                        object_position_transform(kg, sd, &Co[0]);
                        object_position_transform(kg, sd, &Co[1]);
                        object_position_transform(kg, sd, &Co[2]);
@@ -66,8 +66,8 @@ ccl_device_inline float wireframe(KernelGlobals *kg,
                if(pixel_size) {
                        // Project the derivatives of P to the viewing plane defined
                        // by I so we have a measure of how big is a pixel at this point
-                       float pixelwidth_x = len(ccl_fetch(sd, dP).dx - dot(ccl_fetch(sd, dP).dx, ccl_fetch(sd, I)) * ccl_fetch(sd, I));
-                       float pixelwidth_y = len(ccl_fetch(sd, dP).dy - dot(ccl_fetch(sd, dP).dy, ccl_fetch(sd, I)) * ccl_fetch(sd, I));
+                       float pixelwidth_x = len(sd->dP.dx - dot(sd->dP.dx, sd->I) * sd->I);
+                       float pixelwidth_y = len(sd->dP.dy - dot(sd->dP.dy, sd->I) * sd->I);
                        // Take the average of both axis' length
                        pixelwidth = (pixelwidth_x + pixelwidth_y) * 0.5f;
                }
@@ -113,20 +113,20 @@ ccl_device void svm_node_wireframe(KernelGlobals *kg,
         * With OpenCL 2.0 it's possible to avoid this change, but for until
         * then we'll be living with such an exception.
         */
-       float3 P = ccl_fetch(sd, P);
+       float3 P = sd->P;
        float f = wireframe(kg, sd, size, pixel_size, &P);
 #else
-       float f = wireframe(kg, sd, size, pixel_size, &ccl_fetch(sd, P));
+       float f = wireframe(kg, sd, size, pixel_size, &sd->P);
 #endif
 
        /* TODO(sergey): Think of faster way to calculate derivatives. */
        if(bump_offset == NODE_BUMP_OFFSET_DX) {
-               float3 Px = ccl_fetch(sd, P) - ccl_fetch(sd, dP).dx;
-               f += (f - wireframe(kg, sd, size, pixel_size, &Px)) / len(ccl_fetch(sd, dP).dx);
+               float3 Px = sd->P - sd->dP.dx;
+               f += (f - wireframe(kg, sd, size, pixel_size, &Px)) / len(sd->dP.dx);
        }
        else if(bump_offset == NODE_BUMP_OFFSET_DY) {
-               float3 Py = ccl_fetch(sd, P) - ccl_fetch(sd, dP).dy;
-               f += (f - wireframe(kg, sd, size, pixel_size, &Py)) / len(ccl_fetch(sd, dP).dy);
+               float3 Py = sd->P - sd->dP.dy;
+               f += (f - wireframe(kg, sd, size, pixel_size, &Py)) / len(sd->dP.dy);
        }
 
        if(stack_valid(out_fac))