create premake4 solutions for the various OpenCL configurations (AMD, NVIDIA, Intel OpenCL SDKs for Windows)

primarily to distribute project files that work.
CMake is still better supported in general (not all demos/libs have been ported)

Revert a recent change about warnings: %zu doesn't work in printf, %d does
This commit is contained in:
erwin.coumans
2011-09-16 01:28:34 +00:00
parent ce62d7615e
commit bb29d15058
15 changed files with 467 additions and 37 deletions

View File

@@ -0,0 +1,65 @@
hasCL = findOpenCL_AMD()
if (hasCL) then
project "AppOpenCLClothDemo_AMD"
defines { "USE_AMD_OPENCL","CL_PLATFORM_AMD"}
initOpenCL_AMD()
language "C++"
kind "ConsoleApp"
targetdir "../../.."
libdirs {"../../../Glut"}
links {
"LinearMath",
"BulletCollision",
"BulletDynamics",
"BulletSoftBody",
"BulletSoftBodySolvers_OpenCL_AMD",
"opengl32"
}
configuration "x64"
links {
"glut64",
"glew64"
}
configuration "x32"
links {
"glut32",
"glew32"
}
configuration{}
includedirs {
"../../../src",
"../../../Glut",
"../../SharedOpenCL",
"../../OpenGL"
}
files {
"../cl_cloth_demo.cpp",
"../../SharedOpenCL/btOclUtils.h",
"../../SharedOpenCL/btOclCommon.h",
"../../SharedOpenCL/btOclUtils.cpp",
"../../SharedOpenCL/btOclCommon.cpp",
"../../OpenGL/GLDebugDrawer.cpp",
"../../OpenGL/stb_image.cpp",
"../../OpenGL/stb_image.h",
"../gl_win.cpp",
"../clstuff.cpp",
"../clstuff.h",
"../gl_win.h",
"../cloth.h"
}
end

View File

@@ -0,0 +1,65 @@
hasCL = findOpenCL_Intel()
if (hasCL) then
project "AppOpenCLClothDemo_Intel"
defines { "USE_INTEL_OPENCL","CL_PLATFORM_INTEL"}
initOpenCL_Intel()
language "C++"
kind "ConsoleApp"
targetdir "../../.."
libdirs {"../../../Glut"}
links {
"LinearMath",
"BulletCollision",
"BulletDynamics",
"BulletSoftBody",
"BulletSoftBodySolvers_OpenCL_Intel",
"opengl32"
}
configuration "x64"
links {
"glut64",
"glew64"
}
configuration "x32"
links {
"glut32",
"glew32"
}
configuration{}
includedirs {
"../../../src",
"../../../Glut",
"../../SharedOpenCL",
"../../OpenGL"
}
files {
"../cl_cloth_demo.cpp",
"../../SharedOpenCL/btOclUtils.h",
"../../SharedOpenCL/btOclCommon.h",
"../../SharedOpenCL/btOclUtils.cpp",
"../../SharedOpenCL/btOclCommon.cpp",
"../../OpenGL/GLDebugDrawer.cpp",
"../../OpenGL/stb_image.cpp",
"../../OpenGL/stb_image.h",
"../gl_win.cpp",
"../clstuff.cpp",
"../clstuff.h",
"../gl_win.h",
"../cloth.h"
}
end

View File

@@ -0,0 +1,65 @@
hasCL = findOpenCL_NVIDIA()
if (hasCL) then
project "AppOpenCLClothDemo_NVIDIA"
defines { "USE_NVIDIA_OPENCL","CL_PLATFORM_NVIDIA"}
initOpenCL_NVIDIA()
language "C++"
kind "ConsoleApp"
targetdir "../../.."
libdirs {"../../../Glut"}
links {
"LinearMath",
"BulletCollision",
"BulletDynamics",
"BulletSoftBody",
"BulletSoftBodySolvers_OpenCL_NVIDIA",
"opengl32"
}
configuration "x64"
links {
"glut64",
"glew64"
}
configuration "x32"
links {
"glut32",
"glew32"
}
configuration{}
includedirs {
"../../../src",
"../../../Glut",
"../../SharedOpenCL",
"../../OpenGL"
}
files {
"../cl_cloth_demo.cpp",
"../../SharedOpenCL/btOclUtils.h",
"../../SharedOpenCL/btOclCommon.h",
"../../SharedOpenCL/btOclUtils.cpp",
"../../SharedOpenCL/btOclCommon.cpp",
"../../OpenGL/GLDebugDrawer.cpp",
"../../OpenGL/stb_image.cpp",
"../../OpenGL/stb_image.h",
"../gl_win.cpp",
"../clstuff.cpp",
"../clstuff.h",
"../gl_win.h",
"../cloth.h"
}
end

