• Advertisement
Sign in to follow this  

Why is PhysX so Slow?!

This topic is 3312 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I made a ragdoll with 75 bones using D6 joints and I get about 1 frame per second, I also disabled collision between all the bones. Does it normally run this slow with rag dolls and if so how do they make games with fully rigged characters?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by dmail
Unholy Savagery

Quote:
...You are likely to be ignored, or written off as a loser, if you:
...
cross-post to too many different newsgroups


I suspect nobody will supply an answer to your question here now that you have confirmed you have posted to the correct forum.


Most post on the Nvidia forum go unanswered for days and days, this forum is one of the few active forums for programmers on the web. Also I really don't see why someone would not reply to this post if they know the answer.

Share this post


Link to post
Share on other sites
I haven't used PhysX, but is 75 bones a reasonable number of bones for a single character? Maybe it is just me, but it seems a tad high. Also, is this running a debug or release build?

Share this post


Link to post
Share on other sites
Quote:
Original post by CodaKiller
I made a ragdoll with 75 bones using D6 joints and I get about 1 frame per second, I also disabled collision between all the bones. Does it normally run this slow with rag dolls and if so how do they make games with fully rigged characters?


Let's see some profiler output.

Share this post


Link to post
Share on other sites
Quote:
Original post by dmail
I suspect nobody will supply an answer to your question here now that you have confirmed you have posted to the correct forum.


No, that would not be very nice. The only time I see that happening is when the people here are not knowledgeable enough to answer this.

Quote:
Original post by the_edd
Let's see some profiler output.


Ditto. Ever heard the phrase 10% of your code takes 90% of the time? Sometimes it's surprising which ten percent. (And the guy at the other forum said it wasn't a PhysX problem anyway. Please don't be quick to blame external libraries for performance unless you have proof.)

Share this post


Link to post
Share on other sites
Quote:
Original post by Splinter of Chaos
Quote:
Original post by dmail
I suspect nobody will supply an answer to your question here now that you have confirmed you have posted to the correct forum.


No, that would not be very nice. The only time I see that happening is when the people here are not knowledgeable enough to answer this.

The reason I said this is that many times people will not post in threads were their is cross posting as when there are multiple conversation on the subject one generally gets the most attention leaving the other in a stagnant state. As the other post in the in SDK's forums I would have suspected that was the thread that would get the attention. It had nothing to do with being nice.

Share this post


Link to post
Share on other sites
Quote:
Original post by the_edd
Quote:
Original post by CodaKiller
I made a ragdoll with 75 bones using D6 joints and I get about 1 frame per second, I also disabled collision between all the bones. Does it normally run this slow with rag dolls and if so how do they make games with fully rigged characters?


Let's see some profiler output.


I don't really know what you mean, what exactly is profiler output?

Quote:
Original post by smitty1276
Is this hardware accelerated?


No, I know it would run faster with hardware acceleration but I am quite sure it should at least be able to do 75 bones with software.

Quote:
Original post by Splinter of Chaos
(And the guy at the other forum said it wasn't a PhysX problem anyway. Please don't be quick to blame external libraries for performance unless you have proof.)


Yes he also said he used over 100 bones but only 12 joints on his characters, I thought there may be a way to joint together more then 2 actors at a time but even if I did that I would still use around 30, so how did he use only 12?!

Share this post


Link to post
Share on other sites
Quote:
Original post by CodaKiller
Quote:
Original post by the_edd
Let's see some profiler output.
I don't really know what you mean, what exactly is profiler output?
The output of a profiler. Seriously, a profiler is as elementary a part of the programmer's toolkit as a debugger. Find one you like, and learn to use it well - performance optimisation is virtually impossible without.

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
Quote:
Original post by CodaKiller
Quote:
Original post by the_edd
Let's see some profiler output.
I don't really know what you mean, what exactly is profiler output?
The output of a profiler. Seriously, a profiler is as elementary a part of the programmer's toolkit as a debugger. Find one you like, and learn to use it well - performance optimisation is virtually impossible without.


Does Microsoft C++ Express have a built in profiler?

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
See here.

It seems somewhat less than helpful to send him to a documentation page for a feature that doesn't exist in the express editions.

