Task scheduler: Get rid of extended version of parallel range callback
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 5 Jan 2018 15:33:13 +0000 (16:33 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 9 Jan 2018 15:09:33 +0000 (16:09 +0100)
Wrap all arguments into TLS type of argument. Avoids some branching and also
makes it easier to extend things in the future.

33 files changed:
source/blender/blenkernel/intern/CCGSubSurf_legacy.c
source/blender/blenkernel/intern/colortools.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/mask_rasterize.c
source/blender/blenkernel/intern/mesh_evaluate.c
source/blender/blenkernel/intern/ocean.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pbvh.c
source/blender/blenkernel/intern/shrinkwrap.c
source/blender/blenkernel/intern/smoke.c
source/blender/blenkernel/intern/tracking_auto.c
source/blender/blenkernel/intern/tracking_stabilize.c
source/blender/blenlib/BLI_task.h
source/blender/blenlib/intern/BLI_kdopbvh.c
source/blender/blenlib/intern/math_statistics.c
source/blender/blenlib/intern/task.c
source/blender/bmesh/intern/bmesh_interp.c
source/blender/depsgraph/intern/eval/deg_eval.cc
source/blender/depsgraph/intern/eval/deg_eval_flush.cc
source/blender/editors/sculpt_paint/paint_cursor.c
source/blender/editors/sculpt_paint/paint_image_2d.c
source/blender/editors/sculpt_paint/paint_mask.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/sculpt.c
source/blender/editors/sculpt_paint/sculpt_undo.c
source/blender/editors/space_sequencer/sequencer_scopes.c
source/blender/modifiers/intern/MOD_displace.c
source/blender/modifiers/intern/MOD_meshdeform.c
source/blender/modifiers/intern/MOD_ocean.c
source/blender/modifiers/intern/MOD_surfacedeform.c
source/blender/modifiers/intern/MOD_uvwarp.c
source/blender/modifiers/intern/MOD_weightvgproximity.c
source/blender/render/intern/source/pointdensity.c

index f68d1a2697c7a90ec167a730a8f2f7b0c01e9ec2..8b3ea2493960138b824e20d489e58d0375d7e82b 100644 (file)
@@ -136,7 +136,8 @@ typedef struct CCGSubSurfCalcSubdivData {
        int curLvl;
 } CCGSubSurfCalcSubdivData;
 
-static void ccgSubSurf__calcVertNormals_faces_accumulate_cb(void *userdata, int ptrIdx)
+static void ccgSubSurf__calcVertNormals_faces_accumulate_cb(void *userdata, int ptrIdx,
+                                                            const ParallelRangeTLS *UNUSED(tls))
 {
        CCGSubSurfCalcSubdivData *data = userdata;
 
@@ -227,7 +228,8 @@ static void ccgSubSurf__calcVertNormals_faces_accumulate_cb(void *userdata, int
        }
 }
 
-static void ccgSubSurf__calcVertNormals_faces_finalize_cb(void *userdata, int ptrIdx)
+static void ccgSubSurf__calcVertNormals_faces_finalize_cb(void *userdata, int ptrIdx,
+                                                          const ParallelRangeTLS *UNUSED(tls))
 {
        CCGSubSurfCalcSubdivData *data = userdata;
 
@@ -265,7 +267,8 @@ static void ccgSubSurf__calcVertNormals_faces_finalize_cb(void *userdata, int pt
        }
 }
 
-static void ccgSubSurf__calcVertNormals_edges_accumulate_cb(void *userdata, int ptrIdx)
+static void ccgSubSurf__calcVertNormals_edges_accumulate_cb(void *userdata, int ptrIdx,
+                                                            const ParallelRangeTLS *UNUSED(tls))
 {
        CCGSubSurfCalcSubdivData *data = userdata;
 
@@ -396,7 +399,8 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss,
 }
 
 
-static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_midpoints_cb(void *userdata, int ptrIdx)
+static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_midpoints_cb(void *userdata, int ptrIdx,
+                                                                          const ParallelRangeTLS *UNUSED(tls))
 {
        CCGSubSurfCalcSubdivData *data = userdata;
 
@@ -483,7 +487,8 @@ static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_midpoints_cb(void *
        }
 }
 
-static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_centerpoints_shift_cb(void *userdata, int ptrIdx)
+static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_centerpoints_shift_cb(void *userdata, int ptrIdx,
+                                                                                   const ParallelRangeTLS *UNUSED(tls))
 {
        CCGSubSurfCalcSubdivData *data = userdata;
 
@@ -588,7 +593,8 @@ static void ccgSubSurf__calcSubdivLevel_interior_faces_edges_centerpoints_shift_
        }
 }
 
-static void ccgSubSurf__calcSubdivLevel_verts_copydata_cb(void *userdata, int ptrIdx)
+static void ccgSubSurf__calcSubdivLevel_verts_copydata_cb(void *userdata, int ptrIdx,
+                                                          const ParallelRangeTLS *UNUSED(tls))
 {
        CCGSubSurfCalcSubdivData *data = userdata;
 
index 310255a15c16b3284a899015c3520d94934fe98c..67153564a0fe2c3c32f0e5068c5c4bd402e05d0e 100644 (file)
@@ -1165,7 +1165,7 @@ typedef struct ScopesUpdateDataChunk {
        float min[3], max[3];
 } ScopesUpdateDataChunk;
 
-static void scopes_update_cb(void *userdata, void *userdata_chunk, const int y, const int UNUSED(threadid))
+static void scopes_update_cb(void *userdata, const int y, const ParallelRangeTLS *tls)
 {
        const ScopesUpdateData *data = userdata;
 
@@ -1175,7 +1175,7 @@ static void scopes_update_cb(void *userdata, void *userdata_chunk, const int y,
        const unsigned char *display_buffer = data->display_buffer;
        const int ycc_mode = data->ycc_mode;
 
-       ScopesUpdateDataChunk *data_chunk = userdata_chunk;
+       ScopesUpdateDataChunk *data_chunk = tls->userdata_chunk;
        unsigned int *bin_lum = data_chunk->bin_lum;
        unsigned int *bin_r = data_chunk->bin_r;
        unsigned int *bin_g = data_chunk->bin_g;
index b44ee21432cbe491247c0669d5c7e9af3e89aa5a..81a721e77b9737f2aaaf8ab93a8ffeed362f9820 100644 (file)
@@ -611,11 +611,11 @@ static void freeGrid(PaintSurfaceData *data)
        bData->grid = NULL;
 }
 
-static void grid_bound_insert_cb_ex(void *userdata, void *userdata_chunk, const int i, const int UNUSED(thread_id))
+static void grid_bound_insert_cb_ex(void *userdata, const int i, const ParallelRangeTLS *tls)
 {
        PaintBakeData *bData = userdata;
 
-       Bounds3D *grid_bound = userdata_chunk;
+       Bounds3D *grid_bound = tls->userdata_chunk;
 
        boundInsert(grid_bound, bData->realCoord[bData->s_pos[i]].v);
 }
@@ -631,12 +631,12 @@ static void grid_bound_insert_finalize(void *userdata, void *userdata_chunk)
        boundInsert(&grid->grid_bounds, grid_bound->max);
 }
 
-static void grid_cell_points_cb_ex(void *userdata, void *userdata_chunk, const int i, const int UNUSED(thread_id))
+static void grid_cell_points_cb_ex(void *userdata, const int i, const ParallelRangeTLS *tls)
 {
        PaintBakeData *bData = userdata;
        VolumeGrid *grid = bData->grid;
        int *temp_t_index = grid->temp_t_index;
-       int *s_num = userdata_chunk;
+       int *s_num = tls->userdata_chunk;
 
        int co[3];
 
@@ -664,7 +664,7 @@ static void grid_cell_points_finalize(void *userdata, void *userdata_chunk)
        }
 }
 
