fixes to make the OpenCL cloth demo run on Apple/GPU
This commit is contained in:
@@ -16,7 +16,6 @@ subject to the following restrictions:
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
#endif
|
#endif
|
||||||
#ifndef __APPLE__
|
|
||||||
|
|
||||||
#ifndef USE_MINICL
|
#ifndef USE_MINICL
|
||||||
#define USE_SIMDAWARE_SOLVER
|
#define USE_SIMDAWARE_SOLVER
|
||||||
@@ -25,7 +24,6 @@ subject to the following restrictions:
|
|||||||
#define USE_GPU_COPY //only tested on Windows, may work under Linux
|
#define USE_GPU_COPY //only tested on Windows, may work under Linux
|
||||||
#endif //_WIN32
|
#endif //_WIN32
|
||||||
#endif //USE_MINICL
|
#endif //USE_MINICL
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,24 +32,38 @@ void initCL( void* glCtx, void* glDC )
|
|||||||
int ciErrNum = 0;
|
int ciErrNum = 0;
|
||||||
|
|
||||||
#if defined(CL_PLATFORM_MINI_CL)
|
#if defined(CL_PLATFORM_MINI_CL)
|
||||||
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;
|
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;//or use CL_DEVICE_TYPE_DEBUG to debug MiniCL
|
||||||
#elif defined(CL_PLATFORM_AMD)
|
#elif defined(CL_PLATFORM_AMD)
|
||||||
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
|
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
|
||||||
#elif defined(CL_PLATFORM_NVIDIA)
|
#elif defined(CL_PLATFORM_NVIDIA)
|
||||||
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
|
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
|
||||||
#else
|
#else
|
||||||
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;
|
#ifdef __APPLE__
|
||||||
|
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
|
||||||
|
#else
|
||||||
|
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;//CL_DEVICE_TYPE_ALL
|
||||||
|
#endif//__APPLE__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//g_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_ALL, &ciErrNum);
|
|
||||||
//g_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_GPU, &ciErrNum);
|
|
||||||
//g_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_CPU, &ciErrNum);
|
|
||||||
//try CL_DEVICE_TYPE_DEBUG for sequential, non-threaded execution, when using MiniCL on CPU, it gives a full callstack at the crash in the kernel
|
|
||||||
//#ifdef USE_MINICL
|
|
||||||
// g_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_DEBUG, &ciErrNum);
|
|
||||||
//#else
|
|
||||||
g_cxMainContext = btOclCommon::createContextFromType(deviceType, &ciErrNum, glCtx, glDC);
|
g_cxMainContext = btOclCommon::createContextFromType(deviceType, &ciErrNum, glCtx, glDC);
|
||||||
//#endif
|
|
||||||
|
switch (deviceType)
|
||||||
|
{
|
||||||
|
case CL_DEVICE_TYPE_GPU:
|
||||||
|
printf("createContextFromType(CL_DEVICE_TYPE_GPU)\n");
|
||||||
|
break;
|
||||||
|
case CL_DEVICE_TYPE_CPU:
|
||||||
|
printf("createContextFromType(CL_DEVICE_TYPE_CPU)\n");
|
||||||
|
break;
|
||||||
|
case CL_DEVICE_TYPE_ALL:
|
||||||
|
printf("createContextFromType(CL_DEVICE_TYPE_ALL)\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("createContextFromType(unknown device type %d\n",deviceType);
|
||||||
|
};
|
||||||
|
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,9 @@ static char* spPlatformVendor =
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CL_PLATFORM_MINI_CL
|
#ifndef CL_PLATFORM_MINI_CL
|
||||||
|
#ifdef _WIN32
|
||||||
#include "CL/cl_gl.h"
|
#include "CL/cl_gl.h"
|
||||||
|
#endif //_WIN32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cl_context btOclCommon::createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC )
|
cl_context btOclCommon::createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC )
|
||||||
@@ -88,6 +90,7 @@ cl_context btOclCommon::createContextFromType(cl_device_type deviceType, cl_int*
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
#ifndef CL_PLATFORM_MINI_CL
|
#ifndef CL_PLATFORM_MINI_CL
|
||||||
|
#ifdef _WIN32
|
||||||
// If we have a gl context then enable interop
|
// If we have a gl context then enable interop
|
||||||
if( pGLContext )
|
if( pGLContext )
|
||||||
{
|
{
|
||||||
@@ -96,6 +99,7 @@ cl_context btOclCommon::createContextFromType(cl_device_type deviceType, cl_int*
|
|||||||
cps[4] = CL_WGL_HDC_KHR;
|
cps[4] = CL_WGL_HDC_KHR;
|
||||||
cps[5] = (cl_context_properties)pGLDC;
|
cps[5] = (cl_context_properties)pGLDC;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif //CL_PLATFORM_MINI_CL
|
#endif //CL_PLATFORM_MINI_CL
|
||||||
|
|
||||||
/* Use NULL for backward compatibility */
|
/* Use NULL for backward compatibility */
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
|||||||
#ifdef USE_MINICL
|
#ifdef USE_MINICL
|
||||||
#include <MiniCL/cl.h>
|
#include <MiniCL/cl.h>
|
||||||
#else
|
#else
|
||||||
#include <MiniCL/cl.h>
|
#include <OpenCL/cl.h>
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#ifdef USE_MINICL
|
#ifdef USE_MINICL
|
||||||
|
|||||||
@@ -1601,7 +1601,7 @@ void btOpenCLSoftBodySolver::processCollision( btSoftBody *softBody, btCollision
|
|||||||
m_collisionObjectDetails.push_back( newCollisionShapeDescription );
|
m_collisionObjectDetails.push_back( newCollisionShapeDescription );
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
btAssert("Unsupported collision shape type\n");
|
btAssert(0 && "Unsupported collision shape type\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
btAssert("Unknown soft body");
|
btAssert("Unknown soft body");
|
||||||
|
|||||||
Reference in New Issue
Block a user