
OnRenderFrame elapsed time
Posted Sunday, 27 December, 2009 - 07:47 by Bicubic| Project: | The Open Toolkit library |
| Version: | 1.0-beta-3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I keep track of total elapsed time with something like
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); ...TotalTime += e.Time; .... Matrix4.CreateRotationY((float)TotalTime/400f); }
This is used to rotate a quad. On one machine, the rotation is smooth as expected. On another, the rotation is erratic. It slows down to a 10th of what I expect (while fraps reports a steady 60 fps, not that it should matter because we're measuring time and not frames), and speeds up to normal if I am dragging the window, or moving the mouse over the window border. Both are vista machines.


Comments
#1
I should also mention that the same with OnUpdateFrame works correctly on both machines.
#2
What parameters are you passing to the Run() method? Is vsync enabled on the second machine?
#3
game.Run(60.0);
VSync = VSyncMode.Adaptive;
If VSync is either off or on, this does not occur. Both driver configurations don't force vsync. The machine experiencing this issue is the more powerful one of the two.
#4
VSyncMode.Adaptiveexecutes this code (GameWindow.cs:494, RaiseRenderFrame method):As an experiment, what happens if you add a call to
VSync = VSyncMode.Onto the top of your RenderFrame handler? (In other words, is this behavior connected to enabling vsync continuously?)What video cards are these systems equipped with?
#5
Setting VSync to anything at the top of RenderFrame behaves no different than if the same parameter was set on load.
TargetRenderPeriod is showing as 0 on both machines.
Affected card is a 9600GT. Works well on an integrated intel chip, and had a friend test it with unknown hardware; also worked correctly there.
The difference that I see is that RaiseRenderFrame does not necessarily occur at the same rate as OnRenderFrame.
This version behaves correctly. If this adaptive mode is kept, it might be a good idea to have it take an average over a second or so before turning it off, or I can see it flicking off and on several times a second which will produce even worse jitter.
#6
The current approach for VSyncMode.Adaptive behaves like VSyncMode.On when a target framerate is not specified. I will revisit this issue once opentk-1.0 is released (the suggestion on average framerate is very interesting).
In the meantime, I have committed a slightly modified version of the above code, which should completely remove the jitter:
Conceptually, this works exactly like the code above. However, it removes the repeated calls to
Context.VSync = true, which seem to be the cause of the jitter.Committed to r2571.
#7
Cheers.
#8
Closing issues fixed in opentk-1.0-beta-3.