New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off fixed rate scheduling in OpenGL #4004

Merged
merged 1 commit into from Oct 16, 2015

Conversation

Projects
None yet
5 participants
@JakubValtar
Contributor

JakubValtar commented Oct 15, 2015

After some testing, it appears that fixed rate scheduling tries to catch
up later when it runs slower than desired, creating weird speedups when
the load decreases. Turning it back off.

Turn off fixed rate scheduling in OpenGL
After some testing, it appears that fixed rate scheduling tries to catch
up later when it runs slower than desired, creating weird speedups when
the load decreases. Turning it back off.
@gohai

This comment has been minimized.

Show comment
Hide comment
@gohai

gohai Oct 15, 2015

Just to relay a comment that I've received from @xranby: he suggested we use Animator instead of FPSAnimator. There's a patch here: gohai@0e2ee20

(Just want to throw this out for consideration, really don't know enough about the specifics here to have an opinion ;)

gohai commented on 179c8e6 Oct 15, 2015

Just to relay a comment that I've received from @xranby: he suggested we use Animator instead of FPSAnimator. There's a patch here: gohai@0e2ee20

(Just want to throw this out for consideration, really don't know enough about the specifics here to have an opinion ;)

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Oct 15, 2015

Owner

I was talking about this with @codeanticode previously. How are you going to control the frameRate with bare Animator?

Owner

JakubValtar replied Oct 15, 2015

I was talking about this with @codeanticode previously. How are you going to control the frameRate with bare Animator?

This comment has been minimized.

Show comment
Hide comment
@codeanticode

codeanticode Oct 15, 2015

See the second half of this comment.

codeanticode replied Oct 15, 2015

See the second half of this comment.

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Oct 16, 2015

Owner

Yeah, you can throttle it by V-Sync to fractions of display refresh rate (15, 30, 60), but to have, let's say 40, we would need something like LWJGL Sync which blocks the thread until the time is right. If we want to do this I can implement it whne I have time, I already had working version here.

Until it's done, this PR needs to be merged. It creates awful speedups.

Owner

JakubValtar replied Oct 16, 2015

Yeah, you can throttle it by V-Sync to fractions of display refresh rate (15, 30, 60), but to have, let's say 40, we would need something like LWJGL Sync which blocks the thread until the time is right. If we want to do this I can implement it whne I have time, I already had working version here.

Until it's done, this PR needs to be merged. It creates awful speedups.

@gohai

This comment has been minimized.

Show comment
Hide comment
@gohai

gohai Oct 15, 2015

Contributor
Contributor

gohai commented Oct 15, 2015

codeanticode added a commit that referenced this pull request Oct 16, 2015

Merge pull request #4004 from JakubValtar/animator-fix
Turn off fixed rate scheduling in OpenGL

@codeanticode codeanticode merged commit d1bd145 into processing:master Oct 16, 2015

@JakubValtar JakubValtar deleted the JakubValtar:animator-fix branch Oct 22, 2015

@barefists

This comment has been minimized.

Show comment
Hide comment
@barefists

barefists Feb 25, 2016

I'm having a problem where the FPS in my sketch rendered in P2D runs at odd framerates. When I set it at 60, it runs at 32, then when I set it at 30, it runs at 21.3. This doesn't happen all the time - sometimes it runs at the desired FPS, and other times, it seems to throttle at a very specific number mentioned above.

Googling about this problem in Processing yields no result, however when I search with regards to JOGL, I ran across this post: http://stackoverflow.com/questions/12936690/why-does-this-code-sometimes-report-21-3-fps-when-i-ask-for-30-fps

It caught my eye because of the oddly specific throttled FPS number "21.3". The thread seems to point to inaccuracy of java.util.Timer.schedule(), which may be fixed by turning on fixed-rate scheduling in FPSAnimator. I know there's a good reason why you turned off fixed-rate scheduling in JOGL, but can you suggest a workaround for my case? Thanks!

barefists commented Feb 25, 2016

I'm having a problem where the FPS in my sketch rendered in P2D runs at odd framerates. When I set it at 60, it runs at 32, then when I set it at 30, it runs at 21.3. This doesn't happen all the time - sometimes it runs at the desired FPS, and other times, it seems to throttle at a very specific number mentioned above.

Googling about this problem in Processing yields no result, however when I search with regards to JOGL, I ran across this post: http://stackoverflow.com/questions/12936690/why-does-this-code-sometimes-report-21-3-fps-when-i-ask-for-30-fps

It caught my eye because of the oddly specific throttled FPS number "21.3". The thread seems to point to inaccuracy of java.util.Timer.schedule(), which may be fixed by turning on fixed-rate scheduling in FPSAnimator. I know there's a good reason why you turned off fixed-rate scheduling in JOGL, but can you suggest a workaround for my case? Thanks!

@xranby

This comment has been minimized.

Show comment
Hide comment
@xranby

xranby Feb 25, 2016

Contributor

As JakubValtar suggested, the best way to get non-odd numbers such as V-Sync to fractions of display refresh rate (15, 30, 60) then processing should use Animator instead of FPSAnimator. Using a class such as the standalone https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/Sync.java can of course be combined with the Animator to slow it down to the expected framerate, you do this by then running Animator with sync set to 0 and then use the Sync class to throttle it down to the desired FPS.

Contributor

xranby commented Feb 25, 2016

As JakubValtar suggested, the best way to get non-odd numbers such as V-Sync to fractions of display refresh rate (15, 30, 60) then processing should use Animator instead of FPSAnimator. Using a class such as the standalone https://github.com/LWJGL/lwjgl/blob/master/src/java/org/lwjgl/opengl/Sync.java can of course be combined with the Animator to slow it down to the expected framerate, you do this by then running Animator with sync set to 0 and then use the Sync class to throttle it down to the desired FPS.

@barefists

This comment has been minimized.

Show comment
Hide comment
@barefists

barefists Feb 25, 2016

So my current workaround hack is to set frameRate at 70 and swap interval to 1, which brings it back down to my target FPS of 60 on my current monitor. Very hacky, and it'll probably break if I encounter a monitor with another refresh rate, but I don't have much of a choice at the moment. Do let me know if there are any changes regarding this topic. :)

barefists commented Feb 25, 2016

So my current workaround hack is to set frameRate at 70 and swap interval to 1, which brings it back down to my target FPS of 60 on my current monitor. Very hacky, and it'll probably break if I encounter a monitor with another refresh rate, but I don't have much of a choice at the moment. Do let me know if there are any changes regarding this topic. :)

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Feb 25, 2016