Share this post


Link to post
Share on other sites
Quote:
Original post by Adam_42
One option for a free profiler is CodeAnalyst. Even though it's from AMD it will work on Intel processors, although with somewhat less features.


Alright thanks, I have an AMD processor so it's perfect. Now it's asking for a trace point, what do I do?

Share this post


Link to post
Share on other sites
The help file says it will intergrade with Microsoft C++ Express 2008 but it has not and there was no option in the installer. There is no tool bar or any controls that have been added, how can I manually add it?

Share this post


Link to post
Share on other sites
Quote:
Original post by Moe
I haven't used PhysX, but is 75 bones a reasonable number of bones for a single character? Maybe it is just me, but it seems a tad high. Also, is this running a debug or release build?

doom3 characters are about that, often >100 bones ( i just checked )
though doom3 does the skinning on the cpu, thus doesnt suffer constraints of the GPU

Share this post


Link to post
Share on other sites
You don't need a profiler for this problem.
A profiler is useful when you don't know where the bottleneck is, but this is not the case and you can figure this out without one.
Since you want to know if the problem is skinning related, just do these two tests:
1. Run your program with skinning disabled.
2. Problematically remove most of the bones (stay with 5 or so).

If you see the performance is crap even when you do test 1 - the problem has nothing to do with the skinning.

If the performance is crap when you do test 2 - its likely you are not using PhysX correctly (I assume they can handle more then 5 bones) and we will have to see some code.
On the other hand, if you get decent performance with test 2, then there is a bone limitation (or maybe each bone influences too many vertices).

Goodluck

Share this post


Link to post
Share on other sites
Quote:
Original post by doronf
You don't need a profiler for this problem.
A profiler is useful when you don't know where the bottleneck is, but this is not the case and you can figure this out without one.
Since you want to know if the problem is skinning related, just do these two tests:
1. Run your program with skinning disabled.
2. Problematically remove most of the bones (stay with 5 or so).

If you see the performance is crap even when you do test 1 - the problem has nothing to do with the skinning.

If the performance is crap when you do test 2 - its likely you are not using PhysX correctly (I assume they can handle more then 5 bones) and we will have to see some code.
On the other hand, if you get decent performance with test 2, then there is a bone limitation (or maybe each bone influences too many vertices).

Goodluck


Disabled rendering all together and still runs at about 1-2 FPS. I then removed some bones and it ran a little faster, so I removed some more and it ran even faster etc.

I'm not sure what code you guys want to see, it's pretty simple, I created box actors and jointed them together with D6 joints, no constraints or anything just free rotation and locked position, thats all.

I can't really show the code because it's broken up in to many functions that are engine/ scripting dependent.

Share this post


Link to post
Share on other sites
To CodaKiller, I dont think any of the visual express tools will allow addons, so you can't install the CodeAnalyst addon which will allow you to directly launch the profiler from within visual studio express, but you can just as easily create a new project within CodeAnalyst itself and start the profiler from there.

Good Luck!

-ddn

Share this post


Link to post
Share on other sites
Quote:
Original post by CodaKiller
I'm not sure what code you guys want to see, it's pretty simple, I created box actors and jointed them together with D6 joints, no constraints or anything just free rotation and locked position, thats all.


If I created a thread on this forum that asked "Why is my NVidia 9800 GTX is so slow to render 100 boxes" and provided no tangible evidence or information of the investigation I had done, would you suspect the graphics card or the code that I used?

Quote:
I can't really show the code because it's broken up in to many functions that are engine/ scripting dependent.


Then you must either:

(a) create a smaller example that exhibits the problem. Anecdotally, it is almost universally the case that one discovers the problem while doing this. The more you resist in showing code the less people are inclined to help or even believe you; we've seen it all before. This does not give you a license to drop 1000 lines on us, however :)

(b) in some *reliable* way, find out where the bottleneck is. My suggestion of using a profiler would be the most direct way of doing this. If for whatever reason this is proving difficult, then you must find another way.

It is highly likely that it is not in fact PhysX which is slow, but it is the way in which you are using it which is slow, or there is some entirely unrelated code that is slowing the program down. It is up to you to prove that it is PhysX because the body of evidence against your claim is rather large.

