Bullet on Cell Broadband/PS3 : threading concerns

liquidslade
Posts: 16
Joined: Fri Aug 14, 2009 11:56 pm

Bullet on Cell Broadband/PS3 : threading concerns

Post by liquidslade »

Hey all. I understand that Bullet has a multithreaded version for CellBroadband. From looking at the code, you guys dispatch everything to the SPU's.

I was wondering if the following were possible/advisable;

1. We wanted to reserve our SPU usage to AI and graphics. We wanted to restrict all game logic code and physics code in the PPU itself. We don't feel comfortable sending all the code to the SPU's, we want to limit our DMA transfers as much as possible, and we want to avoid clogging the SPU's with a lot of traffic. From your current source, is it advisable to do ppu threads instead? (we plan on refactoring this by ourselves).

2. We wanted to implement planetoid objects similar to the following : http://www.youtube.com/watch?v=KNOez7C7uZw
Does bullet make it possible for an object to have a "gravity field", we wanted to have a game world where objects move from planet to planet.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet on Cell Broadband/PS3 : threading concerns

Post by Erwin Coumans »

liquidslade wrote:1. We wanted to reserve our SPU usage to AI and graphics. We wanted to restrict all game logic code and physics code in the PPU itself. We don't feel comfortable sending all the code to the SPU's, we want to limit our DMA transfers as much as possible, and we want to avoid clogging the SPU's with a lot of traffic. From your current source, is it advisable to do ppu threads instead? (we plan on refactoring this by ourselves).
The Cell SPU is more suitable for doing collision detection and physics, it is best to dispatch it to a few SPUs and avoid the slow PPU for this. It is quite usual to dispatch it to 5 SPUs for a small amount (say 10%) of each frame, so you can re-use the same SPUs for doing AI or graphics for the rest of the frame. SPU sharing can be done using libspe2 (IBM SDK) or SPURS (Sony PS3 SDK).
Does bullet make it possible for an object to have a "gravity field", we wanted to have a game world where objects move from planet to planet.
Yes. You can set the default gravity for object to zero, and manually apply a force each simulation frame. It is best to apply a force in a pre-tick callback, using the latest SVN trunk:

Code: Select all

void MyCallback(btDynamicsWorld *world, btScalar timeStep)
{
//apply force field to objects here
}

void* userInfo = 0; //you can store some user pointer if wanted
bool isPreTick = true;
dynamicsWorld->setInternalTickCallback(& MyCallback,dynamicsWorld,isPreTick) ;
Hope this helps,
Erwin
liquidslade
Posts: 16
Joined: Fri Aug 14, 2009 11:56 pm

Re: Bullet on Cell Broadband/PS3 : threading concerns

Post by liquidslade »

Erwin Coumans wrote:
liquidslade wrote:1. We wanted to reserve our SPU usage to AI and graphics. We wanted to restrict all game logic code and physics code in the PPU itself. We don't feel comfortable sending all the code to the SPU's, we want to limit our DMA transfers as much as possible, and we want to avoid clogging the SPU's with a lot of traffic. From your current source, is it advisable to do ppu threads instead? (we plan on refactoring this by ourselves).
The Cell SPU is more suitable for doing collision detection and physics, it is best to dispatch it to a few SPUs and avoid the slow PPU for this. It is quite usual to dispatch it to 5 SPUs for a small amount (say 10%) of each frame, so you can re-use the same SPUs for doing AI or graphics for the rest of the frame. SPU sharing can be done using libspe2 (IBM SDK) or SPURS (Sony PS3 SDK).
Does bullet make it possible for an object to have a "gravity field", we wanted to have a game world where objects move from planet to planet.
Yes. You can set the default gravity for object to zero, and manually apply a force each simulation frame. It is best to apply a force in a pre-tick callback, using the latest SVN trunk:

Code: Select all

void MyCallback(btDynamicsWorld *world, btScalar timeStep)
{
//apply force field to objects here
}

void* userInfo = 0; //you can store some user pointer if wanted
bool isPreTick = true;
dynamicsWorld->setInternalTickCallback(& MyCallback,dynamicsWorld,isPreTick) ;
Hope this helps,
Erwin
Thanks for the hat-tip sir.

Another concern we had was DMA transfers from PPU-SPU/vice versa, with respect to the number of objects in a particular simulation. We wanted to have hordes of objects in a simulation (around 1024-4096). We havent done any real tests yet, but were curious if Bullet can handle it in the PS3.