Merge remote-tracking branch 'origin/master' into blender2.8
authorDalai Felinto <dfelinto@gmail.com>
Fri, 19 Jan 2018 19:01:48 +0000 (17:01 -0200)
committerDalai Felinto <dfelinto@gmail.com>
Fri, 19 Jan 2018 19:01:48 +0000 (17:01 -0200)
intern/cycles/device/device_cpu.cpp
intern/cycles/util/util_debug.h
source/blender/blenkernel/intern/image.c
source/blender/blenlib/intern/math_base_inline.c
source/blender/editors/space_text/text_draw.c

index 0783230ef14c0ba6daaa57cd37c75a7c68408aee..6b6b3432446f046ada6e77ae69ee9cf6b7812299 100644 (file)
@@ -86,35 +86,35 @@ public:
                (void)kernel_avx;
                (void)kernel_avx2;
 #ifdef WITH_CYCLES_OPTIMIZED_KERNEL_AVX2
-               if(DebugFlags().cpu.avx2 && system_cpu_support_avx2()) {
+               if(DebugFlags().cpu.has_avx2() && system_cpu_support_avx2()) {
                        architecture_name = "AVX2";
                        kernel = kernel_avx2;
                }
                else
 #endif
 #ifdef WITH_CYCLES_OPTIMIZED_KERNEL_AVX
-               if(DebugFlags().cpu.avx && system_cpu_support_avx()) {
+               if(DebugFlags().cpu.has_avx() && system_cpu_support_avx()) {
                        architecture_name = "AVX";
                        kernel = kernel_avx;
                }
                else
 #endif
 #ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
-               if(DebugFlags().cpu.sse41 && system_cpu_support_sse41()) {
+               if(DebugFlags().cpu.has_sse41() && system_cpu_support_sse41()) {
                        architecture_name = "SSE4.1";
                        kernel = kernel_sse41;
                }
                else
 #endif
 #ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
-               if(DebugFlags().cpu.sse3 && system_cpu_support_sse3()) {
+               if(DebugFlags().cpu.has_sse3() && system_cpu_support_sse3()) {
                        architecture_name = "SSE3";
                        kernel = kernel_sse3;
                }
                else
 #endif
 #ifdef WITH_CYCLES_OPTIMIZED_KERNEL_SSE2
-               if(DebugFlags().cpu.sse2 && system_cpu_support_sse2()) {
+               if(DebugFlags().cpu.has_sse2() && system_cpu_support_sse2()) {
                        architecture_name = "SSE2";
                        kernel = kernel_sse2;
                }
index 632c6ae35e7637e88efd6dd3d434ba7b753b6f8a..ec38cd373ba932042e26d74636d959452ef3c8f9 100644 (file)
@@ -45,6 +45,15 @@ public:
                bool sse3;
                bool sse2;
 
+               /* Check functions to see whether instructions up to the given one
+                * are allowed for use.
+                */
+               bool has_avx2()  { return has_avx()   && avx2; }
+               bool has_avx()   { return has_sse41() && avx; }
+               bool has_sse41() { return has_sse3()  && sse41; }
+               bool has_sse3()  { return has_sse2()  && sse3; }
+               bool has_sse2()  { return sse2; }
+
                /* Whether QBVH usage is allowed or not. */
                bool qbvh;
 
index dbb596b1cd67aebfcd060d551593f8c795fb73a3..d720dc41abf117d68ab93dfb42084848727c7345 100644 (file)
@@ -1696,7 +1696,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
                int digits = 1;
 
                if (scene->r.efra > 9)
-                       digits = 1 + (int) log10(scene->r.efra);
+                       digits = integer_digits_i(scene->r.efra);
 
                BLI_snprintf(fmtstr, sizeof(fmtstr), do_prefix ? "Frame %%0%di" : "%%0%di", digits);
                BLI_snprintf(stamp_data->frame, sizeof(stamp_data->frame), fmtstr, scene->r.cfra);
index 9202efce7b458190f5a7a999e50c8bda58220f06..a0c13e14e72225bde516a5b24868a356c53809db 100644 (file)
@@ -397,6 +397,10 @@ MINLINE int integer_digits_d(const double d)
        return (d == 0.0) ? 0 : (int)floor(log10(fabs(d))) + 1;
 }
 
+MINLINE int integer_digits_i(const int i)
+{
+       return (int)log10(i) + 1;
+}
 
 /* Internal helpers for SSE2 implementation.
  *
index fcb675abcf235c5878c0035afb62115cfccfcc39..62fde49cade53f95dbe8e6dbfbb092521b59b6f3 100644 (file)
@@ -596,7 +596,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
                        drawcache->total_lines = 0;
 
                        if (st->showlinenrs)
-                               st->linenrs_tot = (int)floor(log10((float)nlines)) + 1;
+                               st->linenrs_tot = integer_digits_i(nlines);
 
                        while (line) {
                                if (drawcache->valid_head) { /* we're inside valid head lines */
@@ -630,7 +630,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar)
                        nlines = BLI_listbase_count(&txt->lines);
 
                        if (st->showlinenrs)
-                               st->linenrs_tot = (int)floor(log10((float)nlines)) + 1;
+                               st->linenrs_tot = integer_digits_i(nlines);
                }
 
                drawcache->total_lines = nlines;