We will gladly help, but you need to clearly state your case with evidence and information.

Share this post


Link to post
Share on other sites
Quote:
Original post by the_edd
Quote:
Original post by CodaKiller
I'm not sure what code you guys want to see, it's pretty simple, I created box actors and jointed them together with D6 joints, no constraints or anything just free rotation and locked position, thats all.


If I created a thread on this forum that asked "Why is my NVidia 9800 GTX is so slow to render 100 boxes" and provided no tangible evidence or information of the investigation I had done, would you suspect the graphics card or the code that I used?

Quote:
I can't really show the code because it's broken up in to many functions that are engine/ scripting dependent.


Then you must either:

(a) create a smaller example that exhibits the problem. Anecdotally, it is almost universally the case that one discovers the problem while doing this. The more you resist in showing code the less people are inclined to help or even believe you; we've seen it all before. This does not give you a license to drop 1000 lines on us, however :)

(b) in some *reliable* way, find out where the bottleneck is. My suggestion of using a profiler would be the most direct way of doing this. If for whatever reason this is proving difficult, then you must find another way.

It is highly likely that it is not in fact PhysX which is slow, but it is the way in which you are using it which is slow, or there is some entirely unrelated code that is slowing the program down. It is up to you to prove that it is PhysX because the body of evidence against your claim is rather large.

We will gladly help, but you need to clearly state your case with evidence and information.


Initialize PhysX:

if( !g_PhysicsSDK )
{
string error = "Error: PhysX was unable to initialize.";
g_ErrorLog.push_back(error);
MessageBox(NULL, error.c_str(), "ERROR", MB_OK);
return 0;
}
g_PhysicsSDK->getFoundationSDK().getRemoteDebugger()->connect ("localhost", 5425);
g_Cooking = NxGetCookingLib(NX_PHYSICS_SDK_VERSION);
g_Cooking->NxInitCooking();











Create Scene:

int lua_CreateScene(lua_State *L)
{
E_SCENE* Scene = new E_SCENE;
NxSceneDesc sceneDesc;
sceneDesc.gravity.set( 0.0f, -9.81f, 0.0f );
Scene->PhysicsScene = g_PhysicsSDK->createScene(sceneDesc);
NxMaterial* defaultMaterial = Scene->PhysicsScene->getMaterialFromIndex(0);
defaultMaterial->setRestitution(0.0f);
defaultMaterial->setStaticFriction(0.5f);
defaultMaterial->setDynamicFriction(0.5f);
NxPlaneShapeDesc planeDesc;
NxActorDesc actorDesc;
planeDesc.normal = NxVec3(0.0f,1.0f,0.0f);
planeDesc.d = 1.0f;
actorDesc.shapes.pushBack(&planeDesc);
NxActor *planeActor = Scene->PhysicsScene->createActor( actorDesc );
g_Scenes.push_back(Scene);
lua_pushnumber(L, (UINT)Scene);
return 1;
}











Update scene:

void Update( float UpdateTime )
{
PhysicsScene->simulate((NxReal)UpdateTime);
PhysicsScene->flushStream();
PhysicsScene->fetchResults(NX_RIGID_BODY_FINISHED, true);
}











Create Bone Actors, this one requires explanation, it loads a mesh and if the mesh supples bones but no bone shapes then it creates boxes other wise it will use the bone shapes, if the mesh supples no bones then it will try to create a collision mesh from the mesh it's self and if it can't then it creates a box and disables collision on it, I will probably change then later to a box that encapsulates the mesh but I don't have the required information. After thats done it calls the CreateJoints function and disables collision between the joints:


