rasz_pl wrote on 2022-06-14, 21:13:
pan069 wrote on 2022-06-13, 20:38:
Pros and cons. 32-bit is faster to process since it aligns with memory locations whereas 24-bit does not. However, 24-bit takes up less memory (1 byte per pixel color less) but more procssing is required to transfer data.
Did any VGA manufacturer employ a clever trick of transparently translating 24-32bit accesses? Graphic ram is >=64bit anyway, so you could invisibly take care of packing 4 to 3 bytes on writes, 3 to 4 reads and any alignment issues _if you are certain this is a 24bit framebuffer access_. Then again I wonder if anyone reused wasted bytes for anything.
You'd need RAM 96 bits wide to not have any performance hit from misalignment, or some other multiple of 96 bits (3*4*8 bits, so it divides evenly to 3-byte and 4-byte pixel modes).
4 24-bit pixels, one byte per channel: RGB RGB RGB RGB
packed to 32-bit words:
RGBR GBRG BRGB
loading third pixel: load GBRG, load BRGB, combine and discard extra bytes
RGBRGBRG BRGB <- solves some issues (second pixel is now single-cycle) but third pixel still requires fixups
packed to 96 bits:
RGBRGBRGBRGB <- neither 32-bit nor 24-bit pixels require fixups (32-bit would be RGBARGBARGBA)
RGBRGBRGBRGBRGBR GBRGBRGBRGBRGBRG BRGBRGBRGBRGBRGB <- sixth and 11th pixels require multiple accesses and we're pretty much back to the same problems as 32-bit mode in general, only words 0, 3, 6, etc have proper alignment
Now, a graphics card might be able to waste less than 25% space if it had a longer word width like 128 bits, it'd only have to waste one byte per word to keep everything tidy. In particular that last R byte of the first 128-bit word could be forced to unused in hardware for 24-bit pixel modes, and then only 6.25% of memory would be wasted instead of 25%.
That would look like: RGBRGBRGBRGBRGBX RGBRGBRGBRGBRGBX
So, nice alignment, no fixing up any pixels, single loads for everything, and you always know where your R, G, and B components are in your 128 bit words since they're always in the same spots, there's not 3 different spots they could be in depending on address.