Skip to content

Regression since 3.4.4: transparency lost on test/testrendercopyex #16156

Description

@mardy

Hi there!
I'm porting SDL3 to the Nintendo Wii/GameCube, and I got 3.4.0 to run successfully. However, when trying to rebase my changes on top of 3.4.14, I noticed that the transparency on the icon in the test/testrendercopyex was lost (the icon appears on a white square). Bisecting, I traced this back to commit fdfcfc0.

The reason why this commit broke my renderer is that my texture formats are declared in this order:

    SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_RGB565);
    SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_RGBA8888);
    SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_ARGB8888);
    SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_RGB24);
    SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_XRGB8888);

the SDL_PIXELFORMAT_RGB565 is declared first to save some memory, since the console doesn't really have plenty of it. Now, what happens is that in SDL_CreateTextureFromSurface() we get into this branch:

    // Fallback, choose a valid pixel format
    if (format == SDL_PIXELFORMAT_UNKNOWN) {
        format = renderer->texture_formats[0];

        // See what the best texture format is
        ...

At this point format is SDL_PIXELFORMAT_RGB565. Now, with the old code, the loop below would find a more suitable format containing an alpha channel (since the surface uses a color key), so things would work. But with the size check added in commit fdfcfc0 the loop below does not find any match, so the alpha-less RGB565 remains selected.

I don't understand how important it is for the formats to have the same size, but if that is something that's really needed and we cannot revert this commit, then I suggest that we should add another loop that again checks for a format, without considering the size.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions