Commit: c2a2f3553aed58ae9e4c165f8bfcad2b31dcf74b
Author: Andrii Symkin
Date:   Thu Jun 23 14:29:17 2022 +0200
Branches: master
https://developer.blender.org/rBc2a2f3553aed58ae9e4c165f8bfcad2b31dcf74b

Cycles: unify math functions names

This patch unifies the names of math functions for different data types and uses
overloading instead. The goal is to make it possible to swap out all the float3
variables containing RGB data with something else, with as few as possible
changes to the code. It's a requirement for future spectral rendering patches.

Differential Revision: https://developer.blender.org/D15276

===================================================================

M       intern/cycles/kernel/bake/bake.h
M       intern/cycles/kernel/closure/alloc.h
M       intern/cycles/kernel/closure/bsdf.h
M       intern/cycles/kernel/closure/bsdf_hair_principled.h
M       intern/cycles/kernel/closure/bsdf_microfacet.h
M       intern/cycles/kernel/closure/bsdf_microfacet_multi.h
M       intern/cycles/kernel/closure/volume.h
M       intern/cycles/kernel/film/accumulate.h
M       intern/cycles/kernel/film/passes.h
M       intern/cycles/kernel/geom/curve_intersect.h
M       intern/cycles/kernel/integrator/init_from_bake.h
M       intern/cycles/kernel/integrator/mnee.h
M       intern/cycles/kernel/integrator/path_state.h
M       intern/cycles/kernel/integrator/shade_surface.h
M       intern/cycles/kernel/integrator/shade_volume.h
M       intern/cycles/kernel/integrator/subsurface_random_walk.h
M       intern/cycles/kernel/light/sample.h
M       intern/cycles/kernel/svm/color_util.h
M       intern/cycles/kernel/svm/map_range.h
M       intern/cycles/kernel/svm/mapping_util.h
M       intern/cycles/kernel/svm/math_util.h
M       intern/cycles/kernel/svm/voronoi.h
M       intern/cycles/scene/mesh.cpp
M       intern/cycles/scene/mesh_displace.cpp
M       intern/cycles/scene/object.cpp
M       intern/cycles/util/color.h
M       intern/cycles/util/math.h
M       intern/cycles/util/math_float3.h
M       intern/cycles/util/math_float4.h
M       intern/cycles/util/time.cpp
M       intern/cycles/util/transform.cpp
M       intern/cycles/util/transform.h

===================================================================

