Cleanup: use make_float4(f) zero_float4() to simplify code

Differential Revision: https://developer.blender.org/D14426
This commit is contained in:
Ethan-Hall 2022-03-23 15:53:10 +01:00 committed by Brecht Van Lommel
parent 4e56e738a8
commit f5066d43ae
17 changed files with 56 additions and 56 deletions

View File

@ -422,7 +422,7 @@ static float4 lookup_instance_property(BL::DepsgraphObjectInstance &b_instance,
return value;
}
return make_float4(0.0f);
return zero_float4();
}
bool BlenderSync::sync_object_attributes(BL::DepsgraphObjectInstance &b_instance, Object *object)

View File

@ -203,7 +203,7 @@ BVHObjectBinning::BVHObjectBinning(const BVHRange &job,
bestSAH = min(sah, bestSAH);
}
int4 mask = float3_to_float4(cent_bounds_.size()) <= make_float4(0.0f);
int4 mask = float3_to_float4(cent_bounds_.size()) <= zero_float4();
bestSAH = insert<3>(select(mask, make_float4(FLT_MAX), bestSAH), FLT_MAX);
/* find best dimension */

View File

@ -220,7 +220,7 @@ ccl_device_inline void hair_attenuation(KernelGlobals kg,
ccl_private float4 *Ap)
{
/* Primary specular (R). */
Ap[0] = make_float4(f, f, f, f);
Ap[0] = make_float4(f);
/* Transmission (TT). */
float3 col = sqr(1.0f - f) * T;

View File

@ -451,7 +451,7 @@ ccl_device_inline float4 film_calculate_shadow_catcher_matte_with_shadow(
float scale, scale_exposure;
if (!film_get_scale_and_scale_exposure(kfilm_convert, buffer, &scale, &scale_exposure)) {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
return zero_float4();
}
ccl_global const float *in_matte = buffer + kfilm_convert->pass_shadow_catcher_matte;

View File

@ -164,7 +164,7 @@ ccl_device float4 curve_attribute_float4(KernelGlobals kg,
if (dx)
*dx = sd->du.dx * (f1 - f0);
if (dy)
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dy = zero_float4();
# endif
return (1.0f - sd->u) * f0 + sd->u * f1;
@ -172,9 +172,9 @@ ccl_device float4 curve_attribute_float4(KernelGlobals kg,
else {
# ifdef __RAY_DIFFERENTIALS__
if (dx)
*dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dx = zero_float4();
if (dy)
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dy = zero_float4();
# endif
if (desc.element & (ATTR_ELEMENT_CURVE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) {
@ -183,7 +183,7 @@ ccl_device float4 curve_attribute_float4(KernelGlobals kg,
return kernel_tex_fetch(__attributes_float4, offset);
}
else {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
return zero_float4();
}
}
}

View File

@ -391,11 +391,11 @@ ccl_device float4 patch_eval_float4(KernelGlobals kg,
int num_control = patch_eval_control_verts(
kg, sd->object, patch, u, v, channel, indices, weights, weights_du, weights_dv);
float4 val = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 val = zero_float4();
if (du)
*du = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*du = zero_float4();
if (dv)
*dv = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dv = zero_float4();
for (int i = 0; i < num_control; i++) {
float4 v = kernel_tex_fetch(__attributes_float4, offset + indices[i]);
@ -428,11 +428,11 @@ ccl_device float4 patch_eval_uchar4(KernelGlobals kg,
int num_control = patch_eval_control_verts(
kg, sd->object, patch, u, v, channel, indices, weights, weights_du, weights_dv);
float4 val = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 val = zero_float4();
if (du)
*du = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*du = zero_float4();
if (dv)
*dv = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dv = zero_float4();
for (int i = 0; i < num_control; i++) {
float4 v = color_srgb_to_linear_v4(

View File

@ -83,16 +83,16 @@ ccl_device float4 point_attribute_float4(KernelGlobals kg,
{
# ifdef __RAY_DIFFERENTIALS__
if (dx)
*dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dx = zero_float4();
if (dy)
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dy = zero_float4();
# endif
if (desc.element == ATTR_ELEMENT_VERTEX) {
return kernel_tex_fetch(__attributes_float4, desc.offset + sd->prim);
}
else {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
return zero_float4();
}
}

View File

@ -135,10 +135,10 @@ ccl_device_forceinline float4 primitive_surface_attribute_float4(KernelGlobals k
#endif
else {
if (dx)
*dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dx = zero_float4();
if (dy)
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dy = zero_float4();
return zero_float4();
}
}
@ -187,7 +187,7 @@ ccl_device_inline float4 primitive_volume_attribute_float4(KernelGlobals kg,
return volume_attribute_float4(kg, sd, desc);
}
else {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
return zero_float4();
}
}
#endif

View File

@ -566,9 +566,9 @@ ccl_device_noinline float4 subd_triangle_attribute_float4(KernelGlobals kg,
#endif /* __PATCH_EVAL__ */
if (desc.element == ATTR_ELEMENT_FACE) {
if (dx)
*dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dx = zero_float4();
if (dy)
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dy = zero_float4();
return kernel_tex_fetch(__attributes_float4,
desc.offset + subd_triangle_patch_face(kg, patch));
@ -648,19 +648,19 @@ ccl_device_noinline float4 subd_triangle_attribute_float4(KernelGlobals kg,
}
else if (desc.element == ATTR_ELEMENT_OBJECT || desc.element == ATTR_ELEMENT_MESH) {
if (dx)
*dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dx = zero_float4();
if (dy)
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dy = zero_float4();
return kernel_tex_fetch(__attributes_float4, desc.offset);
}
else {
if (dx)
*dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dx = zero_float4();
if (dy)
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dy = zero_float4();
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
return zero_float4();
}
}

View File

@ -338,9 +338,9 @@ ccl_device float4 triangle_attribute_float4(KernelGlobals kg,
else {
#ifdef __RAY_DIFFERENTIALS__
if (dx)
*dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dx = zero_float4();
if (dy)
*dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
*dy = zero_float4();
#endif
if (desc.element & (ATTR_ELEMENT_FACE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) {
@ -349,7 +349,7 @@ ccl_device float4 triangle_attribute_float4(KernelGlobals kg,
return kernel_tex_fetch(__attributes_float4, offset);
}
else {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
return zero_float4();
}
}
}

View File

@ -75,7 +75,7 @@ ccl_device float4 volume_attribute_float4(KernelGlobals kg,
return kernel_tex_image_interp_3d(kg, desc.offset, P, interp);
}
else {
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
return zero_float4();
}
}

View File

@ -595,8 +595,8 @@ static bool set_attribute_float4(float4 f, TypeDesc type, bool derivatives, void
float4 fv[3];
fv[0] = f;
fv[1] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
fv[2] = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
fv[1] = zero_float4();
fv[2] = zero_float4();
return set_attribute_float4(fv, type, derivatives, val);
}

View File

@ -186,7 +186,7 @@ ccl_device_noinline void svm_node_tex_image_box(KernelGlobals kg,
float3 co = stack_load_float3(stack, co_offset);
uint id = node.y;
float4 f = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 f = zero_float4();
/* Map so that no textures are flipped, rotation is somewhat arbitrary. */
if (weight.x > 0.0f) {

View File

@ -684,8 +684,8 @@ ccl_device void voronoi_f1_4d(float4 coord,
float4 localPosition = coord - cellPosition;
float minDistance = 8.0f;
float4 targetOffset = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 targetPosition = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 targetOffset = zero_float4();
float4 targetPosition = zero_float4();
for (int u = -1; u <= 1; u++) {
for (int k = -1; k <= 1; k++) {
ccl_loop_no_unroll for (int j = -1; j <= 1; j++)
@ -724,7 +724,7 @@ ccl_device void voronoi_smooth_f1_4d(float4 coord,
float smoothDistance = 8.0f;
float3 smoothColor = make_float3(0.0f, 0.0f, 0.0f);
float4 smoothPosition = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 smoothPosition = zero_float4();
for (int u = -2; u <= 2; u++) {
for (int k = -2; k <= 2; k++) {
ccl_loop_no_unroll for (int j = -2; j <= 2; j++)
@ -765,10 +765,10 @@ ccl_device void voronoi_f2_4d(float4 coord,
float distanceF1 = 8.0f;
float distanceF2 = 8.0f;
float4 offsetF1 = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 positionF1 = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 offsetF2 = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 positionF2 = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 offsetF1 = zero_float4();
float4 positionF1 = zero_float4();
float4 offsetF2 = zero_float4();
float4 positionF2 = zero_float4();
for (int u = -1; u <= 1; u++) {
for (int k = -1; k <= 1; k++) {
ccl_loop_no_unroll for (int j = -1; j <= 1; j++)
@ -808,7 +808,7 @@ ccl_device void voronoi_distance_to_edge_4d(float4 coord,
float4 cellPosition = floor(coord);
float4 localPosition = coord - cellPosition;
float4 vectorToClosest = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 vectorToClosest = zero_float4();
float minDistance = 8.0f;
for (int u = -1; u <= 1; u++) {
for (int k = -1; k <= 1; k++) {
@ -859,8 +859,8 @@ ccl_device void voronoi_n_sphere_radius_4d(float4 coord,
float4 cellPosition = floor(coord);
float4 localPosition = coord - cellPosition;
float4 closestPoint = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 closestPointOffset = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 closestPoint = zero_float4();
float4 closestPointOffset = zero_float4();
float minDistance = 8.0f;
for (int u = -1; u <= 1; u++) {
for (int k = -1; k <= 1; k++) {
@ -882,7 +882,7 @@ ccl_device void voronoi_n_sphere_radius_4d(float4 coord,
}
minDistance = 8.0f;
float4 closestPointToClosestPoint = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 closestPointToClosestPoint = zero_float4();
for (int u = -1; u <= 1; u++) {
for (int k = -1; k <= 1; k++) {
ccl_loop_no_unroll for (int j = -1; j <= 1; j++)

View File

@ -30,7 +30,7 @@ ccl_device_noinline int svm_node_tex_voxel(
float4 r = kernel_tex_image_interp_3d(kg, id, co, INTERPOLATION_NONE);
#else
float4 r = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 r = zero_float4();
#endif
if (stack_valid(density_out_offset))
stack_store_float(stack, density_out_offset, r.w);

View File

@ -90,13 +90,13 @@ ccl_device_inline float4 zero_float4()
#ifdef __KERNEL_SSE__
return float4(_mm_setzero_ps());
#else
return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
return make_float4(0.0f);
#endif
}
ccl_device_inline float4 one_float4()
{
return make_float4(1.0f, 1.0f, 1.0f, 1.0f);
return make_float4(1.0f);
}
#if !defined(__KERNEL_METAL__)
@ -149,7 +149,7 @@ ccl_device_inline float4 operator/(const float4 &a, const float4 &b)
ccl_device_inline float4 operator+(const float4 &a, const float f)
{
return a + make_float4(f, f, f, f);
return a + make_float4(f);
}
ccl_device_inline float4 operator+(const float4 &a, const float4 &b)
@ -163,7 +163,7 @@ ccl_device_inline float4 operator+(const float4 &a, const float4 &b)
ccl_device_inline float4 operator-(const float4 &a, const float f)
{
return a - make_float4(f, f, f, f);
return a - make_float4(f);
}
ccl_device_inline float4 operator-(const float4 &a, const float4 &b)
@ -297,7 +297,7 @@ ccl_device_inline float4 cross(const float4 &a, const float4 &b)
ccl_device_inline bool is_zero(const float4 &a)
{
# ifdef __KERNEL_SSE__
return a == make_float4(0.0f);
return a == zero_float4();
# else
return (a.x == 0.0f && a.y == 0.0f && a.z == 0.0f && a.w == 0.0f);
# endif
@ -317,7 +317,7 @@ ccl_device_inline float4 reduce_add(const float4 &a)
# endif
# else
float sum = (a.x + a.y) + (a.z + a.w);
return make_float4(sum, sum, sum, sum);
return make_float4(sum);
# endif
}
@ -458,7 +458,7 @@ ccl_device_inline float4 select(const int4 &mask, const float4 &a, const float4
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
{
/* Replace elements of x with zero where mask isn't set. */
return select(mask, a, make_float4(0.0f));
return select(mask, a, zero_float4());
}
ccl_device_inline float4 reduce_min(const float4 &a)

View File

@ -376,7 +376,7 @@ ccl_device void math_matrix_jacobi_eigendecomposition(ccl_private float *A,
ccl_device_inline void math_vector_zero_sse(float4 *A, int n)
{
for (int i = 0; i < n; i++) {
A[i] = make_float4(0.0f);
A[i] = zero_float4();
}
}
@ -384,7 +384,7 @@ ccl_device_inline void math_matrix_zero_sse(float4 *A, int n)
{
for (int row = 0; row < n; row++) {
for (int col = 0; col <= row; col++) {
MAT(A, n, row, col) = make_float4(0.0f);
MAT(A, n, row, col) = zero_float4();
}
}
}