Add PhysicsEffects to Extras. The build is only tested on Windows and Android.

The Android/NEON optimized version of Physics Effects is thanks to Graham Rhodes and Anthony Hamilton, See Issue 587
This commit is contained in:
erwin.coumans
2012-03-05 04:59:58 +00:00
parent 6cf8dfc202
commit a93a661b94
462 changed files with 86626 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
/*
Applied Research Associates Inc. (c)2011
Redistribution and use in source and binary forms,
with or without modification, are permitted provided that the
following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Applied Research Associates Inc nor the names
of its contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SCE_PFX_PTHREADS_H
#define _SCE_PFX_PTHREADS_H
#include "../../base_level/base/pfx_common.h"
#include <errno.h>
namespace sce {
namespace PhysicsEffects {
class PfxBarrier;
class PfxCriticalSection;
class PfxTaskManager;
#define SCE_PFX_CHECK_PTHREADS_OUTCOME(result) \
if(0 != result) \
{ \
SCE_PFX_PRINTF("pthreads problem at line %i in file %s: %i %d\n", __LINE__, __FILE__, result, errno); \
}
PfxBarrier *PfxCreateBarrierPthreads(int n);
PfxCriticalSection *PfxCreateCriticalSectionPthreads();
PfxTaskManager *PfxCreateTaskManagerPthreads(PfxUInt32 numTasks,PfxUInt32 maxTasks,void *workBuff,PfxUInt32 workBytes);
} //namespace PhysicsEffects
} //namespace sce
#endif // _SCE_PFX_PTHREADS_H

View File

@@ -0,0 +1,53 @@
/*
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
All rights reserved.
Physics Effects is open software; you can redistribute it and/or
modify it under the terms of the BSD License.
Physics Effects is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the BSD License for more details.
A copy of the BSD License is distributed with
Physics Effects under the filename: physics_effects_license.txt
*/
#ifndef _SCE_PFX_SYNC_COMPONENTS_H
#define _SCE_PFX_SYNC_COMPONENTS_H
#include "../../base_level/base/pfx_common.h"
//J スレッド間の同期をとるための同期コンポネント
//E Components for threads sychronization
namespace sce {
namespace PhysicsEffects {
class PfxBarrier {
public:
PfxBarrier() {}
virtual ~PfxBarrier() {}
virtual void sync() = 0;
virtual void setMaxCount(int n) = 0;
virtual int getMaxCount() = 0;
};
class PfxCriticalSection {
public:
PfxCriticalSection() {}
virtual ~PfxCriticalSection() {}
PfxUInt32 m_commonBuff[32];
virtual PfxUInt32 getSharedParam(int i) = 0;
virtual void setSharedParam(int i,PfxUInt32 p) = 0;
virtual void lock() = 0;
virtual void unlock() = 0;
};
} //namespace PhysicsEffects
} //namespace sce
#endif // _SCE_PFX_SYNC_COMPONENTS_H

View File

@@ -0,0 +1,96 @@
/*
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
All rights reserved.
Physics Effects is open software; you can redistribute it and/or
modify it under the terms of the BSD License.
Physics Effects is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the BSD License for more details.
A copy of the BSD License is distributed with
Physics Effects under the filename: physics_effects_license.txt
*/
#ifndef _SCE_PFX_TASK_MANAGER_H
#define _SCE_PFX_TASK_MANAGER_H
#include "../../base_level/base/pfx_common.h"
#include "../../base_level/base/pfx_heap_manager.h"
#include "pfx_sync_components.h"
#define SCE_PFX_IO_BUFF_BYTES 1048576
namespace sce {
namespace PhysicsEffects {
//J 並列処理するためのタスクマネージャクラス
//E Task manager class for parallel computation
struct PfxTaskArg
{
int taskId;
int maxTasks;
PfxBarrier *barrier;
PfxCriticalSection *criticalSection;
void *io;
PfxUInt32 data[4];
};
typedef void (*PfxTaskEntry)(PfxTaskArg *arg);
class PfxTaskManager
{
protected:
PfxUInt32 m_numTasks;
PfxUInt32 m_maxTasks;
SCE_PFX_PADDING(1,4)
PfxUInt8 SCE_PFX_ALIGNED(16) m_ioBuff[SCE_PFX_IO_BUFF_BYTES];
PfxHeapManager m_pool;
PfxHeapManager m_ioPool;
PfxTaskEntry m_taskEntry;
PfxTaskArg *m_taskArg;
SCE_PFX_PADDING(2,8)
PfxTaskManager() : m_pool(NULL,0),m_ioPool(NULL,0) {}
public:
void *allocate(size_t bytes) {return m_ioPool.allocate(bytes);}
void deallocate(void *p) {m_ioPool.deallocate(p);}
void clearPool() {m_ioPool.clear();}
virtual PfxUInt32 getSharedParam(int i) = 0;
virtual void setSharedParam(int i,PfxUInt32 p) = 0;
virtual void startTask(int taskId,void *io,PfxUInt32 data1,PfxUInt32 data2,PfxUInt32 data3,PfxUInt32 data4) = 0;
virtual void waitTask(int &taskId,PfxUInt32 &data1,PfxUInt32 &data2,PfxUInt32 &data3,PfxUInt32 &data4) = 0;
virtual void setTaskEntry(void *entry) {m_taskEntry = (PfxTaskEntry)entry;}
public:
PfxTaskManager(PfxUInt32 numTasks,PfxUInt32 maxTasks,void *workBuff,PfxUInt32 workBytes)
: m_pool((unsigned char*)workBuff,workBytes),m_ioPool(m_ioBuff,SCE_PFX_IO_BUFF_BYTES)
{
SCE_PFX_ASSERT(numTasks>0);
SCE_PFX_ASSERT(numTasks<=maxTasks);
m_numTasks = numTasks;
m_maxTasks = maxTasks;
m_taskArg = (PfxTaskArg*)m_pool.allocate(sizeof(PfxTaskArg)*m_maxTasks);
}
virtual ~PfxTaskManager()
{
m_pool.clear();
}
virtual PfxUInt32 getNumTasks() const {return m_numTasks;}
virtual void setNumTasks(PfxUInt32 tasks) {m_numTasks = SCE_PFX_MIN(tasks,m_maxTasks);}
virtual void initialize() = 0;
virtual void finalize() = 0;
};
} //namespace PhysicsEffects
} //namespace sce
#endif // _SCE_PFX_TASK_MANAGER_H