Merge branch 'master' of https://github.com/erwincoumans/bullet3
This commit is contained in:
@@ -46,15 +46,14 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex)
|
||||
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
|
||||
//#endif
|
||||
|
||||
cl_platform_id platformId;
|
||||
|
||||
|
||||
// if (useInterop)
|
||||
// {
|
||||
// m_data->m_clContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, glCtx, glDC);
|
||||
// } else
|
||||
{
|
||||
m_clData->m_clContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, 0,0,preferredDeviceIndex, preferredPlatformIndex,&platformId);
|
||||
b3OpenCLUtils::printPlatformInfo(platformId);
|
||||
m_clData->m_clContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, 0,0,preferredDeviceIndex, preferredPlatformIndex,&m_clData->m_platformId);
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +67,7 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex)
|
||||
m_clData->m_clQueue = clCreateCommandQueue(m_clData->m_clContext, m_clData->m_clDevice, 0, &ciErrNum);
|
||||
oclCHECKERROR(ciErrNum, CL_SUCCESS);
|
||||
|
||||
b3OpenCLUtils::printDeviceInfo(m_clData->m_clDevice);
|
||||
|
||||
b3OpenCLDeviceInfo info;
|
||||
b3OpenCLUtils::getDeviceInfo(m_clData->m_clDevice,&info);
|
||||
m_clData->m_clDeviceName = info.m_deviceName;
|
||||
@@ -78,6 +77,10 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex)
|
||||
|
||||
}
|
||||
|
||||
GpuDemoInternalData* GpuDemo::getInternalData()
|
||||
{
|
||||
return m_clData;
|
||||
}
|
||||
|
||||
int GpuDemo::registerGraphicsSphereShape(const ConstructionInfo& ci, float radius, bool usePointSprites, int largeSphereThreshold, int mediumSphereThreshold)
|
||||
{
|
||||
|
||||
@@ -38,9 +38,9 @@ public:
|
||||
:useOpenCL(true),
|
||||
preferredOpenCLPlatformIndex(-1),
|
||||
preferredOpenCLDeviceIndex(-1),
|
||||
arraySizeX(25),
|
||||
arraySizeY(20),
|
||||
arraySizeZ(25),
|
||||
arraySizeX(30),
|
||||
arraySizeY(30),
|
||||
arraySizeZ(30),
|
||||
m_useConcaveMesh(false),
|
||||
gapX(14.3),
|
||||
gapY(14.0),
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
|
||||
int registerGraphicsSphereShape(const ConstructionInfo& ci, float radius, bool usePointSprites=true, int largeSphereThreshold=100, int mediumSphereThreshold=10);
|
||||
|
||||
struct GpuDemoInternalData* getInternalData();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
struct GpuDemoInternalData
|
||||
{
|
||||
cl_platform_id m_platformId;
|
||||
cl_context m_clContext;
|
||||
cl_device_id m_clDevice;
|
||||
cl_command_queue m_clQueue;
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
#include "OpenGLWindow/X11OpenGLWindow.h"
|
||||
#endif
|
||||
|
||||
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
|
||||
#include "GpuDemoInternalData.h"
|
||||
|
||||
#include "OpenGLWindow/GLPrimitiveRenderer.h"
|
||||
#include "OpenGLWindow/GLInstancingRenderer.h"
|
||||
//#include "OpenGL3CoreRenderer.h"
|
||||
@@ -68,34 +71,36 @@ int selectedDemo = 0;
|
||||
GpuDemo::CreateFunc* allDemos[]=
|
||||
{
|
||||
// ConcaveCompound2Scene::MyCreateFunc,
|
||||
|
||||
GpuBoxPlaneScene::MyCreateFunc,
|
||||
// GpuConvexScene::MyCreateFunc,
|
||||
|
||||
//ConcaveSphereScene::MyCreateFunc,
|
||||
GpuBoxPlaneScene::MyCreateFunc,
|
||||
GpuConvexPlaneScene::MyCreateFunc,
|
||||
|
||||
|
||||
ConcaveSphereScene::MyCreateFunc,
|
||||
|
||||
GpuCompoundScene::MyCreateFunc,
|
||||
|
||||
GpuConvexScene::MyCreateFunc,
|
||||
|
||||
|
||||
|
||||
ConcaveSphereScene::MyCreateFunc,
|
||||
|
||||
ConcaveScene::MyCreateFunc,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ConcaveCompoundScene::MyCreateFunc,
|
||||
|
||||
GpuCompoundPlaneScene::MyCreateFunc,
|
||||
|
||||
GpuSphereScene::MyCreateFunc,
|
||||
|
||||
|
||||
GpuSoftClothDemo::MyCreateFunc,
|
||||
|
||||
|
||||
Bullet2FileDemo::MyCreateFunc,
|
||||
|
||||
PairBench::MyCreateFunc,
|
||||
|
||||
PairBench::MyCreateFunc,
|
||||
|
||||
|
||||
//GpuRigidBodyDemo::MyCreateFunc,
|
||||
@@ -106,9 +111,9 @@ GpuDemo::CreateFunc* allDemos[]=
|
||||
|
||||
|
||||
//ParticleDemo::MyCreateFunc,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//GpuCompoundDemo::CreateFunc,
|
||||
//EmptyDemo::CreateFunc,
|
||||
};
|
||||
@@ -204,7 +209,7 @@ sth_stash* initFont(GLPrimitiveRenderer* primRender)
|
||||
|
||||
struct sth_stash* stash = 0;
|
||||
int datasize;
|
||||
|
||||
|
||||
float sx,sy,dx,dy,lh;
|
||||
GLuint texture;
|
||||
|
||||
@@ -322,7 +327,7 @@ sth_stash* initFont(GLPrimitiveRenderer* primRender)
|
||||
|
||||
void Usage()
|
||||
{
|
||||
printf("\nprogram.exe [--selected_demo=<int>] [--cl_device=<int>] [--benchmark] [--disable_opencl] [--cl_platform=<int>] [--x_dim=<int>] [--y_dim=<num>] [--z_dim=<int>] [--x_gap=<float>] [--y_gap=<float>] [--z_gap=<float>] [--use_concave_mesh] [--new_batching]\n");
|
||||
printf("\nprogram.exe [--selected_demo=<int>] [--cl_device=<int>] [--benchmark] [--dump_timings] [--disable_opencl] [--cl_platform=<int>] [--x_dim=<int>] [--y_dim=<num>] [--z_dim=<int>] [--x_gap=<float>] [--y_gap=<float>] [--z_gap=<float>] [--use_concave_mesh] [--new_batching]\n");
|
||||
};
|
||||
|
||||
|
||||
@@ -392,7 +397,8 @@ extern bool useNewBatchingKernel;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
FILE* defaultOutput = stdout;
|
||||
|
||||
b3Vector3 test(1,2,3);
|
||||
test.x = 1;
|
||||
test.y = 4;
|
||||
@@ -408,10 +414,10 @@ int main(int argc, char* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
args.GetCmdLineArgument("selected_demo",selectedDemo);
|
||||
|
||||
|
||||
|
||||
if (args.CheckCmdLineFlag("new_batching"))
|
||||
{
|
||||
useNewBatchingKernel = true;
|
||||
@@ -435,13 +441,6 @@ int main(int argc, char* argv[])
|
||||
args.GetCmdLineArgument("z_gap", ci.gapZ);
|
||||
|
||||
|
||||
printf("Demo settings:\n");
|
||||
printf("x_dim=%d, y_dim=%d, z_dim=%d\n",ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ);
|
||||
printf("x_gap=%f, y_gap=%f, z_gap=%f\n",ci.gapX,ci.gapY,ci.gapZ);
|
||||
|
||||
printf("Preferred cl_device index %d\n", ci.preferredOpenCLDeviceIndex);
|
||||
printf("Preferred cl_platform index%d\n", ci.preferredOpenCLPlatformIndex);
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
#ifndef B3_NO_PROFILE
|
||||
b3ProfileManager::Reset();
|
||||
@@ -600,17 +599,29 @@ int main(int argc, char* argv[])
|
||||
ci.m_gui = gui;
|
||||
ci.m_instancingRenderer->init();
|
||||
ci.m_instancingRenderer->InitShaders();
|
||||
|
||||
|
||||
// render.init();
|
||||
|
||||
demo->initPhysics(ci);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
FILE* f = 0;
|
||||
FILE* csvFile = 0;
|
||||
FILE* detailsFile = 0;
|
||||
|
||||
if (benchmark)
|
||||
{
|
||||
gPause = false;
|
||||
char fileName[1024];
|
||||
char prefixFileName[1024];
|
||||
char csvFileName[1024];
|
||||
char detailsFileName[1024];
|
||||
|
||||
b3OpenCLDeviceInfo info;
|
||||
b3OpenCLUtils::getDeviceInfo(demo->getInternalData()->m_clDevice,&info);
|
||||
|
||||
#ifdef _WIN32
|
||||
SYSTEMTIME time;
|
||||
@@ -624,23 +635,43 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
printf("unknown", buf);
|
||||
}
|
||||
sprintf(fileName,"%s_%s_%s_%d_%d_%d_date_%d-%d-%d_time_%d-%d-%d.csv",g_deviceName,buf,demoNames[selectedDemo],ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,time.wDay,time.wMonth,time.wYear,time.wHour,time.wMinute,time.wSecond);
|
||||
|
||||
printf("Open file %s\n", fileName);
|
||||
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(fileName,"%s_%d_%d_%d.csv",g_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ);
|
||||
printf("Open file %s\n", fileName);
|
||||
sprintf(prefixFileName,"%s_%d_%d_%d",info.m_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ);
|
||||
|
||||
#endif
|
||||
|
||||
sprintf(csvFileName,"%s.csv",prefixFileName);
|
||||
sprintf(detailsFileName,"%s.txt",prefixFileName);
|
||||
printf("Open csv file %s and details file %s\n", csvFileName,detailsFileName);
|
||||
|
||||
//GetSystemTime(&time2);
|
||||
|
||||
f=fopen(fileName,"w");
|
||||
csvFile=fopen(csvFileName,"w");
|
||||
detailsFile = fopen(detailsFileName,"w");
|
||||
if (detailsFile)
|
||||
defaultOutput = detailsFile;
|
||||
|
||||
//if (f)
|
||||
// fprintf(f,"%s (%dx%dx%d=%d),\n", g_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,ci.arraySizeX*ci.arraySizeY*ci.arraySizeZ);
|
||||
}
|
||||
|
||||
printf("-----------------------------------------------------\n");
|
||||
|
||||
fprintf(defaultOutput,"Demo settings:\n");
|
||||
fprintf(defaultOutput," SelectedDemo=%d, demoname = %s\n", selectedDemo, demo->getName());
|
||||
fprintf(defaultOutput," x_dim=%d, y_dim=%d, z_dim=%d\n",ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ);
|
||||
fprintf(defaultOutput," x_gap=%f, y_gap=%f, z_gap=%f\n",ci.gapX,ci.gapY,ci.gapZ);
|
||||
fprintf(defaultOutput,"\nOpenCL settings:\n");
|
||||
fprintf(defaultOutput," Preferred cl_device index %d\n", ci.preferredOpenCLDeviceIndex);
|
||||
fprintf(defaultOutput," Preferred cl_platform index%d\n", ci.preferredOpenCLPlatformIndex);
|
||||
fprintf(defaultOutput,"\n");
|
||||
|
||||
b3OpenCLUtils::printPlatformInfo(defaultOutput, demo->getInternalData()->m_platformId);
|
||||
fprintf(defaultOutput,"\n");
|
||||
b3OpenCLUtils::printDeviceInfo(defaultOutput, demo->getInternalData()->m_clDevice);
|
||||
fprintf(defaultOutput,"\n");
|
||||
do
|
||||
{
|
||||
b3ProfileManager::Reset();
|
||||
@@ -695,21 +726,30 @@ int main(int argc, char* argv[])
|
||||
B3_PROFILE("glFinish");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (dump_timings)
|
||||
b3ProfileManager::dumpAll();
|
||||
|
||||
if (f)
|
||||
{
|
||||
static int count=0;
|
||||
b3ProfileManager::dumpAll(stdout);
|
||||
}
|
||||
|
||||
if (count>2 && count<102)
|
||||
if (csvFile)
|
||||
{
|
||||
static int frameCount=0;
|
||||
|
||||
if (frameCount>0)
|
||||
{
|
||||
DumpSimulationTime(f);
|
||||
DumpSimulationTime(csvFile);
|
||||
if (detailsFile)
|
||||
{
|
||||
fprintf(detailsFile,"\n==================================\nFrame %d:\n", frameCount);
|
||||
b3ProfileManager::dumpAll(detailsFile);
|
||||
}
|
||||
}
|
||||
if (count>=102)
|
||||
|
||||
if (frameCount>=102)
|
||||
window->setRequestExit();
|
||||
count++;
|
||||
frameCount++;
|
||||
}
|
||||
|
||||
|
||||
@@ -720,8 +760,16 @@ int main(int argc, char* argv[])
|
||||
demo->exitPhysics();
|
||||
b3ProfileManager::CleanupMemory();
|
||||
delete demo;
|
||||
if (f)
|
||||
fclose(f);
|
||||
if (detailsFile)
|
||||
{
|
||||
fclose(detailsFile);
|
||||
detailsFile=0;
|
||||
}
|
||||
if (csvFile)
|
||||
{
|
||||
fclose(csvFile);
|
||||
csvFile=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,13 +25,13 @@ function createProject(vendor)
|
||||
|
||||
links {
|
||||
"gwen",
|
||||
"Bullet3Common",
|
||||
"Bullet3Geometry",
|
||||
"Bullet3Collision",
|
||||
"Bullet3Dynamics",
|
||||
"Bullet2FileLoader",
|
||||
"Bullet3OpenCL_" .. vendor
|
||||
|
||||
"Bullet3OpenCL_" .. vendor,
|
||||
"Bullet3Dynamics",
|
||||
"Bullet3Collision",
|
||||
"Bullet3Geometry",
|
||||
"Bullet3Common",
|
||||
|
||||
}
|
||||
|
||||
files {
|
||||
@@ -89,6 +89,7 @@ function createProject(vendor)
|
||||
end
|
||||
end
|
||||
|
||||
createProject("clew")
|
||||
createProject("Apple")
|
||||
createProject("AMD")
|
||||
createProject("Intel")
|
||||
|
||||
@@ -173,14 +173,16 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
|
||||
f = fopen(relativeFileName,"r");
|
||||
if (f)
|
||||
{
|
||||
fclose(f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (f)
|
||||
{
|
||||
fclose(f);
|
||||
f=0;
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ void GpuConvexScene::setupScene(const ConstructionInfo& ci)
|
||||
index+=createDynamicsObjects(ci);
|
||||
|
||||
m_data->m_rigidBodyPipeline->writeAllInstancesToGpu();
|
||||
|
||||
|
||||
|
||||
|
||||
float camPos[4]={ci.arraySizeX,ci.arraySizeY/2,ci.arraySizeZ,0};
|
||||
//float camPos[4]={1,12.5,1.5,0};
|
||||
m_instancingRenderer->setCameraTargetPosition(camPos);
|
||||
m_instancingRenderer->setCameraDistance(40);
|
||||
m_instancingRenderer->setCameraDistance(100);
|
||||
|
||||
|
||||
char msg[1024];
|
||||
@@ -44,10 +44,15 @@ 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)
|
||||
@@ -67,20 +72,20 @@ int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const flo
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 colors[4] =
|
||||
b3Vector4 colors[4] =
|
||||
{
|
||||
b3Vector4(1,0,0,1),
|
||||
b3Vector4(0,1,0,1),
|
||||
b3Vector4(0,1,1,1),
|
||||
b3Vector4(1,1,0,1),
|
||||
};
|
||||
|
||||
|
||||
int curColor = 0;
|
||||
float scaling[4] = {1,1,1,1};
|
||||
int prevBody = -1;
|
||||
@@ -99,18 +104,18 @@ int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const flo
|
||||
{
|
||||
//mass=0.f;
|
||||
}
|
||||
//b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
|
||||
b3Vector3 position(i*2.2,10+j*2.2,k*2.2);
|
||||
|
||||
b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
|
||||
//b3Vector3 position(i*2.2,10+j*1.9,k*2.2);
|
||||
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
|
||||
b3Vector4 color = colors[curColor];
|
||||
curColor++;
|
||||
curColor&=3;
|
||||
b3Vector4 scaling(1,1,1,1);
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(mass,position,orn,colIndex,index,false);
|
||||
|
||||
|
||||
|
||||
if (prevBody>=0)
|
||||
{
|
||||
@@ -137,19 +142,19 @@ void GpuConvexScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
int group=1;
|
||||
int mask=1;
|
||||
int index=0;
|
||||
|
||||
|
||||
|
||||
{
|
||||
b3Vector4 scaling(400,1,400,1);
|
||||
int colIndex = m_data->m_np->registerConvexHullShape(&cube_vertices[0],strideInBytes,numVertices, scaling);
|
||||
b3Vector3 position(0,0,0);
|
||||
b3Quaternion orn(0,0,0,1);
|
||||
|
||||
|
||||
b3Vector4 color(0,0,1,1);
|
||||
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0.f,position,orn,colIndex,index,false);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,9 +173,9 @@ void GpuConvexPlaneScene::createStaticEnvironment(const ConstructionInfo& ci)
|
||||
int numVertices = sizeof(cube_vertices)/strideInBytes;
|
||||
int numIndices = sizeof(cube_indices)/sizeof(int);
|
||||
int shapeId = ci.m_instancingRenderer->registerShape(&cube_vertices[0],numVertices,cube_indices,numIndices);
|
||||
|
||||
|
||||
|
||||
|
||||
int id = ci.m_instancingRenderer->registerGraphicsInstance(shapeId,position,orn,color,scaling);
|
||||
int pid = m_data->m_rigidBodyPipeline->registerPhysicsInstance(0.f,position,orn,colIndex,index,false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user