~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/bullet/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolverLinkData_OpenCL.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
16
#include "BulletMultiThreaded/GpuSoftBodySolvers/CPU/btSoftBodySolverData.h"
 
17
#include "btSoftBodySolverBuffer_OpenCL.h"
 
18
 
 
19
 
 
20
#ifndef BT_SOFT_BODY_SOLVER_LINK_DATA_OPENCL_H
 
21
#define BT_SOFT_BODY_SOLVER_LINK_DATA_OPENCL_H
 
22
 
 
23
 
 
24
class btSoftBodyLinkDataOpenCL : public btSoftBodyLinkData
 
25
{
 
26
public:
 
27
        bool                            m_onGPU;
 
28
 
 
29
        cl_command_queue        m_cqCommandQue;
 
30
 
 
31
 
 
32
        btOpenCLBuffer<LinkNodePair> m_clLinks;
 
33
        btOpenCLBuffer<float>                                                         m_clLinkStrength;
 
34
        btOpenCLBuffer<float>                                                             m_clLinksMassLSC;
 
35
        btOpenCLBuffer<float>                                                             m_clLinksRestLengthSquared;
 
36
        btOpenCLBuffer<Vectormath::Aos::Vector3>                          m_clLinksCLength;
 
37
        btOpenCLBuffer<float>                                                             m_clLinksLengthRatio;
 
38
        btOpenCLBuffer<float>                                                             m_clLinksRestLength;
 
39
        btOpenCLBuffer<float>                                                             m_clLinksMaterialLinearStiffnessCoefficient;
 
40
 
 
41
        struct BatchPair
 
42
        {
 
43
                int start;
 
44
                int length;
 
45
 
 
46
                BatchPair() :
 
47
                        start(0),
 
48
                        length(0)
 
49
                {
 
50
                }
 
51
 
 
52
                BatchPair( int s, int l ) : 
 
53
                        start( s ),
 
54
                        length( l )
 
55
                {
 
56
                }
 
57
        };
 
58
 
 
59
        /**
 
60
         * Link addressing information for each cloth.
 
61
         * Allows link locations to be computed independently of data batching.
 
62
         */
 
63
        btAlignedObjectArray< int >                                                     m_linkAddresses;
 
64
 
 
65
        /**
 
66
         * Start and length values for computation batches over link data.
 
67
         */
 
68
        btAlignedObjectArray< BatchPair >               m_batchStartLengths;
 
69
 
 
70
        btSoftBodyLinkDataOpenCL(cl_command_queue queue, cl_context ctx);
 
71
 
 
72
        virtual ~btSoftBodyLinkDataOpenCL();
 
73
 
 
74
        /** Allocate enough space in all link-related arrays to fit numLinks links */
 
75
        virtual void createLinks( int numLinks );
 
76
        
 
77
        /** Insert the link described into the correct data structures assuming space has already been allocated by a call to createLinks */
 
78
        virtual void setLinkAt( 
 
79
                const LinkDescription &link, 
 
80
                int linkIndex );
 
81
 
 
82
        virtual bool onAccelerator();
 
83
 
 
84
        virtual bool moveToAccelerator();
 
85
 
 
86
        virtual bool moveFromAccelerator();
 
87
 
 
88
        /**
 
89
         * Generate (and later update) the batching for the entire link set.
 
90
         * This redoes a lot of work because it batches the entire set when each cloth is inserted.
 
91
         * In theory we could delay it until just before we need the cloth.
 
92
         * It's a one-off overhead, though, so that is a later optimisation.
 
93
         */
 
94
        void generateBatches();
 
95
};
 
96
 
 
97
 
 
98
 
 
99
#endif // #ifndef BT_SOFT_BODY_SOLVER_LINK_DATA_OPENCL_H