From a92223890f165986b800912da08859a7ea0e36d2 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 23 May 2013 20:38:27 -0700 Subject: [PATCH] improve Mac OSX/Unix benchmark --- Demos3/GpuDemos/main_opengl3core.cpp | 26 ++++++++++++++++--- Demos3/GpuDemos/rigidbody/ConcaveScene.cpp | 12 ++++----- Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp | 7 +---- .../ParallelPrimitives/b3LauncherCL.h | 3 ++- src/Bullet3OpenCL/RigidBody/b3Config.h | 4 +-- 5 files changed, 34 insertions(+), 18 deletions(-) diff --git a/Demos3/GpuDemos/main_opengl3core.cpp b/Demos3/GpuDemos/main_opengl3core.cpp index ed2bbc8e1..f08a7eb7c 100644 --- a/Demos3/GpuDemos/main_opengl3core.cpp +++ b/Demos3/GpuDemos/main_opengl3core.cpp @@ -3,6 +3,8 @@ #ifdef _WIN32 #include //for GetLocalTime/GetSystemTime +#else +#include //gettimeofday #endif #ifdef __APPLE__ @@ -592,7 +594,7 @@ int main(int argc, char* argv[]) bool useGpu = false; - int maxObjectCapacity=256*1024; + int maxObjectCapacity=128*1024; ci.m_instancingRenderer = new GLInstancingRenderer(maxObjectCapacity);//render.getInstancingRenderer(); ci.m_window = window; @@ -622,7 +624,8 @@ int main(int argc, char* argv[]) b3OpenCLDeviceInfo info; b3OpenCLUtils::getDeviceInfo(demo->getInternalData()->m_clDevice,&info); - + + //todo: move this time stuff into the Platform/Window class #ifdef _WIN32 SYSTEMTIME time; GetLocalTime(&time); @@ -639,7 +642,24 @@ int main(int argc, char* argv[]) sprintf(prefixFileName,"%s_%s_%s_%d_%d_%d_date_%d-%d-%d_time_%d-%d-%d",info.m_deviceName,buf,demoNames[selectedDemo],ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,time.wDay,time.wMonth,time.wYear,time.wHour,time.wMinute,time.wSecond); #else - sprintf(prefixFileName,"%s_%d_%d_%d",info.m_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ); + timeval now; + gettimeofday(&now,0); + + struct tm* ptm; + ptm = localtime (&now.tv_sec); + char buf[1024]; +#ifdef __APPLE__ + sprintf(buf,"MacOSX"); +#else + sprintf(buf,"Unix"); +#endif + sprintf(prefixFileName,"%s_%s_%s_%d_%d_%d_date_%d-%d-%d_time_%d-%d-%d",info.m_deviceName,buf,demoNames[selectedDemo],ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ, + ptm->tm_mday, + ptm->tm_mon+1, + ptm->tm_year+1900, + ptm->tm_hour, + ptm->tm_min, + ptm->tm_sec); #endif diff --git a/Demos3/GpuDemos/rigidbody/ConcaveScene.cpp b/Demos3/GpuDemos/rigidbody/ConcaveScene.cpp index 39affbb30..4acbba70d 100644 --- a/Demos3/GpuDemos/rigidbody/ConcaveScene.cpp +++ b/Demos3/GpuDemos/rigidbody/ConcaveScene.cpp @@ -256,19 +256,19 @@ void ConcaveScene::setupScene(const ConstructionInfo& ci) char* fileName = "data/samurai_monastry.obj"; // char* fileName = "data/teddy2_VHACD_CHs.obj"; - b3Vector3 shift1(0,-50,0);//0,230,80);//150,-100,-120); + b3Vector3 shift1(0,0,0);//0,230,80);//150,-100,-120); b3Vector4 scaling(4,4,4,1); // createConcaveMesh(ci,"data/plane100.obj",shift1,scaling); //createConcaveMesh(ci,"data/plane100.obj",shift,scaling); - b3Vector3 shift2(0,0,0);//0,230,80);//150,-100,-120); - createConcaveMesh(ci,"data/teddy.obj",shift2,scaling); + // b3Vector3 shift2(0,0,0);//0,230,80);//150,-100,-120); + // createConcaveMesh(ci,"data/teddy.obj",shift2,scaling); - b3Vector3 shift3(130,-150,-75);//0,230,80);//150,-100,-120); + // b3Vector3 shift3(130,-150,-75);//0,230,80);//150,-100,-120); // createConcaveMesh(ci,"data/leoTest1.obj",shift3,scaling); - createConcaveMesh(ci,"data/samurai_monastry.obj",shift3,scaling); + createConcaveMesh(ci,"data/samurai_monastry.obj",shift1,scaling); } else { @@ -341,7 +341,7 @@ void ConcaveScene::createDynamicObjects(const ConstructionInfo& ci) float mass = 1; //b3Vector3 position(-2*ci.gapX+i*ci.gapX,25+j*ci.gapY,-2*ci.gapZ+k*ci.gapZ); - b3Vector3 position(-(ci.arraySizeX/2)*CONCAVE_GAPX+i*CONCAVE_GAPX,150+j*CONCAVE_GAPY,-(ci.arraySizeZ/2)*CONCAVE_GAPZ+k*CONCAVE_GAPZ); + b3Vector3 position(-(ci.arraySizeX/2)*CONCAVE_GAPX+i*CONCAVE_GAPX,3+j*CONCAVE_GAPY,-(ci.arraySizeZ/2)*CONCAVE_GAPZ+k*CONCAVE_GAPZ); b3Quaternion orn(0,0,0,1); b3Vector4 color = colors[curColor]; diff --git a/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp b/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp index 82eda0ace..9835391af 100644 --- a/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp +++ b/Demos3/GpuDemos/rigidbody/GpuConvexScene.cpp @@ -44,15 +44,10 @@ void GpuConvexScene::setupScene(const ConstructionInfo& ci) int GpuConvexScene::createDynamicsObjects(const ConstructionInfo& ci) { -/* int strideInBytes = 9*sizeof(float); + int strideInBytes = 9*sizeof(float); int numVertices = sizeof(barrel_vertices)/strideInBytes; int numIndices = sizeof(barrel_indices)/sizeof(int); return createDynamicsObjects2(ci,barrel_vertices,numVertices,barrel_indices,numIndices); - */ - int strideInBytes = 9*sizeof(float); - int numVertices = sizeof(cube_vertices)/strideInBytes; - int numIndices = sizeof(cube_indices)/sizeof(int); - return createDynamicsObjects2(ci,cube_vertices,numVertices,cube_indices,numIndices); } int GpuBoxPlaneScene::createDynamicsObjects(const ConstructionInfo& ci) diff --git a/src/Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h b/src/Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h index 5d1f0db86..18a47dc67 100644 --- a/src/Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h +++ b/src/Bullet3OpenCL/ParallelPrimitives/b3LauncherCL.h @@ -11,11 +11,12 @@ #pragma warning(disable :4996) #endif #define B3_CL_MAX_ARG_SIZE 16 -struct b3KernelArgData +B3_ATTRIBUTE_ALIGNED16(struct) b3KernelArgData { int m_isBuffer; int m_argIndex; int m_argSizeInBytes; + int m_unusedPadding; union { cl_mem m_clBuffer; diff --git a/src/Bullet3OpenCL/RigidBody/b3Config.h b/src/Bullet3OpenCL/RigidBody/b3Config.h index 00befa3c5..a0baee3e3 100644 --- a/src/Bullet3OpenCL/RigidBody/b3Config.h +++ b/src/Bullet3OpenCL/RigidBody/b3Config.h @@ -27,8 +27,8 @@ struct b3Config m_maxConvexIndices(8192), m_maxConvexUniqueEdges(8192), m_maxCompoundChildShapes(8192), - //m_maxTriConvexPairCapacity(512*1024) - m_maxTriConvexPairCapacity(256*1024) + m_maxTriConvexPairCapacity(512*1024) + //m_maxTriConvexPairCapacity(256*1024) { m_maxBroadphasePairs = 16*m_maxConvexBodies; m_maxContactCapacity = m_maxBroadphasePairs;