[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / Bullet3OpenCL / ParallelPrimitives / b3BoundSearchCL.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 #ifndef B3_BOUNDSEARCH_H
17 #define B3_BOUNDSEARCH_H
18
19 #pragma once
20
21 /*#include <Adl/Adl.h>
22 #include <AdlPrimitives/Math/Math.h>
23 #include <AdlPrimitives/Sort/SortData.h>
24 #include <AdlPrimitives/Fill/Fill.h>
25 */
26
27 #include "b3OpenCLArray.h"
28 #include "b3FillCL.h"
29 #include "b3RadixSort32CL.h"  //for b3SortData (perhaps move it?)
30 class b3BoundSearchCL
31 {
32 public:
33         enum Option
34         {
35                 BOUND_LOWER,
36                 BOUND_UPPER,
37                 COUNT,
38         };
39
40         cl_context m_context;
41         cl_device_id m_device;
42         cl_command_queue m_queue;
43
44         cl_kernel m_lowerSortDataKernel;
45         cl_kernel m_upperSortDataKernel;
46         cl_kernel m_subtractKernel;
47
48         b3OpenCLArray<b3Int4>* m_constbtOpenCLArray;
49         b3OpenCLArray<unsigned int>* m_lower;
50         b3OpenCLArray<unsigned int>* m_upper;
51
52         b3FillCL* m_filler;
53
54         b3BoundSearchCL(cl_context context, cl_device_id device, cl_command_queue queue, int size);
55
56         virtual ~b3BoundSearchCL();
57
58         //      src has to be src[i].m_key <= src[i+1].m_key
59         void execute(b3OpenCLArray<b3SortData>& src, int nSrc, b3OpenCLArray<unsigned int>& dst, int nDst, Option option = BOUND_LOWER);
60
61         void executeHost(b3AlignedObjectArray<b3SortData>& src, int nSrc, b3AlignedObjectArray<unsigned int>& dst, int nDst, Option option = BOUND_LOWER);
62 };
63
64 #endif  //B3_BOUNDSEARCH_H