Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / RigidBodyGpuPipeline / opencl / primitives / AdlPrimitives / Search / BoundSearch.h
1 /*
2 Copyright (c) 2012 Advanced Micro Devices, Inc.  
3
4 This software is provided 'as-is', without any express or implied warranty.
5 In no event will the authors be held liable for any damages arising from the use of this software.
6 Permission is granted to anyone to use this software for any purpose, 
7 including commercial applications, and to alter it and redistribute it freely, 
8 subject to the following restrictions:
9
10 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.
11 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
12 3. This notice may not be removed or altered from any source distribution.
13 */
14 //Originally written by Takahiro Harada
15
16
17 #pragma once
18
19 #include <Adl/Adl.h>
20 #include <AdlPrimitives/Math/Math.h>
21 #include <AdlPrimitives/Sort/SortData.h>
22 #include <AdlPrimitives/Fill/Fill.h>
23
24 namespace adl
25 {
26
27 class BoundSearchBase
28 {
29         public:
30                 enum Option
31                 {
32                         BOUND_LOWER,
33                         BOUND_UPPER,
34                         COUNT,
35                 };
36 };
37
38 template<DeviceType TYPE>
39 class BoundSearch : public BoundSearchBase
40 {
41         public:
42                 typedef Launcher::BufferInfo BufferInfo;
43
44                 struct Data
45                 {
46                         const Device* m_device;
47                         Kernel* m_lowerSortDataKernel;
48                         Kernel* m_upperSortDataKernel;
49                         Kernel* m_subtractKernel;
50                         Buffer<int4>* m_constBuffer;
51                         Buffer<u32>* m_lower;
52                         Buffer<u32>* m_upper;
53                         typename Fill<TYPE>::Data* m_fillData;
54                 };
55
56                 static
57                 Data* allocate(const Device* deviceData, int maxSize = 0);
58
59                 static
60                 void deallocate(Data* data);
61
62                 //      src has to be src[i].m_key <= src[i+1].m_key
63                 static
64                 void execute(Data* data, Buffer<SortData>& src, u32 nSrc, Buffer<u32>& dst, u32 nDst, Option option = BOUND_LOWER );
65
66 //              static
67 //              void execute(Data* data, Buffer<u32>& src, Buffer<u32>& dst, int n, Option option = );
68 };
69
70 #include <AdlPrimitives/Search/BoundSearchHost.inl>
71 #include <AdlPrimitives/Search/BoundSearch.inl>
72
73 };