Bullet Collision Detection & Physics Library
btSoftBodySolverLinkData_DX11SIMDAware.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
4 
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:
10 
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.
14 */
15 
18 
19 #ifndef BT_ACCELERATED_SOFT_BODY_LINK_DATA_DX11_SIMDAWARE_H
20 #define BT_ACCELERATED_SOFT_BODY_LINK_DATA_DX11_SIMDAWARE_H
21 
22 struct ID3D11Device;
23 struct ID3D11DeviceContext;
24 
25 
27 {
28 public:
29  bool m_onGPU;
30  ID3D11Device *m_d3dDevice;
31  ID3D11DeviceContext *m_d3dDeviceContext;
32 
33  const int m_wavefrontSize;
34  const int m_linksPerWorkItem;
39 
41 
43  {
46  };
47 
48  // Array storing number of links in each wavefront
52 
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
65 
66  struct BatchPair
67  {
68  int start;
69  int length;
70 
72  start(0),
73  length(0)
74  {
75  }
76 
77  BatchPair( int s, int l ) :
78  start( s ),
79  length( l )
80  {
81  }
82  };
83 
89 
94 
95 
96  //ID3D11Buffer* readBackBuffer;
97 
98  btSoftBodyLinkDataDX11SIMDAware( ID3D11Device *d3dDevice, ID3D11DeviceContext *d3dDeviceContext );
99 
101 
103  virtual void createLinks( int numLinks );
104 
106  virtual void setLinkAt( const LinkDescription &link, int linkIndex );
107 
108  virtual bool onAccelerator();
109 
110  virtual bool moveToAccelerator();
111 
112  virtual bool moveFromAccelerator();
113 
120  void generateBatches();
121 
123  {
125  }
126 
128  {
129  return m_wavefrontSize;
130  }
131 
133  {
134  return m_linksPerWorkItem;
135  }
136 
138  {
139  return m_maxLinksPerWavefront;
140  }
141 
143  {
144  return m_maxBatchesWithinWave;
145  }
146 
148  {
149  return m_numWavefronts;
150  }
151 
153  {
154  return m_numBatchesAndVerticesWithinWaves[wavefront];
155  }
156 
157  int getVertexGlobalAddresses( int vertexIndex )
158  {
159  return m_wavefrontVerticesGlobalAddresses[vertexIndex];
160  }
161 
166  {
167  return m_linkVerticesLocalAddresses[linkIndex];
168  }
169 
170 };
171 
172 
173 #endif // #ifndef BT_ACCELERATED_SOFT_BODY_LINK_DATA_DX11_SIMDAWARE_H
btAlignedObjectArray< NumBatchesVerticesPair > m_numBatchesAndVerticesWithinWaves
btSoftBodyLinkDataDX11SIMDAware(ID3D11Device *d3dDevice, ID3D11DeviceContext *d3dDeviceContext)
NumBatchesVerticesPair getNumBatchesAndVerticesWithinWavefront(int wavefront)
void generateBatches()
Generate (and later update) the batching for the entire link set.
btAlignedObjectArray< int > m_wavefrontVerticesGlobalAddresses
LinkNodePair getVertexPairLocalAddresses(int linkIndex)
Get post-batching local addresses of the vertex pair for a link assuming all vertices used by a wavef...
btAlignedObjectArray< BatchPair > m_wavefrontBatchStartLengths
Start and length values for computation batches over link data.
virtual bool onAccelerator()
Return true if data is on the accelerator.
btAlignedObjectArray< int > m_linkAddresses
Link addressing information for each cloth.
Class representing a link as a set of three indices into the vertex array.
btAlignedObjectArray< LinkNodePair > m_linkVerticesLocalAddresses
virtual bool moveToAccelerator()
Move data from host memory to the accelerator.
Class describing a link for input into the system.
virtual void setLinkAt(const LinkDescription &link, int linkIndex)
Insert the link described into the correct data structures assuming space has already been allocated ...
virtual void createLinks(int numLinks)
Allocate enough space in all link-related arrays to fit numLinks links.
virtual bool moveFromAccelerator()
Move data from host memory from the accelerator.
btDX11Buffer< LinkNodePair > m_dx11LinkVerticesLocalAddresses
btDX11Buffer< NumBatchesVerticesPair > m_dx11NumBatchesAndVerticesWithinWaves
DX11 Buffer that tracks a host buffer on use to ensure size-correctness.