pairsKernel.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
  2. static const char* pairsKernelsCL= \
  3. "__kernel void moveObjectsKernel(__global float4* posOrnColors, int numObjects)\n"
  4. "{\n"
  5. " int iGID = get_global_id(0);\n"
  6. " if (iGID>=numObjects)\n"
  7. " return;\n"
  8. " __global float4* positions = &posOrnColors[0];\n"
  9. " if (iGID<0.5*numObjects)\n"
  10. " {\n"
  11. " positions[iGID].y +=0.01f;\n"
  12. " }\n"
  13. " __global float4* colors = &posOrnColors[numObjects*2];\n"
  14. " colors[iGID] = (float4)(0,0,1,1);\n"
  15. "}\n"
  16. "__kernel void colorPairsKernel2(__global float4* posOrnColors, int numObjects, __global const int4* pairs, int indexOffset, int numPairs)\n"
  17. "{\n"
  18. " int iPairId = get_global_id(0);\n"
  19. " if (iPairId>=numPairs)\n"
  20. " return;\n"
  21. " __global float4* colors = &posOrnColors[numObjects*2];\n"
  22. " int iObjectA = pairs[iPairId].x-indexOffset;\n"
  23. " int iObjectB = pairs[iPairId].y-indexOffset;\n"
  24. " colors[iObjectA] = (float4)(1,0,0,1);\n"
  25. " colors[iObjectB] = (float4)(1,0,0,1);\n"
  26. "}\n"
  27. "__kernel void \n"
  28. " sineWaveKernel( __global float4* posOrnColors, __global float* pBodyTimes,float timeStepPos, float mAmplitude,const int numNodes)\n"
  29. "{\n"
  30. " int nodeID = get_global_id(0);\n"
  31. " if( nodeID < numNodes )\n"
  32. " {\n"
  33. " pBodyTimes[nodeID] += timeStepPos;\n"
  34. " float4 position = posOrnColors[nodeID];\n"
  35. " position.x = native_cos(pBodyTimes[nodeID]*2.17f)*mAmplitude + native_sin(pBodyTimes[nodeID])*mAmplitude*0.5f;\n"
  36. " position.y = native_cos(pBodyTimes[nodeID]*1.38f)*mAmplitude + native_sin(pBodyTimes[nodeID]*mAmplitude);\n"
  37. " position.z = native_cos(pBodyTimes[nodeID]*2.17f)*mAmplitude + native_sin(pBodyTimes[nodeID]*0.777f)*mAmplitude;\n"
  38. " \n"
  39. " posOrnColors[nodeID] = position;\n"
  40. " __global float4* colors = &posOrnColors[numNodes*2];\n"
  41. " colors[nodeID] = (float4)(0,0,1,1);\n"
  42. " }\n"
  43. "}\n"
  44. "typedef struct \n"
  45. "{\n"
  46. " float fx;\n"
  47. " float fy;\n"
  48. " float fz;\n"
  49. " int uw;\n"
  50. "} b3AABBCL;\n"
  51. "__kernel void updateAabbSimple( __global float4* posOrnColors, const int numNodes, __global b3AABBCL* pAABB)\n"
  52. "{\n"
  53. " int nodeId = get_global_id(0);\n"
  54. " if( nodeId < numNodes )\n"
  55. " {\n"
  56. " \n"
  57. " b3AABBCL orgAabbMin = pAABB[nodeId*2];\n"
  58. " b3AABBCL orgAabbMax = pAABB[nodeId*2+1];\n"
  59. " int orgNodeId = orgAabbMin.uw;\n"
  60. " int orgBroadphaseIndex = orgAabbMax.uw;\n"
  61. " \n"
  62. " float4 position = posOrnColors[nodeId];\n"
  63. " float4 argAabbMinVec = (float4)(orgAabbMin.fx,orgAabbMin.fy,orgAabbMin.fz,0.f);\n"
  64. " float4 argAabbMaxVec = (float4)(orgAabbMax.fx,orgAabbMax.fy,orgAabbMax.fz,0.f);\n"
  65. " float4 halfExtents = 0.5f*(argAabbMaxVec-argAabbMinVec);\n"
  66. " \n"
  67. " pAABB[nodeId*2].fx = position.x-halfExtents.x;\n"
  68. " pAABB[nodeId*2].fy = position.y-halfExtents.y;\n"
  69. " pAABB[nodeId*2].fz = position.z-halfExtents.z;\n"
  70. " pAABB[nodeId*2].uw = orgNodeId;\n"
  71. " pAABB[nodeId*2+1].fx = position.x+halfExtents.x;\n"
  72. " pAABB[nodeId*2+1].fy = position.y+halfExtents.y;\n"
  73. " pAABB[nodeId*2+1].fz = position.z+halfExtents.z;\n"
  74. " pAABB[nodeId*2+1].uw = orgBroadphaseIndex; \n"
  75. " }\n"
  76. "}\n"
  77. ;