From ad6fb3afc1563f51dd2808ccd2a60d1cf24d9bd1 Mon Sep 17 00:00:00 2001 From: hujiajie Date: Thu, 3 Mar 2016 15:59:47 +0800 Subject: [PATCH] The 'static' storage-class specifier is not supported in OpenCL. This is documented in Section 6.8 (g) in OpenCL 1.1 specification. --- .../shared/b3MprPenetration.h | 15 ++++++------ .../shared/b3PlatformDefinitions.h | 4 ++++ .../NarrowphaseCollision/kernels/mprKernels.h | 24 ++++++++++++------- .../kernels/primitiveContacts.h | 1 + .../kernels/satClipHullContacts.h | 1 + .../kernels/satConcaveKernels.h | 1 + .../NarrowphaseCollision/kernels/satKernels.h | 1 + .../RigidBody/kernels/batchingKernels.h | 1 + .../RigidBody/kernels/batchingKernelsNew.h | 1 + .../RigidBody/kernels/integrateKernel.h | 1 + .../RigidBody/kernels/solverSetup.h | 1 + .../RigidBody/kernels/solverSetup2.cl | 4 ++-- .../RigidBody/kernels/solverSetup2.h | 5 ++-- .../RigidBody/kernels/solverUtils.h | 1 + .../RigidBody/kernels/updateAabbsKernel.h | 1 + 15 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/Bullet3Collision/NarrowPhaseCollision/shared/b3MprPenetration.h b/src/Bullet3Collision/NarrowPhaseCollision/shared/b3MprPenetration.h index b36ac4b94..083b0b5ea 100644 --- a/src/Bullet3Collision/NarrowPhaseCollision/shared/b3MprPenetration.h +++ b/src/Bullet3Collision/NarrowPhaseCollision/shared/b3MprPenetration.h @@ -21,6 +21,7 @@ #ifndef B3_MPR_PENETRATION_H #define B3_MPR_PENETRATION_H +#include "Bullet3Common/shared/b3PlatformDefinitions.h" #include "Bullet3Common/shared/b3Float4.h" #include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h" #include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h" @@ -151,7 +152,7 @@ inline b3Float4 b3LocalGetSupportVertex(b3Float4ConstArg supportVec,__global con } -static void b3MprConvexSupport(int pairIndex,int bodyIndex, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, +B3_STATIC void b3MprConvexSupport(int pairIndex,int bodyIndex, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, b3ConstArray(b3ConvexPolyhedronData_t) cpuConvexData, b3ConstArray(b3Collidable_t) cpuCollidables, b3ConstArray(b3Float4) cpuVertices, @@ -370,7 +371,7 @@ inline void b3ExpandPortal(b3MprSimplex_t *portal, -static int b3DiscoverPortal(int pairIndex, int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, +B3_STATIC int b3DiscoverPortal(int pairIndex, int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, b3ConstArray(b3ConvexPolyhedronData_t) cpuConvexData, b3ConstArray(b3Collidable_t) cpuCollidables, b3ConstArray(b3Float4) cpuVertices, @@ -505,7 +506,7 @@ static int b3DiscoverPortal(int pairIndex, int bodyIndexA, int bodyIndexB, b3Co } -static int b3RefinePortal(int pairIndex,int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, +B3_STATIC int b3RefinePortal(int pairIndex,int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, b3ConstArray(b3ConvexPolyhedronData_t) cpuConvexData, b3ConstArray(b3Collidable_t) cpuCollidables, b3ConstArray(b3Float4) cpuVertices, @@ -547,7 +548,7 @@ static int b3RefinePortal(int pairIndex,int bodyIndexA, int bodyIndexB, b3Const return -1; } -static void b3FindPos(const b3MprSimplex_t *portal, b3Float4 *pos) +B3_STATIC void b3FindPos(const b3MprSimplex_t *portal, b3Float4 *pos) { b3Float4 zero = b3MakeFloat4(0,0,0,0); @@ -758,7 +759,7 @@ inline float b3MprVec3PointTriDist2(const b3Float4 *P, } -static void b3FindPenetr(int pairIndex,int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, +B3_STATIC void b3FindPenetr(int pairIndex,int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, b3ConstArray(b3ConvexPolyhedronData_t) cpuConvexData, b3ConstArray(b3Collidable_t) cpuCollidables, b3ConstArray(b3Float4) cpuVertices, @@ -811,7 +812,7 @@ static void b3FindPenetr(int pairIndex,int bodyIndexA, int bodyIndexB, b3ConstA } } -static void b3FindPenetrTouch(b3MprSimplex_t *portal,float *depth, b3Float4 *dir, b3Float4 *pos) +B3_STATIC void b3FindPenetrTouch(b3MprSimplex_t *portal,float *depth, b3Float4 *dir, b3Float4 *pos) { // Touching contact on portal's v1 - so depth is zero and direction // is unimportant and pos can be guessed @@ -827,7 +828,7 @@ static void b3FindPenetrTouch(b3MprSimplex_t *portal,float *depth, b3Float4 *dir b3MprVec3Scale(pos, 0.5); } -static void b3FindPenetrSegment(b3MprSimplex_t *portal, +B3_STATIC void b3FindPenetrSegment(b3MprSimplex_t *portal, float *depth, b3Float4 *dir, b3Float4 *pos) { diff --git a/src/Bullet3Common/shared/b3PlatformDefinitions.h b/src/Bullet3Common/shared/b3PlatformDefinitions.h index a3287ae08..1c133fb08 100644 --- a/src/Bullet3Common/shared/b3PlatformDefinitions.h +++ b/src/Bullet3Common/shared/b3PlatformDefinitions.h @@ -20,6 +20,8 @@ inline int b3AtomicAdd (volatile int *p, int val) } #define __global + +#define B3_STATIC static #else //keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX #define B3_LARGE_FLOAT 1e18f @@ -32,6 +34,8 @@ inline int b3AtomicAdd (volatile int *p, int val) #define b3Sqrt native_sqrt #define b3Sin native_sin #define b3Cos native_cos + +#define B3_STATIC #endif #endif diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h index c4c5c160e..7ed4b382c 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h +++ b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/mprKernels.h @@ -17,8 +17,6 @@ static const char* mprKernelsCL= \ " */\n" "#ifndef B3_MPR_PENETRATION_H\n" "#define B3_MPR_PENETRATION_H\n" -"#ifndef B3_FLOAT4_H\n" -"#define B3_FLOAT4_H\n" "#ifndef B3_PLATFORM_DEFINITIONS_H\n" "#define B3_PLATFORM_DEFINITIONS_H\n" "struct MyTest\n" @@ -38,6 +36,14 @@ static const char* mprKernelsCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" +"#endif\n" +"#endif\n" +"#ifndef B3_FLOAT4_H\n" +"#define B3_FLOAT4_H\n" +"#ifndef B3_PLATFORM_DEFINITIONS_H\n" +"#ifdef __cplusplus\n" +"#else\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" @@ -509,7 +515,7 @@ static const char* mprKernelsCL= \ " }\n" " return supVec;\n" "}\n" -"static void b3MprConvexSupport(int pairIndex,int bodyIndex, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, \n" +"B3_STATIC void b3MprConvexSupport(int pairIndex,int bodyIndex, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, \n" " b3ConstArray(b3ConvexPolyhedronData_t) cpuConvexData, \n" " b3ConstArray(b3Collidable_t) cpuCollidables,\n" " b3ConstArray(b3Float4) cpuVertices,\n" @@ -682,7 +688,7 @@ static const char* mprKernelsCL= \ " }\n" " }\n" "}\n" -"static int b3DiscoverPortal(int pairIndex, int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, \n" +"B3_STATIC int b3DiscoverPortal(int pairIndex, int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, \n" " b3ConstArray(b3ConvexPolyhedronData_t) cpuConvexData, \n" " b3ConstArray(b3Collidable_t) cpuCollidables,\n" " b3ConstArray(b3Float4) cpuVertices,\n" @@ -792,7 +798,7 @@ static const char* mprKernelsCL= \ " }\n" " return 0;\n" "}\n" -"static int b3RefinePortal(int pairIndex,int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, \n" +"B3_STATIC int b3RefinePortal(int pairIndex,int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, \n" " b3ConstArray(b3ConvexPolyhedronData_t) cpuConvexData, \n" " b3ConstArray(b3Collidable_t) cpuCollidables,\n" " b3ConstArray(b3Float4) cpuVertices,\n" @@ -826,7 +832,7 @@ static const char* mprKernelsCL= \ " }\n" " return -1;\n" "}\n" -"static void b3FindPos(const b3MprSimplex_t *portal, b3Float4 *pos)\n" +"B3_STATIC void b3FindPos(const b3MprSimplex_t *portal, b3Float4 *pos)\n" "{\n" " b3Float4 zero = b3MakeFloat4(0,0,0,0);\n" " b3Float4* b3mpr_vec3_origin = &zero;\n" @@ -1000,7 +1006,7 @@ static const char* mprKernelsCL= \ " }\n" " return dist;\n" "}\n" -"static void b3FindPenetr(int pairIndex,int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, \n" +"B3_STATIC void b3FindPenetr(int pairIndex,int bodyIndexA, int bodyIndexB, b3ConstArray(b3RigidBodyData_t) cpuBodyBuf, \n" " b3ConstArray(b3ConvexPolyhedronData_t) cpuConvexData, \n" " b3ConstArray(b3Collidable_t) cpuCollidables,\n" " b3ConstArray(b3Float4) cpuVertices,\n" @@ -1043,7 +1049,7 @@ static const char* mprKernelsCL= \ " iterations++;\n" " }\n" "}\n" -"static void b3FindPenetrTouch(b3MprSimplex_t *portal,float *depth, b3Float4 *dir, b3Float4 *pos)\n" +"B3_STATIC void b3FindPenetrTouch(b3MprSimplex_t *portal,float *depth, b3Float4 *dir, b3Float4 *pos)\n" "{\n" " // Touching contact on portal's v1 - so depth is zero and direction\n" " // is unimportant and pos can be guessed\n" @@ -1055,7 +1061,7 @@ static const char* mprKernelsCL= \ " b3MprVec3Add(pos, &b3MprSimplexPoint(portal, 1)->v2);\n" " b3MprVec3Scale(pos, 0.5);\n" "}\n" -"static void b3FindPenetrSegment(b3MprSimplex_t *portal,\n" +"B3_STATIC void b3FindPenetrSegment(b3MprSimplex_t *portal,\n" " float *depth, b3Float4 *dir, b3Float4 *pos)\n" "{\n" " \n" diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.h b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.h index 8ac17745d..b0103fe67 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.h +++ b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.h @@ -23,6 +23,7 @@ static const char* primitiveContactsKernelsCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h index 234942ee5..f0ecfc785 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h +++ b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h @@ -50,6 +50,7 @@ static const char* satClipKernelsCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcaveKernels.h b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcaveKernels.h index 22b26af8b..611569cac 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcaveKernels.h +++ b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satConcaveKernels.h @@ -164,6 +164,7 @@ static const char* satConcaveKernelsCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" diff --git a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satKernels.h b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satKernels.h index 74f4efae0..6f8b0a90d 100644 --- a/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satKernels.h +++ b/src/Bullet3OpenCL/NarrowphaseCollision/kernels/satKernels.h @@ -164,6 +164,7 @@ static const char* satKernelsCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" diff --git a/src/Bullet3OpenCL/RigidBody/kernels/batchingKernels.h b/src/Bullet3OpenCL/RigidBody/kernels/batchingKernels.h index f52131bc4..150eedc94 100644 --- a/src/Bullet3OpenCL/RigidBody/kernels/batchingKernels.h +++ b/src/Bullet3OpenCL/RigidBody/kernels/batchingKernels.h @@ -35,6 +35,7 @@ static const char* batchingKernelsCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" diff --git a/src/Bullet3OpenCL/RigidBody/kernels/batchingKernelsNew.h b/src/Bullet3OpenCL/RigidBody/kernels/batchingKernelsNew.h index b7bf3345b..1e5957ada 100644 --- a/src/Bullet3OpenCL/RigidBody/kernels/batchingKernelsNew.h +++ b/src/Bullet3OpenCL/RigidBody/kernels/batchingKernelsNew.h @@ -35,6 +35,7 @@ static const char* batchingKernelsNewCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" diff --git a/src/Bullet3OpenCL/RigidBody/kernels/integrateKernel.h b/src/Bullet3OpenCL/RigidBody/kernels/integrateKernel.h index f96c337af..a5a432947 100644 --- a/src/Bullet3OpenCL/RigidBody/kernels/integrateKernel.h +++ b/src/Bullet3OpenCL/RigidBody/kernels/integrateKernel.h @@ -35,6 +35,7 @@ static const char* integrateKernelCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" diff --git a/src/Bullet3OpenCL/RigidBody/kernels/solverSetup.h b/src/Bullet3OpenCL/RigidBody/kernels/solverSetup.h index e833e2edd..eb1834ee0 100644 --- a/src/Bullet3OpenCL/RigidBody/kernels/solverSetup.h +++ b/src/Bullet3OpenCL/RigidBody/kernels/solverSetup.h @@ -35,6 +35,7 @@ static const char* solverSetupCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" diff --git a/src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.cl b/src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.cl index 518f708ce..3dc48d435 100644 --- a/src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.cl +++ b/src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.cl @@ -510,7 +510,7 @@ typedef struct } ConstBufferSSD; -static __constant const int gridTable4x4[] = +__constant const int gridTable4x4[] = { 0,1,17,16, 1,2,18,19, @@ -518,7 +518,7 @@ static __constant const int gridTable4x4[] = 16,19,3,34 }; -static __constant const int gridTable8x8[] = +__constant const int gridTable8x8[] = { 0, 2, 3, 16, 17, 18, 19, 1, 66, 64, 80, 67, 82, 81, 65, 83, diff --git a/src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.h b/src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.h index a64be4be3..1b5819f6c 100644 --- a/src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.h +++ b/src/Bullet3OpenCL/RigidBody/kernels/solverSetup2.h @@ -35,6 +35,7 @@ static const char* solverSetup2CL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" @@ -514,14 +515,14 @@ static const char* solverSetup2CL= \ " float m_scale;\n" " int m_nSplit;\n" "} ConstBufferSSD;\n" -"static __constant const int gridTable4x4[] = \n" +"__constant const int gridTable4x4[] = \n" "{\n" " 0,1,17,16,\n" " 1,2,18,19,\n" " 17,18,32,3,\n" " 16,19,3,34\n" "};\n" -"static __constant const int gridTable8x8[] = \n" +"__constant const int gridTable8x8[] = \n" "{\n" " 0, 2, 3, 16, 17, 18, 19, 1,\n" " 66, 64, 80, 67, 82, 81, 65, 83,\n" diff --git a/src/Bullet3OpenCL/RigidBody/kernels/solverUtils.h b/src/Bullet3OpenCL/RigidBody/kernels/solverUtils.h index 13f7b7a6d..fef9dd2a6 100644 --- a/src/Bullet3OpenCL/RigidBody/kernels/solverUtils.h +++ b/src/Bullet3OpenCL/RigidBody/kernels/solverUtils.h @@ -35,6 +35,7 @@ static const char* solverUtilsCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n" diff --git a/src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h b/src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h index 0791b6dd5..d0b4ac9ba 100644 --- a/src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h +++ b/src/Bullet3OpenCL/RigidBody/kernels/updateAabbsKernel.h @@ -25,6 +25,7 @@ static const char* updateAabbsKernelCL= \ "#define b3Sqrt native_sqrt\n" "#define b3Sin native_sin\n" "#define b3Cos native_cos\n" +"#define B3_STATIC\n" "#endif\n" "#endif\n" "#ifdef __cplusplus\n"