[Bf-blender-cvs] [768ebb0] compositor-2016: Fix Cycles compile errors with GCC due to double promotion as errors.

Brecht Van Lommel noreply at git.blender.org
Wed Jun 8 21:49:15 CEST 2016


Commit: 768ebb0433b028b66fc24b609b8ea89b580d5bd2
Author: Brecht Van Lommel
Date:   Sun May 22 19:11:26 2016 +0200
Branches: compositor-2016
https://developer.blender.org/rB768ebb0433b028b66fc24b609b8ea89b580d5bd2

Fix Cycles compile errors with GCC due to double promotion as errors.

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

M	intern/cycles/blender/blender_sync.cpp
M	intern/cycles/device/device_cuda.cpp
M	intern/cycles/graph/node_xml.cpp
M	intern/cycles/render/nodes.cpp
M	intern/cycles/render/shader.cpp
M	intern/cycles/util/util_progress.h
M	intern/cycles/util/util_sky_model.cpp
M	intern/cycles/util/util_transform.cpp
M	intern/cycles/util/util_view.cpp

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

diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 00f9f58..33084f1 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -627,9 +627,9 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
 	else
 		params.threads = 0;
 
-	params.cancel_timeout = get_float(cscene, "debug_cancel_timeout");
-	params.reset_timeout = get_float(cscene, "debug_reset_timeout");
-	params.text_timeout = get_float(cscene, "debug_text_timeout");
+	params.cancel_timeout = (double)get_float(cscene, "debug_cancel_timeout");
+	params.reset_timeout = (double)get_float(cscene, "debug_reset_timeout");
+	params.text_timeout = (double)get_float(cscene, "debug_text_timeout");
 
 	params.progressive_refine = get_boolean(cscene, "use_progressive_refine");
 
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 7fc6213..9a78d05 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -812,8 +812,8 @@ public:
 		printf("threads_per_block %d\n", threads_per_block);
 		printf("num_registers %d\n", num_registers);*/
 
-		int xthreads = (int)sqrt((float)threads_per_block);
-		int ythreads = (int)sqrt((float)threads_per_block);
+		int xthreads = (int)sqrt(threads_per_block);
+		int ythreads = (int)sqrt(threads_per_block);
 		int xblocks = (rtile.w + xthreads - 1)/xthreads;
 		int yblocks = (rtile.h + ythreads - 1)/ythreads;
 
@@ -866,8 +866,8 @@ public:
 		int threads_per_block;
 		cuda_assert(cuFuncGetAttribute(&threads_per_block, CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK, cuFilmConvert));
 
-		int xthreads = (int)sqrt((float)threads_per_block);
-		int ythreads = (int)sqrt((float)threads_per_block);
+		int xthreads = (int)sqrt(threads_per_block);
+		int ythreads = (int)sqrt(threads_per_block);
 		int xblocks = (task.w + xthreads - 1)/xthreads;
 		int yblocks = (task.h + ythreads - 1)/ythreads;
 
diff --git a/intern/cycles/graph/node_xml.cpp b/intern/cycles/graph/node_xml.cpp
index 6a85c66..fe06a24 100644
--- a/intern/cycles/graph/node_xml.cpp
+++ b/intern/cycles/graph/node_xml.cpp
@@ -281,7 +281,7 @@ pugi::xml_node xml_write_node(Node *node, pugi::xml_node xml_root)
 			}
 			case SocketType::FLOAT:
 			{
-				attr = node->get_float(socket);
+				attr = (double)node->get_float(socket);
 				break;
 			}
 			case SocketType::FLOAT_ARRAY:
@@ -321,7 +321,7 @@ pugi::xml_node xml_write_node(Node *node, pugi::xml_node xml_root)
 			case SocketType::NORMAL:
 			{
 				float3 value = node->get_float3(socket);
-				attr = string_printf("%g %g %g", value.x, value.y, value.z).c_str();
+				attr = string_printf("%g %g %g", (double)value.x, (double)value.y, (double)value.z).c_str();
 				break;
 			}
 			case SocketType::COLOR_ARRAY:
