Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

IndirectX

ID3DXFont performance

This topic is 5987 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

Hi, I''m using ID3DXFont to draw some 2D text (like SDK examples do -- fps, vp, etc.) on top of my screen after rendering the scene. Now when I draw help text when F1 is pressed, also like SDK examples do, my framerate drops drastically. I have about 1250 bytes of text in help string, spead over two dozen lines. I''m running this in pure hardware vp on GF3. In 1400x1000x32 window, when the help text is not shown, I get ~60 fps, and when the help text is shown, I get about 38 fps. In 1600x1200x32 fullscreen fps drops from 45 to 30. What gives? I still am drawing the fps statistics, and I call DrawText only once (I concatenate all strings before drawing). If I concatenate that 1K help text without drawing, I get no difference in framerate. I''d appreciate any ideas you might have concerning this issue. Should I just throw ID3DXFont away and use modified CD3DFont? Thanks

Share this post


Link to post
Share on other sites
Advertisement
First of all, creating a font is slow. This has to be moved outside the rendering loop.

If this is already done, displaying text involves a lot of render state changes, and these are also quite slow.


Laurent - http://www.lafaqmfc.com/
My little game: http://www.lafaqmfc.com/starshooter.htm

Share this post


Link to post
Share on other sites
Also be careful with D3DFont, very buggy!

I have posted some quick fixes here:

http://www.lafaqmfc.com/directx.htm

Hope this helps



Laurent - http://www.lafaqmfc.com/
My little game: http://www.lafaqmfc.com/starshooter.htm

Share this post


Link to post
Share on other sites
I''m creating my font during init. I would use your D3DFont (in fact I got it some time ago) but I''m not using SDK samples framework, largely due to the fact that I have my interfaces wrapped around DX. It''s also a bit hard for me to understand that class, because it throws a lot of new stuff at me at once. However, I''m considering modifying your class to work with my wrappers (can I do that?)

Any particular reason why D3DFont is faster than ID3DXFont, as I saw people say?

Share this post


Link to post
Share on other sites
I think D3DFont is faster because it is simpler.

For example, it works with a partial character set, so the texture is much smaller. It does not try to handle all possible cases.

It should be easy to make D3DFont have the same class interface of ID3DXFont.

Also, ID3DXFont does a lot of stuff at construction time, you have to take great care of not inadvertantly creating temporary objects.


Laurent - http://www.lafaqmfc.com/
My little game: http://www.lafaqmfc.com/starshooter.htm

Share this post


Link to post
Share on other sites
G''day!

D3DXFont is slower because each string you output is rendered to a texture by GDI, then a quad is used to render it to the display.

D3DFont pre-builds a texture map of all characters, then just renders the ones you need.

D3DXFont is prettier (marginally) and if you need to do fancy text formatting it will do it better. But how many games REALLY need fancy text formatting? Not many, and fewer still at any point where speed is critical.

Another alternative that should be easy to plug into whatever structure you have is here:
http://www.drunkenhyena.com/docs/dhFastFont.phtml

It uses a pre-created bitmap, which has pros and cons, most of which relate to personal preference.

Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!