Paul Brook wrote:
Will this work also for the CL542x adaptor?  (Does that fall in the
category of vga?)  My current hack works for with/without -std-vga and I
think that's because it lives "underneath" both, in the connection to
SDL.
Each adapter will have to do it's own minimization but that's sort of
the write thing anyway IMHO.  How granular each update is really only
depends on the adapter.  For instance, the VMware adapter really
shouldn't need to do any minimization at all.

It would be nice if we could share the framebuffer blitting routines. We've currently got 3 different implementations (vga/cirrus, tcx and pl110) of basically the same framebuffer rendering routines.

Take a look at the video code in BasiliskII / SheepShaver, a 68k/PPC classic MacOS emulator written by Gwenolé Beauchesne:

http://gwenole.beauchesne.info/projects/sheepshaver/

It contains optimized code (source level) for blitting between various bit depths and endiannesses. See SheepShaver-2.3/src/Unix/video_blit.{h,cpp} in the sources.

It also uses a technique called "video on segfault" (VOSF) to improve performance on platforms which support it: rather than testing each store to see if it modifies the framebuffer, it keeps the framebuffer write-protected (via mprotect(), or the equivalent on non-POSIX systems) and uses a SIGSEGV handler to catch stores to the buffer. When a page receives a store, the handler unprotects the page and updates a bitmap of modified pages. Every so often a display update thread wakes up, consults the bitmap, calculates the updated region, blits it to the screen (using the optimized blitters), and clears the bitmap. See SheepShaver-2.3/src/Unix/video_vosf.h, SheepShaver-2.3/src/Unix/video_x.cpp, and other files.

The emulators also have alternative techniques for tracking update regions on systems for which VOSF is not supported. But VOSF is almost always a big win. And most modern OSes can support it without trouble.

The code is in C++ so it can't be dropped in directly, but Some of the techniques may be useful in qemu.


Brian J. Johnson


Reply via email to