The Problem of Vsync
blackhole0173.blogspot.com
blackhole0173.blogspot.com
I recall hearing that the reason the Video Toaster was an Amiga exclusive piece of hardware was the availability of the video clock as well.
I miss that stuff. But not all the time, double and triple buffering are certainly much easier. It was also possible quite easily to do double buffering on the Amiga, and I think it was probably much more common than the bare-metal copper approach. But for people who really wanted that level of control, it was there.
The various processors did give the Amiga amazing performance, but they also made it very difficult to update the Amiga hardware as time went on, as apps were tuned to the exact number of cycles which would occur before X or Y, and break if anything changed.
There were many examples of Amiga games breaking if you added even a RAM extension, as it threw off the timings, and programs expected to know exactly how the hardware was laid out.
I know of only one case where some german demo coders used CPU/chip timing to multiplex sprites to get more than 8 sprites per row.
Most of the timing bugs were of the kind that the CPU got faster(maybe due to code running from RAM not affected by custom chip cycles, or perhaps a 68020 or better was used) and neglected to wait for the blitter to be ready.
"Fast-RAM" was common enough after a few years to this not being a huge problem.
AmigaOS and the whole of Amiga was a thing of beauty IMHO.
At least that's my impression.
As another poster mentioned, it wasn't really a huge problem. Most programs were written correctly before Fast RAM was common, and afterwards, everyone knew about the issue.
A bigger memory related problem was that the original 68000 CPU had no MMU. The system APIs (for apps that weren't written to the bare metal) included the idea of shared and private memory. But on the 68K it didn't actually make any difference, it was all one big flat memory space addressable by every process. Later, on the 68020 and up, a real MMU was available, but so many programs had been written to just allocate everything in public memory that it was impractical to actually use that MMU properly. That's a major reason the OS never got real virtual memory despite having hardware that should have been capable of it on later models. Having dual-booted NetBSD on an A3000 for a while, my first Unix system at home, I can vouch for the hardware working properly.
On apple platforms, there is CVDisplayLink (osx) and CADisplayLink (ios), that triggers a notification on the vsync interrupt, which should give rock solid framerate-stability with minimum cpu-usage.
I've yet to find similar solutions to other modern platforms, which is a little disappointing. Though there is hope that vsync swapping is implemented little more sanely on other platforms. Also dwm (windows compositing window manager) has some more knobs to tune, don't know if they help.
For the input-lag, handling messages in a different thread than rendering should work, but doesn't help with battery-draining.
And also the input that comes as messages (keys, mouse) have timestamps on them, not sure if they are granular enough though. So while it might come with lag, at least you should be able to simulate the game state so it makes sense with the inputs you've provided
I wonder, do media players on windows work with pure luck or do they attempt some kludges try to keep the framerate stable, without burning the cpu/battery?
OpenGL infrastructure is so damn complicated - internally and externally. It seems to be impossible to write 3d graphics that work well in a modern environment when our API's are designed in the 1990's.
I actually at first tried to improve upon libwm, but didn't go too far with it. There were some design points I disagreed with, and you've seemed to stop updating, so I've started prototyping on my own codebase. I wanted some simplicity, and make it easier for various ffi-bridges, so I went with plain c.
The code is too raw, so I won't link to it, but I'll definitely make some noise when I think it is at usable state.
Another factor was that libwm supports a lot of legacy API's, like GLX 1.0. I wanted to support my g/f's crappy intel based macbook because at the time I was sometimes stuck that as my only computer.
Anyways, the morale of the story is: don't write system level libraries in C++ unless you want to spend the rest of your life writing C++.
Or better yet there should be a way of saying "use this buffer next time you update the screen" (and don't block during vblank time).
And you are calling the game now?
You don't think that's maybe a problematic sample to draw conclusions from?
I mean, from the point of view of iOS and PS3 games, DirectX is non-existent. Taking these kind of sub-samples of the total game market produces degenerate results.
Except that it is used, extensively; it's just not used much on Windows. Therefore, looking at Windows games and proclaiming that OpenGL is dying/dead is a really silly thing to do -- OpenGL ES knowledge is an extremely hot commodity among iOS and Android devs, etc.
This is the same on old and new kernels (anywhere from 2.6.38 to 3.0), and cross distro (Fedora and Ubuntu).
Vsync is great, it gives excellent image quality (no tearing), but brings an inevitable input lag as there is a delay as the frame syncs up to flip. You're not going to notice this on a gui or video, but it can be felt in twitch-games (1st person shooters especially, you'll find pro-gamer types often turn vsync off for this reason) as your input is essentially always at least a frame behind what is going on on screen.
Not sure how it works in opengl, but I recall triple buffering was to be the cure for all issues in d3d land, but as described in the post, it isn't.
For the time being it's something which has to be addressed in the game code itself by way of internally timing frames & such, if it's addressed at all :/