optimal way of using DirectX

Started by
10 comments, last by noaktree 19 years, 1 month ago
Hi guys, how may DIP calls in your games are you guys making, and in comparison how many setTexture calls are you making??
Advertisement
It's very subjective depending on your target hardware (top of the line 6800's and X850's, or mid range GeForce5's and ATI 9x00's) and the type of engine (shader driven, mostly fixed function..).

The general rule of things seems to be:

• 1-4mb for static geometry buffers
• 256kb-1mb for dynamic geometry buffers

• rendering sorted by shader and texture
• use a state management/sorting system to minimize the number of state changes

Look up the two main developer sites:
Nvidia Developer Relations
ATI Developer Relations
The samples, documentation and presentations on those sites are invaluable for this sort of question [grin]

Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Hi,
I asked something similar some time ago. Basically the conclusions I got were:
a. The number of DIP should stay at about 200-300 per frame in current hardware.
b. Its best if you send the most vertices each DIP.

Now. How many tris do you get per second? Cards sat 80million but real life is way lower. To compute the average do something like this:
a. Get your clock speed. Say 240Mhz. Thats the number of operations you get for each vertex.
b. Divide the result by the number of operations in your vertex shader. More complex shader... more cycles used. A standar shader should get you about 10 operations. You may get a complex VS as you add Light and more deformations. Use FXComposer to compute the number of ops in your shader.
c. Divide that by 3 as a tri requires 3 vertices. (This is in case you are using a tri list).

Doing this should get the number of Tris/sec you get. This is in case you are VertexLimited. I get about 4.1 million verts/sec considering a shader with 3 bones and light in my GeforceFX5200. That allowed to render about 50 skinned zombies at 20-30 FPS. Nice.

Computing PS is more difficult. But you will only get this kind of problems if you are rendering too complex deformations.

Hope that helps.
Luck!
Guimo




in that case I have big problems, spotted em from pix.

Part of my problem is that I do not wish to use VS/PS...just yet....want to do it all in fixed funtion to support all cards etc. etc.

Basically when rendering 100 odd animated .X meshes, and a world of ~8000 polys I'm getting ~30FPS. And pix is saying that I'm making 1600+ DIP Calls, and ~26 odd setTextures every frame.......bad I know.....

now the animated meshes are not very high poly...in fact its the skeleton from a game-programming site ( can't remember it right now ) , with one texture, and the level only has one texture also.

I arranged the rendering so that it only sets textures once and goes ahead and renders all the meshes that use that texture.

I am rendering the entire world, so some sort of culling is required, but the FPS I'm getting is still shite, considering I'm running 2.4Ghz 9800Pro.....Totally down to the DIP calls, but how the hell am I suppose to bring those down when I'm using DrawSubset????

edit- I'm stating those figures as of about a week ago, and I've changed the code, so they may be off somewhat....but you get the idea :-0

edit again - Just ran my app with 100 animating models, all that can be individually animated :

FPS ~ 30
DIP @ 1600
SetTexture 26
Locks on VB 101
Locks on IB 101

Any conclusions?
anyone know if it's possible to instance .X meshes??
Quote:Original post by RavNaz
anyone know if it's possible to instance .X meshes??

You mean the DX9.0c "Geometry Instancing" technology?

I don't see any reason why you can't use that sort of stuff with an ID3DXMesh - but you're going to have to rewrite the draw code (could be done elegantly by a container class) so as to set up the device accordingly. A plain ID3DXMesh probably doesn't know enough to trivially implement Geometry Instancing.

If you're really worried about the number of draw calls - and you mention you have a 100-odd animated meshes, then maybe there are some more fundamental things to change:

• Are all the meshes visible on screen? Look at commercial games, you often only have a single figure number on screen at any one time - rarely more than 20-25 from what I've seen.

• Can you decrease the LOD of either the geometry or animation for characters that are partially obscured or a long way from the camera?

• Is it really the drawing time thats hurting you? or is it the constant updating of animations/physics etc..? Theres bound to be a lot of CPU time used on animating such a large number of meshes. The classic 80-20 rule: you might get your best "boost" by optimizing a different part of your code.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

26 SetTexture's per frame is good.
1600 DIP calls on your system is what's hurting you - I would say 30fps is about right for that many calls if you're not doing much else. Why so many? Each dynamic model should really be done in one (or close to one) call. The static geometry will take the most calls, but unless you've got something really complex you don't need 1600 calls.
Use indexed skinning instead of non-indexed... And try to put as much bones in one pass as possible...
Bulma
hi guys, just to give you an update and some thoughts....

Basically re-done a load of my model code and it now uses skinned models with various skinning modes ( as per sample ). Indexed mode being awesome at reducing the number of DIP calls!!

Weird thing though, the FPS doesn't seem to shift from ~30. I have a load of models on screen and the FPS doesn't seem to shift down or up......whats with that?? It is an MFC app, as oppose to before which was a normal winApp......

JJ - I know what your saying about realistically you wouldn't have that many models on the screen, and there would be some kind of LOD on it.....just didn't really think 100 real basic models would be a problem.....

Thanks for you thoughts guys....

Oh one last thing, what do you guys reckon to this:

To have multiple animated meshes ( all the same ), load first model, then for every copy you want:

The copy has it's own matrix ( for transformations )
The copy has a cloned animcontroller from the original
The copy stores a pointer the original frameRoot.

When it comes to rendering, you update all the animcontrollers, update all the matrices, then render each model.

Any good? Pros / cons?


Quote:Original post by jollyjeffers
Look up the two main developer sites:
Nvidia Developer Relations
ATI Developer Relations
The samples, documentation and presentations on those sites are invaluable for this sort of question [grin]

[grin] This is a great slideset on DIP performance. I wish that *every* single person who is learning D3D would take a look at it. First, it analyzes raw DIP performance, and then it gives some great batching strategies.
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )

This topic is closed to new replies.

Advertisement