August 22, 2019, 06:52:56 AM

Author Topic: AGK - Getting worse over time?  (Read 1326 times)

Offline blinkok

  • Full Member
  • ***
  • Posts: 112
Re: AGK - Getting worse over time?
« Reply #15 on: July 30, 2019, 04:47:18 AM »
1. the select option for code does not work with firefox
2. I guarantee that the slowdown is because they have left debug on in vulkan

All three binaries run at 60fps for me

Try running with the VulkanDebugPlayer9.exe from the vulkan thread

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
Re: AGK - Getting worse over time?
« Reply #16 on: July 30, 2019, 05:13:27 AM »
Quote
1. the select option for code does not work with firefox
Stupid Firefox ;D

Quote
2. I guarantee that the slowdown is because they have left debug on in vulkan
Nope, it's present in AGK Classic after version 2018-07-12 too. Along with frame rate stutter. It's also present in both FPS drop and stutter with AGK Studio on MacOS which doesn't even have the Vulkan engine enabled.

Quote
All three binaries run at 60fps for me
Did they all have smooth scrolling when watched for a few minutes?, any frame jumping?. What was the FPS performance like when you switched off vSync ( press S but ignore scroll smoothness )?

Quote
Try running with the VulkanDebugPlayer9.exe from the vulkan thread
It's not a Vulkan issue. The issue crept almost a year ago with AGK Classic along with the knackered IDE on MacOS.
Until the next time...

Offline blinkok

  • Full Member
  • ***
  • Posts: 112
Re: AGK - Getting worse over time?
« Reply #17 on: July 30, 2019, 05:24:32 AM »
Quote
Did they all have smooth scrolling when watched for a few minutes?, any frame jumping?. What was the FPS performance like when you switched off vSync ( press S but ignore scroll smoothness )?
They all scrolled smoothly. There was stutter with the very slow objects (in all versions) but i think that's the nature of using floats to move something at a very slow rate
Vsync off was
07-12 1200
06-11 1200
07-23 1100-1200

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
Re: AGK - Getting worse over time?
« Reply #18 on: July 30, 2019, 05:48:17 AM »
So everything worked pretty spot on for you which is very odd and confusing, lol.

Quote
There was stutter with the very slow objects (in all versions) but i think that's the nature of using floats to move something at a very slow rate
Sub-pixel rendering should be fine so perhaps something else is going on here as it's silky smooth for me.
Until the next time...

Offline blinkok

  • Full Member
  • ***
  • Posts: 112
Re: AGK - Getting worse over time?
« Reply #19 on: July 30, 2019, 05:56:01 AM »
Quote
Sub-pixel rendering should be fine so perhaps something else is going on here as it's silky smooth for me.

As reported by Derron
Quote
Watch the "slow and big" balls - they do not move "smooth" when they are slow (but not the slowest).

I think there is a mac/windows issue for sure.

One thing i just cannot understand is why Rick only got 30fps, so i think there is definitely something going on.

I didn't know hat vulkan wouldn't be available for mac. Is is that something for later on?

Offline Derron

  • Hero Member
  • *****
  • Posts: 2334
Re: AGK - Getting worse over time?
« Reply #20 on: July 30, 2019, 07:03:17 AM »
Quote
Watch the "slow and big" balls - they do not move "smooth" when they are slow (but not the slowest).

I think there is a mac/windows issue for sure.

I tested this on Linux.



Do my games that you've played have tearing too?. It's just that all those have delta timing for 60FPS whereas the example code / binaries for this test are just pure sync with no timing so should lock to your monitors refresh.
Cannot remember any tearing - but the games were no "horizontal scroller" ones where tearing would be visible so easily ("space ship torn apart").

