fix issue with btDbvt::collideOCL, related to memmove (needs further testing)

only enable OpenCL demo if flag --enable_experimental_opencl is passed to ExampleBrowser
This commit is contained in:
Erwin Coumans
2015-05-02 22:33:33 -07:00
parent 37c788841a
commit 7a0288bf56
6 changed files with 49 additions and 22 deletions

View File

@@ -25,10 +25,13 @@ Bullet Physics is a professional open source collision detection, rigid body and
\subsection{New in Bullet 2.83}
\begin{itemize}
\item New ExampleBrowser, replacing the standalone demos. See \path{examples/ExampleBrowser}.
\item Import of Universal Robot Description Files (URDF). See \path{examples/Importers/ImportURDFDemo}.
\item New ExampleBrowser, replacing the standalone demos. Not all demos have been ported over yet, it will happen in upcoming releases. It is recommended to use an OpenGL 3+ system, although there is limited OpenGL 2 fallback. See \path{examples/ExampleBrowser}.
\item Import of Universal Robot Description Files (URDF). See \path{examples/Importers/ImportURDFDemo}. You can use File-Open in the ExampleBrowser.
\item Improved support for btMultiBody with multi-degree of freedom mobilizers, thanks to Jakub Stepien. See \path{examples/MultiBody/MultiDofDemo}.
\item New btGeneric6DofSpring2Constraint, replacing the old generic 6dof constraint, thanks to Gabor PUHR and Tamas Umenhoffer. See \path{examples/Dof6Spring2Setup}
\item OpenCL demo integrated in the ExampleBrowser. The demo is disabled by default, because it only works on high-end desktop GPU systems with compatible up-to-date OpenCL 1.1+ driver. Use $--enable\_experimental\_opencl$ command-line argument in the ExampleBrowser.
\end{itemize}
\subsection{New in Bullet 2.82}
\begin{itemize}

View File

@@ -63,18 +63,22 @@ static ExampleEntry gDefaultExamples[]=
ExampleEntry(0,"API"),
ExampleEntry(1,"Basic Example","Create some rigid bodies using box collision shapes. This is a good example to familiarize with the basic initialization of Bullet. The Basic Example can also be compiled without graphical user interface, as a console application.", BasicExampleCreateFunc),
ExampleEntry(1,"Basic Example","Create some rigid bodies using box collision shapes. This is a good example to familiarize with the basic initialization of Bullet. The Basic Example can also be compiled without graphical user interface, as a console application. Press W for wireframe, A to show AABBs, I to suspend/restart physics simulation. ", BasicExampleCreateFunc),
ExampleEntry(1,"Constraints","Show the use of the various constraints in Bullet. Press the L key to visualize the constraint limits. Press the C key to visualize the constraint frames.",
AllConstraintCreateFunc),
ExampleEntry(1,"Motorized Hinge","Use of a btHingeConstraint. You can adjust the first slider to change the target velocity, and the second slider to adjust the maximum impulse applied to reach the target velocity. Note that the hinge angle can reach beyond -360 and 360 degrees.", ConstraintCreateFunc),
// ExampleEntry(0,"What's new in 2.83"),
ExampleEntry(1,"6DofSpring2","Show the use of the btGeneric6DofSpring2Constraint. This is a replacement of the btGeneric6DofSpringConstraint, it has various improvements. This includes improved spring implementation and better control over the restitution (bounce) when the constraint hits its limits.",
Dof6Spring2CreateFunc),
ExampleEntry(1,"Gyroscopic", "Show the Dzhanibekov effect using various settings of the gyroscopic term. You can select the gyroscopic term computation using btRigidBody::setFlags, with arguments BT_ENABLE_GYROSCOPIC_FORCE_EXPLICIT (using explicit integration, which adds energy and can lead to explosions), BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_WORLD, BT_ENABLE_GYROSCOPIC_FORCE_IMPLICIT_BODY. If you don't set any of these flags, there is no gyroscopic term used.", GyroscopicCreateFunc),
ExampleEntry(1,"Planar 2D","Show the use of 2D collision shapes and rigid body simulation. The collision shape is wrapped into a btConvex2dShape. The rigid bodies are restricted in a plane using the 'setAngularFactor' and 'setLinearFactor' API call.",Planar2DCreateFunc),
ExampleEntry(1,"6DofSpring2","Show the use of the btGeneric6DofSpring2Constraint.",
Dof6Spring2CreateFunc),
ExampleEntry(1,"Constraints","Show the use of the various constraints in Bullet.",
AllConstraintCreateFunc),
ExampleEntry(1,"Motorized Hinge","Use of a btHingeConstraint. You can adjust the first slider to change the target velocity, and the second slider to adjust the maximum impulse applied to reach the target velocity. Note that the hinge angle can reach beyond -360 and 360 degrees.", ConstraintCreateFunc),
ExampleEntry(0,"MultiBody"),
ExampleEntry(1,"MultiDofCreateFunc","Create a basic btMultiBody with 3-DOF spherical joints (mobilizers). The demo uses a fixed base or a floating base at restart.", MultiDofCreateFunc),
@@ -168,6 +172,8 @@ static ExampleEntry gDefaultExamples[]=
ExampleEntry(1,"Voronoi Fracture", "Automatically create a compound rigid body using voronoi tesselation. Individual parts are modeled as rigid bodies using a btConvexHullShape.",
VoronoiFractureCreateFunc),
ExampleEntry(1,"Planar 2D","Show the use of 2D collision shapes and rigid body simulation. The collision shape is wrapped into a btConvex2dShape. The rigid bodies are restricted in a plane using the 'setAngularFactor' and 'setLinearFactor' API call.",Planar2DCreateFunc),
ExampleEntry(1,"Implicit Cloth", "Cloth simulation using implicit integration, by Stan Melax. The cloth is only attached at the corners. Note the stability using a large time step even with high stiffness.",
ImplicitClothCreateFunc),

