[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59274] trunk/blender: Made armatures evaluation safe for threading

Sergey Sharybin sergey.vfx at gmail.com
Mon Aug 19 12:14:22 CEST 2013


Revision: 59274
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59274
Author:   nazgul
Date:     2013-08-19 10:14:22 +0000 (Mon, 19 Aug 2013)
Log Message:
-----------
Made armatures evaluation safe for threading

Apparently, some routines in armature deformation code
were using static arrays. This is probably just an
optimization thing, but it's very bad for threading.

Now made it so bbone matrices array is allocating in
callee function stack. This required exposing
MAX_BBONE_SUBDIV to an external API, This is not so
much crappy from code side, and it shall be the same
fast as before.

--
svn merge -r58278:58279 ^/branches/soc-2013-depsgraph_mt

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58278

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_armature.h
    trunk/blender/source/blender/blenkernel/intern/armature.c
    trunk/blender/source/blender/editors/armature/armature_skinning.c
    trunk/blender/source/blender/editors/space_view3d/drawarmature.c

Property Changed:
----------------
    trunk/blender/
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/space_outliner/


Property changes on: trunk/blender
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/ge_dev:58091-58422
/branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt:57516,57900,57939-57940,57945,57958-57961,58151,58155-58156,58169,58277-58278,58796,59259
/branches/soc-2013-dingto:57424,57487,57507,57525,57599,57670,57918-57919,57981,58091,58245,58253,58587,58772,58774-58775,58828,58835,59032
/tags/blender-2.67b-release/blender:57122
   + /branches/ge_dev:58091-58422
/branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt:57516,57900,57939-57940,57945,57958-57961,58151,58155-58156,58169,58277-58279,58796,59259
/branches/soc-2013-dingto:57424,57487,57507,57525,57599,57670,57918-57919,57981,58091,58245,58253,58587,58772,58774-58775,58828,58835,59032
/tags/blender-2.67b-release/blender:57122

Modified: trunk/blender/source/blender/blenkernel/BKE_armature.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_armature.h	2013-08-19 10:11:48 UTC (rev 59273)
+++ trunk/blender/source/blender/blenkernel/BKE_armature.h	2013-08-19 10:14:22 UTC (rev 59274)
@@ -124,11 +124,13 @@
 void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode);
 
 /* B-Bone support */
+#define MAX_BBONE_SUBDIV    32
+
 typedef struct Mat4 {
 	float mat[4][4];
 } Mat4;
 
-Mat4 *b_bone_spline_setup(struct bPoseChannel *pchan, int rest);
+void b_bone_spline_setup(struct bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BBONE_SUBDIV]);
 
 /* like EBONE_VISIBLE */
 #define PBONE_VISIBLE(arm, bone) ( \

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c	2013-08-19 10:11:48 UTC (rev 59273)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c	2013-08-19 10:14:22 UTC (rev 59274)
@@ -381,8 +381,6 @@
 
 /* ************* B-Bone support ******************* */
 
-#define MAX_BBONE_SUBDIV    32
-
 /* data has MAX_BBONE_SUBDIV+1 interpolated points, will become desired amount with equal distances */
 static void equalize_bezier(float *data, int desired)
 {
@@ -426,11 +424,8 @@
 
 /* returns pointer to static array, filled with desired amount of bone->segments elements */
 /* this calculation is done  within unit bone space */
-Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest)
+void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BBONE_SUBDIV])
 {
-	static Mat4 bbone_array[MAX_BBONE_SUBDIV];
-	static Mat4 bbone_rest_array[MAX_BBONE_SUBDIV];
-	Mat4 *result_array = (rest) ? bbone_rest_array : bbone_array;
 	bPoseChannel *next, *prev;
 	Bone *bone = pchan->bone;
 	float h1[3], h2[3], scale[3], length, hlength1, hlength2, roll1 = 0.0f, roll2;
@@ -587,8 +582,6 @@
 			mul_serie_m4(result_array[a].mat, iscalemat, result_array[a].mat, scalemat, NULL, NULL, NULL, NULL, NULL);
 		}
 	}
-
-	return result_array;
 }
 
 /* ************ Armature Deform ******************* */