View File

@@ -528,12 +528,12 @@ void doFlags()
{
m_dynamicsWorld->stepSimulation(1./60.,0);
btDefaultSerializer* serializer = new btDefaultSerializer();
m_dynamicsWorld->serialize(serializer);
FILE* file = fopen("testFile.bullet","wb");
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
fclose(file);
// Option to save a .bullet file
// btDefaultSerializer* serializer = new btDefaultSerializer();
// m_dynamicsWorld->serialize(serializer);
// FILE* file = fopen("testFile.bullet","wb");
// fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
// fclose(file);
CProfileManager::dumpAll();
}

View File

@@ -137,8 +137,12 @@ class piece_of_cloth
{
int width,height,n;
unsigned char *data = stbi_load(filename.c_str(), &width, &height, &n, 0);
if (!data)
{
//premake project happens to be 2 levels above the root of Bullet, so try this instead:
std::string newname = "../../"+filename;
data = stbi_load(newname.c_str(), &width, &height, &n, 0);
}
GLubyte* image=new GLubyte[512*256*4];
for(int y=0;y<256;++y)

View File

@@ -255,17 +255,17 @@ void btOclPrintDevInfo(cl_device_id device)
// CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
size_t workitem_dims;
clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(workitem_dims), &workitem_dims, NULL);
printf(" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%zu\n", workitem_dims);
printf(" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%d\n", workitem_dims);
// CL_DEVICE_MAX_WORK_ITEM_SIZES
size_t workitem_size[3];
clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(workitem_size), &workitem_size, NULL);
printf(" CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%zu / %zu / %zu \n", workitem_size[0], workitem_size[1], workitem_size[2]);
printf(" CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%d / %d / %d \n", workitem_size[0], workitem_size[1], workitem_size[2]);
// CL_DEVICE_MAX_WORK_GROUP_SIZE
size_t workgroup_size;
clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(workgroup_size), &workgroup_size, NULL);
printf(" CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%zu\n", workgroup_size);
printf(" CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%d\n", workgroup_size);
// CL_DEVICE_MAX_CLOCK_FREQUENCY
cl_uint clock_frequency;
@@ -332,15 +332,15 @@ void btOclPrintDevInfo(cl_device_id device)
size_t szMaxDims[5];
printf("\n CL_DEVICE_IMAGE <dim>");
clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof(size_t), &szMaxDims[0], NULL);
printf("\t\t\t2D_MAX_WIDTH\t %zu\n", szMaxDims[0]);
printf("\t\t\t2D_MAX_WIDTH\t %d\n", szMaxDims[0]);
clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof(size_t), &szMaxDims[1], NULL);
printf("\t\t\t\t\t2D_MAX_HEIGHT\t %zu\n", szMaxDims[1]);
printf("\t\t\t\t\t2D_MAX_HEIGHT\t %d\n", szMaxDims[1]);
clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof(size_t), &szMaxDims[2], NULL);
printf("\t\t\t\t\t3D_MAX_WIDTH\t %zu\n", szMaxDims[2]);
printf("\t\t\t\t\t3D_MAX_WIDTH\t %d\n", szMaxDims[2]);
clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof(size_t), &szMaxDims[3], NULL);
printf("\t\t\t\t\t3D_MAX_HEIGHT\t %zu\n", szMaxDims[3]);
printf("\t\t\t\t\t3D_MAX_HEIGHT\t %d\n", szMaxDims[3]);
clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof(size_t), &szMaxDims[4], NULL);
printf("\t\t\t\t\t3D_MAX_DEPTH\t %zu\n", szMaxDims[4]);
printf("\t\t\t\t\t3D_MAX_DEPTH\t %d\n", szMaxDims[4]);
// CL_DEVICE_EXTENSIONS: get device extensions, and if any then parse & log the string onto separate lines
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, sizeof(device_string), &device_string, NULL);

View File

@@ -18,7 +18,7 @@ function createDemos( demos, incdirs, linknames)
files { "../msvc/bullet.rc" }
configuration {"MaxOSX"}
print "hello"
--print "hello"
linkoptions { "-framework Carbon -framework OpenGL -framework AGL -framework Glut" }
configuration {"not Windows", "not MacOSX"}

View File

