testCompileBullet3RaycastKernels.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include <gtest/gtest.h>
  2. #include "Bullet3Common/b3Logging.h"
  3. #include "Bullet3Common/b3CommandLineArgs.h"
  4. #include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
  5. #include "Bullet3OpenCL/Raycast/kernels/rayCastKernels.h"
  6. extern int gArgc;
  7. extern char** gArgv;
  8. namespace
  9. {
  10. struct CompileBullet3RaycastKernels : public ::testing::Test
  11. {
  12. cl_context m_clContext;
  13. cl_device_id m_clDevice;
  14. cl_command_queue m_clQueue;
  15. char* m_clDeviceName;
  16. cl_platform_id m_platformId;
  17. CompileBullet3RaycastKernels()
  18. :m_clDeviceName(0),
  19. m_clContext(0),
  20. m_clDevice(0),
  21. m_clQueue(0),
  22. m_platformId(0)
  23. {
  24. // You can do set-up work for each test here.
  25. b3CommandLineArgs args(gArgc,gArgv);
  26. int preferredDeviceIndex=-1;
  27. int preferredPlatformIndex = -1;
  28. bool allowCpuOpenCL = false;
  29. initCL();
  30. }
  31. virtual ~CompileBullet3RaycastKernels()
  32. {
  33. // You can do clean-up work that doesn't throw exceptions here.
  34. exitCL();
  35. }
  36. // If the constructor and destructor are not enough for setting up
  37. // and cleaning up each test, you can define the following methods:
  38. #include "initCL.h"
  39. virtual void SetUp()
  40. {
  41. // Code here will be called immediately after the constructor (right
  42. // before each test).
  43. }
  44. virtual void TearDown()
  45. {
  46. // Code here will be called immediately after each test (right
  47. // before the destructor).
  48. }
  49. };
  50. TEST_F(CompileBullet3RaycastKernels,sapFastKernels)
  51. {
  52. cl_int errNum=0;
  53. cl_program prog = b3OpenCLUtils::compileCLProgramFromString(m_clContext,m_clDevice,rayCastKernelCL,&errNum,"",0,true);
  54. ASSERT_EQ(CL_SUCCESS,errNum);
  55. {
  56. cl_kernel k = b3OpenCLUtils::compileCLKernelFromString(m_clContext, m_clDevice,rayCastKernelCL, "rayCastKernel",&errNum,prog);
  57. ASSERT_EQ(CL_SUCCESS,errNum);
  58. clReleaseKernel(k);
  59. }
  60. clReleaseProgram(prog);
  61. }
  62. };