FPS Problem in DirectX

  • Thread starter Thread starter JellyDonutMan
  • Start date Start date
J

JellyDonutMan

Guest
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
Visual Basic:
    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
 
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:
C#:
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
 
Visual Basic:
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.
 
Umm.. I changed it to
Visual Basic:
PresentParams.PresentationInterval = PresentInterval.Immediate
And now I'm getting 1700-2000 fps with a blank screen about 300x300 .. Is that normal, and what does this change exactly?
 
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 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
 
Back
Top