@@ -602,13 +595,15 @@
 static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info, int use_quaternion)
 {
 	Bone *bone = pchan->bone;
-	Mat4 *b_bone = b_bone_spline_setup(pchan, 0);
-	Mat4 *b_bone_rest = b_bone_spline_setup(pchan, 1);
+	Mat4 b_bone[MAX_BBONE_SUBDIV], b_bone_rest[MAX_BBONE_SUBDIV];
 	Mat4 *b_bone_mats;
 	DualQuat *b_bone_dual_quats = NULL;
 	float tmat[4][4] = MAT4_UNITY;
 	int a;
 
+	b_bone_spline_setup(pchan, 0, b_bone);
+	b_bone_spline_setup(pchan, 1, b_bone_rest);
+
 	/* allocate b_bone matrices and dual quats */
 	b_bone_mats = MEM_mallocN((1 + bone->segments) * sizeof(Mat4), "BBone defmats");
 	pdef_info->b_bone_mats = b_bone_mats;

Modified: trunk/blender/source/blender/editors/armature/armature_skinning.c
===================================================================
--- trunk/blender/source/blender/editors/armature/armature_skinning.c	2013-08-19 10:11:48 UTC (rev 59273)
+++ trunk/blender/source/blender/editors/armature/armature_skinning.c	2013-08-19 10:14:22 UTC (rev 59274)
@@ -255,7 +255,7 @@
 	bDeformGroup *dgroup;
 	bPoseChannel *pchan;
 	Mesh *mesh;
-	Mat4 *bbone = NULL;
+	Mat4 bbone_array[MAX_BBONE_SUBDIV], *bbone = NULL;
 	float (*root)[3], (*tip)[3], (*verts)[3];
 	int *selected;
 	int numbones, vertsfilled = 0, i, j, segments = 0;
@@ -309,7 +309,8 @@
 				if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) {
 					if (bone->segments > 1) {
 						segments = bone->segments;
-						bbone = b_bone_spline_setup(pchan, 1);
+						b_bone_spline_setup(pchan, 1, bbone_array);
+						bbone = bbone_array;
 					}
 				}
 			}


Property changes on: trunk/blender/source/blender/editors/interface/interface.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/ge_candy/source/blender/editors/interface/interface.c:45070-46163
/branches/ge_harmony/source/blender/editors/interface/interface.c:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber/source/blender/editors/interface/interface.c:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato/source/blender/editors/interface/interface.c:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt/source/blender/editors/interface/interface.c:57516,57900,57939-57940,57945,57958-57961,58151,58155-58156,58169,58277-58278,58796,59259
   + /branches/ge_candy/source/blender/editors/interface/interface.c:45070-46163
/branches/ge_harmony/source/blender/editors/interface/interface.c:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber/source/blender/editors/interface/interface.c:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato/source/blender/editors/interface/interface.c:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt/source/blender/editors/interface/interface.c:57516,57900,57939-57940,57945,57958-57961,58151,58155-58156,58169,58277-58279,58796,59259


Property changes on: trunk/blender/source/blender/editors/space_outliner
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/soc-2011-cucumber/source/blender/editors/space_outliner:38968,38970,38973,39045,40845
/branches/soc-2011-pepper/source/blender/editors/space_outliner:36831-38987
/branches/soc-2011-tomato/source/blender/editors/space_outliner:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt/source/blender/editors/space_outliner:57516,57900,57939-57940,57945,57958-57961,58151,58155-58156,58169,58277-58278,58796,59259
   + /branches/soc-2011-cucumber/source/blender/editors/space_outliner:38968,38970,38973,39045,40845
/branches/soc-2011-pepper/source/blender/editors/space_outliner:36831-38987
/branches/soc-2011-tomato/source/blender/editors/space_outliner:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt/source/blender/editors/space_outliner:57516,57900,57939-57940,57945,57958-57961,58151,58155-58156,58169,58277-58279,58796,59259

Modified: trunk/blender/source/blender/editors/space_view3d/drawarmature.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawarmature.c	2013-08-19 10:11:48 UTC (rev 59273)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list