Initialize libbullet git in 2.0_beta.
[platform/upstream/libbullet.git] / Extras / RigidBodyGpuPipeline / opencl / primitives / AdlPrimitives / Sort / RadixSort.inl
1 /*
2                 2011 Takahiro Harada
3 */
4
5 #include <AdlPrimitives/Sort/RadixSortSimple.inl>
6 #include <AdlPrimitives/Sort/RadixSortStandard.inl>
7 #include <AdlPrimitives/Sort/RadixSortAdvanced.inl>
8
9
10 #define DISPATCH_IMPL(x) \
11         switch( data->m_option ) \
12         { \
13                 case SORT_SIMPLE: RadixSortSimple<TYPE>::x; break; \
14                 case SORT_STANDARD: RadixSortStandard<TYPE>::x; break; \
15                 case SORT_ADVANCED: RadixSortAdvanced<TYPE>::x; break; \
16                 default:ADLASSERT(0);break; \
17         }
18
19 template<DeviceType TYPE>
20 typename RadixSort<TYPE>::Data* RadixSort<TYPE>::allocate(const Device* deviceData, int maxSize, Option option)
21 {
22         ADLASSERT( TYPE == deviceData->m_type );
23
24         void* dataOut;
25         switch( option )
26         {
27         case SORT_SIMPLE:
28                 dataOut = RadixSortSimple<TYPE>::allocate( deviceData, maxSize, option );
29                 break;
30         case SORT_STANDARD:
31                 dataOut = RadixSortStandard<TYPE>::allocate( deviceData, maxSize, option );
32                 break;
33         case SORT_ADVANCED:
34                 dataOut = RadixSortAdvanced<TYPE>::allocate( deviceData, maxSize, option );
35                 break;
36         default:
37                 ADLASSERT(0);
38                 break;
39         }
40         return (typename RadixSort<TYPE>::Data*)dataOut;
41 }
42
43 template<DeviceType TYPE>
44 void RadixSort<TYPE>::deallocate(Data* data)
45 {
46         DISPATCH_IMPL( deallocate( data ) );
47 }
48
49 template<DeviceType TYPE>
50 void RadixSort<TYPE>::execute(Data* data, Buffer<SortData>& inout, int n, int sortBits)
51 {
52         DISPATCH_IMPL( execute( data, inout, n, sortBits ) );
53 }
54
55
56 #undef DISPATCH_IMPL
57
58