Can you tell me where the BGRA patch idea/source comes from?
Here’s the rough process of how I created that patch:
- To begin with, I captured profiles while viewing laggy sites.
- As you can see, most of the cpu time was consumed in the
mesa_format_convert
function - I put debug prints to mesa, and found firefox calling
glTexSubImage2D
to upload BGRA image to RGBA texture, causing format conversion. - Since the panfrost gallium driver disables blit texture transfer, the format conversion falls to software implementation, which is very slow.
- So I enabled it with the first patch. This worked like a charm.
- But after a while I was curious as to why the conversion was occurring in the first place. So I tested with another machine with an AMD GPU, and found firefox uploading RGBA image.
- This is because the gallium driver supports
GL_EXT_texture_format_BGRA8888
while amdgpu doesn’t. I tried to force firefox to use RGBA texture format bysupports_texture_storage_with_gles_bgra = false
in here - This also eliminated the format conversion, but was not as fast as the previous method.
- Then I investigated why are the texture formats RGBA.
- The cause was the
_mesa_choose_texture_format(..., internalFormat=GL_BGRA8_EXT,...)
here returningPIPE_FORMAT_R8G8B8A8_UNORM
rather thanPIPE_FORMAT_B8G8R8A8_UNORM
. - That could be fixed by reordering the corresponding mesa format order in this table. This is what the second patch does.
- The final method makes firefox to create BGRA formatted textures and no conversions sould occure now.
Also, the blit patch link is 404, what was it about?
Here.
Sorry, I’ve removed that patch from my tree.