Nonetheless I temporarily disabled my second screen - and the tearing was gone (while the "59.xxx" value stayed. So I will have to port your sample code to NG to check it with some other renderers (especially SDL). I think it is an issue with Linux + Nvidia-driver + engines (here AGK) to wait for/accept/receive the wrong vsync-signal.
This of course must not have to do with the "stuttering" others see.
I assume it most probably happens to certain object speeds - too fast objects "smear" along the screen (for your eyes) so the movement is too fast to recognize jitters. Too slow objects just have so low jitters that it should not be visible too - here the visual problem is the "throbbing" or "pumping" of the textures based on the way AGK does subpixel rendering (monitor position is fixed but texture is tried to be on int positions too).
If you have "slow-to-mid" speeded balls then you can see jittering - the movement is not steady. When you calculate your delta this is happening in the "physics" stage (when calculations are done) and until the "render" stage happens, some microseconds more or less are gone (not-steady) so the calculated movement must not necessarily fit exactly to what is to render in that very moment.

Ok... have had a look at your code and you do not use delta-timing at all (which is obvious once you remove "vsync" and the balls just move in lightingspeed). This very very much explains why it can jitter: time between the renders is not guaranteed to be stable - and so the movement isn't guaranteed to be stable too. You might add a "start/stop" key which you can press once your system "has settled" and it then stores low,avg,max fps (as the one in that agk-thread suggested). The difference between min and max is what makes your jitter.
You then just have to find out WHY there is a difference as a hardware vsync should take care of this already (the "start" after a vsync happened is always at the same time difference to the "last vsync" so the handling of all your balls happens at this "fixed" rate).


bye
Ron

Offline 3DzForMe

  • Hero Member
  • *****
  • Posts: 615
Re: AGK - Getting worse over time?
« Reply #21 on: July 30, 2019, 07:56:06 AM »
Great analysis Derron, AGK should take you on as a contractor ;)

Offline Derron

  • Hero Member
  • *****
  • Posts: 2334
Re: AGK - Getting worse over time?
« Reply #22 on: July 30, 2019, 09:02:40 AM »
This is a port of your code to NG + some deltaTime stuff. Tried to do stuff in the very same order than you (so render balls before moving them and so on).

I get more jitter wit hthe "gl2sdlgraphics" from NG than with the "classic" one (no shaders). Yet both begin to jitter in a later stage.
I also get screen tearing with both renderers so I assume it is an issue with the driver / settings / dual screen setup.


