Add the GPU rigid body pipeline from https://github.com/erwincoumans/experiments as a Bullet 3.x preview for Bullet 2.80

This commit is contained in:
erwin.coumans
2012-03-05 00:54:32 +00:00
parent 73c4646b40
commit 571af41cf6
257 changed files with 55106 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
hasCL = findOpenCL_AMD()
if (hasCL) then
project "OpenCL_GL_interop_AMD"
initOpenCL_AMD()
language "C++"
kind "ConsoleApp"
targetdir "../../../bin"
initOpenGL()
initGlut()
initGlew()
includedirs {
"../../../rendering/BulletMath"
}
files {
"../main.cpp",
"../../basic_initialize/btOpenCLUtils.cpp",
"../../basic_initialize/btOpenCLUtils.h",
"../btOpenCLGLInteropBuffer.cpp",
"../btOpenCLGLInteropBuffer.h",
"../btStopwatch.cpp",
"../btStopwatch.h"
}
end

View File

@@ -0,0 +1,34 @@
hasCL = findOpenCL_Intel()
if (hasCL) then
project "OpenCL_GL_interop_Intel"
initOpenCL_Intel()
language "C++"
kind "ConsoleApp"
targetdir "../../../bin"
initOpenGL()
initGlut()
initGlew()
includedirs {
"../../../rendering/BulletMath"
}
files {
"../main.cpp",
"../../basic_initialize/btOpenCLUtils.cpp",
"../../basic_initialize/btOpenCLUtils.h",
"../btOpenCLGLInteropBuffer.cpp",
"../btOpenCLGLInteropBuffer.h",
"../btStopwatch.cpp",
"../btStopwatch.h"
}
end

View File

@@ -0,0 +1,34 @@
hasCL = findOpenCL_NVIDIA()
if (hasCL) then
project "OpenCL_GL_interop_NVIDIA"
initOpenCL_NVIDIA()
language "C++"
kind "ConsoleApp"
targetdir "../../../bin"
initOpenGL()
initGlut()
initGlew()
includedirs {
"../../../rendering/BulletMath"
}
files {
"../main.cpp",
"../../basic_initialize/btOpenCLUtils.cpp",
"../../basic_initialize/btOpenCLUtils.h",
"../btOpenCLGLInteropBuffer.cpp",
"../btOpenCLGLInteropBuffer.h",
"../btStopwatch.cpp",
"../btStopwatch.h"
}
end

View File

@@ -0,0 +1,60 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
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.
*/
///original author: Erwin Coumans
#include "btOpenCLGLInteropBuffer.h"
btOpenCLGLInteropBuffer::btOpenCLGLInteropBuffer(cl_context clContext, cl_command_queue commandQueue,GLuint openGLVBO)
:m_clContext(clContext),
m_commandQueue(commandQueue),
m_openGLVBO(openGLVBO)
{
cl_int ciErrNum = CL_SUCCESS;
// m_buffer = clCreateFromGLBuffer(m_clContext, CL_MEM_WRITE_ONLY, m_openGLVBO, &ciErrNum);
m_buffer = clCreateFromGLBuffer(m_clContext, CL_MEM_READ_WRITE, m_openGLVBO, &ciErrNum);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
}
btOpenCLGLInteropBuffer::~btOpenCLGLInteropBuffer()
{
cl_int ciErrNum = CL_SUCCESS;
clReleaseMemObject (m_buffer);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
}
void btOpenCLGLInteropBuffer::copyCL2GL()
{
cl_int ciErrNum = CL_SUCCESS;
ciErrNum = clEnqueueAcquireGLObjects(m_commandQueue, 1, &m_buffer, 0, 0, NULL);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
//do some stuff
ciErrNum = clEnqueueReleaseGLObjects(m_commandQueue, 1, &m_buffer, 0, 0, 0);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
//only wait if necessary
// clFinish(m_commandQueue);
}
void btOpenCLGLInteropBuffer::copyGL2CL()
{
}

View File

@@ -0,0 +1,49 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2011 Advanced Micro Devices, Inc. http://bulletphysics.org
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.
*/
///original author: Erwin Coumans
#ifndef BT_OPENCL_GL_INTEROP_BUFFER_H
#define BT_OPENCL_GL_INTEROP_BUFFER_H
#include "btGlutInclude.h"
#include "../basic_initialize/btOpenCLInclude.h"
class btOpenCLGLInteropBuffer
{
cl_context m_clContext;
cl_command_queue m_commandQueue;
cl_mem m_buffer;
GLuint m_openGLVBO;
public:
btOpenCLGLInteropBuffer(cl_context clContext, cl_command_queue commandQueue,GLuint openGLVBO);
virtual ~btOpenCLGLInteropBuffer();
void copyCL2GL();
void copyGL2CL();
cl_mem getCLBUffer()
{
return m_buffer;
}
};
#endif //BT_OPENCL_GL_INTEROP_BUFFER_H

View File