int lua_CreateActor(lua_State *L)
{
E_SCENE* Scene = (E_SCENE*)(UINT)lua_tonumber(L, 1);
E_MESH* Mesh = new E_MESH;
Mesh->Load((char*)lua_tostring(L, 2));
E_ACTOR* Actor = new E_ACTOR;
D3DXMATRIX matrix = lua_tomatrix(L, 3);
D3DXMATRIX tmatrix;
Actor->mesh = Mesh;
NxActorDesc actorDesc;
if( Mesh->bones.size() > 0)
{
for( UINT i = 0; i < Mesh->bones.size(); i++ )
{
if(Mesh->bones.mesh)
{
NxConvexShapeDesc ConvexShapeDesc;
ConvexShapeDesc.meshData = Mesh->bones.mesh;
actorDesc.shapes.pushBack(&ConvexShapeDesc);
NxBodyDesc bodyDesc;
actorDesc.body = &bodyDesc;
D3DXMatrixMultiply( &tmatrix, &Mesh->bones.matrix, &matrix );
actorDesc.globalPose.setColumnMajor44(tmatrix);
actorDesc.density = 1;
Actor->bones.push_back(Scene->PhysicsScene->createActor(actorDesc));
}
else
{
NxBoxShapeDesc BoxShapeDesc;
BoxShapeDesc.dimensions.set( 0.25f * (Mesh->bones.length/2), 1.0f * (Mesh->bones.length/2), 0.25f * (Mesh->bones.length/2) );
D3DXMatrixTranslation( &tmatrix, 0, Mesh->bones.length / 2, 0 );
BoxShapeDesc.localPose.setColumnMajor44( tmatrix );
actorDesc.shapes.pushBack( &BoxShapeDesc );
NxBodyDesc bodyDesc;
actorDesc.body = &bodyDesc;
D3DXMatrixMultiply( &tmatrix, &Mesh->bones.matrix, &matrix );
actorDesc.globalPose.setColumnMajor44(tmatrix);
actorDesc.density = 1;
Actor->bones.push_back(Scene->PhysicsScene->createActor(actorDesc));
}
}
}
else
{
NxBoxShapeDesc BoxShapeDesc;
BoxShapeDesc.shapeFlags = NX_SF_DISABLE_COLLISION;
actorDesc.shapes.pushBack(&BoxShapeDesc);
NxBodyDesc bodyDesc;
actorDesc.body = &bodyDesc;
actorDesc.globalPose.setColumnMajor44(matrix);
actorDesc.density = 1;
Actor->bones.push_back(Scene->PhysicsScene->createActor(actorDesc));
}
Actor->enabled = true;
Actor->CreateJoints( Actor->mesh->root_bone );
for(UINT np = 0; np < Actor->bones.size(); np++)
{
for(UINT nq = 0; nq < Actor->bones.size(); nq++)
{
if( np==nq ) continue;
Scene->PhysicsScene->setActorPairFlags( *Actor->bones[np], *Actor->bones[nq], NX_IGNORE_PAIR );
}
}
Actor->matrices.resize( Actor->bones.size() );
Scene->AddActor(Actor);
lua_pushnumber(L, (UINT)Actor);
return 1;
}











Create joints:

void CreateJoints( DWORD bone )
{
if( mesh->bones[bone].childen.size() > 0 )
{
NxD6JointDesc JointDesc;
JointDesc.actor[0] = bones[bone];
for(UINT i = 0; i < mesh->bones[bone].childen.size(); i++)
{
JointDesc.actor[1] = bones[mesh->bones[bone].childen];
E_ACTOR::CreateJoints(mesh->bones[bone].childen);
JointDesc.twistMotion = NX_D6JOINT_MOTION_FREE;
JointDesc.swing1Motion = NX_D6JOINT_MOTION_FREE;
JointDesc.swing2Motion = NX_D6JOINT_MOTION_FREE;
JointDesc.xMotion = NX_D6JOINT_MOTION_LOCKED;
JointDesc.yMotion = NX_D6JOINT_MOTION_LOCKED;
JointDesc.zMotion = NX_D6JOINT_MOTION_LOCKED;
D3DXMATRIX matrix;
bones[mesh->bones[bone].childen]->getGlobalPose().getColumnMajor44(matrix);
JointDesc.setGlobalAnchor( NxVec3( matrix._41, matrix._42, matrix._43 ) );
JointDesc.projectionMode = NX_JPM_NONE;
joints.push_back( bones[bone]->getScene().createJoint( JointDesc ) );
}
}
}











[Edited by - CodaKiller on January 24, 2009 12:50:49 PM]

Share this post


Link to post
Share on other sites
Someone on the Nivida forum said something about visualization being enabled which is slowing it down but what does he mean and how can I disable it?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement