[Bf-blender-cvs] [0f2d0ff124c] master: workaround for T50176

lazydodo noreply at git.blender.org
Tue Apr 25 22:21:52 CEST 2017


Commit: 0f2d0ff124c67d474a29406525953e63a659bb91
Author: lazydodo
Date:   Tue Apr 25 14:17:41 2017 -0600
Branches: master
https://developer.blender.org/rB0f2d0ff124c67d474a29406525953e63a659bb91

workaround for T50176

This works around a long outstanding issue T50176 with cycles on msvc2015/x86 . root cause is still unknown though,feels like a game of whack'a'mole

Reviewers: sergey, dingto

Subscribers: Blendify

Tags: #cycles

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

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

M	intern/cycles/render/shader.cpp

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

diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index a7d42a4b4a0..015d0fa087b 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -49,6 +49,16 @@ static float beckmann_table_slope_max()
 	return 6.0;
 }
 
+
+/* MSVC 2015 needs this ugly hack to prevent a codegen bug on x86
+ * see T50176 for details
+ */
+#if _MSC_VER==1900
+#  define MSVC_VOLATILE volatile  
+#else
+#  define MSVC_VOLATILE 
+#endif
+
 /* Paper used: Importance Sampling Microfacet-Based BSDFs with the
  * Distribution of Visible Normals. Supplemental Material 2/2.
  *
@@ -72,7 +82,7 @@ static void beckmann_table_rows(float *table, int row_from, int row_to)
 		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) {
+		for(MSVC_VOLATILE int index_slope_x = 1; index_slope_x < DATA_TMP_SIZE; ++index_slope_x) {
 			/* slope_x */
 			slope_x[index_slope_x] = (double)(-beckmann_table_slope_max() + 2.0f * beckmann_table_slope_max() * index_slope_x/(DATA_TMP_SIZE - 1.0f));
 
@@ -116,6 +126,8 @@ static void beckmann_table_rows(float *table, int row_from, int row_to)
 	}
 }
 
+#undef MSVC_VOLATILE
+
 static void beckmann_table_build(vector<float>& table)
 {
 	table.resize(BECKMANN_TABLE_SIZE*BECKMANN_TABLE_SIZE);




More information about the Bf-blender-cvs mailing list