Update btOpenCLUtils to allow caching of precompiled program binaries (save/load). See Bullet/Demos/SerializeDemo/AMD for an example use

Fix in btBulletWorldImporter: load friction/restitution and patch radius of btCapsuleShape (it needs to embed the margin)
Partly apply a modified patch to make the SerializeDemo_AMD work, but avoid breaking the MiniCL version. See Issue 594
This commit is contained in:
erwin.coumans
2012-03-04 22:12:12 +00:00
parent 9c6a790e4b
commit 9bc3b5eb10
14 changed files with 422 additions and 180 deletions

View File

@@ -20,7 +20,7 @@ subject to the following restrictions:
#ifndef USE_MINICL
//#define USE_SIMDAWARE_SOLVER
#define USE_SIMDAWARE_SOLVER
#endif
#if !defined (__APPLE__)

View File

@@ -115,7 +115,24 @@ IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES AND NOT INTERNAL_UPDATE_
ADD_CUSTOM_COMMAND(
TARGET AppSerializeDemo_AMD
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/SerializeDemo/testFile.bullet ${CMAKE_CURRENT_BINARY_DIR}/testFile.bullet
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/SerializeDemo/testFileCloth.bullet ${CMAKE_CURRENT_BINARY_DIR}/testFile.bullet
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/ApplyForces.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/ApplyForces.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/ComputeBounds.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/ComputeBounds.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/Integrate.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/Integrate.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/OutputToVertexArray.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/OutputToVertexArray.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/PrepareLinks.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/PrepareLinks.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/SolveCollisionsAndUpdateVelocities.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/SolveCollisionsAndUpdateVelocities.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/SolveCollisionsAndUpdateVelocitiesSIMDBatched.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/SolveCollisionsAndUpdateVelocitiesSIMDBatched.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/SolvePositions.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/SolvePositions.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/SolvePositionsSIMDBatched.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/SolvePositionsSIMDBatched.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/UpdateConstants.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/UpdateConstants.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/UpdateFixedVertexPositions.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/UpdateFixedVertexPositions.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/UpdateNodes.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/UpdateNodes.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/UpdateNormals.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/UpdateNormals.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/UpdatePositions.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/UpdatePositions.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/UpdatePositionsFromVelocities.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/UpdatePositionsFromVelocities.cl
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/OpenCLC10/VSolveLinks.cl ${CMAKE_CURRENT_BINARY_DIR}/OpenCLC10/VSolveLinks.cl
)
ENDIF ()

View File

