#ifndef B3_GPU_GRID_BROADPHASE_H #define B3_GPU_GRID_BROADPHASE_H #include "b3GpuBroadphaseInterface.h" #include "Bullet3OpenCL/ParallelPrimitives/b3RadixSort32CL.h" struct b3ParamsGridBroadphaseCL { float m_invCellSize[4]; int m_gridSize[4]; int getMaxBodiesPerCell() const { return m_gridSize[3]; } void setMaxBodiesPerCell(int maxOverlap) { m_gridSize[3] = maxOverlap; } }; class b3GpuGridBroadphase : public b3GpuBroadphaseInterface { protected: cl_context m_context; cl_device_id m_device; cl_command_queue m_queue; b3OpenCLArray m_allAabbsGPU1; b3AlignedObjectArray m_allAabbsCPU1; b3OpenCLArray m_smallAabbsMappingGPU; b3AlignedObjectArray m_smallAabbsMappingCPU; b3OpenCLArray m_largeAabbsMappingGPU; b3AlignedObjectArray m_largeAabbsMappingCPU; b3AlignedObjectArray m_hostPairs; b3OpenCLArray m_gpuPairs; b3OpenCLArray m_hashGpu; b3OpenCLArray m_cellStartGpu; b3ParamsGridBroadphaseCL m_paramsCPU; b3OpenCLArray m_paramsGPU; class b3RadixSort32CL* m_sorter; public: b3GpuGridBroadphase(cl_context ctx,cl_device_id device, cl_command_queue q ); virtual ~b3GpuGridBroadphase(); static b3GpuBroadphaseInterface* CreateFunc(cl_context ctx,cl_device_id device, cl_command_queue q) { return new b3GpuGridBroadphase(ctx,device,q); } virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask); virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr , int collisionFilterGroup, int collisionFilterMask); virtual void calculateOverlappingPairs(int maxPairs); virtual void calculateOverlappingPairsHost(int maxPairs); //call writeAabbsToGpu after done making all changes (createProxy etc) virtual void writeAabbsToGpu(); virtual cl_mem getAabbBufferWS(); virtual int getNumOverlap(); virtual cl_mem getOverlappingPairBuffer(); virtual b3OpenCLArray& getAllAabbsGPU(); virtual b3AlignedObjectArray& getAllAabbsCPU(); virtual b3OpenCLArray& getOverlappingPairsGPU(); virtual b3OpenCLArray& getSmallAabbIndicesGPU(); virtual b3OpenCLArray& getLargeAabbIndicesGPU(); }; #endif //B3_GPU_GRID_BROADPHASE_H