Skip to content

Fixed BGRA channel assignment for Color struct#7

Draft
thomascp wants to merge 1 commit into
Random06457:masterfrom
thomascp:pcheng-fix-bgra
Draft

Fixed BGRA channel assignment for Color struct#7
thomascp wants to merge 1 commit into
Random06457:masterfrom
thomascp:pcheng-fix-bgra

Conversation

@thomascp

Copy link
Copy Markdown

Hi,

First of all, thank you so much for this amazing project! It has been incredibly helpful for learning Raspberry Pi bare-metal GPU programming.

While running the code, I noticed that my rendered triangle looked different from the one shown in your README.
In my case, the bottom-left vertex is blue, the bottom-right is green, and the top vertex is red.

image

After some investigation, I found that StoreTileBufferGeneral stores the buffer using the V3D_OUTPUT_IMAGE_FORMAT_RGBA8 format. However, when it is copied over to the framebuffer, the framebuffer expects a BGRA format.

To fix this color channel mismatch, I modified the codes in drawTex (swapping the r and b struct members) so that the memory layout aligns correctly with the expected BGRA format.

struct Color
{
...
    union
    {
        struct
        {
            u8 b; // Swapped to match BGRA
            u8 g;
            u8 r; // Swapped to match BGRA
            u8 a;
        };
        u32 argb;
    };
...
};

Could you please take a look? Thank you!

BR,
Peng

@thomascp thomascp marked this pull request as draft June 11, 2026 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant