Skip to content

SDL2 - UpdateYUVTexture on opengles2 flips red/blue channels #13109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
itsmattkc opened this issue May 24, 2025 · 4 comments
Open

SDL2 - UpdateYUVTexture on opengles2 flips red/blue channels #13109

itsmattkc opened this issue May 24, 2025 · 4 comments
Assignees
Milestone

Comments

@itsmattkc
Copy link

My app uses SDL_UpdateYUVTexture extensively for uploading video frames to an SDL_Texture. With the opengl backend, everything displays fine and as expected. However, with the opengles2 backend, the red and blue channels are inexplicably flipped.

✅ Correct result using opengl
Image

❌ Incorrect result using opengles2:
Image

This is particularly problematic on Android (and other embedded/low power systems) where opengles2 is the default/only option.

I'm using SDL 2.32.0 self-compiled as part of my CMake build system. The issue is tracked on our end at vanilla-wiiu/vanilla#133.

I tried investigating but my only guess was some kind of conflict between RGBA and BGRA textures. I couldn't find anything that seemed to definitively solve it. Any help with this issue would be great.

@slouken slouken added this to the 3.2.16 milestone May 25, 2025
@slouken slouken self-assigned this May 25, 2025
@ccawley2011
Copy link
Contributor

It might be a regression from this commit: 9f7ccbe

SDL_PIXELFORMAT_ABGR32 isn't handled elsewhere in the file, while SDL_PIXELFORMAT_BGRA32 is handled by using a shader to swap the R and B components. SDL_PIXELFORMAT_RGBA32 is the pixel format that corresponds to the standard layout, but it's unclear why it was removed.

@itsmattkc
Copy link
Author

Thanks for getting back to me so soon. Indeed, it seems that commit started the issue because I just tested 643437f and it works fine.

@slouken slouken assigned icculus and unassigned slouken May 26, 2025
@slouken
Copy link
Collaborator

slouken commented May 26, 2025

@icculus, can you take a look at this?

@icculus
Copy link
Collaborator

icculus commented May 27, 2025

Yep!

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

No branches or pull requests

4 participants