@@ -0,0 +1,182 @@
/*
Stopwatch for timing and profiling for the Bullet Physics Library, http://bulletphysics.org
Copyright (c) 2003-2011 Erwin Coumans
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 "btStopwatch.h"
#ifdef __CELLOS_LV2__
#include <sys/sys_time.h>
#include <sys/time_util.h>
#include <stdio.h>
#endif
#if defined (SUNOS) || defined (__SUNOS__)
#include <stdio.h>
#endif
#if defined(WIN32) || defined(_WIN32)
#define BT_USE_WINDOWS_TIMERS
#define WIN32_LEAN_AND_MEAN
#define NOWINRES
#define NOMCX
#define NOIME
#ifdef _XBOX
#include <Xtl.h>
#else //_XBOX
#include <windows.h>
#endif //_XBOX
#include <time.h>
#else //_WIN32
#include <sys/time.h>
#endif //_WIN32
#define mymin(a,b) (a > b ? a : b)
struct btStopwatchData
{
#ifdef BT_USE_WINDOWS_TIMERS
LARGE_INTEGER mClockFrequency;
DWORD mStartTick;
LONGLONG mPrevElapsedTime;
LARGE_INTEGER mStartTime;
#else
#ifdef __CELLOS_LV2__
uint64_t mStartTime;
#else
struct timeval mStartTime;
#endif
#endif //__CELLOS_LV2__
};
btStopwatch::btStopwatch()
{
m_data = new btStopwatchData;
#ifdef BT_USE_WINDOWS_TIMERS
QueryPerformanceFrequency(&m_data->mClockFrequency);
#endif
reset();
}
btStopwatch::~btStopwatch()
{
delete m_data;
}
btStopwatch::btStopwatch(const btStopwatch& other)
{
m_data = new btStopwatchData;
*m_data = *other.m_data;
}
btStopwatch& btStopwatch::operator=(const btStopwatch& other)
{
*m_data = *other.m_data;
return *this;
}
/// Resets the initial reference time.
void btStopwatch::reset()
{
#ifdef BT_USE_WINDOWS_TIMERS
QueryPerformanceCounter(&m_data->mStartTime);
m_data->mStartTick = GetTickCount();
m_data->mPrevElapsedTime = 0;
#else
#ifdef __CELLOS_LV2__
typedef uint64_t ClockSize;
ClockSize newTime;
//__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory");
SYS_TIMEBASE_GET( newTime );
m_data->mStartTime = newTime;
#else
gettimeofday(&m_data->mStartTime, 0);
#endif
#endif
}
/// Returns the time in ms since the last call to reset or since
/// the btStopwatch was created.
float btStopwatch::getTimeMilliseconds()
{
return getTimeMicroseconds()/1000.f;
}
/// Returns the time in us since the last call to reset or since
/// the stopwatch was created.
unsigned long int btStopwatch::getTimeMicroseconds()
{
#ifdef BT_USE_WINDOWS_TIMERS
LARGE_INTEGER currentTime;
QueryPerformanceCounter(&currentTime);
LONGLONG elapsedTime = currentTime.QuadPart - m_data->mStartTime.QuadPart;
// Compute the number of millisecond ticks elapsed.
unsigned long msecTicks = (unsigned long)(1000 * elapsedTime / m_data->mClockFrequency.QuadPart);
// Check for unexpected leaps in the Win32 performance counter.
// (This is caused by unexpected data across the PCI to ISA
// bridge, aka south bridge. See Microsoft KB274323.)
unsigned long elapsedTicks = GetTickCount() - m_data->mStartTick;
signed long msecOff = (signed long)(msecTicks - elapsedTicks);
if (msecOff < -100 || msecOff > 100)
{
// Adjust the starting time forwards.
LONGLONG msecAdjustment = mymin(msecOff *
m_data->mClockFrequency.QuadPart / 1000, elapsedTime -
m_data->mPrevElapsedTime);
m_data->mStartTime.QuadPart += msecAdjustment;
elapsedTime -= msecAdjustment;
}
// Store the current elapsed time for adjustments next time.
m_data->mPrevElapsedTime = elapsedTime;
// Convert to microseconds.
unsigned long usecTicks = (unsigned long)(1000000 * elapsedTime /
m_data->mClockFrequency.QuadPart);
return usecTicks;
#else
#ifdef __CELLOS_LV2__
uint64_t freq=sys_time_get_timebase_frequency();
double dFreq=((double) freq)/ 1000000.0;
typedef uint64_t ClockSize;
ClockSize newTime;
//__asm __volatile__( "mftb %0" : "=r" (newTime) : : "memory");
SYS_TIMEBASE_GET( newTime );
return (unsigned long int)((double(newTime-m_data->mStartTime)) / dFreq);
#else
struct timeval currentTime;
gettimeofday(&currentTime, 0);
return (currentTime.tv_sec - m_data->mStartTime.tv_sec) * 1000000 + (currentTime.tv_usec - m_data->mStartTime.tv_usec);
#endif//__CELLOS_LV2__
#endif
}

View File

@@ -0,0 +1,45 @@
/*
Stopwatch for timing and profiling for the Bullet Physics Library, http://bulletphysics.org
Copyright (c) 2003-2011 Erwin Coumans
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.
*/
#ifndef BT_STOPWATCH_H
#define BT_STOPWATCH_H
///The btStopwatch is a portable basic clock that measures real-time, use for profiling etc.
class btStopwatch
{
public:
btStopwatch();
btStopwatch(const btStopwatch& other);
btStopwatch& operator=(const btStopwatch& other);
~btStopwatch();
/// Resets the initial reference time.
void reset();
/// Returns the time in ms since the last call to reset or since
/// the btStopwatch was created.
float getTimeMilliseconds();
/// Returns the time in us since the last call to reset or since
/// the Clock was created.
unsigned long int getTimeMicroseconds();
private:
struct btStopwatchData* m_data;
};
#endif //BT_STOPWATCH_H

View File

@@ -0,0 +1,13 @@
MSTRINGIFY(
__kernel void
interopKernel( const int startOffset, const int numNodes, __global float *g_vertexBuffer)
{
int nodeID = get_global_id(0);
if( nodeID < numNodes )
{
g_vertexBuffer[nodeID*4 + startOffset+1] += 0.01;
}
}
);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
include "AMD"
include "Intel"
-- include "NVIDIA"