@@ -13,7 +13,6 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
#define TEST_SERIALIZATION 1
//#undef DESERIALIZE_SOFT_BODIES
@@ -57,6 +56,8 @@ subject to the following restrictions:
#ifdef USE_AMD_OPENCL
#include <BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCL.h>
#include <BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCLSIMDAware.h>
#include "../SharedOpenCL/btOpenCLUtils.h"
extern cl_context g_cxMainContext;
extern cl_device_id g_cdDevice;
extern cl_command_queue g_cqCommandQue;
@@ -198,7 +199,39 @@ void SerializeDemo::clientMoveAndDisplay()
swapBuffers();
}
#ifdef USE_AMD_OPENCL
///the CachingCLFuncs class will try to create/load precompiled binary programs, instead of the slow on-line compilation of programs
class CachingCLFuncs : public CLFunctions
{
cl_device_id m_device;
public:
CachingCLFuncs (cl_command_queue cqCommandQue, cl_context cxMainContext, cl_device_id device)
:CLFunctions(cqCommandQue,cxMainContext),
m_device(device)
{
}
virtual cl_kernel compileCLKernelFromString( const char* kernelSource, const char* kernelName, const char* additionalMacros, const char* srcFileNameForCaching)
{
cl_int pErrNum;
cl_program prog;
prog = btOpenCLUtils::compileCLProgramFromFile( m_cxMainContext,m_device, &pErrNum,additionalMacros ,srcFileNameForCaching);
if (!prog)
{
printf("Using embedded kernel source instead:\n");
prog = btOpenCLUtils::compileCLProgramFromString( m_cxMainContext,m_device, kernelSource, &pErrNum,additionalMacros);
}
return btOpenCLUtils::compileCLKernelFromString( m_cxMainContext,m_device, kernelSource, kernelName, &pErrNum, prog,additionalMacros);
}
};
#endif
void SerializeDemo::displayCallback(void) {
@@ -277,18 +310,13 @@ void SerializeDemo::setupEmptyDynamicsWorld()
{
case kSolverAccelerationOpenCL_GPU:
{
fSoftBodySolver
= new btOpenCLSoftBodySolverSIMDAware( g_cqCommandQue,
g_cxMainContext );
// fSoftBodySolver = new btOpenCLSoftBodySolver( g_cqCommandQue, g_cxMainContext);
btOpenCLSoftBodySolverSIMDAware* softSolv= new btOpenCLSoftBodySolverSIMDAware( g_cqCommandQue, g_cxMainContext );
//btOpenCLSoftBodySolver* softSolv= new btOpenCLSoftBodySolver( g_cqCommandQue, g_cxMainContext);
fSoftBodySolver = softSolv;
CLFunctions* funcs = new CachingCLFuncs(g_cqCommandQue, g_cxMainContext,g_cdDevice);
softSolv->setCLFunctions(funcs);
/*if (!fSoftBodySolver->checkInitialized())
{
btAssert(0);
delete fSoftBodySolver;
fSoftBodySolver = NULL;
}
*/
break;
}
@@ -523,7 +551,7 @@ public:
psb->m_cfg.kDG = softBodyData->m_config.m_drag;
psb->m_cfg.kMT = softBodyData->m_config.m_poseMatch;
psb->m_cfg.collisions = softBodyData->m_config.m_collisionFlags;
psb->m_cfg.kDF = softBodyData->m_config.m_dynamicFriction;
psb->m_cfg.kDF = 1.f;//softBodyData->m_config.m_dynamicFriction;
psb->m_cfg.kDP = softBodyData->m_config.m_damping;
psb->m_cfg.kPR = softBodyData->m_config.m_pressure;
psb->m_cfg.kVC = softBodyData->m_config.m_volume;
@@ -715,7 +743,7 @@ void SerializeDemo::initPhysics()
setTexturing(true);
setShadows(true);
setCameraDistance(btScalar(SCALING*50.));
setCameraDistance(btScalar(SCALING*30.));
setupEmptyDynamicsWorld();

Binary file not shown.

View File

@@ -22,6 +22,9 @@ subject to the following restrictions:
#include <stdio.h>
#include <stdlib.h>
#define BT_MAX_CL_DEVICES 16 //who needs 16 devices?
//#define BT_USE_CACHE_DIR
#ifdef _WIN32
#include <Windows.h>
#include <assert.h>
@@ -30,7 +33,7 @@ subject to the following restrictions:
#endif
//Set the preferred platform vendor using the OpenCL SDK
static const char* spPlatformVendor =
static char* spPlatformVendor =
#if defined(CL_PLATFORM_MINI_CL)
"MiniCL, SCEA";
#elif defined(CL_PLATFORM_AMD)
@@ -105,7 +108,7 @@ void btOpenCLUtils::getPlatformInfo(cl_platform_id platform, btOpenCLPlatformInf
oclCHECKERROR(ciErrNum,CL_SUCCESS);
}
cl_context btOpenCLUtils::createContextFromPlatform(cl_platform_id platform, cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC)
cl_context btOpenCLUtils::createContextFromPlatform(cl_platform_id platform, cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC, int preferredDeviceIndex, int preferredPlatformIndex)
{
cl_context retContext = 0;
cl_int ciErrNum=0;
@@ -117,22 +120,52 @@ cl_context btOpenCLUtils::createContextFromPlatform(cl_platform_id platform, cl_
cl_context_properties cps[7] = {0,0,0,0,0,0,0};
cps[0] = CL_CONTEXT_PLATFORM;
cps[1] = (cl_context_properties)platform;
#if defined (_WIN32) && defined(_MSC_VER) && !defined (CL_PLATFORM_MINI_CL)
if (pGLContext && pGLDC)
{
#if defined(CL_PLATFORM_AMD) || defined(CL_PLATFORM_NVIDIA)
cps[2] = CL_GL_CONTEXT_KHR;
cps[3] = (cl_context_properties)pGLContext;
cps[4] = CL_WGL_HDC_KHR;
cps[5] = (cl_context_properties)pGLDC;
}
#endif
}
cl_uint num_entries = BT_MAX_CL_DEVICES;
cl_device_id devices[BT_MAX_CL_DEVICES];
cl_uint num_devices=-1;
ciErrNum = clGetDeviceIDs(
platform,
deviceType,
num_entries,
devices,
&num_devices);
cl_context_properties* cprops = (NULL == platform) ? NULL : cps;
retContext = clCreateContextFromType(cprops,
deviceType,
NULL,
NULL,
&ciErrNum);
if (pGLContext)
{
//search for the GPU that relates to the OpenCL context
for (int i=0;i<num_devices;i++)
{
retContext = clCreateContext(cprops,1,&devices[i],NULL,NULL,&ciErrNum);
if (ciErrNum==CL_SUCCESS)
break;
}
}
else
{
if (preferredDeviceIndex>=0 && preferredDeviceIndex<num_devices)
{
//create a context of the preferred device index
retContext = clCreateContext(cprops,1,&devices[preferredDeviceIndex],NULL,NULL,&ciErrNum);
} else
{
//create a context of all devices
retContext = clCreateContext(cprops,num_devices,devices,NULL,NULL,&ciErrNum);
}
}
if(pErrNum != NULL)
{
*pErrNum = ciErrNum;
@@ -141,7 +174,7 @@ cl_context btOpenCLUtils::createContextFromPlatform(cl_platform_id platform, cl_
return retContext;
}
cl_context btOpenCLUtils::createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC )
cl_context btOpenCLUtils::createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC , int preferredDeviceIndex, int preferredPlatformIndex)
{
cl_uint numPlatforms;
cl_context retContext = 0;
@@ -163,6 +196,7 @@ cl_context btOpenCLUtils::createContextFromType(cl_device_type deviceType, cl_in
}
int i;
for ( i = 0; i < numPlatforms; ++i)
{
char pbuf[128];
@@ -177,6 +211,14 @@ cl_context btOpenCLUtils::createContextFromType(cl_device_type deviceType, cl_in
return NULL;
}
if (preferredPlatformIndex>=0 && i==preferredPlatformIndex)
{
cl_platform_id tmpPlatform = platforms[0];
platforms[0] = platforms[i];
platforms[i] = tmpPlatform;
break;
} else
{
if(!strcmp(pbuf, spPlatformVendor))
{
cl_platform_id tmpPlatform = platforms[0];
@@ -185,17 +227,18 @@ cl_context btOpenCLUtils::createContextFromType(cl_device_type deviceType, cl_in
break;
}
}
}
for (i = 0; i < numPlatforms; ++i)
{
cl_platform_id platform = platforms[i];
assert(platform);
retContext = btOpenCLUtils::createContextFromPlatform(platform,deviceType,pErrNum,pGLContext,pGLDC);
retContext = btOpenCLUtils::createContextFromPlatform(platform,deviceType,pErrNum,pGLContext,pGLDC,preferredDeviceIndex);
if (retContext)
{
printf("OpenCL platform details:\n");
// printf("OpenCL platform details:\n");
btOpenCLPlatformInfo platformInfo;
btOpenCLUtils::getPlatformInfo(platform, platformInfo);
@@ -270,10 +313,10 @@ void btOpenCLUtils::printDeviceInfo(cl_device_id device)
printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_DEFAULT");
printf(" CL_DEVICE_MAX_COMPUTE_UNITS:\t\t%u\n", info.m_computeUnits);
printf(" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%d\n", (int)info.m_workitemDims);
printf(" CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%d / %d / %d \n", (int)info.m_workItemSize[0], (int)info.m_workItemSize[1],(int) info.m_workItemSize[2]);
printf(" CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%d\n", (int)info.m_workgroupSize);
printf(" CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%d MHz\n", (int)info.m_clockFrequency);
printf(" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%u\n", info.m_workitemDims);
printf(" CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%u / %u / %u \n", info.m_workItemSize[0], info.m_workItemSize[1], info.m_workItemSize[2]);
printf(" CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%u\n", info.m_workgroupSize);
printf(" CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%u MHz\n", info.m_clockFrequency);
printf(" CL_DEVICE_ADDRESS_BITS:\t\t%u\n", info.m_addressBits);
printf(" CL_DEVICE_MAX_MEM_ALLOC_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_maxMemAllocSize/ (1024 * 1024)));
printf(" CL_DEVICE_GLOBAL_MEM_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_globalMemSize/ (1024 * 1024)));
@@ -291,11 +334,11 @@ void btOpenCLUtils::printDeviceInfo(cl_device_id device)
printf(" CL_DEVICE_MAX_READ_IMAGE_ARGS:\t%u\n", info.m_maxReadImageArgs);
printf(" CL_DEVICE_MAX_WRITE_IMAGE_ARGS:\t%u\n", info.m_maxWriteImageArgs);
printf("\n CL_DEVICE_IMAGE <dim>");
printf("\t\t\t2D_MAX_WIDTH\t %d\n", (int)info.m_image2dMaxWidth);
printf("\t\t\t\t\t2D_MAX_HEIGHT\t %d\n", (int)info.m_image2dMaxHeight);
printf("\t\t\t\t\t3D_MAX_WIDTH\t %d\n", (int)info.m_image3dMaxWidth);
printf("\t\t\t\t\t3D_MAX_HEIGHT\t %d\n", (int)info.m_image3dMaxHeight);
printf("\t\t\t\t\t3D_MAX_DEPTH\t %d\n", (int)info.m_image3dMaxDepth);
printf("\t\t\t2D_MAX_WIDTH\t %u\n", info.m_image2dMaxWidth);
printf("\t\t\t\t\t2D_MAX_HEIGHT\t %u\n", info.m_image2dMaxHeight);
printf("\t\t\t\t\t3D_MAX_WIDTH\t %u\n", info.m_image3dMaxWidth);
printf("\t\t\t\t\t3D_MAX_HEIGHT\t %u\n", info.m_image3dMaxHeight);
printf("\t\t\t\t\t3D_MAX_DEPTH\t %u\n", info.m_image3dMaxDepth);
if (info.m_deviceExtensions != 0)
printf("\n CL_DEVICE_EXTENSIONS:%s\n",info.m_deviceExtensions);
else
@@ -389,21 +432,84 @@ void btOpenCLUtils::getDeviceInfo(cl_device_id device, btOpenCLDeviceInfo& info)
clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, sizeof(cl_uint), &info.m_vecWidthDouble, NULL);
}
static const char* strip2(const char* name, const char* pattern)
static char* strip1(char* name, const char* pattern,int* numOccurences=0)
{
size_t const patlen = strlen(pattern);
char * oriptr;
char * patloc;
// find how many times the pattern occurs in the original string
for (oriptr = name; patloc = strstr(oriptr, pattern); oriptr = patloc + patlen)
{
if (numOccurences)
(*numOccurences)++;
}
return oriptr;
}
static const char* strip2(const char* name, const char* pattern,int* numOccurences=0)
{
size_t const patlen = strlen(pattern);
size_t patcnt = 0;
const char * oriptr;
const char * patloc;
// find how many times the pattern occurs in the original string
for (oriptr = name; patloc = strstr(oriptr, pattern); oriptr = patloc + patlen)
{
patcnt++;
if (numOccurences)
(*numOccurences)++;
}
return oriptr;
}
cl_program btOpenCLUtils::compileCLProgramFromString(cl_context clContext, cl_device_id device, const char* kernelSource, cl_int* pErrNum, const char* additionalMacros , const char* clFileNameForCaching)
cl_program btOpenCLUtils::compileCLProgramFromString(cl_context clContext, cl_device_id device, const char* kernelSource, cl_int* pErrNum, const char* additionalMacros)
{
cl_int localErrNum;
size_t program_length = strlen(kernelSource);
cl_program m_cpProgram = clCreateProgramWithSource(clContext, 1, (const char**)&kernelSource, &program_length, &localErrNum);
if (localErrNum!= CL_SUCCESS)
{
if (pErrNum)
*pErrNum = localErrNum;
return 0;
}
// Build the program with 'mad' Optimization option
#ifdef MAC
char* flags = "-cl-mad-enable -DMAC -DGUID_ARG";
#else
//const char* flags = "-DGUID_ARG= -fno-alias";
const char* flags = "-DGUID_ARG= ";
#endif
char* compileFlags = new char[strlen(additionalMacros) + strlen(flags) + 5];
sprintf(compileFlags, "%s %s", flags, additionalMacros);
localErrNum = clBuildProgram(m_cpProgram, 1, &device, compileFlags, NULL, NULL);
if (localErrNum!= CL_SUCCESS)
{
char *build_log;
size_t ret_val_size;
clGetProgramBuildInfo(m_cpProgram, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
build_log = new char[ret_val_size+1];
clGetProgramBuildInfo(m_cpProgram, device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
// to be carefully, terminate with \0
// there's no information in the reference whether the string is 0 terminated or not
build_log[ret_val_size] = '\0';
printf("Error in clBuildProgram, Line %u in file %s, Log: \n%s\n !!!\n\n", __LINE__, __FILE__, build_log);
delete[] build_log;
if (pErrNum)
*pErrNum = localErrNum;
return 0;
}
delete[] compileFlags;
return m_cpProgram;
}
cl_program btOpenCLUtils::compileCLProgramFromFile(cl_context clContext, cl_device_id device, cl_int* pErrNum, const char* additionalMacros , const char* clFileNameForCaching)
{
cl_program m_cpProgram=0;
@@ -411,7 +517,6 @@ cl_program btOpenCLUtils::compileCLProgramFromString(cl_context clContext, cl_de
char binaryFileName[522];
#if defined (_WIN32) && defined(_MSC_VER)
if (clFileNameForCaching)
{
@@ -423,8 +528,12 @@ cl_program btOpenCLUtils::compileCLProgramFromString(cl_context clContext, cl_de
const char* strippedName = strip2(clFileNameForCaching,"\\");
strippedName = strip2(strippedName,"/");
#ifdef BT_USE_CACHE_DIR
sprintf_s(binaryFileName,"cache/%s.%s.%s.bin",strippedName, deviceName,driverVersion );
#else
sprintf_s(binaryFileName,"%s.%s.%s.bin",strippedName, deviceName,driverVersion );
#endif
//printf("searching for %s\n", binaryFileName);
bool fileUpToDate = false;
@@ -432,6 +541,10 @@ cl_program btOpenCLUtils::compileCLProgramFromString(cl_context clContext, cl_de
FILETIME modtimeBinary;
#ifdef _WIN32
#ifdef BT_USE_CACHE_DIR
CreateDirectory("cache",0);
#endif //BT_USE_CACHE_DIR
{
HANDLE binaryFileHandle = CreateFile(binaryFileName,GENERIC_READ,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
@@ -494,7 +607,6 @@ cl_program btOpenCLUtils::compileCLProgramFromString(cl_context clContext, cl_de
}
else
{
#ifdef _DEBUG
DWORD errorCode;
errorCode = GetLastError();
switch (errorCode)
@@ -516,11 +628,7 @@ cl_program btOpenCLUtils::compileCLProgramFromString(cl_context clContext, cl_de
}
//we should make sure the src file exists so we can verify the timestamp with binary
assert(0);
#else
//if we cannot find the source, assume it is OK in release builds
fileUpToDate = true;
#endif
fileUpToDate = false;
}
}
@@ -557,62 +665,63 @@ cl_program btOpenCLUtils::compileCLProgramFromString(cl_context clContext, cl_de
btAssert(0);
m_cpProgram = 0;
}
delete[] binary;
}
}
#endif //_WIN32
}
#endif
if (!m_cpProgram)
{
// cl_kernel kernel;
cl_int localErrNum;
size_t program_length = strlen(kernelSource);
m_cpProgram = clCreateProgramWithSource(clContext, 1, (const char**)&kernelSource, &program_length, &localErrNum);
if (localErrNum!= CL_SUCCESS)
FILE* file = fopen(clFileNameForCaching, "r");
if (file)
{
if (pErrNum)
*pErrNum = localErrNum;
return 0;
fseek( file, 0L, SEEK_END );
size_t fileSize= ftell( file );
rewind( file );
char* kernelSource2 = new char[fileSize+1];
fread( kernelSource2, sizeof(char), fileSize, file );
fclose( file );
kernelSource2[fileSize]=0;
int numOccurences = 0;
///patch/remove the MSTRINGIFY( and );
char* kernelSource = strip1(kernelSource2,"MSTRINGIFY(",&numOccurences);
int newlen = strlen(kernelSource);
if (numOccurences)
{
int i=newlen-1;
for (;i>=0;i--)
{
if (kernelSource[i] == ';')
{
kernelSource[i] = 0;//' ';
break;
}
}
for (;i>=0;i--)
{
if (kernelSource[i] == ')')
{
kernelSource[i] = 0;//' ';
break;
}
}
}
// Build the program with 'mad' Optimization option
m_cpProgram = compileCLProgramFromString(clContext,device,kernelSource,pErrNum,additionalMacros);
#ifdef MAC
char* flags = "-cl-mad-enable -DMAC -DGUID_ARG";
#else
//const char* flags = "-DGUID_ARG= -fno-alias";
const char* flags = "-DGUID_ARG= ";
#endif
char* compileFlags = new char[strlen(additionalMacros) + strlen(flags) + 5];
sprintf(compileFlags, "%s %s", flags, additionalMacros);
localErrNum = clBuildProgram(m_cpProgram, 1, &device, compileFlags, NULL, NULL);
if (localErrNum!= CL_SUCCESS)
{
char *build_log;
size_t ret_val_size;
clGetProgramBuildInfo(m_cpProgram, device, CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size);
build_log = new char[ret_val_size+1];
clGetProgramBuildInfo(m_cpProgram, device, CL_PROGRAM_BUILD_LOG, ret_val_size, build_log, NULL);
// to be carefully, terminate with \0
// there's no information in the reference whether the string is 0 terminated or not
build_log[ret_val_size] = '\0';
printf("Error in clBuildProgram, Line %u in file %s, Log: \n%s\n !!!\n\n", __LINE__, __FILE__, build_log);
delete[] build_log;
if (pErrNum)
*pErrNum = localErrNum;
return 0;
}
#if defined (_WIN32) && defined(_MSC_VER)
if( clFileNameForCaching )
{ // write to binary
cl_uint numAssociatedDevices;
status = clGetProgramInfo( m_cpProgram, CL_PROGRAM_NUM_DEVICES, sizeof(cl_uint), &numAssociatedDevices, 0 );
btAssert( status == CL_SUCCESS );
if (numAssociatedDevices==1)
{
size_t binarySize;
status = clGetProgramInfo( m_cpProgram, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &binarySize, 0 );
btAssert( status == CL_SUCCESS );
@@ -636,9 +745,8 @@ cl_program btOpenCLUtils::compileCLProgramFromString(cl_context clContext, cl_de
delete [] binary;
}
#endif//defined (_WIN32) && defined(_MSC_VER)
delete [] compileFlags;
}
}
}
return m_cpProgram;

View File

@@ -78,7 +78,7 @@ public:
/// CL Context optionally takes a GL context. This is a generic type because we don't really want this code
/// to have to understand GL types. It is a HGLRC in _WIN32 or a GLXContext otherwise.
static cl_context createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx = 0, void* pGLDC = 0);
static cl_context createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx = 0, void* pGLDC = 0, int preferredDeviceIndex = -1, int preferredPlatformIndex= - 1);
static int getNumDevices(cl_context cxMainContext);
static cl_device_id getDevice(cl_context cxMainContext, int nr);
@@ -88,7 +88,10 @@ public:
static cl_kernel compileCLKernelFromString( cl_context clContext,cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum=0, cl_program prog=0,const char* additionalMacros = "" );
//optional
static cl_program compileCLProgramFromString( cl_context clContext,cl_device_id device, const char* kernelSource, cl_int* pErrNum=0,const char* additionalMacros = "" , const char* srcFileNameForCaching=0);
static cl_program compileCLProgramFromString( cl_context clContext,cl_device_id device, const char* kernelSource, cl_int* pErrNum=0,const char* additionalMacros = "");
///compileCLProgramFromFile will attempt to save/load the binary precompiled program
static cl_program compileCLProgramFromFile( cl_context clContext,cl_device_id device, cl_int* pErrNum=0,const char* additionalMacros = "" , const char* srcFileNameForCaching=0);
//the following optional APIs provide access using specific platform information
static int getNumPlatforms(cl_int* pErrNum=0);
@@ -96,7 +99,7 @@ public:
static cl_platform_id getPlatform(int nr, cl_int* pErrNum=0);
static void getPlatformInfo(cl_platform_id platform, btOpenCLPlatformInfo& platformInfo);
static const char* getSdkVendorName();
static cl_context createContextFromPlatform(cl_platform_id platform, cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx = 0, void* pGLDC = 0);
static cl_context createContextFromPlatform(cl_platform_id platform, cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx = 0, void* pGLDC = 0,int preferredDeviceIndex = -1, int preferredPlatformIndex= -1);
};

View File

@@ -1,3 +1,18 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2010 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btBulletWorldImporter.h"
#include "../BulletFileLoader/btBulletFile.h"
@@ -454,23 +469,24 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
{
case 0:
{
shape = createCapsuleShapeX(implicitShapeDimensions.getY(),2*implicitShapeDimensions.getX());
shape = createCapsuleShapeX(implicitShapeDimensions.getY()+bsd->m_collisionMargin*2,2*implicitShapeDimensions.getX());
break;
}
case 1:
{
shape = createCapsuleShapeY(implicitShapeDimensions.getX(),2*implicitShapeDimensions.getY());
shape = createCapsuleShapeY(implicitShapeDimensions.getX()+bsd->m_collisionMargin*2,2*implicitShapeDimensions.getY());
break;
}
case 2:
{
shape = createCapsuleShapeZ(implicitShapeDimensions.getX(),2*implicitShapeDimensions.getZ());
shape = createCapsuleShapeZ(implicitShapeDimensions.getX()+bsd->m_collisionMargin*2,2*implicitShapeDimensions.getZ());
break;
}
default:
{
printf("error: wrong up axis for btCapsuleShape\n");
}
bsd->m_collisionMargin = 0.f;
};
@@ -567,7 +583,7 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
if (shape)
{
shape->setMargin(bsd->m_collisionMargin);
//shape->setMargin(bsd->m_collisionMargin);
btVector3 localScaling;
localScaling.deSerializeFloat(bsd->m_localScaling);
shape->setLocalScaling(localScaling);
@@ -654,7 +670,9 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
compoundShape->addChildShape(localTransform,childShape);
} else
{
#ifdef _DEBUG
printf("error: couldn't create childShape for compoundShape\n");
#endif
}
}
@@ -668,7 +686,9 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
}
default:
{
#ifdef _DEBUG
printf("unsupported shape type (%d)\n",shapeData->m_shapeType);
#endif
}
}
@@ -827,6 +847,10 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
}
bool isDynamic = mass!=0.f;
btRigidBody* body = createRigidBody(isDynamic,mass,startTransform,shape,colObjData->m_collisionObjectData.m_name);
body->setFriction(colObjData->m_collisionObjectData.m_friction);
body->setRestitution(colObjData->m_collisionObjectData.m_restitution);
#ifdef USE_INTERNAL_EDGE_UTILITY
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
{
@@ -857,6 +881,8 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
startTransform.deSerializeDouble(colObjData->m_worldTransform);
btCollisionShape* shape = (btCollisionShape*)*shapePtr;
btCollisionObject* body = createCollisionObject(startTransform,shape,colObjData->m_name);
body->setFriction(colObjData->m_friction);
body->setRestitution(colObjData->m_restitution);
#ifdef USE_INTERNAL_EDGE_UTILITY
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)

View File

@@ -55,6 +55,10 @@ namespace bParse
};
///The btBulletWorldImporter is a starting point to import .bullet files.
///note that not all data is converted yet. You are expected to override or modify this class.
///See Bullet/Demos/SerializeDemo for a derived class that extract btSoftBody objects too.
class btBulletWorldImporter
{
protected:

View File

@@ -20,7 +20,7 @@ subject to the following restrictions:
#include "btSoftBodySolverVertexBuffer_DX11.h"
#include "BulletSoftBody/btSoftBody.h"
#include "BulletCollision/CollisionShapes/btCapsuleShape.h"
#include <stdio.h> //printf
#define MSTRINGIFY(A) #A
static char* PrepareLinksHLSLString =
#include "HLSL/PrepareLinks.hlsl"
@@ -2190,7 +2190,9 @@ void btDX11SoftBodySolver::processCollision( btSoftBody *softBody, btCollisionOb
m_collisionObjectDetails.push_back( newCollisionShapeDescription );
} else {
btAssert("Unsupported collision shape type\n");
#ifdef _DEBUG
printf("Unsupported collision shape type\n");
#endif
}
} else {
btAssert("Unknown soft body");

View File

@@ -1,9 +1,23 @@
MSTRINGIFY(
float mydot3(float4 a, float4 b)
//#pragma OPENCL EXTENSION cl_amd_printf:enable\n
float mydot3a(float4 a, float4 b)
{
return a.x*b.x + a.y*b.y + a.z*b.z;
}
float mylength3(float4 a)
{
a.w = 0;
return length(a);
}
float4 mynormalize3(float4 a)
{
a.w = 0;
return normalize(a);
}
typedef struct
{
@@ -37,8 +51,7 @@ typedef struct
// From btBroadphaseProxy.h
__constant int CAPSULE_SHAPE_PROXYTYPE = 10;
/* Multiply column-major matrix against vector */
// Multiply column-major matrix against vector
float4 matrixVectorMul( float4 matrix[4], float4 vector )
{
float4 returnVector;
@@ -66,7 +79,8 @@ SolveCollisionsAndUpdateVelocitiesKernel(
__global float4 * g_vertexForces,
__global float4 *g_vertexVelocities,
__global float4 *g_vertexPositions,
__local CollisionShapeDescription *localCollisionShapes)
__local CollisionShapeDescription *localCollisionShapes,
__global float * g_vertexInverseMasses)
{
int nodeID = get_global_id(0);
float4 forceOnVertex = (float4)(0.f, 0.f, 0.f, 0.f);
@@ -78,18 +92,20 @@ SolveCollisionsAndUpdateVelocitiesKernel(
return;
float4 position = (float4)(g_vertexPositions[nodeID].xyz, 1.f);
float4 previousPosition = (float4)(g_vertexPreviousPositions[nodeID].xyz, 1.f);
float4 position = (float4)(g_vertexPositions[nodeID].xyz, 0.f);
float4 previousPosition = (float4)(g_vertexPreviousPositions[nodeID].xyz, 0.f);
float clothFriction = g_perClothFriction[clothIdentifier];
float dampingFactor = g_clothDampingFactor[clothIdentifier];
float velocityCoefficient = (1.f - dampingFactor);
// Update velocity
float4 difference = position - previousPosition;
float4 velocity = difference*velocityCoefficient*isolverdt;
float inverseMass = g_vertexInverseMasses[nodeID];
CollisionObjectIndices collisionObjectIndices = g_perClothCollisionObjectIndices[clothIdentifier];
int numObjects = collisionObjectIndices.endObject - collisionObjectIndices.firstObject;
if( numObjects > 0 )
{
// We have some possible collisions to deal with
@@ -113,7 +129,7 @@ SolveCollisionsAndUpdateVelocitiesKernel(
// We have some possible collisions to deal with
for( int collision = 0; collision < numObjects; ++collision )
{
//CollisionShapeDescription shapeDescription = localCollisionShapes[collision];
CollisionShapeDescription shapeDescription = localCollisionShapes[collision];
float colliderFriction = localCollisionShapes[collision].friction;
if( localCollisionShapes[collision].collisionShapeType == CAPSULE_SHAPE_PROXYTYPE )
@@ -125,14 +141,14 @@ SolveCollisionsAndUpdateVelocitiesKernel(
float capsuleMargin = localCollisionShapes[collision].margin;
int capsuleupAxis = localCollisionShapes[collision].upAxis;
if ( capsuleHalfHeight <= 0 )
capsuleHalfHeight = 0.0001f;
float4 worldTransform[4];
worldTransform[0] = localCollisionShapes[collision].shapeTransform[0];
worldTransform[1] = localCollisionShapes[collision].shapeTransform[1];
worldTransform[2] = localCollisionShapes[collision].shapeTransform[2];
worldTransform[3] = localCollisionShapes[collision].shapeTransform[3];
//float4 c1 = (float4)(0.f, -capsuleHalfHeight, 0.f, 1.f);
//float4 c2 = (float4)(0.f, +capsuleHalfHeight, 0.f, 1.f);
// Correctly define capsule centerline vector
float4 c1 = (float4)(0.f, 0.f, 0.f, 1.f);
float4 c2 = (float4)(0.f, 0.f, 0.f, 1.f);
@@ -145,65 +161,72 @@ SolveCollisionsAndUpdateVelocitiesKernel(
float4 worldC1 = matrixVectorMul(worldTransform, c1);
float4 worldC2 = matrixVectorMul(worldTransform, c2);
float4 segment = (worldC2 - worldC1);
float4 segment = (float4)((worldC2 - worldC1).xyz, 0.f);
float4 segmentNormalized = mynormalize3(segment);
float distanceAlongSegment =mydot3a( (position - worldC1), segmentNormalized );
// compute distance of tangent to vertex along line segment in capsule
float distanceAlongSegment = -( mydot3( (worldC1 - position), segment ) / mydot3(segment, segment) );
float4 closestPoint = (worldC1 + (float4)(segment * distanceAlongSegment));
float distanceFromLine = length(position - closestPoint);
float distanceFromC1 = length(worldC1 - position);
float distanceFromC2 = length(worldC2 - position);
float4 closestPointOnSegment = (worldC1 + (float4)(segmentNormalized * distanceAlongSegment));
float distanceFromLine = mylength3(position - closestPointOnSegment);
float distanceFromC1 = mylength3(worldC1 - position);
float distanceFromC2 = mylength3(worldC2 - position);
// Final distance from collision, point to push from, direction to push in
// for impulse force
float dist;
float4 normalVector;
if( distanceAlongSegment < 0 )
{
dist = distanceFromC1;
normalVector = normalize(position - worldC1);
} else if( distanceAlongSegment > 1.f ) {
normalVector = (float4)(normalize(position - worldC1).xyz, 0.f);
} else if( distanceAlongSegment > length(segment) ) {
dist = distanceFromC2;
normalVector = normalize(position - worldC2);
normalVector = (float4)(normalize(position - worldC2).xyz, 0.f);
} else {
dist = distanceFromLine;
normalVector = normalize(position - closestPoint);
normalVector = (float4)(normalize(position - closestPointOnSegment).xyz, 0.f);
}
float4 colliderLinearVelocity = localCollisionShapes[collision].linearVelocity;
float4 colliderAngularVelocity = localCollisionShapes[collision].angularVelocity;
float4 velocityOfSurfacePoint = colliderLinearVelocity + cross(colliderAngularVelocity, position - (float4)(worldTransform[0].w, worldTransform[1].w, worldTransform[2].w, 0.f));
float minDistance = capsuleRadius + capsuleMargin;
float4 closestPointOnSurface = (float4)((position + (minDistance - dist) * normalVector).xyz, 0.f);
// In case of no collision, this is the value of velocity
velocity = (position - previousPosition) * velocityCoefficient * isolverdt;
float4 colliderLinearVelocity = shapeDescription.linearVelocity;
float4 colliderAngularVelocity = shapeDescription.angularVelocity;
float4 velocityOfSurfacePoint = colliderLinearVelocity + cross(colliderAngularVelocity, closestPointOnSurface - (float4)(worldTransform[0].w, worldTransform[1].w, worldTransform[2].w, 0.f));
// Check for a collision
if( dist < minDistance )
{
// Project back to surface along normal
position = position + (float4)((minDistance - dist)*normalVector*0.9f);
position = closestPointOnSurface;
velocity = (position - previousPosition) * velocityCoefficient * isolverdt;
float4 relativeVelocity = velocity - velocityOfSurfacePoint;
float4 p1 = (float4)(normalize(cross(normalVector, segment)).xyz, 0.f);
float4 p2 = (float4)(normalize(cross(p1, normalVector)).xyz, 0.f);
// Full friction is sum of velocities in each direction of plane
float4 frictionVector = p1*mydot3(relativeVelocity, p1) + p2*mydot3(relativeVelocity, p2);
float4 p1 = mynormalize3(cross(normalVector, segment));
float4 p2 = mynormalize3(cross(p1, normalVector));
// Real friction is peak friction corrected by friction coefficients
frictionVector = frictionVector * (colliderFriction*clothFriction);
float4 tangentialVel = p1*mydot3a(relativeVelocity, p1) + p2*mydot3a(relativeVelocity, p2);
float frictionCoef = (colliderFriction * clothFriction);
if (frictionCoef>1.f)
frictionCoef = 1.f;
float approachSpeed = dot(relativeVelocity, normalVector);
if( approachSpeed <= 0.0f )
forceOnVertex -= frictionVector;
//only apply friction if objects are not moving apart
float projVel = mydot3a(relativeVelocity,normalVector);
if ( projVel >= -0.001f)
{
if ( inverseMass > 0 )
{
//float4 myforceOnVertex = -tangentialVel * frictionCoef * isolverdt * (1.0f / inverseMass);
position += (-tangentialVel * frictionCoef) / (isolverdt);
}
}
// In case of no collision, this is the value of velocity
velocity = (position - previousPosition) * velocityCoefficient * isolverdt;
}
}
}
}

View File

@@ -739,7 +739,7 @@ void btOpenCLSoftBodySolver::optimize( btAlignedObjectArray< btSoftBody * > &sof
m_perClothDragFactor.push_back( softBody->m_cfg.kDG );
m_perClothMediumDensity.push_back(softBody->getWorldInfo()->air_density);
// Simple init values. Actually we'll put 0 and -1 into them at the appropriate time
m_perClothFriction.push_back( softBody->getFriction() );
m_perClothFriction.push_back(softBody->m_cfg.kDF);
m_perClothCollisionObjects.push_back( CollisionObjectIndices(-1, -1) );
// Add space for new vertices and triangles in the default solver for now
@@ -1737,7 +1737,9 @@ void btOpenCLSoftBodySolver::processCollision( btSoftBody *softBody, btCollision
}
else {
#ifdef _DEBUG
printf("Unsupported collision shape type\n");
#endif
//btAssert(0 && "Unsupported collision shape type\n");
}
} else {

View File

@@ -217,7 +217,7 @@ void btOpenCLSoftBodySolverSIMDAware::optimize( btAlignedObjectArray< btSoftBody
m_perClothDragFactor.push_back( softBody->m_cfg.kDG );
m_perClothMediumDensity.push_back(softBody->getWorldInfo()->air_density);
// Simple init values. Actually we'll put 0 and -1 into them at the appropriate time
m_perClothFriction.push_back( softBody->getFriction() );
m_perClothFriction.push_back(softBody->m_cfg.kDF);
m_perClothCollisionObjects.push_back( CollisionObjectIndices(-1, -1) );
// Add space for new vertices and triangles in the default solver for now
@@ -253,6 +253,10 @@ void btOpenCLSoftBodySolverSIMDAware::optimize( btAlignedObjectArray< btSoftBody
m_anchorIndex.push_back(-1.0);
}
for( int vertex = numVertices; vertex < maxVertices; ++vertex )
{
m_anchorIndex.push_back(-1.0);
}
// Copy triangles similarly
// We're assuming here that vertex indices are based on the firstVertex rather than the entire scene
@@ -524,6 +528,7 @@ void btOpenCLSoftBodySolverSIMDAware::solveCollisionsAndUpdateVelocities( float
ciErrNum = clSetKernelArg(m_solveCollisionsAndUpdateVelocitiesKernel, 9, sizeof(cl_mem),&m_vertexData.m_clVertexVelocity.m_buffer);
ciErrNum = clSetKernelArg(m_solveCollisionsAndUpdateVelocitiesKernel, 10, sizeof(cl_mem),&m_vertexData.m_clVertexPosition.m_buffer);
ciErrNum = clSetKernelArg(m_solveCollisionsAndUpdateVelocitiesKernel, 11, sizeof(CollisionShapeDescription)*16,0);
ciErrNum = clSetKernelArg(m_solveCollisionsAndUpdateVelocitiesKernel, 12, sizeof(cl_mem),&m_vertexData.m_clVertexInverseMass.m_buffer);
size_t numWorkItems = workGroupSize*((m_vertexData.getNumVertices() + (workGroupSize-1)) / workGroupSize);
if (numWorkItems)

View File

@@ -646,7 +646,9 @@ extern CL_API_ENTRY cl_int CL_API_CALL clGetContextInfo(cl_context /* co
return 0;
}
CL_API_ENTRY cl_context CL_API_CALL clCreateContextFromType(cl_context_properties * /* properties */,
CL_API_ENTRY cl_context CL_API_CALL clCreateContextFromType(const cl_context_properties * /* properties */,
cl_device_type device_type ,
void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */,
void * /* user_data */,
@@ -706,6 +708,28 @@ CL_API_ENTRY cl_context CL_API_CALL clCreateContextFromType(cl_context_propertie
return (cl_context)scheduler;
}
CL_API_ENTRY cl_int CL_API_CALL
clGetDeviceIDs(cl_platform_id /* platform */,
cl_device_type /* device_type */,
cl_uint /* num_entries */,
cl_device_id * /* devices */,
cl_uint * /* num_devices */) CL_API_SUFFIX__VERSION_1_0
{
return 0;
}
CL_API_ENTRY cl_context CL_API_CALL
clCreateContext(const cl_context_properties * properties ,
cl_uint num_devices ,
const cl_device_id * devices ,
void (*pfn_notify)(const char *, const void *, size_t, void *),
void * user_data ,
cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0
{
return clCreateContextFromType(properties,CL_DEVICE_TYPE_ALL,pfn_notify,user_data,errcode_ret);
}
CL_API_ENTRY cl_int CL_API_CALL clReleaseContext(cl_context context ) CL_API_SUFFIX__VERSION_1_0
{

View File

@@ -437,7 +437,7 @@ clGetDeviceInfo(cl_device_id /* device */,
// Context APIs
extern CL_API_ENTRY cl_context CL_API_CALL
clCreateContext(cl_context_properties * /* properties */,
clCreateContext(const cl_context_properties * /* properties */,
cl_uint /* num_devices */,
const cl_device_id * /* devices */,
void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */,
@@ -445,7 +445,7 @@ clCreateContext(cl_context_properties * /* properties */,
cl_int * /* errcode_ret */) CL_API_SUFFIX__VERSION_1_0;
extern CL_API_ENTRY cl_context CL_API_CALL
clCreateContextFromType(cl_context_properties * /* properties */,
clCreateContextFromType(const cl_context_properties * /* properties */,
cl_device_type /* device_type */,
void (*pfn_notify)(const char *, const void *, size_t, void *) /* pfn_notify */,
void * /* user_data */,