Commit: b0b310e65d0851e87272caeb7cf6fb0119212a44
Author: Bastien Montagne
Date:   Wed Jan 20 20:39:18 2016 +0100
Branches: master
https://developer.blender.org/rBb0b310e65d0851e87272caeb7cf6fb0119212a44

Cleanup: remove remainings of OMP in sculptpaint area.

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

M       source/blender/editors/sculpt_paint/paint_cursor.c
M       source/blender/editors/sculpt_paint/paint_mask.c
M       source/blender/editors/sculpt_paint/sculpt.c
M       source/blender/editors/sculpt_paint/sculpt_intern.h
M       source/blender/editors/sculpt_paint/sculpt_undo.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c 
b/source/blender/editors/sculpt_paint/paint_cursor.c
index 8dc2667..aad9df1 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -69,10 +69,6 @@
  * removed eventually (TODO) */
 #include "sculpt_intern.h"
 
-#ifdef _OPENMP
-#include <omp.h>
-#endif
-
 /* TODOs:
  *
  * Some of the cursor drawing code is doing non-draw stuff
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c 
b/source/blender/editors/sculpt_paint/paint_mask.c
index 5d9afb1..2702528 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -156,7 +156,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
 
        BLI_task_parallel_range(
                    0, totnode, &data, mask_flood_fill_task_cb,
-                   ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_OMP_LIMIT));
+                   ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_THREADED_LIMIT));
 
        if (multires)
                multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED);
@@ -300,7 +300,7 @@ int ED_sculpt_mask_box_select(struct bContext *C, 
ViewContext *vc, const rcti *r
 
                        BLI_task_parallel_range(
                                    0, totnode, &data, mask_box_select_task_cb,
-                                   ((sd->flags & SCULPT_USE_OPENMP) && totnode 
> SCULPT_OMP_LIMIT));
+                                   ((sd->flags & SCULPT_USE_OPENMP) && totnode 
> SCULPT_THREADED_LIMIT));
 
                        if (nodes)
                                MEM_freeN(nodes);
@@ -480,7 +480,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, 
wmOperator *op)
 
                                BLI_task_parallel_range(
                                            0, totnode, &data, 
mask_gesture_lasso_task_cb,
-                                           ((sd->flags & SCULPT_USE_OPENMP) && 
(totnode > SCULPT_OMP_LIMIT)));
+                                           ((sd->flags & SCULPT_USE_OPENMP) && 
(totnode > SCULPT_THREADED_LIMIT)));
 
                                if (nodes)
                                        MEM_freeN(nodes);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 602fe68..da2a987 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -99,23 +99,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef _OPENMP
-#include <omp.h>
-#endif
-
-#if defined(__APPLE__) && defined _OPENMP
-#include <sys/sysctl.h>
-
-/* Query how many cores not counting HT aka physical cores we've got. */
-static int system_physical_thread_count(void)
-{
-       int pcount;
-       size_t pcount_len = sizeof(pcount);
-       sysctlbyname("hw.physicalcpu", &pcount, &pcount_len, NULL, 0);
-       return pcount;
-}
-#endif  /* __APPLE__ */
-
 /** \name Tool Capabilities
  *
  * Avoid duplicate checks, internal logic only,
@@ -513,7 +496,7 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob)
 
        BLI_task_parallel_range(
                    0, totnode, &data, paint_mesh_restore_co_task_cb,
-                   ((sd->flags & SCULPT_USE_OPENMP) && !ss->bm && totnode > 
SCULPT_OMP_LIMIT));
+                   ((sd->flags & SCULPT_USE_OPENMP) && !ss->bm && totnode > 
SCULPT_THREADED_LIMIT));
 
        if (nodes)
                MEM_freeN(nodes);
@@ -969,7 +952,7 @@ static void calc_area_center(
 
        BLI_task_parallel_range(
                    0, totnode, &data, calc_area_normal_and_center_task_cb,
-                   ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_OMP_LIMIT));
+                   ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_THREADED_LIMIT));
 
        BLI_mutex_end(&data.mutex);
 
@@ -1009,7 +992,7 @@ static void calc_area_normal(
 
        BLI_task_parallel_range(
                    0, totnode, &data, calc_area_normal_and_center_task_cb,
-                   ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_OMP_LIMIT));
+                   ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_THREADED_LIMIT));
 
        BLI_mutex_end(&data.mutex);
 
@@ -1047,7 +1030,7 @@ static void calc_area_normal_and_center(
 
        BLI_task_parallel_range(
                    0, totnode, &data, calc_area_normal_and_center_task_cb,
-                   ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_OMP_LIMIT));
+                   ((sd->flags & SCULPT_USE_OPENMP) && totnode > 
SCULPT_THREADED_LIMIT));
 
        BLI_mutex_end(&data.mutex);
 
@@ -1172,14 +1155,14 @@ static float tex_strength(SculptSession *ss, Brush *br,
                           const float len,
                           const short vno[3],
                           const float fno[3],
-                          const float mask)
+                          const float mask,
+                          const int thread_id)
 {
        StrokeCache *cache = ss->cache;
        const Scene *scene = cache->vc->scene;
        MTex *mtex = &br->mtex;
        float avg = 1;
        float rgba[4];
-       int thread_num;
 
        if (!mtex->tex) {
                avg = 1;
@@ -1222,12 +1205,7 @@ static float tex_strength(SculptSession *ss, Brush *br,
                        x += br->mtex.ofs[0];
                        y += br->mtex.ofs[1];
 
-#ifdef _OPENMP
-                       thread_num = omp_get_thread_num();
-#else
-                       thread_num = 0;
-#endif
-                       avg = paint_get_tex_pixel(&br->mtex, x, y, 
ss->tex_pool, thread_num);
+                       avg = paint_get_tex_pixel(&br->mtex, x, y, 
ss->tex_pool, thread_id);
 
                        avg += br->texture_sample_bias;
                }
@@ -1564,7 +1542,8 @@ typedef struct SculptDoBrushSmoothGridDataChunk {
        size_t tmpgrid_size;
 } SculptDoBrushSmoothGridDataChunk;
 
-static void do_smooth_brush_mesh_task_cb(void *userdata, int n)
+static void do_smooth_brush_mesh_task_cb_ex(
+        void *userdata, void *UNUSED(userdata_chunk), const int n, const int 
thread_id)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1585,7 +1564,8 @@ static void do_smooth_brush_mesh_task_cb(void *userdata, 
int n)
                if (sculpt_brush_test(&test, vd.co)) {
                        const float fade = bstrength * tex_strength(
                                               ss, brush, vd.co, test.dist, 
vd.no, vd.fno,
-                                              smooth_mask ? 0.0f : (vd.mask ? 
*vd.mask : 0.0f));
+                                              smooth_mask ? 0.0f : (vd.mask ? 
*vd.mask : 0.0f),
+                                              thread_id);
                        if (smooth_mask) {
                                float val = neighbor_average_mask(ss, 
vd.vert_indices[vd.i]) - *vd.mask;
                                val *= fade * bstrength;
@@ -1610,7 +1590,8 @@ static void do_smooth_brush_mesh_task_cb(void *userdata, 
int n)
        BKE_pbvh_vertex_iter_end;
 }
 
-static void do_smooth_brush_bmesh_task_cb(void *userdata, int n)
+static void do_smooth_brush_bmesh_task_cb_ex(
+        void *userdata, void *UNUSED(userdata_chunk), const int n, const int 
thread_id)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1630,7 +1611,8 @@ static void do_smooth_brush_bmesh_task_cb(void *userdata, 
int n)
        {
                if (sculpt_brush_test(&test, vd.co)) {
                        const float fade = bstrength * tex_strength(
-                                              ss, brush, vd.co, test.dist, 
vd.no, vd.fno, smooth_mask ? 0.0f : *vd.mask);
+                                              ss, brush, vd.co, test.dist, 
vd.no, vd.fno, smooth_mask ? 0.0f : *vd.mask,
+                                              thread_id);
                        if (smooth_mask) {
                                float val = 
bmesh_neighbor_average_mask(vd.bm_vert, vd.cd_vert_mask_offset) - *vd.mask;
                                val *= fade * bstrength;
@@ -1656,7 +1638,7 @@ static void do_smooth_brush_bmesh_task_cb(void *userdata, 
int n)
 }
 
 static void do_smooth_brush_multires_task_cb_ex(
-        void *userdata, void *userdata_chunk, const int n, const int 
UNUSED(thread_id))
+        void *userdata, void *userdata_chunk, const int n, const int thread_id)
 {
        SculptThreadedTaskData *data = userdata;
        SculptDoBrushSmoothGridDataChunk *data_chunk = userdata_chunk;
@@ -1768,7 +1750,8 @@ static void do_smooth_brush_multires_task_cb_ex(
 
                                if (sculpt_brush_test(&test, co)) {
                                        const float strength_mask = 
(smooth_mask ? 0.0f : *mask);
-                                       const float fade = bstrength * 
tex_strength(ss, brush, co, test.dist, NULL, fno, strength_mask);
+                                       const float fade = bstrength * 
tex_strength(
+                                                              ss, brush, co, 
test.dist, NULL, fno, strength_mask, thread_id);
                                        float f = 1.0f / 16.0f;
 
                                        if (x == 0 || x == gridsize - 1)
@@ -1842,20 +1825,20 @@ static void smooth(
 
                                BLI_task_parallel_range_ex(
                                            0, totnode, &data, data_chunk, 
size, do_smooth_brush_multires_task_cb_ex,
-                                           ((sd->flags & SCULPT_USE_OPENMP) && 
totnode > SCULPT_OMP_LIMIT), false);
+                                           ((sd->flags & SCULPT_USE_OPENMP) && 
totnode > SCULPT_THREADED_LIMIT), false);
 
                                MEM_freeN(data_chunk);
                                break;
                        }
                        case PBVH_FACES:
-                               BLI_task_parallel_range(
-                                           0, totnode, &data, 
do_smooth_brush_mesh_task_cb,
-                                           ((sd->flags & SCULPT_USE_OPENMP) && 
totnode > SCULPT_OMP_LIMIT));
+                               BLI_task_parallel_range_ex(
+                                           0, totnode, &data, NULL, 0, 
do_smooth_brush_mesh_task_cb_ex,
+                                           ((sd->flags & SCULPT_USE_OPENMP) && 
totnode > SCULPT_THREADED_LIMIT), false);
                                break;
                        case PBVH_BMESH:
-                               BLI_task_parallel_range(
-                                           0, totnode, &data, 
do_smooth_brush_bmesh_task_cb,
-                                           ((sd->flags & SCULPT_USE_OPENMP) && 
totnode > SCULPT_OMP_LIMIT));
+                               BLI_task_parallel_range_ex(
+                                           0, totnode, &data, NULL, 0, 
do_smooth_brush_bmesh_task_cb_ex,
+                                           ((sd->flags & SCULPT_USE_OPENMP) && 
totnode > SCULPT_THREADED_LIMIT), false);
                                break;
                }
 
@@ -1870,7 +1853,8 @@ static void do_smooth_brush(Sculpt *sd, Object *ob, 
PBVHNode **nodes, int totnod
        smooth(sd, ob, nodes, totnode, ss->cache->bstrength, false);
 }
 
-static void do_mask_brush_draw_task_cb(void *userdata, const int n)
+static void do_mask_brush_draw_task_cb_ex(
+        void *userdata, void *UNUSED(userdata_chunk), const int n, const int 
thread_id)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1885,7 +1869,7 @@ static void do_mask_brush_draw_task_cb(void *userdata, 
const int n)
        BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, 
PBVH_ITER_UNIQUE)
        {
                if (sculpt_brush_test(&test, vd.co)) {
-                       const float fade = tex_strength(ss, brush, vd.co, 
test.dist, vd.no, vd.fno, 0.0f);
+                       const float fade = tex_strength(ss, brush, vd.co, 
test.dist, vd.no, vd.fno, 0.0f, thread_id);
 
                        (*vd.mask) += fade * bstrength;
                        CLAMP(*vd.mask, 0, 1);
@@ -1906,9 +1890,9 @@ static void do_mask_brush_draw(S

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to