2
Bullet Continuous Collision Detection and Physics Library
3
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
5
This software is provided 'as-is', without any express or implied warranty.
6
In no event will the authors be held liable for any damages arising from the use of this software.
7
Permission is granted to anyone to use this software for any purpose,
8
including commercial applications, and to alter it and redistribute it freely,
9
subject to the following restrictions:
11
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13
3. This notice may not be removed or altered from any source distribution.
16
#include "BulletMultiThreaded/GpuSoftBodySolvers/CPU/btSoftBodySolverData.h"
17
#include "btSoftBodySolverBuffer_DX11.h"
19
#ifndef BT_ACCELERATED_SOFT_BODY_LINK_DATA_DX11_SIMDAWARE_H
20
#define BT_ACCELERATED_SOFT_BODY_LINK_DATA_DX11_SIMDAWARE_H
23
struct ID3D11DeviceContext;
26
class btSoftBodyLinkDataDX11SIMDAware : public btSoftBodyLinkData
30
ID3D11Device *m_d3dDevice;
31
ID3D11DeviceContext *m_d3dDeviceContext;
33
const int m_wavefrontSize;
34
const int m_linksPerWorkItem;
35
const int m_maxLinksPerWavefront;
36
int m_maxBatchesWithinWave;
37
int m_maxVerticesWithinWave;
42
struct NumBatchesVerticesPair
48
// Array storing number of links in each wavefront
49
btAlignedObjectArray<int> m_linksPerWavefront;
50
btAlignedObjectArray<NumBatchesVerticesPair> m_numBatchesAndVerticesWithinWaves;
51
btDX11Buffer< NumBatchesVerticesPair > m_dx11NumBatchesAndVerticesWithinWaves;
53
// All arrays here will contain batches of m_maxLinksPerWavefront links
54
// ordered by wavefront.
55
// with either global vertex pairs or local vertex pairs
56
btAlignedObjectArray< int > m_wavefrontVerticesGlobalAddresses; // List of global vertices per wavefront
57
btDX11Buffer<int> m_dx11WavefrontVerticesGlobalAddresses;
58
btAlignedObjectArray< LinkNodePair > m_linkVerticesLocalAddresses; // Vertex pair for the link
59
btDX11Buffer<LinkNodePair> m_dx11LinkVerticesLocalAddresses;
60
btDX11Buffer<float> m_dx11LinkStrength;
61
btDX11Buffer<float> m_dx11LinksMassLSC;
62
btDX11Buffer<float> m_dx11LinksRestLengthSquared;
63
btDX11Buffer<float> m_dx11LinksRestLength;
64
btDX11Buffer<float> m_dx11LinksMaterialLinearStiffnessCoefficient;
77
BatchPair( int s, int l ) :
85
* Link addressing information for each cloth.
86
* Allows link locations to be computed independently of data batching.
88
btAlignedObjectArray< int > m_linkAddresses;
91
* Start and length values for computation batches over link data.
93
btAlignedObjectArray< BatchPair > m_wavefrontBatchStartLengths;
96
//ID3D11Buffer* readBackBuffer;
98
btSoftBodyLinkDataDX11SIMDAware( ID3D11Device *d3dDevice, ID3D11DeviceContext *d3dDeviceContext );
100
virtual ~btSoftBodyLinkDataDX11SIMDAware();
102
/** Allocate enough space in all link-related arrays to fit numLinks links */
103
virtual void createLinks( int numLinks );
105
/** Insert the link described into the correct data structures assuming space has already been allocated by a call to createLinks */
106
virtual void setLinkAt( const LinkDescription &link, int linkIndex );
108
virtual bool onAccelerator();
110
virtual bool moveToAccelerator();
112
virtual bool moveFromAccelerator();
115
* Generate (and later update) the batching for the entire link set.
116
* This redoes a lot of work because it batches the entire set when each cloth is inserted.
117
* In theory we could delay it until just before we need the cloth.
118
* It's a one-off overhead, though, so that is a later optimisation.
120
void generateBatches();
122
int getMaxVerticesPerWavefront()
124
return m_maxVerticesWithinWave;
127
int getWavefrontSize()
129
return m_wavefrontSize;
132
int getLinksPerWorkItem()
134
return m_linksPerWorkItem;
137
int getMaxLinksPerWavefront()
139
return m_maxLinksPerWavefront;
142
int getMaxBatchesPerWavefront()
144
return m_maxBatchesWithinWave;
147
int getNumWavefronts()
149
return m_numWavefronts;
152
NumBatchesVerticesPair getNumBatchesAndVerticesWithinWavefront( int wavefront )
154
return m_numBatchesAndVerticesWithinWaves[wavefront];
157
int getVertexGlobalAddresses( int vertexIndex )
159
return m_wavefrontVerticesGlobalAddresses[vertexIndex];
163
* Get post-batching local addresses of the vertex pair for a link assuming all vertices used by a wavefront are loaded locally.
165
LinkNodePair getVertexPairLocalAddresses( int linkIndex )
167
return m_linkVerticesLocalAddresses[linkIndex];
173
#endif // #ifndef BT_ACCELERATED_SOFT_BODY_LINK_DATA_DX11_SIMDAWARE_H