Jump to content
  • Advertisement
Sign in to follow this  
muhkuh

ID3DXFont::DrawText causes strange stuttering

This topic is 5109 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'm using the DirectX 9.0c SDK and wrote a little demo app. I print out some text displaying framerate, number of triangles ... Depending on the load of the GPU there are some very short stutterings in the framerate of the app. The framerate increases, jumping from 70 to >100 and decreases to something <60 before it returns to normal. I checked this with the nvPerfHud and it shows a regular heartbeat like curve of the red line (driver time) and only the red line (frame time stays the same). I found out thet the ID3DXFont::DrawText function was the reason for this. When it's commented out everything works as it should. I really do not print a lot of text, just this: "fps= \ntris= \ntris/s= \nthres= \n""used video memory= \n""h : toggle help screen on/off" The more text I draw the higher is the frequency of the stuttering. What am I doing wrong? All optimizations I tried (PreloadCharacters , PreloadGlyphs , PreloadText, passing a self created sprite to DrawText) didn't help.

Share this post


Link to post
Share on other sites
Advertisement
I would think the DrawText function works by filling up a vertex buffer and looping when it is full - this can cause a stall if a previous render has not happened before it needs to fill a new part - now this is just a guess. I solved this problem with my own font class by using the events methods to check the driver had completed the previous frame.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Very unusual. I am conducting a study on different methods of text output in 3d and I haven't encountered behaviour you describing. But I can tell you that ID3DXFont does have some CPU dependency and something else happening in your secene could interfere to create effect you described.

Share this post


Link to post
Share on other sites
I am suprised you say it is unusual as the last few version of the DirectX SDK (apart from the 9 ones) have come with a font class that does just this. It is also the way I render my fonts. I think I did not explain it very well first time - this is what I mean:

1. A texture is created and via the Win32 bitmap functions it is filled with the characters from a font
2. A vertex buffer is created of a set size with D3DUSAGE_DYNAMIC
3. When you come to render some text the vertex buffer is locked (using D3DLOCK_DISCARD) from the position it was last filled to and is then filled with the correct chars for the text (uv,s set). DrawPrim is then called.

This is the most efficient way of rendering the text that I can think of - do you know of a better way?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
In fact I do. The alternative method I am using in some cases gives me double performance compared to ID3DXFont. It will take me few more weeks to finish my work. Once I am done I will post results of my investigation.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Trip99
I would think the DrawText function works by filling up a vertex buffer and looping when it is full - this can cause a stall if a previous render has not happened before it needs to fill a new part - now this is just a guess. I solved this problem with my own font class by using the events methods to check the driver had completed the previous frame.


Could you please be a bit more specific how do you solved it? What events method?

Share this post


Link to post
Share on other sites
The anonymous one post above was me, forgot to log in.

I solved the problem by placing the fps output before all other rendering. This is acceptable except when framerates get very low.

Share this post


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

  • 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!