Jump to content
Xtreme .Net Talk

FPS Problem in DirectX


Recommended Posts

Guest JellyDonutMan
Posted

Having a problem with DirectX 9 and VB.NET displaying only 50 FPS max ... This is the code I'm using to get the FPS

   Public Function GetFPS()
       CurrentTime = Environment.TickCount()
       Frames += 1
       If CurrentTime - LastTime >= 1000 Then
           FPS = Frames
           LastTime = CurrentTime
           Frames = 0
       End If
       Return FPS
   End Function

  • *Experts*
Posted

If you're setting your device's present parameter's interval to anything but Immediate, you may be locking yourself into the monitor refresh. If you change the value to One, you should see it pick up:

presentParams.PresentationInterval = PresentInterval.One;

 

Check out the values for your swap effect and interval in the help for more info. You may want to use the C++ documentation if the C# docs aren't helpful enough.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

...did you change your PresentInterval as well?

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

PresentParams.Windowed = True
PresentParams.SwapEffect = SwapEffect.Discard
PresentParams.PresentationInterval = PresentInterval.One
Device = New Device(0, DeviceType.Hardware, Me.Handle, CreateFlags.HardwareVertexProcessing, PresentParams)

 

Is what I have.

  • *Experts*
Posted

If One, it's syncing up each refresh to the monitor's refresh. If your monitor is at 100hz, you can expect 50 FPS to be the max, give or take. If you had a really fast machine and graphics card, you might get closer to 100 FPS, but you wouldn't go faster than the refresh.

 

By changing it to Immediate, you're saying don't wait for the monitor to refresh, flip the backbuffer immediately.

 

I'd read up on the "tearing" effects that might get introduced using certain PresentIntervals and SwapEffects.

 

Also, anything about 30FPS is generally considered acceptable though 60FPS or higher is ideal. 50 FPS shouldn't be a worry. I'd wait til you add some objects and other logic to your app's main loop then see what FPS you're getting.

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
  • *Experts*
Posted

I haven't seen any other option similar to the old D3DSWAPEFFECT_COPY_VSYNC. Just by playing around did I find the PresentInterval (which used to be reserved for FullScreen) and read up on the SwapEffect (some good info in the help for C# on this).

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...