From 0f2d0ff124c67d474a29406525953e63a659bb91 Mon Sep 17 00:00:00 2001 From: lazydodo Date: Tue, 25 Apr 2017 14:17:41 -0600 Subject: [PATCH] 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 --- intern/cycles/render/shader.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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& table) { table.resize(BECKMANN_TABLE_SIZE*BECKMANN_TABLE_SIZE);