You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 54da2c4
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: Jolt/Physics/PhysicsUpdateContext.h
+22-8Lines changed: 22 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -39,8 +39,11 @@ class PhysicsUpdateContext : public NonCopyable
39
39
40
40
structBodyPairQueue
41
41
{
42
-
alignas(JPH_CACHE_LINE_SIZE) atomic<uint32> mWriteIdx { 0 }; ///< Next index to write in mBodyPair array (need to add thread index * mMaxBodyPairsPerQueue and modulo mMaxBodyPairsPerQueue)
43
-
alignas(JPH_CACHE_LINE_SIZE) atomic<uint32> mReadIdx { 0 }; ///< Next index to read in mBodyPair array (need to add thread index * mMaxBodyPairsPerQueue and modulo mMaxBodyPairsPerQueue)
42
+
atomic<uint32> mWriteIdx { 0 }; ///< Next index to write in mBodyPair array (need to add thread index * mMaxBodyPairsPerQueue and modulo mMaxBodyPairsPerQueue)
43
+
uint8 mPadding1[JPH_CACHE_LINE_SIZE - sizeof(atomic<uint32>)];///< Moved to own cache line to avoid conflicts with consumer jobs
44
+
45
+
atomic<uint32> mReadIdx { 0 }; ///< Next index to read in mBodyPair array (need to add thread index * mMaxBodyPairsPerQueue and modulo mMaxBodyPairsPerQueue)
46
+
uint8 mPadding2[JPH_CACHE_LINE_SIZE - sizeof(atomic<uint32>)];///< Moved to own cache line to avoid conflicts with producer/consumer jobs
44
47
};
45
48
46
49
using BodyPairQueues = StaticArray<BodyPairQueue, cMaxConcurrency>;
@@ -63,12 +66,23 @@ class PhysicsUpdateContext : public NonCopyable
63
66
64
67
uint32 mNumActiveBodiesAtStepStart; ///< Number of bodies that were active at the start of the physics update step. Only these bodies will receive gravity (they are the first N in the active body list).
65
68
66
-
alignas(JPH_CACHE_LINE_SIZE) atomic<uint32> mDetermineActiveConstraintReadIdx { 0 }; ///< Next constraint for determine active constraints (in separate cache line to avoid false sharing)
67
-
alignas(JPH_CACHE_LINE_SIZE) atomic<uint32> mNumActiveConstraints { 0 }; ///< Number of constraints in the mActiveConstraints array (in separate cache line to avoid false sharing)
68
-
alignas(JPH_CACHE_LINE_SIZE) atomic<uint32> mSetupVelocityConstraintsReadIdx { 0 }; ///< Next constraint for setting up velocity constraints (in separate cache line to avoid false sharing)
69
-
alignas(JPH_CACHE_LINE_SIZE) atomic<uint32> mStepListenerReadIdx { 0 }; ///< Next step listener to call (in separate cache line to avoid false sharing)
70
-
alignas(JPH_CACHE_LINE_SIZE) atomic<uint32> mApplyGravityReadIdx { 0 }; ///< Next body to apply gravity to (in separate cache line to avoid false sharing)
71
-
alignas(JPH_CACHE_LINE_SIZE) atomic<uint32> mActiveBodyReadIdx { 0 }; ///< Index of fist active body that has not yet been processed by the broadphase (in separate cache line to avoid false sharing)
69
+
atomic<uint32> mDetermineActiveConstraintReadIdx { 0 }; ///< Next constraint for determine active constraints
70
+
uint8 mPadding1[JPH_CACHE_LINE_SIZE - sizeof(atomic<uint32>)];///< Padding to avoid sharing cache line with the next atomic
71
+
72
+
atomic<uint32> mNumActiveConstraints { 0 }; ///< Number of constraints in the mActiveConstraints array
73
+
uint8 mPadding2[JPH_CACHE_LINE_SIZE - sizeof(atomic<uint32>)];///< Padding to avoid sharing cache line with the next atomic
74
+
75
+
atomic<uint32> mSetupVelocityConstraintsReadIdx { 0 }; ///< Next constraint for setting up velocity constraints
76
+
uint8 mPadding3[JPH_CACHE_LINE_SIZE - sizeof(atomic<uint32>)];///< Padding to avoid sharing cache line with the next atomic
77
+
78
+
atomic<uint32> mStepListenerReadIdx { 0 }; ///< Next step listener to call
79
+
uint8 mPadding4[JPH_CACHE_LINE_SIZE - sizeof(atomic<uint32>)];///< Padding to avoid sharing cache line with the next atomic
80
+
81
+
atomic<uint32> mApplyGravityReadIdx { 0 }; ///< Next body to apply gravity to
82
+
uint8 mPadding5[JPH_CACHE_LINE_SIZE - sizeof(atomic<uint32>)];///< Padding to avoid sharing cache line with the next atomic
83
+
84
+
atomic<uint32> mActiveBodyReadIdx { 0 }; ///< Index of fist active body that has not yet been processed by the broadphase
85
+
uint8 mPadding6[JPH_CACHE_LINE_SIZE - sizeof(atomic<uint32>)];///< Padding to avoid sharing cache line with the next atomic
72
86
73
87
BodyPairQueues mBodyPairQueues; ///< Queues in which to put body pairs that need to be tested by the narrowphase
0 commit comments