diff --git a/intern/cycles/kernel/bake/bake.h b/intern/cycles/kernel/bake/bake.h
index 544a8217bef..ec87990b699 100644
--- a/intern/cycles/kernel/bake/bake.h
+++ b/intern/cycles/kernel/bake/bake.h
@@ -29,14 +29,14 @@ ccl_device void kernel_displace_evaluate(KernelGlobals kg,
   object_inverse_dir_transform(kg, &sd, &D);
 
 #ifdef __KERNEL_DEBUG_NAN__
-  if (!isfinite3_safe(D)) {
+  if (!isfinite_safe(D)) {
     kernel_assert(!"Cycles displacement with non-finite value detected");
   }
 #endif
 
   /* Ensure finite displacement, preventing BVH from becoming degenerate and 
avoiding possible
    * traversal issues caused by non-finite math. */
-  D = ensure_finite3(D);
+  D = ensure_finite(D);
 
   /* Write output. */
   output[offset * 3 + 0] += D.x;
@@ -68,13 +68,13 @@ ccl_device void kernel_background_evaluate(KernelGlobals kg,
   float3 color = shader_background_eval(&sd);
 
 #ifdef __KERNEL_DEBUG_NAN__
-  if (!isfinite3_safe(color)) {
+  if (!isfinite_safe(color)) {
     kernel_assert(!"Cycles background with non-finite value detected");
   }
 #endif
 
   /* Ensure finite color, avoiding possible numerical instabilities in the 
path tracing kernels. */
-  color = ensure_finite3(color);
+  color = ensure_finite(color);
 
   /* Write output. */
   output[offset * 3 + 0] += color.x;
diff --git a/intern/cycles/kernel/closure/alloc.h 
b/intern/cycles/kernel/closure/alloc.h
index a6975a63d5d..933c07a5102 100644
--- a/intern/cycles/kernel/closure/alloc.h
+++ b/intern/cycles/kernel/closure/alloc.h
@@ -51,7 +51,7 @@ ccl_device_inline ccl_private ShaderClosure 
*bsdf_alloc(ccl_private ShaderData *
                                                         int size,
                                                         float3 weight)
 {
-  kernel_assert(isfinite3_safe(weight));
+  kernel_assert(isfinite_safe(weight));
 
   const float sample_weight = fabsf(average(weight));
 
@@ -77,7 +77,7 @@ ccl_device_inline ShaderClosure *bsdf_alloc_osl(ShaderData 
*sd,
                                                 float3 weight,
                                                 void *data)
 {
-  kernel_assert(isfinite3_safe(weight));
+  kernel_assert(isfinite_safe(weight));
 
   const float sample_weight = fabsf(average(weight));
 
diff --git a/intern/cycles/kernel/closure/bsdf.h 
b/intern/cycles/kernel/closure/bsdf.h
index 6f3c2092c64..4feb21c43e3 100644
--- a/intern/cycles/kernel/closure/bsdf.h
+++ b/intern/cycles/kernel/closure/bsdf.h
@@ -439,7 +439,7 @@ ccl_device_inline int bsdf_sample(KernelGlobals kg,
       *eval *= shift_cos_in(dot(*omega_in, sc->N), frequency_multiplier);
     }
     if (label & LABEL_DIFFUSE) {
-      if (!isequal_float3(sc->N, sd->N)) {
+      if (!isequal(sc->N, sd->N)) {
         *eval *= bump_shadowing_term((label & LABEL_TRANSMIT) ? -sd->N : 
sd->N, sc->N, *omega_in);
       }
     }
@@ -550,7 +550,7 @@ ccl_device_inline
         break;
     }
     if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
-      if (!isequal_float3(sc->N, sd->N)) {
+      if (!isequal(sc->N, sd->N)) {
         eval *= bump_shadowing_term(sd->N, sc->N, omega_in);
       }
     }
@@ -635,7 +635,7 @@ ccl_device_inline
         break;
     }
     if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
-      if (!isequal_float3(sc->N, sd->N)) {
+      if (!isequal(sc->N, sd->N)) {
         eval *= bump_shadowing_term(-sd->N, sc->N, omega_in);
       }
     }
diff --git a/intern/cycles/kernel/closure/bsdf_hair_principled.h 
b/intern/cycles/kernel/closure/bsdf_hair_principled.h
index 33706213403..2cdf6c9f349 100644
--- a/intern/cycles/kernel/closure/bsdf_hair_principled.h
+++ b/intern/cycles/kernel/closure/bsdf_hair_principled.h
@@ -203,7 +203,7 @@ ccl_device int bsdf_principled_hair_setup(ccl_private 
ShaderData *sd,
   float h = (sd->type & PRIMITIVE_CURVE_RIBBON) ? -sd->v : dot(cross(sd->Ng, 
X), Z);
 
   kernel_assert(fabsf(h) < 1.0f + 1e-4f);
-  kernel_assert(isfinite3_safe(Y));
+  kernel_assert(isfinite_safe(Y));
   kernel_assert(isfinite_safe(h));
 
   bsdf->extra->geom = make_float4(Y.x, Y.y, Y.z, h);
@@ -272,7 +272,7 @@ ccl_device float3 bsdf_principled_hair_eval(KernelGlobals 
kg,
                                             const float3 omega_in,
                                             ccl_private float *pdf)
 {
-  kernel_assert(isfinite3_safe(sd->P) && isfinite_safe(sd->ray_length));
+  kernel_assert(isfinite_safe(sd->P) && isfinite_safe(sd->ray_length));
 
   ccl_private const PrincipledHairBSDF *bsdf = (ccl_private const 
PrincipledHairBSDF *)sc;
   float3 Y = float4_to_float3(bsdf->extra->geom);
@@ -299,7 +299,7 @@ ccl_device float3 bsdf_principled_hair_eval(KernelGlobals 
kg,
   float cos_gamma_t = cos_from_sin(sin_gamma_t);
   float gamma_t = safe_asinf(sin_gamma_t);
 
-  float3 T = exp3(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t));
+  float3 T = exp(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t));
   float4 Ap[4];
   hair_attenuation(kg, fresnel_dielectric_cos(cos_theta_o * cos_gamma_o, 
bsdf->eta), T, Ap);
 
@@ -319,25 +319,25 @@ ccl_device float3 bsdf_principled_hair_eval(KernelGlobals 
kg,
   Mp = longitudinal_scattering(angles[0], angles[1], sin_theta_o, cos_theta_o, 
bsdf->m0_roughness);
   Np = azimuthal_scattering(phi, 0, bsdf->s, gamma_o, gamma_t);
   F = Ap[0] * Mp * Np;
-  kernel_assert(isfinite3_safe(float4_to_float3(F)));
+  kernel_assert(isfinite_safe(float4_to_float3(F)));
 
   /* Transmission (TT). */
   Mp = longitudinal_scattering(angles[2], angles[3], sin_theta_o, cos_theta_o, 
0.25f * bsdf->v);
   Np = azimuthal_scattering(phi, 1, bsdf->s, gamma_o, gamma_t);
   F += Ap[1] * Mp * Np;
-  kernel_assert(isfinite3_safe(float4_to_float3(F)));
+  kernel_assert(isfinite_safe(float4_to_float3(F)));
 
   /* Secondary specular (TRT). */
   Mp = longitudinal_scattering(angles[4], angles[5], sin_theta_o, cos_theta_o, 
4.0f * bsdf->v);
   Np = azimuthal_scattering(phi, 2, bsdf->s, gamma_o, gamma_t);
   F += Ap[2] * Mp * Np;
-  kernel_assert(isfinite3_safe(float4_to_float3(F)));
+  kernel_assert(isfinite_safe(float4_to_float3(F)));
 
   /* Residual component (TRRT+). */
   Mp = longitudinal_scattering(sin_theta_i, cos_theta_i, sin_theta_o, 
cos_theta_o, 4.0f * bsdf->v);
   Np = M_1_2PI_F;
   F += Ap[3] * Mp * Np;
-  kernel_assert(isfinite3_safe(float4_to_float3(F)));
+  kernel_assert(isfinite_safe(float4_to_float3(F)));
 
   *pdf = F.w;
   return float4_to_float3(F);
@@ -385,7 +385,7 @@ ccl_device int bsdf_principled_hair_sample(KernelGlobals kg,
   float cos_gamma_t = cos_from_sin(sin_gamma_t);
   float gamma_t = safe_asinf(sin_gamma_t);
 
-  float3 T = exp3(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t));
+  float3 T = exp(-bsdf->sigma * (2.0f * cos_gamma_t / cos_theta_t));
   float4 Ap[4];
   hair_attenuation(kg, fresnel_dielectric_cos(cos_theta_o * cos_gamma_o, 
bsdf->eta), T, Ap);
 
@@ -436,25 +436,25 @@ ccl_device int bsdf_principled_hair_sample(KernelGlobals 
kg,
   Mp = longitudinal_scattering(angles[0], angles[1], sin_theta_o, cos_theta_o, 
bsdf->m0_roughness);
   Np = azimuthal_scattering(phi, 0, bsdf->s, gamma_o, gamma_t);
   F = Ap[0] * Mp * Np;
-  kernel_assert(isfinite3_safe(float4_to_float3(F)));
+  kernel_assert(isfinite_safe(float4_to_float3(F)));
 
   /* Transmission (TT). */
   Mp = longitudinal_scattering(angles[2], angles[3], sin_theta_o, cos_theta_o, 
0.25f * bsdf->v);
   Np = azimuthal_scattering(phi, 1, bsdf->s, gamma_o, gamma_t);
   F += Ap[1] * Mp * Np;
-  kernel_assert(isfinite3_safe(float4_to_float3(F)));
+  kernel_assert(isfinite_safe(float4_to_float3(F)));
 
   /* Secondary specular (TRT). */
   Mp = longitudinal_scattering(angles[4], angles[5], sin_theta_o, cos_theta_o, 
4.0f * bsdf->v);
   Np = azimuthal_scattering(phi, 2, bsdf->s, gamma_o, gamma_t);
   F += Ap[2] * Mp * Np;
-  kernel_assert(isfinite3_safe(float4_to_float3(F)));
+  kernel_assert(isfinite_safe(float4_to_float3(F)));
 
   /* Residual component (TRRT+). */
   Mp = longitudinal_scattering(sin_theta_i, cos_theta_i, sin_theta_o, 
cos_theta_o, 4.0f * bsdf->v);
   Np = M_1_2PI_F;
   F += Ap[3] * Mp * Np;
-  kernel_assert(isfinite3_safe(float4_to_float3(F)));
+  kernel_assert(isfinite_safe(float4_to_float3(F)));
 
   *eval = float4_to_float3(F);
   *pdf = F.w;
@@ -492,13 +492,13 @@ ccl_device_inline float 
bsdf_principled_hair_albedo_roughness_scale(
 ccl_device float3 bsdf_principled_hair_albedo(ccl_private const ShaderClosure 
*sc)
 {
   ccl_private PrincipledHairBSDF *bsdf = (ccl_private PrincipledHairBSDF *)sc;
-  return exp3(-sqrt(bsdf->sigma) * 
bsdf_principled_hair_albedo_roughness_scale(bsdf->v));
+  return exp(-sqrt(bsdf->sigma) * 
bsdf_principled_hair_albedo_roughness_scale(bsdf->v));
 }
 
 ccl_device_inline float3
 bsdf_principled_hair_sigma_from_reflectance(const float3 color, const float 
azimuthal_roughness)
 {
-  const float3 sigma = log3(color) /
+  const float3 sigma = log(color) /
                        
bsdf_principled_hair_albedo_roughness_scale(azimuthal_roughness);
   return sigma * sigma;
 }
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet.h 
b/intern/cycles/kernel/closure/bsdf_microfacet.h
index db50712f9f0..c6cbd1ffae7 100644
--- a/intern/cycles/kernel/closure/bsdf_microfacet.h
+++ b/intern/cycles/kernel/closure/bsdf_microfacet.h
@@ -310,7 +310,7 @@ ccl_device int 
bsdf_microfacet_ggx_isotropic_setup(ccl_private MicrofacetBsdf *b
 ccl_device int bsdf_microfacet_ggx_fresnel_setup(ccl_private MicrofacetBsdf 
*bsdf,
                                                  ccl_private const ShaderData 
*sd)
 {
-  bsdf->extra->cspec0 = saturate3(bsdf->extra->cspec0);
+  bsdf->extra->cspec0 = saturate(bsdf->extra->cspec0);
 
   bsdf->alpha_x = saturatef(bsdf->alpha_x);
   bsdf->alpha_y = saturatef(bsdf->alpha_y);
@@ -325,7 +325,7 @@ ccl_device int 
bsdf_microfacet_ggx_fresnel_setup(ccl_private MicrofacetBsdf *bsd
 ccl_device int bsdf_microfacet_ggx_clearcoat_setup(ccl_private MicrofacetBsdf 
*bsdf,
                                                    ccl_private const 
ShaderData *sd)
 {
-  bsdf->extra->cspec0 = saturate3(bsdf->extra->cspec0);
+  bsdf->extra->cspec0 = saturate(bsdf->extra->cspec0);
 
   bsdf->alpha_x = saturatef(bsdf->alpha_x);
   bsdf->alpha_y = bsdf->alpha_x;
diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi.h 
b/intern/cycles/kernel/closur

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to