Cycles: small code cleanup + fix SSS closure mixed with other closures doing
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 2 Apr 2013 16:37:28 +0000 (16:37 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 2 Apr 2013 16:37:28 +0000 (16:37 +0000)
a bit too much work.

intern/cycles/kernel/kernel_displace.h
intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/kernel_subsurface.h
intern/cycles/kernel/kernel_types.h

index fc2be342e029d70287824794c382806b0c30fca7..5f95e0c2e3b668dbf7d8d51e8168e5562367d339 100644 (file)
@@ -66,8 +66,6 @@ __device void kernel_shader_evaluate(KernelGlobals *kg, uint4 *input, float4 *ou
                out = shader_eval_background(kg, &sd, flag, SHADER_CONTEXT_MAIN);
        }
        
-       shader_release(kg, &sd);
-       
        /* write output */
        output[i] = make_float4(out.x, out.y, out.z, 0.0f);
 }
index 9787af535bb027f6897d7903de13810a91cb4ce1..7d7494657e2cbad40b3047842b5238602d2bdfb4 100644 (file)
@@ -69,8 +69,6 @@ __device_noinline float3 direct_emissive_eval(KernelGlobals *kg, float rando,
        
        eval *= ls->eval_fac;
 
-       shader_release(kg, &sd);
-
        return eval;
 }
 
@@ -207,7 +205,6 @@ __device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int pa
        ShaderData sd;
        shader_setup_from_background(kg, &sd, ray);
        float3 L = shader_eval_background(kg, &sd, path_flag, SHADER_CONTEXT_EMISSION);
-       shader_release(kg, &sd);
 
 #ifdef __BACKGROUND_MIS__
        /* check if background light exists or if we should skip pdf */
index bfa449301089b0ddf222339a603dae8a66aded29..f64a4306aebea9d5cc22d90cc2e74cc4b037e869 100644 (file)
@@ -216,8 +216,6 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra
                                if(ray->t != FLT_MAX)
                                        ray->D = normalize_len(Pend - ray->P, &ray->t);
 
-                               shader_release(kg, &sd);
-
                                bounce++;
                        }
                }
@@ -327,10 +325,8 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
                                L_transparent += average(holdout_weight*throughput);
                        }
 
-                       if(sd.flag & SD_HOLDOUT_MASK) {
-                               shader_release(kg, &sd);
+                       if(sd.flag & SD_HOLDOUT_MASK)
                                break;
-                       }
                }
 #endif
 
@@ -349,10 +345,8 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
                float probability = path_state_terminate_probability(kg, &state, throughput);
                float terminate = path_rng(kg, rng, sample, rng_offset + PRNG_TERMINATE);
 
-               if(terminate >= probability) {
-                       shader_release(kg, &sd);
+               if(terminate >= probability)
                        break;
-               }
 
                throughput /= probability;
 
@@ -437,10 +431,8 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
 #endif
 
                /* no BSDF? we can stop here */
-               if(!(sd.flag & SD_BSDF)) {
-                       shader_release(kg, &sd);
+               if(!(sd.flag & SD_BSDF))
                        break;
-               }
 
                /* sample BSDF */
                float bsdf_pdf;
@@ -454,8 +446,6 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
                label = shader_bsdf_sample(kg, &sd, bsdf_u, bsdf_v, &bsdf_eval,
                        &bsdf_omega_in, &bsdf_domega_in, &bsdf_pdf);
 
-               shader_release(kg, &sd);
-
                if(bsdf_pdf == 0.0f || bsdf_eval_is_zero(&bsdf_eval))
                        break;
 
@@ -579,10 +569,8 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
                float probability = path_state_terminate_probability(kg, &state, throughput*num_samples_adjust);
                float terminate = path_rng(kg, rng, sample, rng_offset + PRNG_TERMINATE);
 
-               if(terminate >= probability) {
-                       shader_release(kg, &sd);
+               if(terminate >= probability)
                        break;
-               }
 
                throughput /= probability;
 
@@ -668,10 +656,8 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
 #endif
 
                /* no BSDF? we can stop here */
-               if(!(sd.flag & SD_BSDF)) {
-                       shader_release(kg, &sd);
+               if(!(sd.flag & SD_BSDF))
                        break;
-               }
 
                /* sample BSDF */
                float bsdf_pdf;
@@ -685,8 +671,6 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
                label = shader_bsdf_sample(kg, &sd, bsdf_u, bsdf_v, &bsdf_eval,
                        &bsdf_omega_in, &bsdf_domega_in, &bsdf_pdf);
 
-               shader_release(kg, &sd);
-
                if(bsdf_pdf == 0.0f || bsdf_eval_is_zero(&bsdf_eval))
                        break;
 
@@ -967,10 +951,8 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
                                L_transparent += average(holdout_weight*throughput);
                        }
 
-                       if(sd.flag & SD_HOLDOUT_MASK) {
-                               shader_release(kg, &sd);
+                       if(sd.flag & SD_HOLDOUT_MASK)
                                break;
-                       }
                }
 #endif
 
@@ -990,10 +972,8 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
                        float probability = path_state_terminate_probability(kg, &state, throughput);
                        float terminate = path_rng(kg, rng, sample, rng_offset + PRNG_TERMINATE);
 
-                       if(terminate >= probability) {
-                               shader_release(kg, &sd);
+                       if(terminate >= probability)
                                break;
-                       }
 
                        throughput /= probability;
                }
@@ -1033,7 +1013,6 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
 
                /* continue in case of transparency */
                throughput *= shader_bsdf_transparency(kg, &sd);
-               shader_release(kg, &sd);
 
                if(is_zero(throughput))
                        break;
index b5acf4824e327d7688dcab574e72017571ef2365..444543bf709f90b08c372fb6eed5dc6b11b3642c 100644 (file)
@@ -925,12 +925,5 @@ __device void shader_merge_closures(KernelGlobals *kg, ShaderData *sd)
 }
 #endif
 
-/* Free ShaderData */
-
-__device void shader_release(KernelGlobals *kg, ShaderData *sd)
-{
-       /* nothing to do currently */
-}
-
 CCL_NAMESPACE_END
 
index 7dd5c2d447529a520ee98f3512142aec8bd64f28..cd4d4179410faa9eec7d8e45336bcd4ef9ab384f 100644 (file)
@@ -143,6 +143,7 @@ __device void subsurface_scatter_setup_diffuse_bsdf(ShaderData *sd, float3 weigh
        sc->data0 = 0.0f;
        sc->data1 = 0.0f;
        sc->N = sd->N;
+       sd->flag &= ~SD_CLOSURE_FLAGS;
        sd->flag |= bsdf_diffuse_setup(sc);
        sd->randb_closure = 0.0f;
 
index 9c126074e837dac2a559bc7bdf6296a3cd2bb9d4..526609d0506f2355b038ee079bf57caba755827e 100644 (file)
@@ -452,6 +452,8 @@ enum ShaderDataFlag {
        SD_VOLUME = 128,                /* have volume closure? */
        SD_AO = 256,                    /* have ao closure? */
 
+       SD_CLOSURE_FLAGS = (SD_EMISSION|SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY|SD_BSSRDF|SD_HOLDOUT|SD_VOLUME|SD_AO),
+
        /* shader flags */
        SD_SAMPLE_AS_LIGHT = 512,                       /* direct light sample */
        SD_HAS_SURFACE_TRANSPARENT = 1024,      /* has surface transparency */