@@ -1,4 +1,5 @@
--add the 0 so the solution comes first in the directory (when sorted on name)
--print "uncomment this hello premake4 world for debugging the script"
solution "0BulletSolution"
@@ -17,6 +18,25 @@ solution "0BulletSolution"
description = "Enable DirectX11 build"
}
newoption {
trigger = "with-opencl",
description = "Enable OpenCL builds (various SDKs)"
}
newoption {
trigger = "with-opencl-amd",
description = "Enable OpenCL builds (AMD SDK)"
}
newoption {
trigger = "with-opencl-intel",
description = "Enable OpenCL builds (Intel SDK)"
}
newoption {
trigger = "with-opencl-nvidia",
description = "Enable OpenCL builds (NVIDIA SDK)"
}
configurations {"Release", "Debug"}
configuration "Release"
@@ -63,9 +83,39 @@ end
include "../src/BulletMultiThreaded/GpuSoftBodySolvers/DX11"
end
--choose any OpenCL sdk that is installed on the system
if _OPTIONS["with-opencl"] then
include "../Demos/OpenCLClothDemo/AMD"
include "../src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/AMD"
include "../Demos/OpenCLClothDemo/NVidia"
include "../src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/NVidia"
include "../Demos/OpenCLClothDemo/Intel"
include "../src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Intel"
end
--choose a particular OpenCL sdk, this is useful for distributing project files that just work for one OpenCL SDK
if _OPTIONS["with-opencl-amd"] then
include "../Demos/OpenCLClothDemo/AMD"
include "../src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/AMD"
end
if not _OPTIONS["with-dx11"] and not _OPTIONS["with-nacl"] then
if _OPTIONS["with-opencl-intel"] then
include "../Demos/OpenCLClothDemo/Intel"
include "../src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/Intel"
end
if _OPTIONS["with-opencl-nvidia"] then
include "../Demos/OpenCLClothDemo/NVidia"
include "../src/BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/NVidia"
end
if not _OPTIONS["with-opencl-amd"] and
not _OPTIONS["with-opencl-nvidia"] and
not _OPTIONS["with-opencl-intel"] and
not _OPTIONS["with-opencl"] and
not _OPTIONS["with-dx11"] and
not _OPTIONS["with-nacl"] then
include "../Demos"
include "../Extras"
end

View File

@@ -1,4 +1,5 @@
premake4 --with-dx11 vs2008
rename vs2008 vs2008_dx11
pause

36
msvc/vs_all.bat Normal file
View File

@@ -0,0 +1,36 @@
rem this script is mainly to create distributable visual studio project file
premake4 --with-opencl-nvidia vs2008
rename vs2008 vs2008_opencl_nvidia
premake4 --with-opencl-intel vs2008
rename vs2008 vs2008_opencl_intel
premake4 --with-opencl-amd vs2008
rename vs2008 vs2008_opencl_amd
premake4 --with-opencl-nvidia vs2010
rename vs2010 vs2010_opencl_nvidia
premake4 --with-opencl-intel vs2010
rename vs2010 vs2010_opencl_intel
premake4 --with-opencl-amd vs2010
rename vs2010 vs2010_opencl_amd
premake4 --with-dx11 vs2008
rename vs2008 vs2008_dx11
premake4 --with-dx11 vs2010
rename vs2010 vs2010_dx11
premake4 --with-dx11 vs2005
rename vs2005 vs2005_dx11
premake4 vs2005
premake4 vs2008
premake4 vs2010
pause

View File

@@ -28,25 +28,6 @@ SET(BulletSoftBodyOpenCLSolvers_HDRS
../btSoftBodySolverOutputCLtoGL.h
)
# OpenCL and HLSL Shaders.
# Build rules generated to stringify these into headers
# which are needed by some of the sources
SET(BulletSoftBodyOpenCLSolvers_Shaders
# OutputToVertexArray
UpdateNormals
Integrate
UpdatePositions
UpdateNodes
SolvePositions
UpdatePositionsFromVelocities
ApplyForces
PrepareLinks
VSolveLinks
)
foreach(f ${BulletSoftBodyOpenCLSolvers_Shaders})
LIST(APPEND BulletSoftBodyOpenCLSolvers_OpenCLC "../OpenCLC/${f}.cl")
endforeach(f)

View File

@@ -0,0 +1,27 @@
hasCL = findOpenCL_AMD()
if (hasCL) then
project "BulletSoftBodySolvers_OpenCL_AMD"
defines { "USE_AMD_OPENCL","CL_PLATFORM_AMD"}
initOpenCL_AMD()
kind "StaticLib"
targetdir "../../../../../lib"
includedirs {
".",
"../../../..",
"../../../../../Glut"
}
files {
"../btSoftBodySolver_OpenCL.cpp",
"../btSoftBodySolver_OpenCLSIMDAware.cpp",
"../btSoftBodySolverOutputCLtoGL.cpp"
}
end

View File

