| |
Mr SQL
Registered: Feb 2023 Posts: 158 |
Multiple Buffering Demos
This thread is inspired by Sokrates double buffering thread:
Release id #252024 : C64ColorRamDoubleBuffer
In computer science, multiple buffering is the use of more than one buffer to hold a block of data, so that a "reader" will see a complete (though perhaps old) version of the data instead of a partially updated version of the data being created by a "writer".
https://en.wikipedia.org/wiki/Multiple_buffering
Are there any Multiple Buffering Demos?
This demo shows one example:
Christmas Inertia
This example is frame based. The display buffers are prepared prior to rendering the screen and can be updated with lazy writes while the screen is displayed.
The colorRAM in this example is static but the development kit now supports multiple buffering for colorRAM. |
|
... 5 posts hidden. Click here to view all posts.... |
| |
chatGPZ
Registered: Dec 2001 Posts: 11499 |
Mmmh i have used triple buffers somewhere - but i can't remember what effect it was /o\ |
| |
WVL
Registered: Mar 2002 Posts: 923 |
The bitmap-mover in Halloweed IV uses a triple buffer. This is to save cycles preparing the next bitmap (which is shifted up by 6 rows). The part copies bytes from the displayed bitmap to the next bitmap (but 6 rows higher) and can reuse the byte for the third bitmap (12 rows higher).
This was needed to make the >25 rows of bitmap data possible (besides copying the bitmap up, the part also has to copy a new line at the bottom in each frame and the data also gets reused in bitmaps 2 and 3). Without triple buffering the copying was too slow.
The copies are also optimized to not pass page boundaries and such things. |
| |
hollowman
Registered: Dec 2001 Posts: 475 |
Nothing But Code/Beyond Force
"...a piece of advice to coders outthere: use triple buffering to prevent frame update bugs.
.. i've seen some terrible bugs in c64 and pc-demos lately." |
| |
mankeli
Registered: Oct 2010 Posts: 152 |
First effect in Skybox (scrolling petscii screen) was doublebuffered! :P
But since it was in screen mode, and d800 can't be doublebuffered in full resolution, it was updated in several passes less tall passes while racing the beam..
And afaik on Atari ST, some of the largest rotating 3d objects are done with multiple buffers (like 16 or more) in a such way that CPU renders frames as fast as it can, and then interrupt switches buffers 50Hz. It's a very obvious thing but apparently not very common on Amiga or something :) |
| |
Monte Carlos
Registered: Jun 2004 Posts: 370 |
I feel,the technique is too widely applied to discuss in a thread. Even mentioning only the names of releases with dbl bffr would fill a bible. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11499 |
It'd indeed be easier to just list the ones that claim to do so, but actually don't :) |
| |
Krill
Registered: Apr 2002 Posts: 3070 |
Triple-or-more buffering isn't so common on C-64 now, is it? :) |
| |
chatGPZ
Registered: Dec 2001 Posts: 11499 |
Not what the original troll was about though :) |
| |
Mr SQL
Registered: Feb 2023 Posts: 158 |
Quoting KrillQuoting MixerI guess the reason for third buffer was that to use the calculation time effectively. f.ex if it takes 1.5 frames to draw, then you lose 0.5 frames until you can swap the displayed bitmap. So, begin drawing 3rd frame instead. Triple-buffering also helps if there is some non-trivial variation in render times from one frame to the next.
Yes I made a sequel with multiple color RAM buffers and needed an extra frame to accommodate:
Inertia Zones 2
I was trying to do this without the extra frame but not enough cycles. Fortunately the update is infrequent just when the level is cleared so the extra frame is not noticed and the smooth cadence stays the whole round. I agree that is a primary reason for double and multiple buffering.
Ring Raiders keeps a smooth cadence by always taking two frames (or one double length frame) to render display buffers so color cycling can be part of the animation. |
| |
Mr SQL
Registered: Feb 2023 Posts: 158 |
Quoting WVLThe bitmap-mover in Halloweed IV uses a triple buffer. This is to save cycles preparing the next bitmap (which is shifted up by 6 rows). The part copies bytes from the displayed bitmap to the next bitmap (but 6 rows higher) and can reuse the byte for the third bitmap (12 rows higher).
This was needed to make the >25 rows of bitmap data possible (besides copying the bitmap up, the part also has to copy a new line at the bottom in each frame and the data also gets reused in bitmaps 2 and 3). Without triple buffering the copying was too slow.
The copies are also optimized to not pass page boundaries and such things.
Quoting cobbpgStunt Car Racer doesn't waste time either after finishing work on frame 2 while presenting frame 1, it immediately starts processing the physics calculations for frame 3. It works out because that part of the workload always takes long enough that it can start presenting frame 2 by the time it needs to clear the back buffer.
Excellent multiple buffering engine details.
The engine doing the multiple buffering in Inertia is a soft blitter modeled after the ANTIC chip in the Atari 400/800.
This is a Display list scripting engine with scripting commands that can be programmed from assembly or BASIC.
The display list programs take an LMS (load memory scan) address to buffer all or part of the screen. And it adds an extra [intrinsic] JVB assembly instruction - jump after vertical blank - this runs the display list programs (or jumps to another set) again.
Just like ANTIC Display list programs are called only from within the vertical blanks.
What's different is you are already programming in both vertical blanks by running a gameloop in each one to saturate the available vertical blank cycles.
There is an option to raise an event to use a full frame if processing time beyond both vertical blanks is required.
This can be done constantly to half the framerate and greatly increase available cycles like in Ring Raiders.
The two RingRaiders binaries show this option to either insert a blank frame for MBR motion blur reduction or double the frame for more solidity.
This can also be done intermittently like the Inertia example when more cycles are needed for specific events.
I uploaded the BASIC program showing the display list programs to create the multiple buffering zones.
This scripting language can be programmed from Assembly or BASIC similarly.
JVB jump after vertical blank
The intrinsic scrollvirtualworldtoggle command is the JVB jump after vertical blank instruction.
You can see it being set to a different LMS address to render multiple screen zone buffers from the large tile bitmap backbuffer.
When it is set to 1 it uses an entire frame for rendering rather than the vertical blanks.
Sound list scripting language
I was inspired by display list programming to create a similar music list scripting language.
It allows programing the Tracker using "tracker scripts" in the chiptunes similar to ANTIC display list programming.
An MLI music scripting list similarly can JVB (jump after vertical blank) at any time in the sequence and can
call other music lists as events or repeat the same music list program like display list programming. |
Previous - 1 | 2 - Next |