We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3870

Summary: opengles2 renderer by default do rgb/bgr conversion
Product: SDL Reporter: Sylvain <sylvain.becker>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: don't know   
Hardware: All   
OS: All   
Attachments: patch

Description Sylvain 2017-10-10 18:03:05 UTC
For a texture that has a format SDL_PIXELFORMAT_ARGB8888 (default, as texture_format[0]), opengles2 renderer selects a gl format "GL_RGBA" in GLES2_CreateTexture(). This parameter is used for loading the pixels data with glTexImage2D().
But this leads to have a fragment shader that have to swap r/b.
This is the default path that does swapping for each RenderCopy.

Event if we don't notice anything, could this has a (very) little performance impact ?

Other renderers: 
opengl render uses format = GL_BGRA. 
D3D11 is also using DXGI_FORMAT_B8G8R8A8_UNORM.

maybe opengles2 renderer should also use GL_BGRA and do no swapping in his shader.
Comment 1 Sylvain 2017-10-11 09:34:50 UTC
Created attachment 2974 [details]
patch

In openGLES2, GL_BGRA_EXT depends on the extension GL_EXT_texture_format_BGRA8888.

Here's the patch I thought to submit, to use minimal shader path.
I tested both on desktop and android device. But I see no fps improvements.
So just discarding it, and closing the issue.
Comment 2 Sylvain 2017-10-11 09:35:23 UTC
Closing as invalid.