From b9d1852c5ae7a9d488a48668aff974abd6729164 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Wed, 14 Sep 2016 20:09:37 +0200 Subject: Cycles: Deduplicate light pass code --- intern/cycles/kernel/kernel_accumulate.h | 70 ++++++++++++++++---------------- 1 file changed, 34 insertions(+), 36 deletions(-) (limited to 'intern') diff --git a/intern/cycles/kernel/kernel_accumulate.h b/intern/cycles/kernel/kernel_accumulate.h index 0e13b22bd2c..dd5752f4c91 100644 --- a/intern/cycles/kernel/kernel_accumulate.h +++ b/intern/cycles/kernel/kernel_accumulate.h @@ -48,10 +48,10 @@ ccl_device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 v eval->scatter = value; } else - eval->diffuse = value; -#else - eval->diffuse = value; #endif + { + eval->diffuse = value; + } } /* TODO(sergey): This is just a workaround for annoying 6.5 compiler bug. */ @@ -78,10 +78,10 @@ void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value) /* skipping transparent, this function is used by for eval(), will be zero then */ } else - eval->diffuse += value; -#else - eval->diffuse += value; #endif + { + eval->diffuse += value; + } } ccl_device_inline bool bsdf_eval_is_zero(BsdfEval *eval) @@ -96,10 +96,10 @@ ccl_device_inline bool bsdf_eval_is_zero(BsdfEval *eval) && is_zero(eval->scatter); } else - return is_zero(eval->diffuse); -#else - return is_zero(eval->diffuse); #endif + { + return is_zero(eval->diffuse); + } } ccl_device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value) @@ -115,10 +115,10 @@ ccl_device_inline void bsdf_eval_mul(BsdfEval *eval, float3 value) /* skipping transparent, this function is used by for eval(), will be zero then */ } else - eval->diffuse *= value; -#else - eval->diffuse *= value; #endif + { + eval->diffuse *= value; + } } /* Path Radiance @@ -170,10 +170,10 @@ ccl_device_inline void path_radiance_init(PathRadiance *L, int use_light_pass) L->mist = 0.0f; } else - L->emission = make_float3(0.0f, 0.0f, 0.0f); -#else - L->emission = make_float3(0.0f, 0.0f, 0.0f); #endif + { + L->emission = make_float3(0.0f, 0.0f, 0.0f); + } } ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, ccl_addr_space float3 *throughput, @@ -205,10 +205,10 @@ ccl_device_inline void path_radiance_bsdf_bounce(PathRadiance *L, ccl_addr_space } } else - *throughput *= bsdf_eval->diffuse*inverse_pdf; -#else - *throughput *= bsdf_eval->diffuse*inverse_pdf; #endif + { + *throughput *= bsdf_eval->diffuse*inverse_pdf; + } } ccl_device_inline void path_radiance_accum_emission(PathRadiance *L, float3 throughput, float3 value, int bounce) @@ -223,10 +223,10 @@ ccl_device_inline void path_radiance_accum_emission(PathRadiance *L, float3 thro L->indirect += throughput*value; } else - L->emission += throughput*value; -#else - L->emission += throughput*value; #endif + { + L->emission += throughput*value; + } } ccl_device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 alpha, float3 bsdf, float3 ao, int bounce) @@ -244,10 +244,10 @@ ccl_device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput } } else - L->emission += throughput*bsdf*ao; -#else - L->emission += throughput*bsdf*ao; #endif + { + L->emission += throughput*bsdf*ao; + } } ccl_device_inline void path_radiance_accum_light(PathRadiance *L, float3 throughput, BsdfEval *bsdf_eval, float3 shadow, float shadow_fac, int bounce, bool is_lamp) @@ -275,10 +275,10 @@ ccl_device_inline void path_radiance_accum_light(PathRadiance *L, float3 through } } else - L->emission += throughput*bsdf_eval->diffuse*shadow; -#else - L->emission += throughput*bsdf_eval->diffuse*shadow; #endif + { + L->emission += throughput*bsdf_eval->diffuse*shadow; + } } ccl_device_inline void path_radiance_accum_background(PathRadiance *L, float3 throughput, float3 value, int bounce) @@ -293,10 +293,10 @@ ccl_device_inline void path_radiance_accum_background(PathRadiance *L, float3 th L->indirect += throughput*value; } else - L->emission += throughput*value; -#else - L->emission += throughput*value; #endif + { + L->emission += throughput*value; + } } ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L) @@ -439,10 +439,10 @@ ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadi /* No Light Passes */ else - L_sum = L->emission; -#else - L_sum = L->emission; #endif + { + L_sum = L->emission; + } /* Reject invalid value */ float sum = fabsf((L_sum).x) + fabsf((L_sum).y) + fabsf((L_sum).z); @@ -471,14 +471,12 @@ ccl_device_inline void path_radiance_accum_sample(PathRadiance *L, PathRadiance L->indirect_subsurface += L_sample->indirect_subsurface*fac; L->indirect_scatter += L_sample->indirect_scatter*fac; - L->emission += L_sample->emission*fac; L->background += L_sample->background*fac; L->ao += L_sample->ao*fac; L->shadow += L_sample->shadow*fac; L->mist += L_sample->mist*fac; -#else - L->emission += L_sample->emission * fac; #endif + L->emission += L_sample->emission * fac; } CCL_NAMESPACE_END -- cgit v1.2.3