View File

@@ -73,9 +73,9 @@ extern bool gDisableDeactivation;
int gPreferredOpenCLDeviceIndex=-1;
int gPreferredOpenCLPlatformIndex=-1;
int gGpuArraySizeX=25;
int gGpuArraySizeY=25;
int gGpuArraySizeZ=25;
int gGpuArraySizeX=15;
int gGpuArraySizeY=15;
int gGpuArraySizeZ=15;
//#include <float.h>
//unsigned int fp_control_state = _controlfp(_EM_INEXACT, _MCW_EM);
@@ -375,13 +375,15 @@ void MyStatusBarPrintf(const char* msg)
}
void MyStatusBarWarning(const char* msg)
void MyStatusBarError(const char* msg)
{
printf("Warning: %s\n", msg);
if (gui)
{
bool isLeft = false;
gui->setStatusBarMessage(msg,isLeft);
gui->textOutput(msg);
gui->forceUpdateScrollBars();
}
}
@@ -583,6 +585,17 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
{
b3CommandLineArgs args(argc,argv);
///The OpenCL rigid body pipeline is experimental and
///most OpenCL drivers and OpenCL compilers have issues with our kernels.
///If you have a high-end desktop GPU such as AMD 7970 or better, or NVIDIA GTX 680 with up-to-date drivers
///you could give it a try
if (args.CheckCmdLineFlag("enable_experimental_opencl"))
{
gAllExamples->initOpenCLExampleEntries();
}
int width = 1024;
int height=768;
@@ -599,7 +612,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
if (sUseOpenGL2 )
{
char title[1024];
sprintf(title,"%s using OpenGL2 fallback. %s", appTitle,optMode);
sprintf(title,"%s using limited OpenGL2 fallback. %s", appTitle,optMode);
s_app = new SimpleOpenGL2App(title,width,height);
s_app->m_renderer = new SimpleOpenGL2Renderer(width,height);
} else
@@ -630,9 +643,9 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
s_app->m_renderer->getActiveCamera()->setCameraPitch(0);
s_app->m_renderer->getActiveCamera()->setCameraTargetPosition(0,0,0);
b3SetCustomWarningMessageFunc(MyStatusBarWarning);
//b3SetCustomPrintfFunc(MyStatusBarPrintf);
b3SetCustomWarningMessageFunc(MyGuiPrintf);
b3SetCustomPrintfFunc(MyGuiPrintf);
b3SetCustomErrorMessageFunc(MyStatusBarError);
assert(glGetError()==GL_NO_ERROR);

View File

@@ -20,7 +20,6 @@ int main(int argc, char* argv[])
ExampleEntries examples;
examples.initExampleEntries();
examples.initOpenCLExampleEntries();
ExampleBrowserInterface* exampleBrowser = new DefaultBrowser(&examples);
bool init = exampleBrowser->init(argc,argv);

View File

@@ -822,7 +822,7 @@ void MacOpenGLWindow::startRendering()
uint32 virtualKeycode = [event keyCode];
int keycode = getAsciiCodeFromVirtualKeycode(virtualKeycode);
printf("keycode = %d\n", keycode);
// printf("keycode = %d\n", keycode);
if (m_keyboardCallback)
{
@@ -839,7 +839,7 @@ void MacOpenGLWindow::startRendering()
uint32 virtualKeycode = [event keyCode];
int keycode = getAsciiCodeFromVirtualKeycode(virtualKeycode);
printf("keycode = %d\n", keycode);
//printf("keycode = %d\n", keycode);
if (m_keyboardCallback)
{

View File

@@ -1193,17 +1193,23 @@ inline void btDbvt::collideOCL( const btDbvtNode* root,
/* Insert 0 */
j=nearest(&stack[0],&stock[0],nes[q].value,0,stack.size());
stack.push_back(0);
//void * memmove ( void * destination, const void * source, size_t num );
#if DBVT_USE_MEMMOVE
memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
memmove(&stack[j],&stack[j-1],sizeof(int)*(stack.size()-j-1));
#else
for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
for(int k=stack.size()-1;k>j;--k)
{
stack[k]=stack[k-1];
}
#endif
stack[j]=allocate(ifree,stock,nes[q]);
/* Insert 1 */
j=nearest(&stack[0],&stock[0],nes[1-q].value,j,stack.size());
stack.push_back(0);
#if DBVT_USE_MEMMOVE
memmove(&stack[j+1],&stack[j],sizeof(int)*(stack.size()-j-1));
memmove(&stack[j],&stack[j-1],sizeof(int)*(stack.size()-j-1));
#else
for(int k=stack.size()-1;k>j;--k) stack[k]=stack[k-1];
#endif