Contributor

Thanks guys, I will give Animator a shot in combination with LWJGL Sync and hopefully it will improve your frame rate.

I think I got it working before, but didn't see any noticable difference from what we have (except for adding bunch of new code).

Contributor

JakubValtar commented Feb 25, 2016

Thanks guys, I will give Animator a shot in combination with LWJGL Sync and hopefully it will improve your frame rate.

I think I got it working before, but didn't see any noticable difference from what we have (except for adding bunch of new code).

@JakubValtar

This comment has been minimized.

Show comment
Hide comment
@JakubValtar

JakubValtar Feb 25, 2016

Contributor

Just a quick question for @xranby, do you think it is possible to use Animator + Sync together with VSync? Right now we set setSwapInterval as follows:

  • 60: setSwapInterval(0)

  • 60-30: setSwapInterval(1)
  • < 30: setSwapInterval(2)
Contributor

JakubValtar commented Feb 25, 2016

Just a quick question for @xranby, do you think it is possible to use Animator + Sync together with VSync? Right now we set setSwapInterval as follows:

  • 60: setSwapInterval(0)

  • 60-30: setSwapInterval(1)
  • < 30: setSwapInterval(2)
@xranby

This comment has been minimized.

Show comment
Hide comment
@xranby

xranby Feb 25, 2016

Contributor

i think Animator + Sync can work well together with VSync. sync calculates the optimal time to delay the draw frame to archive the desired FPS.

The Sync class needs a JogAmp provided accurate timer function:
JogAmp gluegen have the currentTimeMicros that can be used in the Sync class.
https://jogamp.org/deployment/v2.3.2/javadoc/gluegen/javadoc/com/jogamp/common/os/Platform.html

Contributor

xranby commented Feb 25, 2016

i think Animator + Sync can work well together with VSync. sync calculates the optimal time to delay the draw frame to archive the desired FPS.

The Sync class needs a JogAmp provided accurate timer function:
JogAmp gluegen have the currentTimeMicros that can be used in the Sync class.
https://jogamp.org/deployment/v2.3.2/javadoc/gluegen/javadoc/com/jogamp/common/os/Platform.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment