Sign in to follow this  
Hassanbasil

LPD3DXFONT is slow

Recommended Posts

Hassanbasil    195
Hello everyone, Using LPD3DXFONT is really slow that i lose over 700 FPS when i use it, is there any other method for drawing text? i tried CD3DFont but it gives even worse results ( over 1900 FPS loss.. )

Share this post


Link to post
Share on other sites
Evil Steve    2017
FPS is a meaningless number. If you loose 700 FPS and go from 2000 FPS to 1300 FPS, that's a microscopic performance difference. If you lose 700 FSP going from 701 FPS to 1 FPS, that's a huge difference.

Exactly how much of a difference does it make? How much text are you drawing? Can we see your code?

Share this post


Link to post
Share on other sites
Hassanbasil    195
from 2000 to 1300, how can it be "meaningless", when its about 35% loss?, here's some code:


//text drawing method
char FPS[50];
float fps = myCore->GetFPS ( );
sprintf_s ( FPS, 20, "hasX engine\nFPS : %d", (int)fps );
myCore->DrawText ( 10, 10, FPS, 255, 175, 75, 225, 0 );

//render
RECT rect;
rect.top = TextV[i].y;
rect.left = TextV[i].x;
TEXTMETRICA met;
TextV[i].font->GetTextMetricsA ( &met );
rect.right = rect.left + ( met.tmHeight*strlen ( TextV[i].Text ) ) + 10;
rect.bottom = rect.top + ( ( met.tmHeight + 2 ) * numLines ) + 10;
TextV[i].font->DrawTextA ( NULL, TextV[i].Text, strlen ( TextV[i].Text ), &rect, DT_NOCLIP, TextV[i].color );

Share this post


Link to post
Share on other sites
Evil Steve    2017
2000 FPS is 0.5ms per frame
1300 FPS is 0.77ms per frame

That's a difference of 0.27ms per frame, which is nothing - and there'll be too much background noise for that to be remotely accurate. You need to put more load on the system before you can profile

If you're drawing multiple lines of text, you can get better performance by specifying a sprite for the first parameter to DrawText() (And use the same sprite for all draw calls).

Share this post


Link to post
Share on other sites
Hassanbasil    195
Quote:
Original post by Evil Steve
If you're drawing multiple lines of text, you can get better performance by specifying a sprite for the first parameter to DrawText() (And use the same sprite for all draw calls).


well, i get the same FPS whether writing 1 line or 10 lines, so i think its not a "noticeable" performance improve

Quote:
Original post by Evil Steve
2000 FPS is 0.5ms per frame
1300 FPS is 0.77ms per frame

That's a difference of 0.27ms per frame, which is nothing


i see, thank you for the reply.

Share this post


Link to post
Share on other sites
Evil Steve    2017
Quote:
Original post by Hassanbasil
Quote:
Original post by Evil Steve
If you're drawing multiple lines of text, you can get better performance by specifying a sprite for the first parameter to DrawText() (And use the same sprite for all draw calls).


well, i get the same FPS whether writing 1 line or 10 lines, so i think its not a "noticeable" performance improve
Maybe not at the moment, but as you add more to your engine and it becomes CPU bound, that could gain you some FPS.

Share this post


Link to post
Share on other sites
Hassanbasil    195
Quote:
Original post by Evil Steve
Quote:
Original post by Hassanbasil
Quote:
Original post by Evil Steve
If you're drawing multiple lines of text, you can get better performance by specifying a sprite for the first parameter to DrawText() (And use the same sprite for all draw calls).


well, i get the same FPS whether writing 1 line or 10 lines, so i think its not a "noticeable" performance improve
Maybe not at the moment, but as you add more to your engine and it becomes CPU bound, that could gain you some FPS.


I see, i shall try that when i go into sprites

Share this post


Link to post
Share on other sites
Tom KQT    1704
Quote:
( over 1900 FPS loss.. )


Just a little note, although E.S.'s answer is really comprehensive:
Seems you're having really HUGE FPS which means your application is doing/drawing almost nothing (or really nothing?). You cannot wonder that when you add something, your FPS drops a lot ;)

Share this post


Link to post
Share on other sites
jpetrie    13100
Quote:

from 2000 to 1300, how can it be "meaningless", when its about 35% loss?, here's some code:

While I would disagree that FPS is a "meaningless" number, it is mostly-useless as a performance metric because it is a nonlinear measurement.

Share this post


Link to post
Share on other sites
EJH    315
Does your app actually do anything yet? I don't think I've seen 2000 fps on app doing nothing and drawing a blank screen.

Share this post


Link to post
Share on other sites
Hassanbasil    195
Quote:
Original post by EJH
Does your app actually do anything yet? I don't think I've seen 2000 fps on app doing nothing and drawing a blank screen.


it does, lights / 3 objects + alpha blending, i think it's because the graphic card is a little good ( it runs on 10-11k fps on my friend's )

EDIT:
Quote:
Just a little note, although E.S.'s answer is really comprehensive:
Seems you're having really HUGE FPS which means your application is doing/drawing almost nothing (or really nothing?). You cannot wonder that when you add something, your FPS drops a lot ;)


no, this 1900 was actually huge, from 2k to 100

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this