From c637e749b2bab67f9ce27937cf0430965cacc907 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 7 Apr 2017 16:06:05 +0200 Subject: [PATCH 01/13] Tests: Fix compilation error with static OpenMP --- build_files/cmake/Modules/GTestTesting.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build_files/cmake/Modules/GTestTesting.cmake b/build_files/cmake/Modules/GTestTesting.cmake index 0732e10133c..e688db35ef1 100644 --- a/build_files/cmake/Modules/GTestTesting.cmake +++ b/build_files/cmake/Modules/GTestTesting.cmake @@ -39,6 +39,9 @@ macro(BLENDER_SRC_GTEST_EX NAME SRC EXTRA_LIBS DO_ADD_TEST) ${PTHREADS_LIBRARIES} extern_glog extern_gflags) + if(WITH_OPENMP_STATIC) + target_link_libraries(${NAME}_test ${OpenMP_LIBRARIES}) + endif() set_target_properties(${NAME}_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTS_OUTPUT_DIR}" RUNTIME_OUTPUT_DIRECTORY_RELEASE "${TESTS_OUTPUT_DIR}" From 4360a74715c635b7dd6c5a5cb76e4679fb6d5e42 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 7 Apr 2017 17:00:06 +0200 Subject: [PATCH 02/13] CMake: Fix detection of idiff program --- build_files/cmake/Modules/FindOpenImageIO.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_files/cmake/Modules/FindOpenImageIO.cmake b/build_files/cmake/Modules/FindOpenImageIO.cmake index 789097dfd51..d59f9cfcdfc 100644 --- a/build_files/cmake/Modules/FindOpenImageIO.cmake +++ b/build_files/cmake/Modules/FindOpenImageIO.cmake @@ -60,7 +60,7 @@ FIND_FILE(OPENIMAGEIO_IDIFF NAMES idiff HINTS - ${OPENIMAGEIO_ROOT_DIR} + ${_openimageio_SEARCH_DIRS} PATH_SUFFIXES bin ) From 07708b85b4e903ea1be82d82396285c2518e1b3a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 7 Apr 2017 17:00:43 +0200 Subject: [PATCH 03/13] Buildbot: Link statically against freetype --- build_files/buildbot/config/blender_linux.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build_files/buildbot/config/blender_linux.cmake b/build_files/buildbot/config/blender_linux.cmake index ed5417c1c6e..45b327f8aeb 100644 --- a/build_files/buildbot/config/blender_linux.cmake +++ b/build_files/buildbot/config/blender_linux.cmake @@ -94,6 +94,10 @@ set(OPENCOLORIO_OPENCOLORIO_LIBRARY "${OPENCOLORIO_ROOT_DIR}/lib/libOpenColorIO. set(OPENCOLORIO_TINYXML_LIBRARY "${OPENCOLORIO_ROOT_DIR}/lib/libtinyxml.a" CACHE STRING "" FORCE) set(OPENCOLORIO_YAML-CPP_LIBRARY "${OPENCOLORIO_ROOT_DIR}/lib/libyaml-cpp.a" CACHE STRING "" FORCE) +# Freetype +set(FREETYPE_INCLUDE_DIRS "/usr/include/freetype2" CACHE STRING "" FORCE) +set(FREETYPE_LIBRARY "/usr/lib${MULTILIB}/libfreetype.a" CACHE STRING "" FORCE) + # OpenImageIO if(GLIBC EQUAL "2.19") set(OPENIMAGEIO_LIBRARY From eae691f89e3cb584047196b15c6e75eaea287dcc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 7 Apr 2017 17:01:07 +0200 Subject: [PATCH 04/13] Buildbot: List freetype for OIIO libraries OIIO in release environment is compiled with Freetype support. This fixes compilation error of static unit tests. --- build_files/buildbot/config/blender_linux.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/build_files/buildbot/config/blender_linux.cmake b/build_files/buildbot/config/blender_linux.cmake index 45b327f8aeb..56f18967300 100644 --- a/build_files/buildbot/config/blender_linux.cmake +++ b/build_files/buildbot/config/blender_linux.cmake @@ -106,6 +106,7 @@ if(GLIBC EQUAL "2.19") /usr/lib${MULTILIB}/libwebp.a /usr/lib${MULTILIB}/liblzma.a /usr/lib${MULTILIB}/libjbig.a + ${FREETYPE_LIBRARY} CACHE STRING "" FORCE ) endif() From a1f8755d32d547190f781fa162a80fbd210b9671 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 7 Apr 2017 17:10:44 +0200 Subject: [PATCH 05/13] Libmv: Fix crash of keyframe selection on 32bit linux --- intern/libmv/libmv/multiview/homography.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/libmv/libmv/multiview/homography.cc b/intern/libmv/libmv/multiview/homography.cc index ce533a3ead2..a7679c33bbf 100644 --- a/intern/libmv/libmv/multiview/homography.cc +++ b/intern/libmv/libmv/multiview/homography.cc @@ -209,8 +209,8 @@ class HomographySymmetricGeometricCostFunctor { return true; } - const Vec2 x_; - const Vec2 y_; + const Vec2 &x_; + const Vec2 &y_; }; // Termination checking callback used for homography estimation. From 8e0cdfd0c916e30b1496d0632e824042e9406cd5 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 7 Apr 2017 17:57:48 +0200 Subject: [PATCH 06/13] Libmv: Correction to previous commit We do need to make a copy of the values. --- intern/libmv/libmv/multiview/homography.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/intern/libmv/libmv/multiview/homography.cc b/intern/libmv/libmv/multiview/homography.cc index a7679c33bbf..69177743f94 100644 --- a/intern/libmv/libmv/multiview/homography.cc +++ b/intern/libmv/libmv/multiview/homography.cc @@ -209,8 +209,10 @@ class HomographySymmetricGeometricCostFunctor { return true; } - const Vec2 &x_; - const Vec2 &y_; + EIGEN_MAKE_ALIGNED_OPERATOR_NEW + + const Vec2 x_; + const Vec2 y_; }; // Termination checking callback used for homography estimation. From b332fc8f23c9995923abbf526e67517f1a26f073 Mon Sep 17 00:00:00 2001 From: lazydodo Date: Fri, 7 Apr 2017 10:25:54 -0600 Subject: [PATCH 07/13] [Cycles/msvc] Get cycles_kernel compile time under control. Ever since we merged the extra texture types (half etc) and spit kernel the compile time for cycles_kernel has been going out of control. It's currently sitting at a cool 1295.762 seconds with our standard compiler (2013/x64/release) I'm not entirely sure why msvc gets upset with it, but the inlining of matrix near the bottom of the tri-cubic 3d interpolator is the source of the issue, this patch excludes it from being inlined. This patch bring it back down to a manageable 186 seconds. (7x faster!!) with the attached bzzt.blend that @sergey kindly provided i got the following results with builds with identical hashes 58:51.73 buildbot 58:04.23 Patched it's really close, the slight speedup could be explained by the switch instead of having multiple if's (switches do generate more optimal code than a chain of if/else/if/else statements) but in all honesty it might just have been pure luck (dev box,very polluted, bad for benchmarks) regardless, this patch doesn't seem to slow down anything with my limited testing. {F532336} {F532337} Reviewers: brecht, lukasstockner97, juicyfruit, dingto, sergey Reviewed By: brecht, dingto, sergey Subscribers: InsigMathK, sergey Tags: #cycles Differential Revision: https://developer.blender.org/D2595 --- intern/cycles/kernel/kernel_compat_cpu.h | 317 ++++++++++++----------- intern/cycles/util/util_types.h | 2 + 2 files changed, 170 insertions(+), 149 deletions(-) diff --git a/intern/cycles/kernel/kernel_compat_cpu.h b/intern/cycles/kernel/kernel_compat_cpu.h index ae7c9b836c4..cad5f4d2959 100644 --- a/intern/cycles/kernel/kernel_compat_cpu.h +++ b/intern/cycles/kernel/kernel_compat_cpu.h @@ -316,184 +316,203 @@ template struct texture_image { return interp_3d_ex(x, y, z, interpolation); } - ccl_always_inline float4 interp_3d_ex(float x, float y, float z, - int interpolation = INTERPOLATION_LINEAR) + ccl_always_inline float4 interp_3d_ex_closest(float x, float y, float z) { - if(UNLIKELY(!data)) - return make_float4(0.0f, 0.0f, 0.0f, 0.0f); + int ix, iy, iz; + frac(x*(float)width, &ix); + frac(y*(float)height, &iy); + frac(z*(float)depth, &iz); - int ix, iy, iz, nix, niy, niz; - - if(interpolation == INTERPOLATION_CLOSEST) { - frac(x*(float)width, &ix); - frac(y*(float)height, &iy); - frac(z*(float)depth, &iz); - - switch(extension) { - case EXTENSION_REPEAT: - ix = wrap_periodic(ix, width); - iy = wrap_periodic(iy, height); - iz = wrap_periodic(iz, depth); - break; - case EXTENSION_CLIP: - if(x < 0.0f || y < 0.0f || z < 0.0f || - x > 1.0f || y > 1.0f || z > 1.0f) - { - return make_float4(0.0f, 0.0f, 0.0f, 0.0f); - } - /* Fall through. */ - case EXTENSION_EXTEND: - ix = wrap_clamp(ix, width); - iy = wrap_clamp(iy, height); - iz = wrap_clamp(iz, depth); - break; - default: - kernel_assert(0); + switch(extension) { + case EXTENSION_REPEAT: + ix = wrap_periodic(ix, width); + iy = wrap_periodic(iy, height); + iz = wrap_periodic(iz, depth); + break; + case EXTENSION_CLIP: + if(x < 0.0f || y < 0.0f || z < 0.0f || + x > 1.0f || y > 1.0f || z > 1.0f) + { return make_float4(0.0f, 0.0f, 0.0f, 0.0f); - } - - return read(data[ix + iy*width + iz*width*height]); + } + /* Fall through. */ + case EXTENSION_EXTEND: + ix = wrap_clamp(ix, width); + iy = wrap_clamp(iy, height); + iz = wrap_clamp(iz, depth); + break; + default: + kernel_assert(0); + return make_float4(0.0f, 0.0f, 0.0f, 0.0f); } - else if(interpolation == INTERPOLATION_LINEAR) { - float tx = frac(x*(float)width - 0.5f, &ix); - float ty = frac(y*(float)height - 0.5f, &iy); - float tz = frac(z*(float)depth - 0.5f, &iz); - switch(extension) { - case EXTENSION_REPEAT: - ix = wrap_periodic(ix, width); - iy = wrap_periodic(iy, height); - iz = wrap_periodic(iz, depth); + return read(data[ix + iy*width + iz*width*height]); + } - nix = wrap_periodic(ix+1, width); - niy = wrap_periodic(iy+1, height); - niz = wrap_periodic(iz+1, depth); - break; - case EXTENSION_CLIP: - if(x < 0.0f || y < 0.0f || z < 0.0f || - x > 1.0f || y > 1.0f || z > 1.0f) - { - return make_float4(0.0f, 0.0f, 0.0f, 0.0f); - } - /* Fall through. */ - case EXTENSION_EXTEND: - nix = wrap_clamp(ix+1, width); - niy = wrap_clamp(iy+1, height); - niz = wrap_clamp(iz+1, depth); + ccl_always_inline float4 interp_3d_ex_linear(float x, float y, float z) + { + int ix, iy, iz; + int nix, niy, niz; + + float tx = frac(x*(float)width - 0.5f, &ix); + float ty = frac(y*(float)height - 0.5f, &iy); + float tz = frac(z*(float)depth - 0.5f, &iz); - ix = wrap_clamp(ix, width); - iy = wrap_clamp(iy, height); - iz = wrap_clamp(iz, depth); - break; - default: - kernel_assert(0); + switch(extension) { + case EXTENSION_REPEAT: + ix = wrap_periodic(ix, width); + iy = wrap_periodic(iy, height); + iz = wrap_periodic(iz, depth); + + nix = wrap_periodic(ix+1, width); + niy = wrap_periodic(iy+1, height); + niz = wrap_periodic(iz+1, depth); + break; + case EXTENSION_CLIP: + if(x < 0.0f || y < 0.0f || z < 0.0f || + x > 1.0f || y > 1.0f || z > 1.0f) + { return make_float4(0.0f, 0.0f, 0.0f, 0.0f); - } + } + /* Fall through. */ + case EXTENSION_EXTEND: + nix = wrap_clamp(ix+1, width); + niy = wrap_clamp(iy+1, height); + niz = wrap_clamp(iz+1, depth); - float4 r; - - r = (1.0f - tz)*(1.0f - ty)*(1.0f - tx)*read(data[ix + iy*width + iz*width*height]); - r += (1.0f - tz)*(1.0f - ty)*tx*read(data[nix + iy*width + iz*width*height]); - r += (1.0f - tz)*ty*(1.0f - tx)*read(data[ix + niy*width + iz*width*height]); - r += (1.0f - tz)*ty*tx*read(data[nix + niy*width + iz*width*height]); - - r += tz*(1.0f - ty)*(1.0f - tx)*read(data[ix + iy*width + niz*width*height]); - r += tz*(1.0f - ty)*tx*read(data[nix + iy*width + niz*width*height]); - r += tz*ty*(1.0f - tx)*read(data[ix + niy*width + niz*width*height]); - r += tz*ty*tx*read(data[nix + niy*width + niz*width*height]); - - return r; + ix = wrap_clamp(ix, width); + iy = wrap_clamp(iy, height); + iz = wrap_clamp(iz, depth); + break; + default: + kernel_assert(0); + return make_float4(0.0f, 0.0f, 0.0f, 0.0f); } - else { - /* Tricubic b-spline interpolation. */ - const float tx = frac(x*(float)width - 0.5f, &ix); - const float ty = frac(y*(float)height - 0.5f, &iy); - const float tz = frac(z*(float)depth - 0.5f, &iz); - int pix, piy, piz, nnix, nniy, nniz; - switch(extension) { - case EXTENSION_REPEAT: - ix = wrap_periodic(ix, width); - iy = wrap_periodic(iy, height); - iz = wrap_periodic(iz, depth); + float4 r; - pix = wrap_periodic(ix-1, width); - piy = wrap_periodic(iy-1, height); - piz = wrap_periodic(iz-1, depth); + r = (1.0f - tz)*(1.0f - ty)*(1.0f - tx)*read(data[ix + iy*width + iz*width*height]); + r += (1.0f - tz)*(1.0f - ty)*tx*read(data[nix + iy*width + iz*width*height]); + r += (1.0f - tz)*ty*(1.0f - tx)*read(data[ix + niy*width + iz*width*height]); + r += (1.0f - tz)*ty*tx*read(data[nix + niy*width + iz*width*height]); - nix = wrap_periodic(ix+1, width); - niy = wrap_periodic(iy+1, height); - niz = wrap_periodic(iz+1, depth); + r += tz*(1.0f - ty)*(1.0f - tx)*read(data[ix + iy*width + niz*width*height]); + r += tz*(1.0f - ty)*tx*read(data[nix + iy*width + niz*width*height]); + r += tz*ty*(1.0f - tx)*read(data[ix + niy*width + niz*width*height]); + r += tz*ty*tx*read(data[nix + niy*width + niz*width*height]); - nnix = wrap_periodic(ix+2, width); - nniy = wrap_periodic(iy+2, height); - nniz = wrap_periodic(iz+2, depth); - break; - case EXTENSION_CLIP: - if(x < 0.0f || y < 0.0f || z < 0.0f || - x > 1.0f || y > 1.0f || z > 1.0f) - { - return make_float4(0.0f, 0.0f, 0.0f, 0.0f); - } - /* Fall through. */ - case EXTENSION_EXTEND: - pix = wrap_clamp(ix-1, width); - piy = wrap_clamp(iy-1, height); - piz = wrap_clamp(iz-1, depth); + return r; + } - nix = wrap_clamp(ix+1, width); - niy = wrap_clamp(iy+1, height); - niz = wrap_clamp(iz+1, depth); + ccl_never_inline float4 interp_3d_ex_tricubic(float x, float y, float z) + { + int ix, iy, iz; + int nix, niy, niz; + /* Tricubic b-spline interpolation. */ + const float tx = frac(x*(float)width - 0.5f, &ix); + const float ty = frac(y*(float)height - 0.5f, &iy); + const float tz = frac(z*(float)depth - 0.5f, &iz); + int pix, piy, piz, nnix, nniy, nniz; - nnix = wrap_clamp(ix+2, width); - nniy = wrap_clamp(iy+2, height); - nniz = wrap_clamp(iz+2, depth); + switch(extension) { + case EXTENSION_REPEAT: + ix = wrap_periodic(ix, width); + iy = wrap_periodic(iy, height); + iz = wrap_periodic(iz, depth); - ix = wrap_clamp(ix, width); - iy = wrap_clamp(iy, height); - iz = wrap_clamp(iz, depth); - break; - default: - kernel_assert(0); + pix = wrap_periodic(ix-1, width); + piy = wrap_periodic(iy-1, height); + piz = wrap_periodic(iz-1, depth); + + nix = wrap_periodic(ix+1, width); + niy = wrap_periodic(iy+1, height); + niz = wrap_periodic(iz+1, depth); + + nnix = wrap_periodic(ix+2, width); + nniy = wrap_periodic(iy+2, height); + nniz = wrap_periodic(iz+2, depth); + break; + case EXTENSION_CLIP: + if(x < 0.0f || y < 0.0f || z < 0.0f || + x > 1.0f || y > 1.0f || z > 1.0f) + { return make_float4(0.0f, 0.0f, 0.0f, 0.0f); - } + } + /* Fall through. */ + case EXTENSION_EXTEND: + pix = wrap_clamp(ix-1, width); + piy = wrap_clamp(iy-1, height); + piz = wrap_clamp(iz-1, depth); - const int xc[4] = {pix, ix, nix, nnix}; - const int yc[4] = {width * piy, - width * iy, - width * niy, - width * nniy}; - const int zc[4] = {width * height * piz, - width * height * iz, - width * height * niz, - width * height * nniz}; - float u[4], v[4], w[4]; + nix = wrap_clamp(ix+1, width); + niy = wrap_clamp(iy+1, height); + niz = wrap_clamp(iz+1, depth); - /* Some helper macro to keep code reasonable size, - * let compiler to inline all the matrix multiplications. - */ + nnix = wrap_clamp(ix+2, width); + nniy = wrap_clamp(iy+2, height); + nniz = wrap_clamp(iz+2, depth); + + ix = wrap_clamp(ix, width); + iy = wrap_clamp(iy, height); + iz = wrap_clamp(iz, depth); + break; + default: + kernel_assert(0); + return make_float4(0.0f, 0.0f, 0.0f, 0.0f); + } + + const int xc[4] = {pix, ix, nix, nnix}; + const int yc[4] = {width * piy, + width * iy, + width * niy, + width * nniy}; + const int zc[4] = {width * height * piz, + width * height * iz, + width * height * niz, + width * height * nniz}; + float u[4], v[4], w[4]; + + /* Some helper macro to keep code reasonable size, + * let compiler to inline all the matrix multiplications. + */ #define DATA(x, y, z) (read(data[xc[x] + yc[y] + zc[z]])) #define COL_TERM(col, row) \ - (v[col] * (u[0] * DATA(0, col, row) + \ - u[1] * DATA(1, col, row) + \ - u[2] * DATA(2, col, row) + \ - u[3] * DATA(3, col, row))) + (v[col] * (u[0] * DATA(0, col, row) + \ + u[1] * DATA(1, col, row) + \ + u[2] * DATA(2, col, row) + \ + u[3] * DATA(3, col, row))) #define ROW_TERM(row) \ - (w[row] * (COL_TERM(0, row) + \ - COL_TERM(1, row) + \ - COL_TERM(2, row) + \ - COL_TERM(3, row))) + (w[row] * (COL_TERM(0, row) + \ + COL_TERM(1, row) + \ + COL_TERM(2, row) + \ + COL_TERM(3, row))) - SET_CUBIC_SPLINE_WEIGHTS(u, tx); - SET_CUBIC_SPLINE_WEIGHTS(v, ty); - SET_CUBIC_SPLINE_WEIGHTS(w, tz); + SET_CUBIC_SPLINE_WEIGHTS(u, tx); + SET_CUBIC_SPLINE_WEIGHTS(v, ty); + SET_CUBIC_SPLINE_WEIGHTS(w, tz); - /* Actual interpolation. */ - return ROW_TERM(0) + ROW_TERM(1) + ROW_TERM(2) + ROW_TERM(3); + /* Actual interpolation. */ + return ROW_TERM(0) + ROW_TERM(1) + ROW_TERM(2) + ROW_TERM(3); #undef COL_TERM #undef ROW_TERM #undef DATA + } + + ccl_always_inline float4 interp_3d_ex(float x, float y, float z, + int interpolation = INTERPOLATION_LINEAR) + { + + if(UNLIKELY(!data)) + return make_float4(0.0f, 0.0f, 0.0f, 0.0f); + + switch(interpolation) { + case INTERPOLATION_CLOSEST: + return interp_3d_ex_closest(x, y, z); + case INTERPOLATION_LINEAR: + return interp_3d_ex_linear(x, y, z); + default: + return interp_3d_ex_tricubic(x, y, z); } } diff --git a/intern/cycles/util/util_types.h b/intern/cycles/util/util_types.h index bf4a134b998..aa22f6a2c57 100644 --- a/intern/cycles/util/util_types.h +++ b/intern/cycles/util/util_types.h @@ -55,6 +55,7 @@ #endif #define ccl_may_alias #define ccl_always_inline __forceinline +#define ccl_never_inline __declspec(noinline) #define ccl_maybe_unused #else @@ -68,6 +69,7 @@ #define ccl_try_align(...) __attribute__((aligned(__VA_ARGS__))) #define ccl_may_alias __attribute__((__may_alias__)) #define ccl_always_inline __attribute__((always_inline)) +#define ccl_never_inline __attribute__((noinline)) #define ccl_maybe_unused __attribute__((used)) #endif From 8c22a974d63db2b3182a5b7855c5794bc9cb111f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 7 Apr 2017 18:26:39 +0200 Subject: [PATCH 08/13] Tests: Compare vectors with epsilon SOlves the test false-positively failing in 32 bit environment. --- tests/python/bl_pyapi_mathutils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/python/bl_pyapi_mathutils.py b/tests/python/bl_pyapi_mathutils.py index 7761b6cb7b1..9ca0376192a 100644 --- a/tests/python/bl_pyapi_mathutils.py +++ b/tests/python/bl_pyapi_mathutils.py @@ -260,6 +260,11 @@ class KDTreeTesting(unittest.TestCase): k.balance() return k + def assertAlmostEqualVector(self, first, second, places=7, msg=None, delta=None): + self.assertAlmostEqual(first[0], second[0], places=places, msg=msg, delta=delta) + self.assertAlmostEqual(first[1], second[1], places=places, msg=msg, delta=delta) + self.assertAlmostEqual(first[2], second[2], places=places, msg=msg, delta=delta) + def test_kdtree_single(self): co = (0,) * 3 index = 2 @@ -360,12 +365,12 @@ class KDTreeTesting(unittest.TestCase): ret_regular = k_odd.find(co) self.assertEqual(ret_regular[1] % 2, 1) ret_filter = k_all.find(co, lambda i: (i % 2) == 1) - self.assertEqual(ret_regular, ret_filter) + self.assertAlmostEqualVector(ret_regular, ret_filter) ret_regular = k_evn.find(co) self.assertEqual(ret_regular[1] % 2, 0) ret_filter = k_all.find(co, lambda i: (i % 2) == 0) - self.assertEqual(ret_regular, ret_filter) + self.assertAlmostEqualVector(ret_regular, ret_filter) # filter out all values (search odd tree for even values and the reverse) From 7d77b3e813355d832b7fbc5e4f55773ab792d0e3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 7 Apr 2017 18:27:07 +0200 Subject: [PATCH 09/13] Cycles: Fix compilation error with certain CUDA and host compiler configuration This seems to happen on Windows only, happened to Thomas and Nathan already. Similar patch Thomas was showing, but i do not see it committted. So comitting now in order to get more developers and users happy. --- intern/cycles/kernel/kernel_compat_cuda.h | 1 + 1 file changed, 1 insertion(+) diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h index 39e98c7dda6..a6b44acc809 100644 --- a/intern/cycles/kernel/kernel_compat_cuda.h +++ b/intern/cycles/kernel/kernel_compat_cuda.h @@ -33,6 +33,7 @@ #include #include #include +#include /* Qualifier wrappers for different names on different devices */ From 867d31130769b45c6f1b71ef619f247634ae890c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 7 Apr 2017 18:28:16 +0200 Subject: [PATCH 10/13] Cycles: Fix warning with MSVC --- intern/cycles/device/device_cuda.cpp | 2 +- intern/cycles/device/opencl/opencl_split.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 606494f08ed..4c1a49878f5 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1613,7 +1613,7 @@ int2 CUDASplitKernel::split_kernel_local_size() return make_int2(32, 1); } -int2 CUDASplitKernel::split_kernel_global_size(device_memory& /*kg*/, device_memory& /*data*/, DeviceTask */*task*/) +int2 CUDASplitKernel::split_kernel_global_size(device_memory& /*kg*/, device_memory& /*data*/, DeviceTask * /*task*/) { /* TODO(mai): implement something here to detect ideal work size */ return make_int2(256, 256); diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp index 579dbc84f53..b8df57ec7b9 100644 --- a/intern/cycles/device/opencl/opencl_split.cpp +++ b/intern/cycles/device/opencl/opencl_split.cpp @@ -340,7 +340,7 @@ public: return make_int2(64, 1); } - virtual int2 split_kernel_global_size(device_memory& kg, device_memory& data, DeviceTask */*task*/) + virtual int2 split_kernel_global_size(device_memory& kg, device_memory& data, DeviceTask * /*task*/) { cl_device_type type = OpenCLInfo::get_device_type(device->cdDevice); /* Use small global size on CPU devices as it seems to be much faster. */ From 1cd54ec225d9fd66bfed51b18bd5605f49ec1b07 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 8 Apr 2017 11:06:44 +0200 Subject: [PATCH 11/13] Add helpers in bpy_extras.keyconfig_utils for addons to (un)register their keymaps. Doing this in a fully 'clean' way is far from obvious, especially unregister, you often end up leaving nasty 'orphanned' keymap items referring to unregistered operators... --- .../modules/bpy_extras/keyconfig_utils.py | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/release/scripts/modules/bpy_extras/keyconfig_utils.py b/release/scripts/modules/bpy_extras/keyconfig_utils.py index 6ecdd0c5e13..3203bc41b76 100644 --- a/release/scripts/modules/bpy_extras/keyconfig_utils.py +++ b/release/scripts/modules/bpy_extras/keyconfig_utils.py @@ -140,6 +140,78 @@ KM_HIERARCHY = [ ] +# ----------------------------------------------------------------------------- +# Add-on helpers to properly (un)register their own keymaps. + +# Example of keymaps_description: +keymaps_description_doc = """ +keymaps_description is a tuple (((keymap_description), (tuple of keymap_item_descriptions))). +keymap_description is a tuple (name, space_type, region_type, is_modal). +keymap_item_description is a tuple ({kw_args_for_keymap_new}, (tuple of properties)). +kw_args_for_keymap_new is a mapping which keywords match parameters of keymap.new() function. +tuple of properties is a tuple of pairs (prop_name, prop_value) (properties being those of called operator). + +Example: + +KEYMAPS = ( + # First, keymap identifiers (last bool is True for modal km). + (('Sequencer', 'SEQUENCE_EDITOR', 'WINDOW', False), ( + # Then a tuple of keymap items, defined by a dict of kwargs for the km new func, and a tuple of tuples (name, val) + # for ops properties, if needing non-default values. + ({"idname": export_strips.SEQExportStrip.bl_idname, "type": 'P', "value": 'PRESS', "shift": True, "ctrl": True}, + ()), + )), +) +""" + + +def addon_keymap_register(wm, keymaps_description): + """ + Register a set of keymaps for addons. + + """ + keymaps_description_doc + kconf = wm.keyconfigs.addon + if not kconf: + return # happens in background mode... + for km_info, km_items in keymaps_description: + km_name, km_sptype, km_regtype, km_ismodal = km_info + kmap = [k for k in kconf.keymaps + if k.name == km_name and k.region_type == km_regtype and + k.space_type == km_sptype and k.is_modal == km_ismodal] + if kmap: + kmap = kmap[0] + else: + kmap = kconf.keymaps.new(km_name, region_type=km_regtype, space_type=km_sptype, modal=km_ismodal) + for kmi_kwargs, props in km_items: + kmi = kmap.keymap_items.new(**kmi_kwargs) + kmi.active = True + for prop, val in props: + setattr(kmi.properties, prop, val) + + +def addon_keymap_unregister(wm, keymaps_description): + """ + Unregister a set of keymaps for addons. + + """ + keymaps_description_doc + # NOTE: We must also clean up user keyconfig, else, if user has customized one of add-on's shortcut, this + # customization remains in memory, and comes back when re-enabling the addon, causing a segfault... :/ + kconfs = wm.keyconfigs + for kconf in (kconfs.user, kconfs.addon): + for km_info, km_items in keymaps_description: + km_name, km_sptype, km_regtype, km_ismodal = km_info + kmaps = (k for k in kconf.keymaps + if k.name == km_name and k.region_type == km_regtype and + k.space_type == km_sptype and k.is_modal == km_ismodal) + for kmap in kmaps: + for kmi_kwargs, props in km_items: + idname = kmi_kwargs["idname"] + for kmi in kmap.keymap_items: + if kmi.idname == idname: + kmap.keymap_items.remove(kmi) + # NOTE: We won't remove addons keymaps themselves, other addons might also use them! + + # ----------------------------------------------------------------------------- # Utility functions From b60d4800c6e52a8fe861702ecd79486a94da10be Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Sat, 8 Apr 2017 07:12:04 -0400 Subject: [PATCH 12/13] Cycles: Fix building of CUDA kernels with compilers where C++11 is disabled --- intern/cycles/kernel/kernel_compat_cuda.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/kernel/kernel_compat_cuda.h b/intern/cycles/kernel/kernel_compat_cuda.h index a6b44acc809..c375d17a95f 100644 --- a/intern/cycles/kernel/kernel_compat_cuda.h +++ b/intern/cycles/kernel/kernel_compat_cuda.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include /* Qualifier wrappers for different names on different devices */ From 162e184ffd0f2e5f1584b95339df6cb3c429f017 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 9 Apr 2017 16:07:09 +1000 Subject: [PATCH 13/13] ListBase: Add insert-replace function Handy to replace an existing link (without having to store before/after links) Use for id-props --- source/blender/blenkernel/intern/idprop.c | 29 ++++++------------- source/blender/blenlib/BLI_listbase.h | 1 + source/blender/blenlib/intern/listbase.c | 34 +++++++++++++++++++++++ 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index a596869e5e8..6ebdd371acb 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -503,14 +503,9 @@ void IDP_SyncGroupValues(IDProperty *dest, const IDProperty *src) break; default: { - IDProperty *tmp = other; - IDProperty *copy = IDP_CopyProperty(prop); - - BLI_insertlinkafter(&dest->data.group, other, copy); - BLI_remlink(&dest->data.group, tmp); - - IDP_FreeProperty(tmp); - MEM_freeN(tmp); + BLI_insertlinkreplace(&dest->data.group, other, IDP_CopyProperty(prop)); + IDP_FreeProperty(other); + MEM_freeN(other); break; } } @@ -530,11 +525,9 @@ void IDP_SyncGroupTypes(IDProperty *dst, const IDProperty *src, const bool do_ar if ((prop_dst->type != prop_src->type || prop_dst->subtype != prop_src->subtype) || (do_arraylen && ELEM(prop_dst->type, IDP_ARRAY, IDP_IDPARRAY) && (prop_src->len != prop_dst->len))) { - IDP_FreeFromGroup(dst, prop_dst); - prop_dst = IDP_CopyProperty(prop_src); - - dst->len++; - BLI_insertlinkbefore(&dst->data.group, prop_dst_next, prop_dst); + BLI_insertlinkreplace(&dst->data.group, prop_dst, IDP_CopyProperty(prop_src)); + IDP_FreeProperty(prop_dst); + MEM_freeN(prop_dst); } else if (prop_dst->type == IDP_GROUP) { IDP_SyncGroupTypes(prop_dst, prop_src, do_arraylen); @@ -559,11 +552,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, const IDProperty *src) for (prop = src->data.group.first; prop; prop = prop->next) { for (loop = dest->data.group.first; loop; loop = loop->next) { if (STREQ(loop->name, prop->name)) { - IDProperty *copy = IDP_CopyProperty(prop); - - BLI_insertlinkafter(&dest->data.group, loop, copy); - - BLI_remlink(&dest->data.group, loop); + BLI_insertlinkreplace(&dest->data.group, loop, IDP_CopyProperty(prop)); IDP_FreeProperty(loop); MEM_freeN(loop); break; @@ -590,9 +579,7 @@ void IDP_ReplaceInGroup_ex(IDProperty *group, IDProperty *prop, IDProperty *prop BLI_assert(prop_exist == IDP_GetPropertyFromGroup(group, prop->name)); if ((prop_exist = IDP_GetPropertyFromGroup(group, prop->name))) { - BLI_insertlinkafter(&group->data.group, prop_exist, prop); - - BLI_remlink(&group->data.group, prop_exist); + BLI_insertlinkreplace(&group->data.group, prop_exist, prop); IDP_FreeProperty(prop_exist); MEM_freeN(prop_exist); } diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h index 96349a7b066..00e761b81bc 100644 --- a/source/blender/blenlib/BLI_listbase.h +++ b/source/blender/blenlib/BLI_listbase.h @@ -67,6 +67,7 @@ void *BLI_poptail(ListBase *listbase) ATTR_NONNULL(1); void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1); void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1); void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1); +void BLI_insertlinkreplace(ListBase *listbase, void *v_l_src, void *v_l_dst) ATTR_NONNULL(1, 2, 3); void BLI_listbase_sort(struct ListBase *listbase, int (*cmp)(const void *, const void *)) ATTR_NONNULL(1, 2); void BLI_listbase_sort_r(ListBase *listbase, int (*cmp)(void *, const void *, const void *), void *thunk) ATTR_NONNULL(1, 2); bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL(); diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index c9bf4976ae8..6cb7b7d8e3e 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -342,6 +342,40 @@ void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) } } + +/** + * Insert a link in place of another, without changing it's position in the list. + * + * Puts `vnewlink` in the position of `vreplacelink`, removing `vreplacelink`. + * - `vreplacelink` *must* be in the list. + * - `vnewlink` *must not* be in the list. + */ +void BLI_insertlinkreplace(ListBase *listbase, void *vreplacelink, void *vnewlink) +{ + Link *l_old = vreplacelink; + Link *l_new = vnewlink; + + /* update adjacent links */ + if (l_old->next != NULL) { + l_old->next->prev = l_new; + } + if (l_old->prev != NULL) { + l_old->prev->next = l_new; + } + + /* set direct links */ + l_new->next = l_old->next; + l_new->prev = l_old->prev; + + /* update list */ + if (listbase->first == l_old) { + listbase->first = l_new; + } + if (listbase->last == l_old) { + listbase->last = l_new; + } +} + /** * Reinsert \a vlink relative to its current position but offset by \a step. Doesn't move * item if new position would exceed list (could optionally move to head/tail).