How are BitBlt raster opcodes calculated? (2018)
devblogs.microsoft.com
devblogs.microsoft.com
A more modern version might be some sort of AVX filter-instruction generator. Although these days we try to avoid letting the CPU dirty its hands with bitmaps and leave them to the GPU.
The Windows documentation for BitBlt dates it to Windows 2000, which is definitely wrong. I wonder if anyone has a 3.0 or even 1.0 API reference lying around?
Check page 116 of this: http://www.os2museum.com/files/docs/win10sdk/windows-1.03-sd...
It was there from the beginning, as you might have expected.
So here, where there's a need to perform operations in bulk as quickly as possible, this sort of extreme optimization makes a bunch of sense. Conditionals inside the loop would blow your performance, and the other options buy back performance with memory that was itself in short supply. So... dynamic compilation threads the needle between these two constraints at the cost of some up front development complexity. (Probably ongoing complexity too, as additional types of graphics boards were released with their own sorts of peculiar optimization strategies.)
But why do you need conditionals? It's just bit operations...
The output is found simply as f&(1<<((p<<2)|(s<<1)|d)) != 0.
Yeah, if you use the index to map to a bunch of ands and ors and whatnot to execute, you have a conditional. But if you just use the index directly and do bit operations, there's no conditional. What am I missing?
There are also format issues. Circa Windows 1.0, you might be likely to have a CGA, Hercules graphics board, or EGA. All three have different memory formats and architectures. (CGA was fairly ordinary, Hercules used an odd line ordering, and EGA had multiplexing hardware on board that let you operate on 32-bits at a time over an 8-bit interface.)
Any approach based on lookup tables would've both taken a lot of memory that wasn't available and introduced extra memory references in the inner loop of what was probably the most performance critical code in the OS from a GUI PoV. (Keep in mind that unlike the Mac, these machines were not originally designed to run a GUI.)
This story is set ten or more years after the design of BitBlt was done, but I think it does nicely illustrate how people were thinking about memory back then. The reason Windows 95 didn't update the seconds on the taskbar clock was to allow it to page out font rendering code on small machines. If you're rendering text every second, you can't really do that.
https://devblogs.microsoft.com/oldnewthing/20031010-00/?p=42...
(And Windows 1.0 was written to run on hardware with 1/16th the memory of Windows 95.)