AGK - Getting worse over time?

Started by Qube, July 27, 2019, 02:44:05

Previous topic - Next topic

blinkok

#15
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

Qube

Quote1. the select option for code does not work with firefox
Stupid Firefox ;D

Quote2. 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.

QuoteAll 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 )?

QuoteTry 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.
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

blinkok

QuoteDid 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

Qube

So everything worked pretty spot on for you which is very odd and confusing, lol.

QuoteThere 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.
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

blinkok

QuoteSub-pixel rendering should be fine so perhaps something else is going on here as it's silky smooth for me.

As reported by Derron
QuoteWatch 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?

Derron

Quote from: blinkok on July 30, 2019, 05:56:01
QuoteWatch 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.



Quote from: Qube on July 29, 2019, 23:29:32
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

3DzForMe

Great analysis Derron, AGK should take you on as a contractor ;)
BLitz3D, IDEal, AGK Studio, BMax, Java Code, Cerberus
Recent Hardware: Dell Laptop
Oldest Hardware: Commodore Amiga 1200 with 1084S Monitor & Blitz Basic 2.1

Derron

#22
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) Select

SuperStrict
Framework Brl.StandardIO
Import SDL.SDLTimer
Import SDL.d3d9sdlmax2d
Import SDL.gl2sdlmax2d
Import SDL.glsdlmax2d
Import Brl.PNGLoader
Import Brl.Random



global vsync:int = True
global useDeltaTime:int = False
global screenW:int = 1920 'DesktopWidth()
global screenH:int = 1080 'DesktopHeight()
global renderer:int = 0
global rendererString:string


Select renderer
Case 0
SetGraphicsDriver GLMax2DDriver()
rendererString = "GLMax2DDriver"
Case 1
SetGraphicsDriver GL2Max2DDriver()
rendererString = "GL2Max2DDriver"
?win32
Case 2
SetGraphicsDriver D3D9SDLMax2DDriver()
rendererString = "D3D9SDLMax2DDriver"
?
End Select

Graphics(screenW, screenH, 32)
'SetVirtualResolution(screenW, screenH)
HideMouse()




Type TBall
Field x:Float
Field y:Float
Field speed:Float
Field size:int
End Type


Global balls:TBall[200]
Global ballImage:TImage = LoadImage( "media/ball.png", DYNAMICIMAGE)
For Local count:int = 1 To 200
balls[count] = new TBall
balls[count].x = Rand( 0, 1919 )
balls[count].y = Rand( 0, 1079 )
balls[count].speed = Rand( 1, 6 ) + ( Rand( 1, 50 ) / 100.0 )
balls[count].size = Rand( 32, 32 * 4 )
Next


'fps handling
Global lastTime:int = Millisecs()
Global timeGone:int
Global timesRendered:int
Global loopBeginTime:int
Global fpsMin:int = -1, fpsMax:int = -1, fpsCurrent:int
Global deltaTime:Float

Repeat
timeGone :+ Millisecs() - lastTime
deltaTime = (Millisecs() - lastTime) / 1000.0
lastTime = Millisecs()
if timeGone > 1000
'scale if more than 1000ms are gone...
fpsCurrent = timesRendered * (timeGone/1000.0)
if fpsMin = -1 or fpsMin > fpsCurrent then fpsMin = fpsCurrent
if fpsMax = -1 or fpsMax < fpsCurrent then fpsMax = fpsCurrent
timeGone = 0
timesRendered = 0
endif
if KeyHit(KEY_S) then vsync = 1 - vsync
if KeyHit(KEY_D) then useDeltaTime = 1 - useDeltaTime

cls
For Local count:int = 0 To balls.length
SetScale(balls[count].size /32.0, balls[count].size /32.0)
'draw at OLD position
DrawImage(ballImage, balls[count].x, balls[count].y)
SetScale(1, 1)

'move to NEW position
if useDeltaTime
'speed is given in "per 60", so we need to multiply * 60
balls[count].x :+ balls[count].speed * deltaTime * 60
else
balls[count].x :+ balls[count].speed
endif
If balls[count].x > 1920 Then balls[count].x = 1920 - balls[count].x - balls[count].size
Next

DrawText("vsync: " + vsync, 10, 10)
DrawText("FPS:   " + fpsCurrent + " ("+fpsMin +" - " + fpsMax+")", 10, 30)
DrawText("delta:   " + useDeltaTime + " ("+string(deltaTime)[..6]+"ms)", 10, 50)
flip vsync

timesRendered :+ 1
Until AppTerminate() or KeyHit(KEY_ESCAPE)



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

Steve Elliott

#23
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.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Derron

Sorry for offtopic:
nvidia-settings --assign CurrentMetaMode="$(nvidia-settings -q CurrentMetaMode -t|tr '\n' ' '|sed -e 's/.*:: \(.*\)/\1\n/g' -e 's/}/, ForceCompositionPipeline = On}/g')" > /dev/null
And the tearing was gone ... will have to put it into a startup file ;-)


bye
Ron

Steve Elliott

Cool.  Glad you got it fixed.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

plenatus

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.

Qube

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

Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

plenatus

QuoteAll 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.

QuotePerhaps 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

Qube

Quote from: Derron on July 30, 2019, 09:02:40
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.
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.