Code: BlitzMax
  1. SuperStrict
  2. Framework Brl.StandardIO
  3. Import SDL.SDLTimer
  4. Import SDL.d3d9sdlmax2d
  5. Import SDL.gl2sdlmax2d
  6. Import SDL.glsdlmax2d
  7. Import Brl.PNGLoader
  8. Import Brl.Random
  9.  
  10.  
  11.  
  12. global vsync:int = True
  13. global useDeltaTime:int = False
  14. global screenW:int = 1920 'DesktopWidth()
  15. global screenH:int = 1080 'DesktopHeight()
  16. global renderer:int = 0
  17. global rendererString:string
  18.  
  19.  
  20. Select renderer
  21.                 Case 0
  22.                                 SetGraphicsDriver GLMax2DDriver()
  23.                                 rendererString = "GLMax2DDriver"
  24.                 Case 1
  25.                                 SetGraphicsDriver GL2Max2DDriver()
  26.                                 rendererString = "GL2Max2DDriver"
  27.                 ?win32
  28.                 Case 2
  29.                                 SetGraphicsDriver D3D9SDLMax2DDriver()
  30.                                 rendererString = "D3D9SDLMax2DDriver"
  31.                 ?
  32. End Select
  33.  
  34. Graphics(screenW, screenH, 32)
  35. 'SetVirtualResolution(screenW, screenH)
  36. HideMouse()
  37.  
  38.  
  39.  
  40.  
  41. Type TBall
  42.         Field x:Float
  43.         Field y:Float
  44.         Field speed:Float
  45.         Field size:int
  46. End Type
  47.  
  48.  
  49. Global balls:TBall[200]
  50. Global ballImage:TImage = LoadImage( "media/ball.png", DYNAMICIMAGE)
  51. For Local count:int = 1 To 200
  52.         balls[count] = new TBall
  53.         balls[count].x = Rand( 0, 1919 )
  54.         balls[count].y = Rand( 0, 1079 )
  55.         balls[count].speed = Rand( 1, 6 ) + ( Rand( 1, 50 ) / 100.0 )
  56.         balls[count].size = Rand( 32, 32 * 4 )
  57. Next
  58.  
  59.  
  60. 'fps handling
  61. Global lastTime:int = Millisecs()
  62. Global timeGone:int
  63. Global timesRendered:int
  64. Global loopBeginTime:int
  65. Global fpsMin:int = -1, fpsMax:int = -1, fpsCurrent:int
  66. Global deltaTime:Float
  67.  
  68. Repeat
  69.         timeGone :+ Millisecs() - lastTime
  70.         deltaTime = (Millisecs() - lastTime) / 1000.0
  71.         lastTime = Millisecs()
  72.         if timeGone > 1000
  73.                 'scale if more than 1000ms are gone...
  74.                 fpsCurrent = timesRendered * (timeGone/1000.0)
  75.                 if fpsMin = -1 or fpsMin > fpsCurrent then fpsMin = fpsCurrent
  76.                 if fpsMax = -1 or fpsMax < fpsCurrent then fpsMax = fpsCurrent
  77.                 timeGone = 0
  78.                 timesRendered = 0
  79.         endif
  80.         if KeyHit(KEY_S) then vsync = 1 - vsync
  81.         if KeyHit(KEY_D) then useDeltaTime = 1 - useDeltaTime
  82.  
  83.         cls
  84.         For Local count:int = 0 To balls.length
  85.                 SetScale(balls[count].size /32.0, balls[count].size /32.0)
  86.                 'draw at OLD position
  87.                 DrawImage(ballImage, balls[count].x, balls[count].y)
  88.                 SetScale(1, 1)
  89.  
  90.                 'move to NEW position
  91.                 if useDeltaTime
  92.                         'speed is given in "per 60", so we need to multiply * 60
  93.                         balls[count].x :+ balls[count].speed * deltaTime * 60
  94.                 else
  95.                         balls[count].x :+ balls[count].speed
  96.                 endif
  97.                 If balls[count].x > 1920 Then balls[count].x = 1920 - balls[count].x - balls[count].size
  98.         Next
  99.  
  100.         DrawText("vsync: " + vsync, 10, 10)
  101.         DrawText("FPS:   " + fpsCurrent + " ("+fpsMin +" - " + fpsMax+")", 10, 30)
  102.         DrawText("delta:   " + useDeltaTime + " ("+string(deltaTime)[..6]+"ms)", 10, 50)
  103.         flip vsync
  104.  
  105.         timesRendered :+ 1
  106. Until AppTerminate() or KeyHit(KEY_ESCAPE)
  107.  


PS: With GLMax2D I reach 3200 fps (compared to the 2000 of AGK) and with GL2Max2D (very basic shader-based rendering) I reach 2400. Maybe it is the "tier 1" kicking in?

bye
Ron

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 1917
Re: AGK - Getting worse over time?
« Reply #23 on: July 30, 2019, 09:06:26 AM »
Quote
I also get screen tearing with both renderers so I assume it is an issue with the driver / settings / dual screen setup.

Yep, like I said I don't get tearing on my (non dual screen) Linux System.

https://www.syntaxbomb.com/index.php/topic,5872.msg28206/topicseen.html#new

Quote
PS: With GLMax2D I reach 3200 fps (compared to the 2000 of AGK) and with GL2Max2D (very basic shader-based rendering) I reach 2400. Maybe it is the "tier 1" kicking in?

I get 2800 FPS for the quickest build of AGK and AGK is not compiled to machine code, but to bytecode and then interpreted.
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.1, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspbian Buster, pi4 4Gb RAM,1.5Ghz

Offline Derron

  • Hero Member
  • *****
  • Posts: 2334
Re: AGK - Getting worse over time?
« Reply #24 on: July 30, 2019, 09:37:19 AM »
Sorry for offtopic:
Code: [Select]
nvidia-settings --assign CurrentMetaMode="$(nvidia-settings -q CurrentMetaMode -t|tr '\n' ' '|sed -e 's/.*:: \(.*\)/\1\n/g' -e 's/}/, ForceCompositionPipeline = On}/g')" > /dev/nullAnd the tearing was gone ... will have to put it into a startup file ;-)


bye
Ron

Offline Steve Elliott

  • Hero Member
  • *****
  • Posts: 1917
