2

I'm using SharpDX 2.5.0 and I have a game class, and I try to disable the fixed time step, however it doesn't seem to work, I still get 59-60 FPS. I'm only drawing a utah teapot, so I'm pretty sure it must work with a lot more (like 1000) FPS. Here is what I do:

    protected override void LoadContent()
    {
        // ...

        // Disabling fix time step.
        this.IsFixedTimeStep = false;

        // ...

        base.LoadContent();
    }

Do I forget something? Do I have to apply this change somehow? Or am I doing it in the wrong place (I also tried doing it elsewhere without any success)? Thanks for the answers:

Muad'Dib

Muad'Dib
  • 47
  • 7

2 Answers2

3

You need to disable both vsync and fixed timestep, try to add this to the game constructor:

// GraphicsDeviceManager is mandatory for a Toolkit Game
_graphicsDeviceManager = new GraphicsDeviceManager(this);
// disable vsync
_graphicsDeviceManager.SynchronizeWithVerticalRetrace = false;
// disable fixed timestep
this.IsFixedTimeStep = false;
Artiom Ciumac
  • 414
  • 2
  • 10
  • I can confirm that this code needs to be IN THE CONSTRUCTOR. It does not work when placed inside the Initialize method. – Jaanus Varus Jun 14 '14 at 16:07
1

Have you also tried disabling vsync? If vsync is enabled and your monitor is running at 60Hz (very likely) then you will also see this behaviour. I'm not sure about the Game class but I usually do it in the PresentationParameters when creating the device.

new PresentParameters(width, height) {
    PresentationInterval = PresentInterval.Immediate
}

"Immediate" indicates that present will not wait for the monitor to refresh.

This is assuming D3D9, which version of DirectX are you using?

MattDavey
  • 8,897
  • 3
  • 31
  • 54
  • Now it became samewhat better, but it still doesn't work how it's supposed to. Now I get something like 170-180 FPS, even if I don't do anything at all in the Draw and Update methods, just counting the frames. Setting VSync doesn't seem to effect the FPS rate. I'm trying to create a D3D11 application. I also tried doing the same in SharpDX code samples using D3D11 and have the same issue. Note that when using D3D9 code samples I don't experience this low FPS issue. It would be great to see a working code, where the class is derived from SharpDX.Toolkit.Game and the FPS is high. – Muad'Dib Sep 08 '13 at 12:50
  • Try counting the frames for instance in the code sample Direct3D11.MiniTri. – Muad'Dib Sep 08 '13 at 13:09
  • @Muad'Dib Have you tried running a profiler to see which method is taking the most time? This is built in to Visual Studio in 2012 Professional and above, or there are several alternatives (some free, search ".NET free profiler"). – MattDavey Sep 09 '13 at 06:24
  • Profiling is more suited for CPU performance measurements, I kind of figured out, that this is not a SharpDX related issue anymore, but rather has something to do with my video card's (AMD Radeon HD 7670M) driver and/or some energy saving optimization or something like that, because if I switch to my other video card (Intel HD Graphics 4000) I get something like 2000 FPS (it doesn't really does anti-aliasing). It's very annoying that an optimazation like that is implemented such a way, that one cannot simply disable it with one uncheck... – Muad'Dib Sep 09 '13 at 07:30
  • That's true, a profiler would likely tell you that the system is waiting a very long time on the `Present` call. – MattDavey Sep 09 '13 at 08:42