curious question between DX and MDX

This topic is 4910 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 on other sites
What kind of game loop are you using? Tom Miller's posted an efficient game loop in his blog, and I've used it to create a skeleton application here.

Share on other sites
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 on other sites
i just implemented it now, and it doesnt do much of a difference :(

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 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 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_GuapoYeah, 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_GuapoAlso, 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.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 14
• 10
• 11
• 13
• Forum Statistics

• Total Topics
634096
• Total Posts
3015487
×