@@ -332,7 +332,7 @@ pugi::xml_node xml_write_node(Node *node, pugi::xml_node xml_root)
 				std::stringstream ss;
 				const array<float3>& value = node->get_float3_array(socket);
 				for(size_t i = 0; i < value.size(); i++) {
-					ss << string_printf("%g %g %g", value[i].x, value[i].y, value[i].z);
+					ss << string_printf("%g %g %g", (double)value[i].x, (double)value[i].y, (double)value[i].z);
 					if(i != value.size() - 1) {
 						ss << " ";
 					}
@@ -343,7 +343,7 @@ pugi::xml_node xml_write_node(Node *node, pugi::xml_node xml_root)
 			case SocketType::POINT2:
 			{
 				float2 value = node->get_float2(socket);
-				attr = string_printf("%g %g", value.x, value.y).c_str();
+				attr = string_printf("%g %g", (double)value.x, (double)value.y).c_str();
 				break;
 			}
 			case SocketType::POINT2_ARRAY:
@@ -351,7 +351,7 @@ pugi::xml_node xml_write_node(Node *node, pugi::xml_node xml_root)
 				std::stringstream ss;
 				const array<float2>& value = node->get_float2_array(socket);
 				for(size_t i = 0; i < value.size(); i++) {
-					ss << string_printf("%g %g", value[i].x, value[i].y);
+					ss << string_printf("%g %g", (double)value[i].x, (double)value[i].y);
 					if(i != value.size() - 1) {
 						ss << " ";
 					}
@@ -383,7 +383,7 @@ pugi::xml_node xml_write_node(Node *node, pugi::xml_node xml_root)
 				Transform tfm = node->get_transform(socket);
 				std::stringstream ss;
 				for(int i = 0; i < 4; i++) {
-					ss << string_printf("%g %g %g %g", tfm[i][0], tfm[i][1], tfm[i][2], tfm[i][3]);
+					ss << string_printf("%g %g %g %g", (double)tfm[i][0], (double)tfm[i][1], (double)tfm[i][2], (double)tfm[i][3]);
 					if(i != 3) {
 						ss << " ";
 					}
@@ -399,7 +399,7 @@ pugi::xml_node xml_write_node(Node *node, pugi::xml_node xml_root)
 					const Transform& tfm = value[j];
 
 					for(int i = 0; i < 4; i++) {
-						ss << string_printf("%g %g %g %g", tfm[i][0], tfm[i][1], tfm[i][2], tfm[i][3]);
+						ss << string_printf("%g %g %g %g", (double)tfm[i][0], (double)tfm[i][1], (double)tfm[i][2], (double)tfm[i][3]);
 						if(j != value.size() - 1 || i != 3) {
 							ss << " ";
 						}
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 110bbca..998d9cf 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -718,11 +718,11 @@ static void sky_texture_precompute_new(SunSky *sunsky, float3 dir, float turbidi
 	sunsky->theta = theta;
 	sunsky->phi = phi;
 
-	double solarElevation = M_PI_2_F - theta;
+	float solarElevation = M_PI_2_F - theta;
 
 	/* Initialize Sky Model */
 	ArHosekSkyModelState *sky_state;
-	sky_state = arhosek_xyz_skymodelstate_alloc_init(turbidity, ground_albedo, solarElevation);
+	sky_state = arhosek_xyz_skymodelstate_alloc_init((double)turbidity, (double)ground_albedo, (double)solarElevation);
 
 	/* Copy values from sky_state to SunSky */
 	for(int i = 0; i < 9; ++i) {
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index b140af6..635024d 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -69,12 +69,12 @@ static void beckmann_table_rows(float *table, int row_from, int row_to)
 
 		/* for a given incident vector
 		 * integrate P22_{omega_i}(x_slope, 1, 1), Eq. (10) */
-		slope_x[0] = -beckmann_table_slope_max();
+		slope_x[0] = (double)-beckmann_table_slope_max();
 		CDF_P22_omega_i[0] = 0;
 
 		for(int index_slope_x = 1; index_slope_x < DATA_TMP_SIZE; ++index_slope_x) {
 			/* slope_x */
-			slope_x[index_slope_x] = -beckmann_table_slope_max() + 2.0f * beckmann_table_slope_max() * index_slope_x/(DATA_TMP_SIZE - 1.0f);
+			slope_x[index_slope_x] = (double)(-beckmann_table_slope_max() + 2.0f * beckmann_table_slope_max() * index_slope_x/(DATA_TMP_SIZE - 1.0f));
 
 			/* dot product with incident vector */
 			float dot_product = fmaxf(0.0f, -(float)slope_x[index_slope_x]*sin_theta + cos_theta);
diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h
index 0b35142..4ae1d61 100644
--- a/intern/cycles/util/util_progress.h
+++ b/intern/cycles/util/util_progress.h
@@ -37,9 +37,9 @@ public:
 		tile = 0;
 		sample = 0;
 		start_time = time_dt();
-		total_time = 0.0f;
-		render_time = 0.0f;
-		tile_time = 0.0f;
+		total_time = 0.0;
+		render_time = 0.0;
+		tile_time = 0.0;
 		status = "Initializing";
 		substatus = "";
 		sync_status = "";
@@ -75,9 +75,9 @@ public:
 		sample = 0;
 		start_time = time_dt();
 		render_start_time = time_dt();
-		total_time = 0.0f;
-		render_time = 0.0f;
-		tile_time = 0.0f;
+		total_time = 0.0;
+		render_time = 0.0;
+		tile_time = 0.0;
 		status = "Initializing";
 		substatus = "";
 		sync_status = "";
diff --git a/intern/cycles/util/util_sky_model.cpp b/intern/cycles/util/util_sky_model.cpp
index a53c2ce..5730986 100644
--- a/intern/cycles/util/util_sky_model.cpp
+++ b/intern/cycles/util/util_sky_model.cpp
@@ -301,7 +301,7 @@ double arhosekskymodel_radiance(ArHosekSkyModelState  *state,
 	int low_wl = (int)((wavelength - 320.0) / 40.0);
 
 	if(low_wl < 0 || low_wl >= 11)
-		return 0.0f;
+		return 0.0;
 
 	double interp = fmod((wavelength - 320.0 ) / 40.0, 1.0);
 
diff --git a/intern/cycles/util/util_transform.cpp b/intern/cycles/util/util_transform.cpp
index 79e1137..2f10540 100644
--- a/intern/cycles/util/util_transform.cpp
+++ b/intern/cycles/util/util_transform.cpp
@@ -158,7 +158,7 @@ Transform transform_inverse(const Transform& tfm)
 
 float4 transform_to_quat(const Transform& tfm)
 {
-	double trace = tfm[0][0] + tfm[1][1] + tfm[2][2];
+	double trace = (double)(tfm[0][0] + tfm[1][1] + tfm[2][2]);
 	float4 qt;
 
 	if(trace > 0.0) {
diff --git a/intern/cycles/util/util_view.cpp b/intern/cycles/util/util_view.cpp
index 4d2adf3..9796a5f 100644
--- a/intern/cycles/util/util_view.cpp
+++ b/intern/cycles/util/util_view.cpp
@@ -222,7 +222,7 @@ static void view_idle(void)
 		glutPostRedisplay();
 	}
 
-	time_sleep(0.1f);
+	time_sleep(0.1);
 }
 
 void view_main_loop(const char *title, int width, int height,




More information about the Bf-blender-cvs mailing list