Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Fixed TimeStep 1 Core nearly 100 %  (Read 2119 times)

0 Members and 1 Guest are viewing this topic.

CodingDolphin

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Fixed TimeStep 1 Core nearly 100 %
« on: July 14, 2014, 10:12:35 am »
Dear Lady's and Gentlemen,

i have a Problem, i try to get a Fixed Timestep Loop running. I got it so far that it now has the same Framerate on 60 or 99999(and everything between).

If i use VSYNC the Programm need a whole Core to run this simple Program. --> http://snag.gy/kADOW.jpg

BUT

If i use SetMaxFrameRate(60) i use just 1 - 3 % of my CPU --> http://snag.gy/byQlA.jpg

Can somebody please tell me where is the Problem of my Code?

http://pastebin.com/5XtkgJDC

(click to show/hide)

Greetings

Dolphin
« Last Edit: July 14, 2014, 10:15:10 am by CodingDolphin »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Fixed TimeStep 1 Core nearly 100 %
« Reply #1 on: July 14, 2014, 10:23:04 am »
Oh this is C# something code. Was just confused about your CamelCase bits. ;D

As for VSync, check your driver settings. Some drivers allow you to force VSync off, so the setting with SFML, will have no affect.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CodingDolphin

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Fixed TimeStep 1 Core nearly 100 %
« Reply #2 on: July 14, 2014, 10:46:45 am »
Thanks for the quick reply,

i did change now my NVIDA Setting's to forced on and let the program decide. With VSYNC on my Program still use the Full Core.

Greetings

WhySoSad

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Fixed TimeStep 1 Core nearly 100 %
« Reply #3 on: July 14, 2014, 10:54:19 am »
Then it might be a cheap/bad implementation of VSync in your driver. To get zero latency they sometimes using a spinlock or something like that, which will make out the CPU, but they then can at least guarantee proper VSync.

With "Fixed TimeStep" in your title, are you trying to fix your frame time with VSync, so you get a fixed timestep for your logic, or were you actually talking about fixed timestep?
If it was the first, then stop now. You should not try to fix your frame time and then use it for your calculations. Always assume that the frametime will be jumping, as such you might want to look at the link above.
If you actually meant what is mentioned in the linked article, then there's no reason in requiring VSync at all cost. Your logic will already be independent of whatever your frame time does.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

CodingDolphin

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Fixed TimeStep 1 Core nearly 100 %
« Reply #4 on: July 14, 2014, 11:04:00 am »
Then it might be a cheap/bad implementation of VSync in your driver. To get zero latency they sometimes using a spinlock or something like that, which will make out the CPU, but they then can at least guarantee proper VSync.

With "Fixed TimeStep" in your title, are you trying to fix your frame time with VSync, so you get a fixed timestep for your logic, or were you actually talking about fixed timestep?
If it was the first, then stop now. You should not try to fix your frame time and then use it for your calculations. Always assume that the frametime will be jumping, as such you might want to look at the link above.
If you actually meant what is mentioned in the linked article, then there's no reason in requiring VSync at all cost. Your logic will already be independent of whatever your frame time does.

Very very strange, i have a up to date NVIDA Driver, and yes i try the second one may i have a mistake in my Code? But it seems too work.

Unfornatly i dont have any Content in my Project so i can't test if this will cause later Stutter with more Content and AI Calculation's and Stuff.

Greetings

Dolphin

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Fixed TimeStep 1 Core nearly 100 %
« Reply #5 on: July 14, 2014, 11:24:46 am »
It's not about having an up to date driver, this is intended behavior by NVidia. You could kind of think of it as if you had implemented a busy-waiting loop to make sure that you render only when the refreshing for the monitor is happening, all the other time is spent just looping around doing nothing.
But if you now were to implement some logic for your game, the busy-waiting loop will do iterations. That way your CPU core will always be maxed, but you still got frame time left for your logic.

If it's really the case, then you shouldn't get stuttering later on, unless you implemented it wrong (I didn't check any of your code bits).
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/