Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(4 edits) (+1)

I'm still at solving technical issues 

finally figured out a solution for the vsync problem:
- so the thing is the rendering and game logic was optimised out of the wazoo but there were still problems
- turns out swapping the buffers takes time too - and if vsync is turned on it pretty much blocks everything
- also I need to issue a glFinish (it just waits until all drawing operations are complete) otherwise I get weird flickering
- in theory the video card (or gpu) and cpu work in parallel so you could just wait until the gpu finishes
- but in practice the gpu driver is usually a weird black box where anything can happen inside
(e.g. you have no control over triple buffering - only  works in fullscreen - or not - if the gpu feels like it - and afaik that is for every graphics api)
- so I had to move the rendering into a seperate thread
- which at first sounds sensible and obvious but sharing an opengl context between two windows is a minefield
- so now the game works great on my laptop (which is about 10 years old btw)
- works great on my potato machine for testing ( win XP and 20 years old)
- and goes completely wackoo on my third test machine (3 years old  Win10  and has some bogus Intel celeron gpu)
- it's a driver problem on the last one but I cannot seem to update the driver (installer just doesn't start and it's supposed to be the latest )
- the good news is that the game is fully playable otherwise and there are just some graphical shenanigans .. but it bothers me 
- now the strange thing is I measure about 10-12ms for the vsync swap on single thread
- but now that it's on a seperate thread it's only 1-2ms
- also all rendering had to be moved to the seperate thread because I cannot just swap in a different thread - I'm not sure why
- so my main problem is that things seem to behave a bit differently  on every PC
- I looked into other frameworks and engines and they seem to have the same problem - so at least I'm not the one who got mad

- and I almost forgot the best part - in the end I had to revert to the old single thread rendering
because using more than one thread caused the textures to not load
(sharing textures between context just doesn't seem to work as intended .. or there is some black magic trick to it that I'm not aware of )

- in the end what optimisation that sort of worked is to put the cart before the horse: do the rendering first and then the game update
and in the end I gave up on vsync -  of course this was just a quest to get vsync work with 60fps  so nothing really happened
and there is now just a choice in the options  to turn it on - with vsync on you get 30fps tops but no weird glitches
otherwise the game renders at 60fps and either has tearing or glitches or not

some exclusive shaky cam footage running on my  mini-laptop (win10 and worlds crappiest gpu)

of course I didn't quite master recording  and playing at the same time


anyway moving on to problems actually caused by my shenanigans:
- so I added an optimization where enemies don't bother to update their physics until  they get activated
- this resulted in an amusing scenario - where I placed a miniboss on a vent
and after it notices you the physics kick in and he immediately flies upwards Mach3.. observe:

until next time!

(+1)

Hmm, glFinish and then processing was tricky only at first glace.

As i understand this: when you process/render-calls, you only give data to driver(starts rendering at same time as get data, but really blackbox), then call glFinish and now it's time to render rest of data return control, but only when finished everything including buffer swapping. (glFinishTime= ~16ms - processTime)

And if you glFinish at start, you just ensure all old draw calls already rendered and buffer already swapped for elapsed <16ms from last frame, and now can prepare next portion.

And yes, it's me, unfortunate LAB remaker from 2019... Still has a terrible english and watching for your projects.

it's nice to see that you are still around !
(why LAB got so popular on itch i'll never know )

right now i ditched glFinish completely (swapbuffer is supposed to call it ? I just dont know anymore.. but seems to work better now)
and just do a glFlush .. the thing is no matter what I do everything works until I try to turn on vsync or try to add a second thread..
anway in hindsight I should have made a 30fps game instead - it's hard for me to tell the difference anyway
it's just wacky that in this age we can draw million-billion triangles  but draw calls and timing is still a problem