[Bf-blender-cvs] [89d5714d8f2] master: Build: match GCC and Clang float conversion warnings in Cycles

Brecht Van Lommel noreply at git.blender.org
Wed Nov 17 18:25:38 CET 2021


Commit: 89d5714d8f233b4bbb83f6a7b33237e2ec04ee79
Author: Brecht Van Lommel
Date:   Wed Nov 17 17:22:05 2021 +0100
Branches: master
https://developer.blender.org/rB89d5714d8f233b4bbb83f6a7b33237e2ec04ee79

Build: match GCC and Clang float conversion warnings in Cycles

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

M	intern/cycles/CMakeLists.txt
M	intern/cycles/blender/sync.cpp
M	intern/cycles/bvh/embree.cpp
M	intern/cycles/scene/mesh_subdivision.cpp
M	intern/cycles/util/math.h
M	intern/cycles/util/progress.h

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

diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 64fe70c886d..6ba80bf9e18 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -334,16 +334,13 @@ else()
 endif()
 
 # Warnings
-if(CMAKE_COMPILER_IS_GNUCXX)
+if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
   ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_cxxflag_float_conversion "-Werror=float-conversion")
   ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_cxxflag_double_promotion "-Werror=double-promotion")
   ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_no_error_unused_macros "-Wno-error=unused-macros")
   unset(_has_cxxflag_float_conversion)
   unset(_has_cxxflag_double_promotion)
   unset(_has_no_error_unused_macros)
-elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
-  ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS _has_cxxflag_implicit_float_conversion "-Werror=implicit-float-conversion")
-  unset(_has_cxxflag_implicit_float_conversion)
 endif()
 
 if(WITH_CYCLES_CUDA_BINARIES AND (NOT WITH_CYCLES_CUBIN_COMPILER))
diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp
index 59d684dcf05..76118fdc6b7 100644
--- a/intern/cycles/blender/sync.cpp
+++ b/intern/cycles/blender/sync.cpp
@@ -872,7 +872,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine &b_engine,
 
   /* Time limit. */
   if (background) {
-    params.time_limit = get_float(cscene, "time_limit");
+    params.time_limit = (double)get_float(cscene, "time_limit");
   }
   else {
     /* For the viewport it kind of makes more sense to think in terms of the noise floor, which is
diff --git a/intern/cycles/bvh/embree.cpp b/intern/cycles/bvh/embree.cpp
index 944a84ce0da..b54b38f2798 100644
--- a/intern/cycles/bvh/embree.cpp
+++ b/intern/cycles/bvh/embree.cpp
@@ -303,7 +303,7 @@ static void rtc_error_func(void *, enum RTCError, const char *str)
   VLOG(1) << str;
 }
 
-static double progress_start_time = 0.0f;
+static double progress_start_time = 0.0;
 
 static bool rtc_progress_func(void *user_ptr, const double n)
 {
diff --git a/intern/cycles/scene/mesh_subdivision.cpp b/intern/cycles/scene/mesh_subdivision.cpp
index a0c0bc68f8b..35f15cfafbc 100644
--- a/intern/cycles/scene/mesh_subdivision.cpp
+++ b/intern/cycles/scene/mesh_subdivision.cpp
@@ -331,7 +331,8 @@ struct OsdPatch : Patch {
 
   void eval(float3 *P, float3 *dPdu, float3 *dPdv, float3 *N, float u, float v)
   {
-    const Far::PatchTable::PatchHandle *handle = osd_data->patch_map->FindPatch(patch_index, u, v);
+    const Far::PatchTable::PatchHandle *handle = osd_data->patch_map->FindPatch(
+        patch_index, (double)u, (double)v);
     assert(handle);
 
     float p_weights[20], du_weights[20], dv_weights[20];
diff --git a/intern/cycles/util/math.h b/intern/cycles/util/math.h
index e4c7df6e44a..2e13eecd002 100644
--- a/intern/cycles/util/math.h
+++ b/intern/cycles/util/math.h
@@ -801,7 +801,7 @@ ccl_device_inline float2 map_to_sphere(const float3 co)
  * https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
  */
 
-ccl_device_inline float compare_floats(float a, float b, float abs_diff, int ulp_diff)
+ccl_device_inline bool compare_floats(float a, float b, float abs_diff, int ulp_diff)
 {
   if (fabsf(a - b) < abs_diff) {
     return true;
diff --git a/intern/cycles/util/progress.h b/intern/cycles/util/progress.h
index f2d80e49ab8..15bd26d34bf 100644
--- a/intern/cycles/util/progress.h
+++ b/intern/cycles/util/progress.h
@@ -207,7 +207,7 @@ class Progress {
     if (total_pixel_samples > 0) {
       return ((double)pixel_samples) / (double)total_pixel_samples;
     }
-    return 0.0f;
+    return 0.0;
   }
 
   void add_samples(uint64_t pixel_samples_, int tile_sample)



More information about the Bf-blender-cvs mailing list