-static void grid_cell_bounds_cb(void *userdata, const int x)
+static void grid_cell_bounds_cb(void *userdata, const int x, const ParallelRangeTLS *UNUSED(tls))
 {
        PaintBakeData *bData = userdata;
        VolumeGrid *grid = bData->grid;
@@ -1397,7 +1397,8 @@ typedef struct DynamicPaintSetInitColorData {
        const bool scene_color_manage;
 } DynamicPaintSetInitColorData;
 
-static void dynamic_paint_set_init_color_tex_to_vcol_cb(void *userdata, const int i)
+static void dynamic_paint_set_init_color_tex_to_vcol_cb(void *userdata, const int i,
+                                                       const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintSetInitColorData *data = userdata;
 
@@ -1431,7 +1432,8 @@ static void dynamic_paint_set_init_color_tex_to_vcol_cb(void *userdata, const in
        }
 }
 
-static void dynamic_paint_set_init_color_tex_to_imseq_cb(void *userdata, const int i)
+static void dynamic_paint_set_init_color_tex_to_imseq_cb(void *userdata, const int i,
+                                                         const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintSetInitColorData *data = userdata;
 
@@ -1469,7 +1471,8 @@ static void dynamic_paint_set_init_color_tex_to_imseq_cb(void *userdata, const i
        pPoint[i].color[3] = texres.tin;
 }
 
-static void dynamic_paint_set_init_color_vcol_to_imseq_cb(void *userdata, const int i)
+static void dynamic_paint_set_init_color_vcol_to_imseq_cb(void *userdata, const int i,
+                                                          const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintSetInitColorData *data = userdata;
 
@@ -1673,7 +1676,8 @@ typedef struct DynamicPaintModifierApplyData {
        MLoopCol *mloopcol_preview;
 } DynamicPaintModifierApplyData;
 
-static void dynamic_paint_apply_surface_displace_cb(void *userdata, const int i)
+static void dynamic_paint_apply_surface_displace_cb(void *userdata, const int i,
+                                                    const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintModifierApplyData *data = userdata;
 
@@ -1708,7 +1712,8 @@ static void dynamicPaint_applySurfaceDisplace(DynamicPaintSurface *surface, Deri
        }
 }
 
-static void dynamic_paint_apply_surface_vpaint_blend_cb(void *userdata, const int i)
+static void dynamic_paint_apply_surface_vpaint_blend_cb(void *userdata, const int i,
+                                                        const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintModifierApplyData *data = userdata;
 
@@ -1719,7 +1724,8 @@ static void dynamic_paint_apply_surface_vpaint_blend_cb(void *userdata, const in
        blendColors(pPoint[i].color, pPoint[i].color[3], pPoint[i].e_color, pPoint[i].e_color[3], fcolor[i]);
 }
 
-static void dynamic_paint_apply_surface_vpaint_cb(void *userdata, const int p_index)
+static void dynamic_paint_apply_surface_vpaint_cb(void *userdata, const int p_index,
+                                                  const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintModifierApplyData *data = userdata;
        Object *ob = data->ob;
@@ -1789,7 +1795,8 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *userdata, const int p_in
        }
 }
 
-static void dynamic_paint_apply_surface_wave_cb(void *userdata, const int i)
+static void dynamic_paint_apply_surface_wave_cb(void *userdata, const int i,
+                                                const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintModifierApplyData *data = userdata;
 
@@ -2106,7 +2113,8 @@ typedef struct DynamicPaintCreateUVSurfaceData {
        uint32_t *active_points;
 } DynamicPaintCreateUVSurfaceData;
 
-static void dynamic_paint_create_uv_surface_direct_cb(void *userdata, const int ty)
+static void dynamic_paint_create_uv_surface_direct_cb(void *userdata, const int ty,
+                                                      const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintCreateUVSurfaceData *data = userdata;
 
@@ -2203,7 +2211,8 @@ static void dynamic_paint_create_uv_surface_direct_cb(void *userdata, const int
        }
 }
 
-static void dynamic_paint_create_uv_surface_neighbor_cb(void *userdata, const int ty)
+static void dynamic_paint_create_uv_surface_neighbor_cb(void *userdata, const int ty,
+                                                        const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintCreateUVSurfaceData *data = userdata;
 
@@ -2995,7 +3004,8 @@ typedef struct DynamicPaintOutputSurfaceImageData {
        ImBuf *ibuf;
 } DynamicPaintOutputSurfaceImageData;
 
-static void dynamic_paint_output_surface_image_paint_cb(void *userdata, const int index)
+static void dynamic_paint_output_surface_image_paint_cb(void *userdata, const int index,
+                                                        const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintOutputSurfaceImageData *data = userdata;
 
@@ -3015,7 +3025,8 @@ static void dynamic_paint_output_surface_image_paint_cb(void *userdata, const in
        }
 }
 
-static void dynamic_paint_output_surface_image_displace_cb(void *userdata, const int index)
+static void dynamic_paint_output_surface_image_displace_cb(void *userdata, const int index,
+                                                           const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintOutputSurfaceImageData *data = userdata;
 
@@ -3039,7 +3050,8 @@ static void dynamic_paint_output_surface_image_displace_cb(void *userdata, const
        ibuf->rect_float[pos + 3] = 1.0f;
 }
 
-static void dynamic_paint_output_surface_image_wave_cb(void *userdata, const int index)
+static void dynamic_paint_output_surface_image_wave_cb(void *userdata, const int index,
+                                                       const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintOutputSurfaceImageData *data = userdata;
 
@@ -3061,7 +3073,8 @@ static void dynamic_paint_output_surface_image_wave_cb(void *userdata, const int
        ibuf->rect_float[pos + 3] = 1.0f;
 }
 
-static void dynamic_paint_output_surface_image_wetmap_cb(void *userdata, const int index)
+static void dynamic_paint_output_surface_image_wetmap_cb(void *userdata, const int index,
+                                                         const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintOutputSurfaceImageData *data = userdata;
 
@@ -3549,7 +3562,8 @@ typedef struct DynamicPaintBrushVelocityData {
        const float timescale;
 } DynamicPaintBrushVelocityData;
 
-static void dynamic_paint_brush_velocity_compute_cb(void *userdata, const int i)
+static void dynamic_paint_brush_velocity_compute_cb(void *userdata, const int i,
+                                                    const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintBrushVelocityData *data = userdata;
 
@@ -3699,7 +3713,7 @@ typedef struct DynamicPaintPaintData {
  *     Paint a brush object mesh to the surface
  */
 static void dynamic_paint_paint_mesh_cell_point_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int id, const int UNUSED(threadid))
+        void *userdata, const int id, const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintPaintData *data = userdata;
 
@@ -4140,7 +4154,7 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
  *     Paint a particle system to the surface
  */
 static void dynamic_paint_paint_particle_cell_point_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int id, const int UNUSED(threadid))
+        void *userdata, const int id, const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintPaintData *data = userdata;
 
@@ -4415,7 +4429,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface,
 
 /* paint a single point of defined proximity radius to the surface */
 static void dynamic_paint_paint_single_point_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int index, const int UNUSED(threadid))
+        void *userdata, const int index, const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintPaintData *data = userdata;
 
@@ -4561,7 +4575,8 @@ static int dynamicPaint_paintSinglePoint(
  *     Calculate current frame distances and directions for adjacency data
  */
 
-static void dynamic_paint_prepare_adjacency_cb(void *userdata, const int index)
+static void dynamic_paint_prepare_adjacency_cb(void *userdata, const int index,
+                                               const ParallelRangeTLS *UNUSED(tls))
 {
        PaintSurfaceData *sData = userdata;
        PaintBakeData *bData = sData->bData;
@@ -4788,7 +4803,8 @@ typedef struct DynamicPaintEffectData {
  *     Prepare data required by effects for current frame.
  *     Returns number of steps required
  */
-static void dynamic_paint_prepare_effect_cb(void *userdata, const int index)
+static void dynamic_paint_prepare_effect_cb(void *userdata, const int index,
+                                            const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintEffectData *data = userdata;
 
@@ -4893,7 +4909,8 @@ static int dynamicPaint_prepareEffectStep(
 /**
  *     Processes active effect step.
  */
-static void dynamic_paint_effect_spread_cb(void *userdata, const int index)
+static void dynamic_paint_effect_spread_cb(void *userdata, const int index,
+                                           const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintEffectData *data = userdata;
 
@@ -4938,7 +4955,8 @@ static void dynamic_paint_effect_spread_cb(void *userdata, const int index)
        }
 }
 
-static void dynamic_paint_effect_shrink_cb(void *userdata, const int index)
+static void dynamic_paint_effect_shrink_cb(void *userdata, const int index,
+                                           const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintEffectData *data = userdata;
 
@@ -4988,7 +5006,8 @@ static void dynamic_paint_effect_shrink_cb(void *userdata, const int index)
        }
 }
 
-static void dynamic_paint_effect_drip_cb(void *userdata, const int index)
+static void dynamic_paint_effect_drip_cb(void *userdata, const int index,
+                                         const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintEffectData *data = userdata;
 
@@ -5166,7 +5185,8 @@ static void dynamicPaint_doEffectStep(
        }
 }
 
-static void dynamic_paint_border_cb(void *userdata, const int b_index)
+static void dynamic_paint_border_cb(void *userdata, const int b_index,
+                                    const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintEffectData *data = userdata;
 
@@ -5240,7 +5260,8 @@ static void dynamicPaint_doBorderStep(DynamicPaintSurface *surface)
                    0, sData->adj_data->total_border, &data, dynamic_paint_border_cb, sData->adj_data->total_border > 1000);
 }
 
-static void dynamic_paint_wave_step_cb(void *userdata, const int index)
+static void dynamic_paint_wave_step_cb(void *userdata, const int index,
+                                       const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintEffectData *data = userdata;
 
@@ -5403,7 +5424,8 @@ typedef struct DynamicPaintDissolveDryData {
        const float timescale;
 } DynamicPaintDissolveDryData;
 
-static void dynamic_paint_surface_pre_step_cb(void *userdata, const int index)
+static void dynamic_paint_surface_pre_step_cb(void *userdata, const int index,
+                                              const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintDissolveDryData *data = userdata;
 
@@ -5526,7 +5548,8 @@ typedef struct DynamicPaintGenerateBakeData {
        const bool new_bdata;
 } DynamicPaintGenerateBakeData;
 
-static void dynamic_paint_generate_bake_data_cb(void *userdata, const int index)
+static void dynamic_paint_generate_bake_data_cb(void *userdata, const int index,
+                                                const ParallelRangeTLS *UNUSED(tls))
 {
        const DynamicPaintGenerateBakeData *data = userdata;
 
index 104bb0c07a655def71748946fef182d8b06d3838..489f19658841e011b5e78e836e2692c36b6d2e1d 100644 (file)
@@ -1434,7 +1434,8 @@ typedef struct MaskRasterizeBufferData {
        float *buffer;
 } MaskRasterizeBufferData;
 
-static void maskrasterize_buffer_cb(void *userdata, int y)
+static void maskrasterize_buffer_cb(void *userdata, int y,
+                                    const ParallelRangeTLS *UNUSED(tls))
 {
        MaskRasterizeBufferData *data = userdata;
 
index 35757557f76bbfba25582055b2f4234147697fc0..b58bea941e59c675c956d6b061005e00bc238e15 100644 (file)
@@ -177,7 +177,8 @@ typedef struct MeshCalcNormalsData {
        float (*vnors)[3];
 } MeshCalcNormalsData;
 
-static void mesh_calc_normals_poly_cb(void *userdata, const int pidx)
+static void mesh_calc_normals_poly_cb(void *userdata, const int pidx,
+                                      const ParallelRangeTLS *UNUSED(tls))
 {
        MeshCalcNormalsData *data = userdata;
        const MPoly *mp = &data->mpolys[pidx];
@@ -185,7 +186,8 @@ static void mesh_calc_normals_poly_cb(void *userdata, const int pidx)
        BKE_mesh_calc_poly_normal(mp, data->mloop + mp->loopstart, data->mverts, data->pnors[pidx]);
 }
 
-static void mesh_calc_normals_poly_prepare_cb(void *userdata, const int pidx)
+static void mesh_calc_normals_poly_prepare_cb(void *userdata, const int pidx,
+                                              const ParallelRangeTLS *UNUSED(tls))
 {
        MeshCalcNormalsData *data = userdata;
        const MPoly *mp = &data->mpolys[pidx];
@@ -247,14 +249,16 @@ static void mesh_calc_normals_poly_prepare_cb(void *userdata, const int pidx)
        }
 }
 
-static void mesh_calc_normals_poly_accum_cb(void *userdata, const int lidx)
+static void mesh_calc_normals_poly_accum_cb(void *userdata, const int lidx,
+                                            const ParallelRangeTLS *UNUSED(tls))
 {
        MeshCalcNormalsData *data = userdata;
 
        add_v3_v3(data->vnors[data->mloop[lidx].v], data->lnors_weighted[lidx]);
 }
 
-static void mesh_calc_normals_poly_finalize_cb(void *userdata, const int vidx)
+static void mesh_calc_normals_poly_finalize_cb(void *userdata, const int vidx,
+                                               const ParallelRangeTLS *UNUSED(tls))
 {
        MeshCalcNormalsData *data = userdata;
 
index 537c8926a5b104d6b4bdbfcae486e7ae910630c7..53e4119987f005f7aeb14148f00253b33e2e119a 100644 (file)
@@ -502,7 +502,8 @@ typedef struct OceanSimulateData {
        float chop_amount;
 } OceanSimulateData;
 
-static void ocean_compute_htilda(void *userdata, const int i)
+static void ocean_compute_htilda(void *userdata, const int i,
+                                 const ParallelRangeTLS *UNUSED(tls))
 {
        OceanSimulateData *osd = userdata;
        const Ocean *o = osd->o;
index 38eb861599a58762327730690a5b50629dc3c398..505f6c63baf0e00e0666358af83dd33cd7347a3d 100644 (file)
@@ -3371,14 +3371,14 @@ typedef struct DynamicStepSolverTaskData {
 } DynamicStepSolverTaskData;
 
 static void dynamics_step_sph_ddr_task_cb_ex(
-        void *userdata, void *userdata_chunk, const int p, const int UNUSED(thread_id))
+        void *userdata, const int p, const ParallelRangeTLS *tls)
 {
        DynamicStepSolverTaskData *data = userdata;
        ParticleSimulationData *sim = data->sim;
        ParticleSystem *psys = sim->psys;
        ParticleSettings *part = psys->part;
 
-       SPHData *sphdata = userdata_chunk;
+       SPHData *sphdata = tls->userdata_chunk;
 
        ParticleData *pa;
 
@@ -3405,7 +3405,7 @@ static void dynamics_step_sph_ddr_task_cb_ex(
 }
 
 static void dynamics_step_sph_classical_basic_integrate_task_cb_ex(
-        void *userdata,  void *UNUSED(userdata_chunk), const int p, const int UNUSED(thread_id))
+        void *userdata,  const int p, const ParallelRangeTLS *UNUSED(tls))
 {
        DynamicStepSolverTaskData *data = userdata;
        ParticleSimulationData *sim = data->sim;
@@ -3421,13 +3421,13 @@ static void dynamics_step_sph_classical_basic_integrate_task_cb_ex(
 }
 
 static void dynamics_step_sph_classical_calc_density_task_cb_ex(
-        void *userdata, void *userdata_chunk, const int p, const int UNUSED(thread_id))
+        void *userdata, const int p, const ParallelRangeTLS *tls)
 {
        DynamicStepSolverTaskData *data = userdata;
        ParticleSimulationData *sim = data->sim;
        ParticleSystem *psys = sim->psys;
 
-       SPHData *sphdata = userdata_chunk;
+       SPHData *sphdata = tls->userdata_chunk;
 
        ParticleData *pa;
 
@@ -3439,14 +3439,14 @@ static void dynamics_step_sph_classical_calc_density_task_cb_ex(
 }
 
 static void dynamics_step_sph_classical_integrate_task_cb_ex(
-        void *userdata, void *userdata_chunk, const int p, const int UNUSED(thread_id))
+        void *userdata, const int p, const ParallelRangeTLS *tls)
 {
        DynamicStepSolverTaskData *data = userdata;
        ParticleSimulationData *sim = data->sim;
        ParticleSystem *psys = sim->psys;
        ParticleSettings *part = psys->part;
 
-       SPHData *sphdata = userdata_chunk;
+       SPHData *sphdata = tls->userdata_chunk;
 
        ParticleData *pa;
 
index 39d1d8e8510a34854d5731d8b7687a93350a8d41..e476ccbc48b6f268ac49a80f842b089217fac91b 100644 (file)
@@ -938,7 +938,8 @@ typedef struct PBVHUpdateData {
        int flag;
 } PBVHUpdateData;
 
-static void pbvh_update_normals_accum_task_cb(void *userdata, const int n)
+static void pbvh_update_normals_accum_task_cb(void *userdata, const int n,
+                                              const ParallelRangeTLS *UNUSED(tls))
 {
        PBVHUpdateData *data = userdata;
 
@@ -991,7 +992,8 @@ static void pbvh_update_normals_accum_task_cb(void *userdata, const int n)
        }
 }
 
-static void pbvh_update_normals_store_task_cb(void *userdata, const int n)
+static void pbvh_update_normals_store_task_cb(void *userdata, const int n,
+                                              const ParallelRangeTLS *UNUSED(tls))
 {
        PBVHUpdateData *data = userdata;
        PBVH *bvh = data->bvh;
@@ -1057,7 +1059,8 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes,
        MEM_freeN(vnors);
 }
 
-static void pbvh_update_BB_redraw_task_cb(void *userdata, const int n)
+static void pbvh_update_BB_redraw_task_cb(void *userdata, const int n,
+                                          const ParallelRangeTLS *UNUSED(tls))
 {
        PBVHUpdateData *data = userdata;
        PBVH *bvh = data->bvh;
index f9d1793d7cbd660c3c826c922059a314c24d0dbc..09b0dc569cb5d5c172d41a183307399b100b60f2 100644 (file)
@@ -88,13 +88,13 @@ typedef struct ShrinkwrapCalcCBData {
  * for each vertex performs a nearest vertex search on the tree
  */
 static void shrinkwrap_calc_nearest_vertex_cb_ex(
-        void *userdata, void *userdata_chunk, const int i, const int UNUSED(threadid))
+        void *userdata, const int i, const ParallelRangeTLS *tls)
 {
        ShrinkwrapCalcCBData *data = userdata;
 
        ShrinkwrapCalcData *calc = data->calc;
        BVHTreeFromMesh *treeData = data->treeData;
-       BVHTreeNearest *nearest = userdata_chunk;
+       BVHTreeNearest *nearest = tls->userdata_chunk;
 
        float *co = calc->vertexCos[i];
        float tmp_co[3];
@@ -257,7 +257,7 @@ bool BKE_shrinkwrap_project_normal(
 }
 
 static void shrinkwrap_calc_normal_projection_cb_ex(
-        void *userdata, void *userdata_chunk, const int i, const int UNUSED(threadid))
+        void *userdata, const int i, const ParallelRangeTLS *tls)
 {
        ShrinkwrapCalcCBData *data = userdata;
 
@@ -272,7 +272,7 @@ static void shrinkwrap_calc_normal_projection_cb_ex(
        float *proj_axis = data->proj_axis;
        SpaceTransform *local2aux = data->local2aux;
 
-       BVHTreeRayHit *hit = userdata_chunk;
+       BVHTreeRayHit *hit = tls->userdata_chunk;
 
        const float proj_limit_squared = calc->smd->projLimit * calc->smd->projLimit;
        float *co = calc->vertexCos[i];
@@ -495,13 +495,13 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for
  * NN matches for each vertex
  */
 static void shrinkwrap_calc_nearest_surface_point_cb_ex(
-        void *userdata, void *userdata_chunk, const int i, const int UNUSED(threadid))
+        void *userdata, const int i, const ParallelRangeTLS *tls)
 {
        ShrinkwrapCalcCBData *data = userdata;
 
        ShrinkwrapCalcData *calc = data->calc;
        BVHTreeFromMesh *treeData = data->treeData;
-       BVHTreeNearest *nearest = userdata_chunk;
+       BVHTreeNearest *nearest = tls->userdata_chunk;
 
        float *co = calc->vertexCos[i];
        float tmp_co[3];
index fcf4724bd1c3aad08f8a15219e09c7eb058056ec..37b9466645d29a4b2f9f70136c9968a80e652434 100644 (file)
@@ -738,7 +738,7 @@ typedef struct ObstaclesFromDMData {
        int *num_obstacles;
 } ObstaclesFromDMData;
 
-static void obstacles_from_derivedmesh_task_cb(void *userdata, const int z)
+static void obstacles_from_derivedmesh_task_cb(void *userdata, const int z, const ParallelRangeTLS *UNUSED(tls))
 {
        ObstaclesFromDMData *data = userdata;
        SmokeDomainSettings *sds = data->sds;
@@ -1184,7 +1184,7 @@ typedef struct EmitFromParticlesData {
        float hr_smooth;
 } EmitFromParticlesData;
 
-static void emit_from_particles_task_cb(void *userdata, const int z)
+static void emit_from_particles_task_cb(void *userdata, const int z, const ParallelRangeTLS *UNUSED(tls))
 {
        EmitFromParticlesData *data = userdata;
        SmokeFlowSettings *sfs = data->sfs;
@@ -1567,7 +1567,7 @@ typedef struct EmitFromDMData {
        int *min, *max, *res;
 } EmitFromDMData;
 
-static void emit_from_derivedmesh_task_cb(void *userdata, const int z)
+static void emit_from_derivedmesh_task_cb(void *userdata, const int z, const ParallelRangeTLS *UNUSED(tls))
 {
        EmitFromDMData *data = userdata;
        EmissionMap *em = data->em;
@@ -2436,7 +2436,7 @@ typedef struct UpdateEffectorsData {
        unsigned char *obstacle;
 } UpdateEffectorsData;
 
-static void update_effectors_task_cb(void *userdata, const int x)
+static void update_effectors_task_cb(void *userdata, const int x, const ParallelRangeTLS *UNUSED(tls))
 {
        UpdateEffectorsData *data = userdata;
        SmokeDomainSettings *sds = data->sds;
index 40234bacdfe2ce87a11ae787baa9c2570a52e483..5dc350640c02e5911c818843fc3caef7d6d85006 100644 (file)
@@ -432,7 +432,9 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
        return context;
 }
 
-static void autotrack_context_step_cb(void *userdata, int track)
+static void autotrack_context_step_cb(void *userdata,
+                                      int track,
+                                      const ParallelRangeTLS *UNUSED(tls))
 {
        AutoTrackContext *context = userdata;
        const int frame_delta = context->backwards ? -1 : 1;
index edddeb41cc89dbe5f23017489b24acb758279346..9e8f01df1d5f038d2a3e9a97f6278523ac973f69 100644 (file)
@@ -1503,7 +1503,10 @@ typedef struct TrackingStabilizeFrameInterpolationData {
        interpolation_func interpolation;
 } TrackingStabilizeFrameInterpolationData;
 
-static void tracking_stabilize_frame_interpolation_cb(void *userdata, int j)
+static void tracking_stabilize_frame_interpolation_cb(
+        void *userdata,
+        int j,
+        const ParallelRangeTLS *UNUSED(tls))
 {
        TrackingStabilizeFrameInterpolationData *data = userdata;
        ImBuf *ibuf = data->ibuf;
index ccfa2b6e2e760ed838c594f4856d3d7986b61d18..acfdd3729c1bdc74688ee569599f6848b29aac95 100644 (file)
@@ -116,15 +116,27 @@ void BLI_task_pool_delayed_push_begin(TaskPool *pool, int thread_id);
 void BLI_task_pool_delayed_push_end(TaskPool *pool, int thread_id);
 
 /* Parallel for routines */
-typedef void (*TaskParallelRangeFunc)(void *userdata, const int iter);
-typedef void (*TaskParallelRangeFuncEx)(void *userdata, void *userdata_chunk, const int iter, const int thread_id);
+
+/* Per-thread specific data passed to the callback. */
+typedef struct ParallelRangeTLS {
+       /* Identifier of the thread who this data belongs to. */
+       int thread_id;
+       /* Copy of user-specifier chunk, which is copied from original chunk to all
+        * worker threads. This is similar to OpenMP's firstprivate.
+        */
+       void *userdata_chunk;
+} ParallelRangeTLS;
+
+typedef void (*TaskParallelRangeFunc)(void *userdata,
+                                      const int iter,
+                                      const ParallelRangeTLS *tls);
 typedef void (*TaskParallelRangeFuncFinalize)(void *userdata, void *userdata_chunk);
 void BLI_task_parallel_range_ex(
         int start, int stop,
         void *userdata,
         void *userdata_chunk,
         const size_t userdata_chunk_size,
-        TaskParallelRangeFuncEx func_ex,
+        TaskParallelRangeFunc func,
         const bool use_threading,
         const bool use_dynamic_scheduling);
 void BLI_task_parallel_range(
@@ -138,7 +150,7 @@ void BLI_task_parallel_range_finalize(
         void *userdata,
         void *userdata_chunk,
         const size_t userdata_chunk_size,
-        TaskParallelRangeFuncEx func_ex,
+        TaskParallelRangeFunc func,
         TaskParallelRangeFuncFinalize func_finalize,
         const bool use_threading,
         const bool use_dynamic_scheduling);
index bd16bc1a9c64d3d38b61ab8a3e275b894361f4b3..6e33f75fe69ec607d435b10ab8ab561cfe167e16 100644 (file)
@@ -798,7 +798,7 @@ typedef struct BVHDivNodesData {
        int first_of_next_level;
 } BVHDivNodesData;
 
-static void non_recursive_bvh_div_nodes_task_cb(void *userdata, const int j)
+static void non_recursive_bvh_div_nodes_task_cb(void *userdata, const int j, const ParallelRangeTLS *UNUSED(tls))
 {
        BVHDivNodesData *data = userdata;
 
@@ -929,8 +929,9 @@ static void non_recursive_bvh_div_nodes(
                }
                else {
                        /* Less hassle for debugging. */
+                       ParallelRangeTLS tls = {0};
                        for (int i_task = i; i_task < i_stop; i_task++) {
-                               non_recursive_bvh_div_nodes_task_cb(&cb_data, i_task);
+                               non_recursive_bvh_div_nodes_task_cb(&cb_data, i_task, &tls);
                        }
                }
        }
@@ -1276,7 +1277,7 @@ int BLI_bvhtree_overlap_thread_num(const BVHTree *tree)
        return (int)MIN2(tree->tree_type, tree->nodes[tree->totleaf]->totnode);
 }
 
-static void bvhtree_overlap_task_cb(void *userdata, const int j)
+static void bvhtree_overlap_task_cb(void *userdata, const int j, const ParallelRangeTLS *UNUSED(tls))
 {
        BVHOverlapData_Thread *data = &((BVHOverlapData_Thread *)userdata)[j];
        BVHOverlapData_Shared *data_shared = data->shared;
index fd7418a8f7b85ab7c7fa4240f8cb65e41e76d922..cfadbba028f06b84af3994a472f02f2fdcc740d3 100644 (file)
@@ -46,7 +46,8 @@ typedef struct CovarianceData {
        int nbr_cos_vn;
 } CovarianceData;
 
-static void covariance_m_vn_ex_task_cb(void *userdata, const int a)
+static void covariance_m_vn_ex_task_cb(void *userdata, const int a,
+                                       const ParallelRangeTLS *UNUSED(tls))
 {
        CovarianceData *data = userdata;
        const float *cos_vn = data->cos_vn;
index afa20e3d766ce855c934c7ab517b46bc025ba777..030d4124e62414e86cf33253800a0da0ba74d427 100644 (file)
@@ -994,7 +994,6 @@ typedef struct ParallelRangeState {
        void *userdata;
 
        TaskParallelRangeFunc func;
-       TaskParallelRangeFuncEx func_ex;
 
        int iter;
        int chunk_size;
@@ -1015,23 +1014,17 @@ BLI_INLINE bool parallel_range_next_iter_get(
 static void parallel_range_func(
         TaskPool * __restrict pool,
         void *userdata_chunk,
-        int threadid)
+        int thread_id)
 {
        ParallelRangeState * __restrict state = BLI_task_pool_userdata(pool);
+       ParallelRangeTLS tls = {
+               .thread_id = thread_id,
+               .userdata_chunk = userdata_chunk,
+       };
        int iter, count;
-
        while (parallel_range_next_iter_get(state, &iter, &count)) {
-               int i;
-
-               if (state->func_ex) {
-                       for (i = 0; i < count; ++i) {
-                               state->func_ex(state->userdata, userdata_chunk, iter + i, threadid);
-                       }
-               }
-               else {
-                       for (i = 0; i < count; ++i) {
-                               state->func(state->userdata, iter + i);
-                       }
+               for (int i = 0; i < count; ++i) {
+                       state->func(state->userdata, iter + i, &tls);
                }
        }
 }
@@ -1047,7 +1040,6 @@ static void task_parallel_range_ex(
         void *userdata_chunk,
         const size_t userdata_chunk_size,
         TaskParallelRangeFunc func,
-        TaskParallelRangeFuncEx func_ex,
         TaskParallelRangeFuncFinalize func_finalize,
         const bool use_threading,
         const bool use_dynamic_scheduling)
@@ -1059,7 +1051,7 @@ static void task_parallel_range_ex(
 
        void *userdata_chunk_local = NULL;
        void *userdata_chunk_array = NULL;
-       const bool use_userdata_chunk = (func_ex != NULL) && (userdata_chunk_size != 0) && (userdata_chunk != NULL);
+       const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != NULL);
 
        if (start == stop) {
                return;
@@ -1067,7 +1059,6 @@ static void task_parallel_range_ex(
 
        BLI_assert(start < stop);
        if (userdata_chunk_size != 0) {
-               BLI_assert(func_ex != NULL && func == NULL);
                BLI_assert(userdata_chunk != NULL);
        }
 
@@ -1075,28 +1066,25 @@ static void task_parallel_range_ex(
         * do everything from the main thread.
         */
        if (!use_threading) {
-               if (func_ex) {
-                       if (use_userdata_chunk) {
-                               userdata_chunk_local = MALLOCA(userdata_chunk_size);
-                               memcpy(userdata_chunk_local, userdata_chunk, userdata_chunk_size);
-                       }
-
-                       for (i = start; i < stop; ++i) {
-                               func_ex(userdata, userdata_chunk_local, i, 0);
-                       }
-
-                       if (func_finalize) {
-                               func_finalize(userdata, userdata_chunk_local);
-                       }
+               if (use_userdata_chunk) {
+                       userdata_chunk_local = MALLOCA(userdata_chunk_size);
+                       memcpy(userdata_chunk_local, userdata_chunk, userdata_chunk_size);
+               }
 
-                       MALLOCA_FREE(userdata_chunk_local, userdata_chunk_size);
+               ParallelRangeTLS tls = {
+                       .thread_id = 0,
+                       .userdata_chunk = userdata_chunk_local,
+               };
+               for (i = start; i < stop; ++i) {
+                       func(userdata, i, &tls);
                }
-               else {
-                       for (i = start; i < stop; ++i) {
-                               func(userdata, i);
-                       }
+
+               if (func_finalize) {
+                       func_finalize(userdata, userdata_chunk_local);
                }
 
+               MALLOCA_FREE(userdata_chunk_local, userdata_chunk_size);
+
                return;
        }
 
@@ -1114,7 +1102,6 @@ static void task_parallel_range_ex(
        state.stop = stop;
        state.userdata = userdata;
        state.func = func;
-       state.func_ex = func_ex;
        state.iter = start;
        if (use_dynamic_scheduling) {
                state.chunk_size = 32;
@@ -1180,12 +1167,12 @@ void BLI_task_parallel_range_ex(
         void *userdata,
         void *userdata_chunk,
         const size_t userdata_chunk_size,
-        TaskParallelRangeFuncEx func_ex,
+        TaskParallelRangeFunc func,
         const bool use_threading,
         const bool use_dynamic_scheduling)
 {
        task_parallel_range_ex(
-                   start, stop, userdata, userdata_chunk, userdata_chunk_size, NULL, func_ex, NULL,
+                   start, stop, userdata, userdata_chunk, userdata_chunk_size, func, NULL,
                    use_threading, use_dynamic_scheduling);
 }
 
@@ -1206,7 +1193,7 @@ void BLI_task_parallel_range(
         TaskParallelRangeFunc func,
         const bool use_threading)
 {
-       task_parallel_range_ex(start, stop, userdata, NULL, 0, func, NULL, NULL, use_threading, false);
+       task_parallel_range_ex(start, stop, userdata, NULL, 0, func, NULL, use_threading, false);
 }
 
 /**
@@ -1232,13 +1219,13 @@ void BLI_task_parallel_range_finalize(
         void *userdata,
         void *userdata_chunk,
         const size_t userdata_chunk_size,
-        TaskParallelRangeFuncEx func_ex,
+        TaskParallelRangeFunc func,
         TaskParallelRangeFuncFinalize func_finalize,
         const bool use_threading,
         const bool use_dynamic_scheduling)
 {
        task_parallel_range_ex(
-                   start, stop, userdata, userdata_chunk, userdata_chunk_size, NULL, func_ex, func_finalize,
+                   start, stop, userdata, userdata_chunk, userdata_chunk_size, func, func_finalize,
                    use_threading, use_dynamic_scheduling);
 }
 
index 96b2eb17c4c620a1f0c3880cc3a7a0f7334e4d63..29f74b13af866133a475a2b811d4f2bccfadc0ef 100644 (file)
@@ -419,7 +419,8 @@ typedef struct BMLoopInterpMultiresData {
        float d;
 } BMLoopInterpMultiresData;
 
-static void loop_interp_multires_cb(void *userdata, int ix)
+static void loop_interp_multires_cb(void *userdata, int ix,
+                                    const ParallelRangeTLS *UNUSED(tls))
 {
        BMLoopInterpMultiresData *data = userdata;
 
index 09d25be41d6e12e7b1d46affa72b16205ae11455..4c5d68fb7efced037d2cb615b80e6c197d108200 100644 (file)
@@ -107,7 +107,9 @@ typedef struct CalculatePengindData {
        unsigned int layers;
 } CalculatePengindData;
 
-static void calculate_pending_func(void *data_v, int i)
+static void calculate_pending_func(void *data_v,
+                                   int i,
+                                   const ParallelRangeTLS * /*tls*/)
 {
        CalculatePengindData *data = (CalculatePengindData *)data_v;
        Depsgraph *graph = data->graph;
index 63d010849c3661f0dcaee36d70b23b3941f6e4af..546d4e3cf5d8d6a7dac4412d3d36445fba48eb3e 100644 (file)
@@ -83,14 +83,18 @@ void lib_id_recalc_data_tag(Main *bmain, ID *id)
        DEG_id_type_tag(bmain, GS(id->name));
 }
 
-void flush_init_operation_node_func(void *data_v, int i)
+void flush_init_operation_node_func(void *data_v,
+                                    int i,
+                                    const ParallelRangeTLS * /*tls*/)
 {
        Depsgraph *graph = (Depsgraph *)data_v;
        OperationDepsNode *node = graph->operations[i];
        node->scheduled = false;
 }
 
-void flush_init_id_node_func(void *data_v, int i)
+void flush_init_id_node_func(void *data_v,
+                             int i,
+                             const ParallelRangeTLS * /*tls*/)
 {
        Depsgraph *graph = (Depsgraph *)data_v;
        IDDepsNode *id_node = graph->id_nodes[i];
@@ -279,7 +283,9 @@ void deg_graph_flush_updates(Main *bmain, Depsgraph *graph)
        flush_editors_id_update(bmain, graph);
 }
 
-static void graph_clear_func(void *data_v, int i)
+static void graph_clear_func(void *data_v,
+                             int i,
+                             const ParallelRangeTLS * /*tls*/)
 {
        Depsgraph *graph = (Depsgraph *)data_v;
        OperationDepsNode *node = graph->operations[i];
index f0d9a0bbb68746f59ad35694b8a0bed126fd7822..1378952c4cc88de49cb3f90eac8d3a84802b1620 100644 (file)
@@ -151,7 +151,7 @@ typedef struct LoadTexData {
        float radius;
 } LoadTexData;
 
-static void load_tex_task_cb_ex(void *userdata, void *UNUSED(userdata_chunck), const int j, const int thread_id)
+static void load_tex_task_cb_ex(void *userdata, const int j, const ParallelRangeTLS *tls)
 {
        LoadTexData *data = userdata;
        Brush *br = data->br;
@@ -212,7 +212,7 @@ static void load_tex_task_cb_ex(void *userdata, void *UNUSED(userdata_chunck), c
                        if (col) {
                                float rgba[4];
 
-                               paint_get_tex_pixel_col(mtex, x, y, rgba, pool, thread_id, convert_to_linear, colorspace);
+                               paint_get_tex_pixel_col(mtex, x, y, rgba, pool, tls->thread_id, convert_to_linear, colorspace);
 
                                buffer[index * 4]     = rgba[0] * 255;
                                buffer[index * 4 + 1] = rgba[1] * 255;
@@ -220,7 +220,7 @@ static void load_tex_task_cb_ex(void *userdata, void *UNUSED(userdata_chunck), c
                                buffer[index * 4 + 3] = rgba[3] * 255;
                        }
                        else {
-                               float avg = paint_get_tex_pixel(mtex, x, y, pool, thread_id);
+                               float avg = paint_get_tex_pixel(mtex, x, y, pool, tls->thread_id);
 
                                avg += br->texture_sample_bias;
 
@@ -367,7 +367,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima
        return 1;
 }
 
-static void load_tex_cursor_task_cb(void *userdata, const int j)
+static void load_tex_cursor_task_cb(void *userdata, const int j, const ParallelRangeTLS *UNUSED(tls))
 {
        LoadTexData *data = userdata;
        Brush *br = data->br;
index a1aad2bdc5776b96c1b59824109fd6d9e794f325..b687c937a2265c5c1a57f239c28ab33c9c7ba13f 100644 (file)
@@ -1070,7 +1070,8 @@ typedef struct Paint2DForeachData {
        int tilew;
 } Paint2DForeachData;
 
-static void paint_2d_op_foreach_do(void *data_v, const int iter)
+static void paint_2d_op_foreach_do(void *data_v, const int iter,
+                                   const ParallelRangeTLS *UNUSED(tls))
 {
        Paint2DForeachData *data = (Paint2DForeachData *)data_v;
        paint_2d_do_making_brush(data->s, data->region, data->curveb,
index 3b1b993a3e31f35a86ed2c0c2bb1740cb2d5a4ed..a48a3666ef961fcac93038bad5b90368d1d4ff51 100644 (file)
@@ -104,7 +104,8 @@ typedef struct MaskTaskData {
        float (*clip_planes_final)[4];
 } MaskTaskData;
 
-static void mask_flood_fill_task_cb(void *userdata, const int i)
+static void mask_flood_fill_task_cb(void *userdata, const int i,
+                                    const ParallelRangeTLS *UNUSED(tls))
 {
        MaskTaskData *data = userdata;
 
@@ -218,7 +219,8 @@ static void flip_plane(float out[4], const float in[4], const char symm)
        out[3] = in[3];
 }
 
-static void mask_box_select_task_cb(void *userdata, const int i)
+static void mask_box_select_task_cb(void *userdata, const int i,
+                                    const ParallelRangeTLS *UNUSED(tls))
 {
        MaskTaskData *data = userdata;
 
@@ -373,7 +375,8 @@ static void mask_lasso_px_cb(int x, int x_end, int y, void *user_data)
        } while (++index != index_end);
 }
 
-static void mask_gesture_lasso_task_cb(void *userdata, const int i)
+static void mask_gesture_lasso_task_cb(void *userdata, const int i,
+                                       const ParallelRangeTLS *UNUSED(tls))
 {
        LassoMaskData *lasso_data = userdata;
        MaskTaskData *data = &lasso_data->task_data;
index d61777a6d12eea198dc7e24ba93be6242e18ded4..666272bd11aa7357d064fb45147d676ec8c922ec 100644 (file)
@@ -1431,7 +1431,7 @@ static float wpaint_get_active_weight(const MDeformVert *dv, const WeightPaintIn
 }
 
 static void do_wpaint_precompute_weight_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+        void *userdata, const int n, const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        const MDeformVert *dv = &data->me->dvert[n];
@@ -1458,7 +1458,7 @@ static void precompute_weight_values(
 }
 
 static void do_wpaint_brush_blur_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+        void *userdata, const int n, const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1547,7 +1547,7 @@ static void do_wpaint_brush_blur_task_cb_ex(
 }
 
 static void do_wpaint_brush_smear_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+        void *userdata, const int n, const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1654,7 +1654,7 @@ static void do_wpaint_brush_smear_task_cb_ex(
 }
 
 static void do_wpaint_brush_draw_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+        void *userdata, const int n, const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1724,7 +1724,7 @@ static void do_wpaint_brush_draw_task_cb_ex(
 }
 
 static void do_wpaint_brush_calc_average_weight_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+        void *userdata, const int n, const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2377,7 +2377,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
 }
 
 static void do_vpaint_brush_calc_average_color_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+        void *userdata, const int n, const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2439,7 +2439,7 @@ static float tex_color_alpha_ubyte(
 }
 
 static void do_vpaint_brush_draw_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+        void *userdata,  const int n, const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2531,7 +2531,7 @@ static void do_vpaint_brush_draw_task_cb_ex(
 }
 
 static void do_vpaint_brush_blur_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+        void *userdata, const int n, const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2640,7 +2640,7 @@ static void do_vpaint_brush_blur_task_cb_ex(
 }
 
 static void do_vpaint_brush_smear_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int UNUSED(thread_id))
+        void *userdata, const int n, const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
index 53d7684e331feb746a02cf1aa913295125cf5293..4684395c18d2defc3dab262294111a024300f5f4 100644 (file)
@@ -376,7 +376,8 @@ static bool sculpt_stroke_is_dynamic_topology(
 
 /*** paint mesh ***/
 
-static void paint_mesh_restore_co_task_cb(void *userdata, const int n)
+static void paint_mesh_restore_co_task_cb(void *userdata, const int n,
+                                          const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -794,7 +795,8 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache *cache)
  * \note These are all _very_ similar, when changing one, check others.
  * \{ */
 
-static void calc_area_normal_and_center_task_cb(void *userdata, const int n)
+static void calc_area_normal_and_center_task_cb(void *userdata, const int n,
+                                                const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1626,7 +1628,7 @@ typedef struct {
 } SculptFindNearestToRayData;
 
 static void do_smooth_brush_mesh_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1648,7 +1650,7 @@ static void do_smooth_brush_mesh_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, vd.co)) {
                        const float fade = bstrength * tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f), thread_id);
+                               vd.no, vd.fno, smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f), tls->thread_id);
                        if (smooth_mask) {
                                float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask;
                                val *= fade * bstrength;
@@ -1674,7 +1676,7 @@ static void do_smooth_brush_mesh_task_cb_ex(
 }
 
 static void do_smooth_brush_bmesh_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1696,7 +1698,7 @@ static void do_smooth_brush_bmesh_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, vd.co)) {
                        const float fade = bstrength * tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, smooth_mask ? 0.0f : *vd.mask, thread_id);
+                               vd.no, vd.fno, smooth_mask ? 0.0f : *vd.mask, tls->thread_id);
                        if (smooth_mask) {
                                float val = bmesh_neighbor_average_mask(vd.bm_vert, vd.cd_vert_mask_offset) - *vd.mask;
                                val *= fade * bstrength;
@@ -1722,10 +1724,10 @@ static void do_smooth_brush_bmesh_task_cb_ex(
 }
 
 static void do_smooth_brush_multires_task_cb_ex(
-        void *userdata, void *userdata_chunk, const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
-       SculptDoBrushSmoothGridDataChunk *data_chunk = userdata_chunk;
+       SculptDoBrushSmoothGridDataChunk *data_chunk = tls->userdata_chunk;
        SculptSession *ss = data->ob->sculpt;
        Sculpt *sd = data->sd;
        const Brush *brush = data->brush;
@@ -1837,7 +1839,7 @@ static void do_smooth_brush_multires_task_cb_ex(
                                        const float strength_mask = (smooth_mask ? 0.0f : *mask);
                                        const float fade = bstrength * tex_strength(
                                                ss, brush, co, sqrtf(test.dist),
-                                               NULL, fno, strength_mask, thread_id);
+                                               NULL, fno, strength_mask, tls->thread_id);
                                        float f = 1.0f / 16.0f;
 
                                        if (x == 0 || x == gridsize - 1)
@@ -1940,7 +1942,7 @@ static void do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
 }
 
 static void do_mask_brush_draw_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -1958,7 +1960,7 @@ static void do_mask_brush_draw_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, vd.co)) {
                        const float fade = tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, 0.0f, thread_id);
+                               vd.no, vd.fno, 0.0f, tls->thread_id);
 
                        (*vd.mask) += fade * bstrength;
                        CLAMP(*vd.mask, 0, 1);
@@ -2000,7 +2002,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
 }
 
 static void do_draw_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2022,7 +2024,7 @@ static void do_draw_brush_task_cb_ex(
                        /* offset vertex */
                        const float fade = tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                        mul_v3_v3fl(proxy[vd.i], offset, fade);
 
@@ -2060,7 +2062,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
  * Used for 'SCULPT_TOOL_CREASE' and 'SCULPT_TOOL_BLOB'
  */
 static void do_crease_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2084,7 +2086,7 @@ static void do_crease_brush_task_cb_ex(
                        /* offset vertex */
                        const float fade = tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
                        float val1[3];
                        float val2[3];
 
@@ -2154,7 +2156,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
 }
 
 static void do_pinch_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2175,7 +2177,7 @@ static void do_pinch_brush_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, vd.co)) {
                        const float fade = bstrength * tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
                        float val[3];
 
                        sub_v3_v3v3(val, test.location, vd.co);
@@ -2205,7 +2207,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
 }
 
 static void do_grab_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2232,7 +2234,7 @@ static void do_grab_brush_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, orig_data.co)) {
                        const float fade = bstrength * tex_strength(
                                ss, brush, orig_data.co, sqrtf(test.dist),
-                               orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                        mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
 
@@ -2266,7 +2268,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
 }
 
 static void do_nudge_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2288,7 +2290,7 @@ static void do_nudge_brush_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, vd.co)) {
                        const float fade = bstrength * tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                        mul_v3_v3fl(proxy[vd.i], cono, fade);
 
@@ -2322,7 +2324,7 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
 }
 
 static void do_snake_hook_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2349,7 +2351,7 @@ static void do_snake_hook_brush_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, vd.co)) {
                        const float fade = bstrength * tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                        mul_v3_v3fl(proxy[vd.i], grab_delta, fade);
 
@@ -2428,7 +2430,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to
 }
 
 static void do_thumb_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2455,7 +2457,7 @@ static void do_thumb_brush_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, orig_data.co)) {
                        const float fade = bstrength * tex_strength(
                                ss, brush, orig_data.co, sqrtf(test.dist),
-                               orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                        mul_v3_v3fl(proxy[vd.i], cono, fade);
 
@@ -2489,7 +2491,7 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
 }
 
 static void do_rotate_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2517,7 +2519,7 @@ static void do_rotate_brush_task_cb_ex(
                        float vec[3], rot[3][3];
                        const float fade = bstrength * tex_strength(
                                ss, brush, orig_data.co, sqrtf(test.dist),
-                               orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                        sub_v3_v3v3(vec, orig_data.co, ss->cache->location);
                        axis_angle_normalized_to_mat3(rot, ss->cache->sculpt_normal_symm, angle * fade);
@@ -2551,7 +2553,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
 }
 
 static void do_layer_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2585,7 +2587,7 @@ static void do_layer_brush_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, orig_data.co)) {
                        const float fade = bstrength * tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
                        float *disp = &layer_disp[vd.i];
                        float val[3];
 
@@ -2638,7 +2640,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode
 }
 
 static void do_inflate_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2659,7 +2661,7 @@ static void do_inflate_brush_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, vd.co)) {
                        const float fade = bstrength * tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
                        float val[3];
 
                        if (vd.fno)
@@ -2802,7 +2804,7 @@ static float get_offset(Sculpt *sd, SculptSession *ss)
 }
 
 static void do_flatten_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2835,7 +2837,7 @@ static void do_flatten_brush_task_cb_ex(
                        if (plane_trim(ss->cache, brush, val)) {
                                const float fade = bstrength * tex_strength(
                                        ss, brush, vd.co, sqrtf(test.dist),
-                                       vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                                       vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                                mul_v3_v3fl(proxy[vd.i], val, fade);
 
@@ -2880,7 +2882,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
 }
 
 static void do_clay_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -2917,7 +2919,7 @@ static void do_clay_brush_task_cb_ex(
                                         * causes glitch with planes, see: T44390 */
                                        const float fade = bstrength * tex_strength(
                                                ss, brush, vd.co, sqrtf(test.dist),
-                                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                                        mul_v3_v3fl(proxy[vd.i], val, fade);
 
@@ -2966,7 +2968,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
 }
 
 static void do_clay_strips_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -3002,7 +3004,7 @@ static void do_clay_strips_brush_task_cb_ex(
                                         * causes glitch with planes, see: T44390 */
                                        const float fade = bstrength * tex_strength(
                                                ss, brush, vd.co, ss->cache->radius * test.dist,
-                                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                                        mul_v3_v3fl(proxy[vd.i], val, fade);
 
@@ -3076,7 +3078,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t
 }
 
 static void do_fill_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -3110,7 +3112,7 @@ static void do_fill_brush_task_cb_ex(
                                if (plane_trim(ss->cache, brush, val)) {
                                        const float fade = bstrength * tex_strength(
                                                ss, brush, vd.co, sqrtf(test.dist),
-                                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                                        mul_v3_v3fl(proxy[vd.i], val, fade);
 
@@ -3157,7 +3159,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
 }
 
 static void do_scrape_brush_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -3190,7 +3192,7 @@ static void do_scrape_brush_task_cb_ex(
                                if (plane_trim(ss->cache, brush, val)) {
                                        const float fade = bstrength * tex_strength(
                                                ss, brush, vd.co, sqrtf(test.dist),
-                                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                                        mul_v3_v3fl(proxy[vd.i], val, fade);
 
@@ -3237,7 +3239,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod
 }
 
 static void do_gravity_task_cb_ex(
-        void *userdata, void *UNUSED(userdata_chunk), const int n, const int thread_id)
+        void *userdata, const int n, const ParallelRangeTLS *tls)
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -3257,7 +3259,7 @@ static void do_gravity_task_cb_ex(
                if (sculpt_brush_test_sq_fn(&test, vd.co)) {
                        const float fade = tex_strength(
                                ss, brush, vd.co, sqrtf(test.dist),
-                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, thread_id);
+                               vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id);
 
                        mul_v3_v3fl(proxy[vd.i], offset, fade);
 
@@ -3392,7 +3394,8 @@ static void sculpt_topology_update(Sculpt *sd, Object *ob, Brush *brush, Unified
        }
 }
 
-static void do_brush_action_task_cb(void *userdata, const int n)
+static void do_brush_action_task_cb(void *userdata, const int n,
+                                    const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
 
@@ -3533,7 +3536,8 @@ static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd)
                copy_v3_v3(me->mvert[index].co, newco);
 }
 
-static void sculpt_combine_proxies_task_cb(void *userdata, const int n)
+static void sculpt_combine_proxies_task_cb(void *userdata, const int n,
+                                           const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
@@ -3628,7 +3632,8 @@ static void sculpt_update_keyblock(Object *ob)
        }
 }
 
-static void sculpt_flush_stroke_deform_task_cb(void *userdata, const int n)
+static void sculpt_flush_stroke_deform_task_cb(void *userdata, const int n,
+                                               const ParallelRangeTLS *UNUSED(tls))
 {
        SculptThreadedTaskData *data = userdata;
        SculptSession *ss = data->ob->sculpt;
index 44bd872d107c9503b1e5c6ae7908d641cee4be14..ed3acf0edbbeaad324e3460cc45666fd3ec7fbae 100644 (file)
@@ -316,7 +316,8 @@ static bool sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNod
        return 1;
 }
 
-static void sculpt_undo_bmesh_restore_generic_task_cb(void *userdata, const int n)
+static void sculpt_undo_bmesh_restore_generic_task_cb(void *userdata, const int n,
+                                                      const ParallelRangeTLS *UNUSED(tls))
 {
        PBVHNode **nodes = userdata;
 
index 80cb42c0b3d40f395f03533e8f5913c89d4c25f5..4c060f12a4b57e73d81cc853382c56347b2fe1aa 100644 (file)
@@ -459,13 +459,13 @@ typedef struct MakeHistogramViewData {
 } MakeHistogramViewData;
 
 static void make_histogram_view_from_ibuf_byte_cb_ex(
-        void *userdata, void *userdata_chunk, const int y, const int UNUSED(threadid))
+        void *userdata, const int y, const ParallelRangeTLS *tls)
 {
        MakeHistogramViewData *data = userdata;
        const ImBuf *ibuf = data->ibuf;
        const unsigned char *src = (unsigned char *)ibuf->rect;
 
-       uint32_t (*cur_bins)[HIS_STEPS] = userdata_chunk;
+       uint32_t (*cur_bins)[HIS_STEPS] = tls->userdata_chunk;
 
        for (int x = 0; x < ibuf->x; x++) {
                const unsigned char *pixel = src + (y * ibuf->x + x) * 4;
@@ -548,13 +548,13 @@ BLI_INLINE int get_bin_float(float f)
 }
 
 static void make_histogram_view_from_ibuf_float_cb_ex(
-        void *userdata, void *userdata_chunk, const int y, const int UNUSED(threadid))
+        void *userdata, const int y, const ParallelRangeTLS *tls)
 {
        const MakeHistogramViewData *data = userdata;
        const ImBuf *ibuf = data->ibuf;
        const float *src = ibuf->rect_float;
 
-       uint32_t (*cur_bins)[HIS_STEPS] = userdata_chunk;
+       uint32_t (*cur_bins)[HIS_STEPS] = tls->userdata_chunk;
 
        for (int x = 0; x < ibuf->x; x++) {
                const float *pixel = src + (y * ibuf->x + x) * 4;
index fb8c0dd05a539b8f4db8a905b409bb05969d2fb1..16fd3b098c9c95e76907dfb01eaaf4c58a63ad58 100644 (file)
@@ -213,7 +213,7 @@ typedef struct DisplaceUserdata {
        float (*vert_clnors)[3];
 } DisplaceUserdata;
 
-static void displaceModifier_do_task(void *userdata, const int iter)
+static void displaceModifier_do_task(void *userdata, const int iter, const ParallelRangeTLS *UNUSED(tls))
 {
        DisplaceUserdata *data = (DisplaceUserdata *)userdata;
        DisplaceModifierData *dmd = data->dmd;
index b1938395a7b1b690c43d331776fdaca6581b101a..afae29da350d4b8c193854f04d6c9e54d6dc8f52 100644 (file)
@@ -234,7 +234,8 @@ typedef struct MeshdeformUserdata {
        float (*icagemat)[3];
 } MeshdeformUserdata;
 
-static void meshdeform_vert_task(void *userdata, const int iter)
+static void meshdeform_vert_task(void *userdata, const int iter,
+                                 const ParallelRangeTLS *UNUSED(tls))
 {
        MeshdeformUserdata *data = userdata;
        /*const*/ MeshDeformModifierData *mmd = data->mmd;
index 8d8565e7e6247cea0f0e050b4112235abb089bdb..7fa539a0b5ef9a8215680ba550a8b3c23804b91e 100644 (file)
@@ -261,7 +261,8 @@ typedef struct GenerateOceanGeometryData {
        float ix, iy;
 } GenerateOceanGeometryData;
 
-static void generate_ocean_geometry_vertices(void *userdata, const int y)
+static void generate_ocean_geometry_vertices(void *userdata, const int y,
+                                             const ParallelRangeTLS *UNUSED(tls))
 {
        GenerateOceanGeometryData *gogd = userdata;
        int x;
@@ -275,7 +276,8 @@ static void generate_ocean_geometry_vertices(void *userdata, const int y)
        }
 }
 
-static void generate_ocean_geometry_polygons(void *userdata, const int y)
+static void generate_ocean_geometry_polygons(void *userdata, const int y,
+                                             const ParallelRangeTLS *UNUSED(tls))
 {
        GenerateOceanGeometryData *gogd = userdata;
        int x;
@@ -305,7 +307,8 @@ static void generate_ocean_geometry_polygons(void *userdata, const int y)
        }
 }
 
-static void generate_ocean_geometry_uvs(void *userdata, const int y)
+static void generate_ocean_geometry_uvs(void *userdata, const int y,
+                                        const ParallelRangeTLS *UNUSED(tls))
 {
        GenerateOceanGeometryData *gogd = userdata;
        int x;
index f8bad417f0b41fc03b392f43539c8b0c8bbf0d7d..d947ae148e9718591b55a42dc32bc41c24c4b35a 100644 (file)
@@ -753,7 +753,7 @@ BLI_INLINE float computeNormalDisplacement(const float point_co[3], const float
        return normal_dist;
 }
 
-static void bindVert(void *userdata, void *UNUSED(userdata_chunk), const int index, const int UNUSED(threadid))
+static void bindVert(void *userdata, const int index, const ParallelRangeTLS *UNUSED(tls))
 {
        SDefBindCalcData * const data = (SDefBindCalcData *)userdata;
        float point_co[3];
@@ -1049,7 +1049,7 @@ static bool surfacedeformBind(SurfaceDeformModifierData *smd, float (*vertexCos)
        return data.success == 1;
 }
 
-static void deformVert(void *userdata, void *UNUSED(userdata_chunk), const int index, const int UNUSED(threadid))
+static void deformVert(void *userdata, const int index, const ParallelRangeTLS *UNUSED(tls))
 {
        const SDefDeformData * const data = (SDefDeformData *)userdata;
        const SDefBind *sdbind = data->bind_verts[index].binds;
index b3fc3842635c2c865be38d1867a526a0cc9b32cd..99dc7a7bd92be659320dff183f7cbbb87bc993a2 100644 (file)
@@ -112,7 +112,7 @@ typedef struct UVWarpData {
        int axis_v;
 } UVWarpData;
 
-static void uv_warp_compute(void *userdata, const int i)
+static void uv_warp_compute(void *userdata, const int i, const ParallelRangeTLS *UNUSED(tls))
 {
        const UVWarpData *data = userdata;
 
index 2ca380ba5c217aaebb1139ced014e34917905e65..e26a3c49b7e6eaa169d34e1a084f832e7e10274f 100644 (file)
@@ -91,10 +91,10 @@ typedef struct Vert2GeomDataChunk {
 /**
  * Callback used by BLI_task 'for loop' helper.
  */
-static void vert2geom_task_cb_ex(void *userdata, void *userdata_chunk, const int iter, const int UNUSED(thread_id))
+static void vert2geom_task_cb_ex(void *userdata, const int iter, const ParallelRangeTLS *tls)
 {
        Vert2GeomData *data = userdata;
-       Vert2GeomDataChunk *data_chunk = userdata_chunk;
+       Vert2GeomDataChunk *data_chunk = tls->userdata_chunk;
 
        float tmp_co[3];
        int i;
index b215db49264fda545b08c8f19b645349e40eeff4..a33b6800df7072d36ef0ccee97034c2080dafb52 100644 (file)
@@ -1007,7 +1007,8 @@ typedef struct SampleCallbackData {
        float *values;
 } SampleCallbackData;
 
-static void point_density_sample_func(void *data_v, const int iter)
+static void point_density_sample_func(void *data_v, const int iter,
+                                      const ParallelRangeTLS *UNUSED(tls))
 {
        SampleCallbackData *data = (SampleCallbackData *)data_v;