On Wed, 18 Mar 2026, Chad Jablonski wrote:
+static uint32_t make_filler(int bpp, uint32_t color)
+{
+    if (bpp < 24) {
+        color |= color << 16;
+        if (bpp < 15) {
+            color |= color << 8;
+        }
+    }
+    return color;
+}
+

Does this assume that the upper bits of color are zeroed when bpp < 24? Is that
a safe assumption or could those bits be garbage?

I think to be a valid <24 bit color the upper bits should be 0 here. In practice this is called with register values where we only support 32 bit writes so the only way to get garbage there if the guest does a 32 bit write with garbage bits. (I.e. it can't do an 8 or 16 bit write and leave garbage in upper bits from earier value.) It seems unlikely that a guest doing 32 bit write would leave garbage in upper bits and if this could happen it's better to take care of that at register write not here so I'd assume color is some valid color for the bpp and the caller should make sure if needed. This function just expands that to 32 bits so we don't have to care about other sizes later.

Regards,
BALATON Zoltan

Reply via email to