Re: AGK - Getting worse over time?
« Reply #25 on: July 30, 2019, 09:40:28 AM »
Cool.  Glad you got it fixed.
Windows 10, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
MacOS Mojave, 64-bit, 8Gb RAM, CPU Intel i5, 2.3 Ghz, Intel Iris Plus Graphics 640 1536 MB.
Linux Mint 19.1, 64-bit, 16Gb RAM, CPU Intel i5, 3.2 GHz, Nvidia GeForce GTX 1050 (2Gb).
Raspbian Buster, pi4 4Gb RAM,1.5Ghz

Offline c0d3r9

  • Full Member
  • ***
  • Posts: 139
Re: AGK - Getting worse over time?
« Reply #26 on: July 30, 2019, 09:21:32 PM »
I have to smile a little bit.
I saw Ricks screenrecords and i remember that i have that shaking sprites since i use AGK.
Nobody have an solution for that and this problem have many other engines too?
VSync helps a lot but not in all cases.
Freesync could be a good solution to drop such issues.
Stuttering after a short "warmup" ;) every x seconds.Its definitely a sync problem.(that what i read some month ago of many many websites/forums etc.)
I test it all atm on my non-vulkan laptop so the framedrop is opengl related.I will test how many fps are possible if the update allows change between opengl and vulkan.
Laptop: Win10@64bit - i3 2x2Ghz - 8GB Ram - 1TB HDD
Desktop: Win10@64bit - AMD Ryzen 5 2400G - MSI B450 Tomahawk - 8GB Ram - 240GB SSD

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
Re: AGK - Getting worse over time?
« Reply #27 on: July 30, 2019, 09:33:24 PM »
You'll never get 100% constant uninterrupted 2D silky smooth scrolling on modern OS's as there is so much junk going on in the background that it's bound to skip a beat from time to time.

All I know is that AGK Classic 2018-07-12 was the most constant at being smooth across all OS's ( and the fastest with vSync off ). In my games I use vSync on + delta time movement with a target frame rate of 60FPS. It's worked overall really well but after noticing in later versions of AGK it getting worse and now the new AGK Studio being the worst I'm amazed no-one else has said anything.

Perhaps the serious game makers in AGK are make 3D games or don't really aim for silky smooth 2D games. If I was happy with 30FPS or less for 2D then I'd be happy in jerky jerk jerk land but I'm old and anal about smooth scrolling for 2D games :P

Until the next time...

Offline c0d3r9

  • Full Member
  • ***
  • Posts: 139
Re: AGK - Getting worse over time?
« Reply #28 on: July 30, 2019, 09:39:41 PM »
Quote
All I know is that AGK Classic 2018-07-12 was the most constant at being smooth across all OS's ( and the fastest with vSync off ). In my games I use vSync on + delta time movement with a target frame rate of 60FPS. It's worked overall really well but after noticing in later versions of AGK it getting worse and now the new AGK Studio being the worst I'm amazed no-one else has said anything.
Yes it seems that you´re right.
And i haven´t compared the different version because i have always vsync on.

Quote
Perhaps the serious game makers in AGK are make 3D games or don't really aim for silky smooth 2D games. If I was happy with 30FPS or less for 2D then I'd be happy in jerky jerk jerk land but I'm old and anal about smooth scrolling for 2D games :P
Thats so true...  ;D
Laptop: Win10@64bit - i3 2x2Ghz - 8GB Ram - 1TB HDD
Desktop: Win10@64bit - AMD Ryzen 5 2400G - MSI B450 Tomahawk - 8GB Ram - 240GB SSD

Offline Qube

  • Administrator
  • Hero Member
  • *****
  • Posts: 2046
Re: AGK - Getting worse over time?
« Reply #29 on: July 30, 2019, 09:46:52 PM »
This is a port of your code to NG + some deltaTime stuff. Tried to do stuff in the very same order than you (so render balls before moving them and so on).
Cool, tried this on MacOS with BlitzMax NG and it ran every well indeed with only the very occasional judder too. As this nigh on matches how AGK 2018-07-02 works for me it further just clarifies that something has gone wrong in later version of AGK.
Until the next time...