@@ -0,0 +1,82 @@
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${INTEL_OPENCL_INCLUDES}
)
ADD_DEFINITIONS(-DUSE_INTEL_OPENCL)
ADD_DEFINITIONS(-DCL_PLATFORM_INTEL)
SET(BulletSoftBodyOpenCLSolvers_SRCS
../btSoftBodySolver_OpenCL.cpp
../btSoftBodySolver_OpenCLSIMDAware.cpp
../btSoftBodySolverOutputCLtoGL.cpp
)
SET(BulletSoftBodyOpenCLSolvers_HDRS
../btSoftBodySolver_OpenCL.h
../btSoftBodySolver_OpenCLSIMDAware.h
../../CPU/btSoftBodySolverData.h
../btSoftBodySolverVertexData_OpenCL.h
../btSoftBodySolverTriangleData_OpenCL.h
../btSoftBodySolverLinkData_OpenCL.h
../btSoftBodySolverLinkData_OpenCLSIMDAware.h
../btSoftBodySolverBuffer_OpenCL.h
../btSoftBodySolverVertexBuffer_OpenGL.h
../btSoftBodySolverOutputCLtoGL.h
)
# OpenCL and HLSL Shaders.
# Build rules generated to stringify these into headers
# which are needed by some of the sources
SET(BulletSoftBodyOpenCLSolvers_Shaders
# OutputToVertexArray
UpdateNormals
Integrate
UpdatePositions
UpdateNodes
SolvePositions
UpdatePositionsFromVelocities
ApplyForces
PrepareLinks
VSolveLinks
)
foreach(f ${BulletSoftBodyOpenCLSolvers_Shaders})
LIST(APPEND BulletSoftBodyOpenCLSolvers_OpenCLC "../OpenCLC/${f}.cl")
endforeach(f)
ADD_LIBRARY(BulletSoftBodySolvers_OpenCL_Intel
${BulletSoftBodyOpenCLSolvers_SRCS}
${BulletSoftBodyOpenCLSolvers_HDRS}
${BulletSoftBodyOpenCLSolvers_OpenCLC}
)
SET_TARGET_PROPERTIES(BulletSoftBodySolvers_OpenCL_Intel PROPERTIES VERSION ${BULLET_VERSION})
SET_TARGET_PROPERTIES(BulletSoftBodySolvers_OpenCL_Intel PROPERTIES SOVERSION ${BULLET_VERSION})
IF (BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(BulletSoftBodySolvers_OpenCL_Intel BulletSoftBody)
ENDIF (BUILD_SHARED_LIBS)
IF (INSTALL_LIBS)
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
INSTALL(TARGETS BulletSoftBodySolvers_OpenCL_Intel DESTINATION .)
ELSE (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
INSTALL(TARGETS BulletSoftBodySolvers_OpenCL_Intel DESTINATION lib${LIB_SUFFIX})
#headers are already installed by BulletMultiThreaded library
ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
IF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
SET_TARGET_PROPERTIES(BulletSoftBodySolvers_OpenCL_Intel PROPERTIES FRAMEWORK true)
SET_TARGET_PROPERTIES(BulletSoftBodySolvers_OpenCL_Intel PROPERTIES PUBLIC_HEADER "${BulletSoftBodyOpenCLSolvers_HDRS}")
ENDIF (APPLE AND BUILD_SHARED_LIBS AND FRAMEWORK)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
ENDIF (INSTALL_LIBS)

View File

@@ -0,0 +1,27 @@
hasCL = findOpenCL_Intel()
if (hasCL) then
project "BulletSoftBodySolvers_OpenCL_Intel"
defines { "USE_INTEL_OPENCL","CL_PLATFORM_INTEL"}
initOpenCL_Intel()
kind "StaticLib"
targetdir "../../../../../lib"
includedirs {
".",
"../../../..",
"../../../../../Glut"
}
files {
"../btSoftBodySolver_OpenCL.cpp",
"../btSoftBodySolver_OpenCLSIMDAware.cpp",
"../btSoftBodySolverOutputCLtoGL.cpp"
}
end

View File

@@ -0,0 +1,27 @@
hasCL = findOpenCL_NVIDIA()
if (hasCL) then
project "BulletSoftBodySolvers_OpenCL_NVIDIA"
defines { "USE_NVIDIA_OPENCL","CL_PLATFORM_NVIDIA"}
initOpenCL_NVIDIA()
kind "StaticLib"
targetdir "../../../../../lib"
includedirs {
".",
"../../../..",
"../../../../../Glut"
}
files {
"../btSoftBodySolver_OpenCL.cpp",
"../btSoftBodySolver_OpenCLSIMDAware.cpp",
"../btSoftBodySolverOutputCLtoGL.cpp"
}
end