Jump to content
  • Advertisement
Sign in to follow this  
ramy

curious question between DX and MDX

This topic is 4847 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 was stuck with a curious thing. the native direct3d sample in the sdk renders about 1700 frames per second, the managed direct3d sample in C# renders arround the same frames per sond. wat im curious about, i have implemented a 3d device using managed direct3d, and i got FPS about 300, note that i have "m_PresentParameters.PresentationInterval = PresentInterval.Immediate;" so what could be the problem?? i got 300 with a regular render, without any primitives drawing, just a BeginScene and a EndScene. not to mention i did a direct3d implementation also under native c++ and i got about 1400 FPS, so the way that im measuring the FPS in my managed DX implementation is right. anybody has a clue?

Share this post


Link to post
Share on other sites
Advertisement
thats my render loop:

private void Form1_Paint(object sender, PaintEventArgs e)
{
cam.Look(camPos, camView, camUp);
timer.UpdateTick();
dev.BeginScene();

dev.DrawString("Frames Per Second: " + timer.FPS.ToString(), 0, 0);
dev.EndScene();
Application.DoEvents();
Invalidate();
}

Tom Miller render loop, uses the Native functions for msgs and stuff, i didnt use that, can that be the problem?

BTW, thats for ur link, i would be revising that soon.

Share this post


Link to post
Share on other sites
1. How do you calculate your FPS? (The calcluation code could be buggy)
2. How do you display them? (The display code could be the bottleneck)

EDIT: D'oh! You're using Device.DrawString, but that's not in the documentation. How does this function work? It might very well be your bottleneck (if it's creating the font everytime, or using GDI, or something equally slow).

Share this post


Link to post
Share on other sites
Yeah, I haven't seen that draw string before. Perhaps you should try rendering a blank screen without text and just write the FPS to the command line...

Also, what version of DX9 are you using? IIRC, before 9.0b, the text could be fairly slow. I believe that MS optimized all the text drawing in 9.0b however. I could be a little off though...

Share this post


Link to post
Share on other sites
that draw string is a function i wrapped.

here is how i calculate the FPS:

float fCurrentTime = (float)(timeGetTime() * 0.001f);
m_fFrameInterval = (fCurrentTime - m_fPreviousFrameTime) + 0.015f;
m_fPreviousFrameTime = fCurrentTime;
m_iFramePerSecondCounter++;
if (fCurrentTime - m_fLastSecondTime > m_fTimeInterval)
{
m_fLastSecondTime = fCurrentTime;
m_iFramePerSecond = m_iFramePerSecondCounter;
m_iFramePerSecondCounter = 0;
}





Quote:
Original post by Sr_Guapo
Yeah, I haven't seen that draw string before.


and here is how i draw the string (btw im using direct font for it):


m_Text = new Microsoft.DirectX.Direct3D.Font(m_D3DDevice, -m_iFontSize * 96 / 72, 0, FontWeight.Bold, 1,
false, CharacterSet.Default, Precision.Default, FontQuality.AntiAliased | FontQuality.Default, PitchAndFamily.DefaultPitch, "Arial");





i discovered the bottleneck, i was doing a stupid thing, i was creating a Font object and disposing it everything i want to draw text.
im getting 1500 fps now.
1200 fps cost for creating and disposing Font object each frame is too much :s was it that bad? :S

Quote:
Original post by Sr_Guapo
Also, what version of DX9 are you using? IIRC, before 9.0b, the text could be fairly slow. I believe that MS optimized all the text drawing in 9.0b however. I could be a little off though...

im using DirectX 9.0c June 2005.

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!