WebGL canvas with or without alpha (performance)

524 views
Skip to first unread message

Andre Weissflog

unread,
Feb 20, 2016, 6:32:23 AM2/20/16
to WebGL Dev List
Hi, I wonder if Chrome and Firefox do faster composition with the background if the WebGL canvas has been setup without alpha channel (alpha:false)?

I'm currently cleaning up the context initialization code in my multiplatform engine which is running on WebGL via emscipten, and I noticed that some native platforms and 3D APIs do not accept RGB framebuffer formats (without alpha channel), so I'd like to drop RGB from the list of valid render target formats.

Also, Safari on iOS completely ignores the alpha:false, and always alpha-blends with the background (which was another reason to always use RGBA everywhere so that all platforms look the same).

So... if I don't actually care about alpha-composition with the webpage, do Chrome and Firefox give an actual performance advantage if I create the WebGL canvas without alpha, especially on HighDPI displays with low-end GPUs it could make a difference I guess.

Cheers,
-Floh.



Kenneth Russell

unread,
Feb 22, 2016, 4:58:13 PM2/22/16
to webgl-d...@googlegroups.com
On Sat, Feb 20, 2016 at 3:32 AM, Andre Weissflog <flo...@gmail.com> wrote:
Hi, I wonder if Chrome and Firefox do faster composition with the background if the WebGL canvas has been setup without alpha channel (alpha:false)?

I'm currently cleaning up the context initialization code in my multiplatform engine which is running on WebGL via emscipten, and I noticed that some native platforms and 3D APIs do not accept RGB framebuffer formats (without alpha channel), so I'd like to drop RGB from the list of valid render target formats.

The browsers have run into the same problem. On platforms where RGB textures are not renderable, the browser allocates an RGBA texture for the WebGL back buffer behind the scenes, and reports to the application that there are 0 alpha bits (as well as emulating other kinds of behaviors and ensuring that the alpha channel always contains 1.0.)

 

Also, Safari on iOS completely ignores the alpha:false, and always alpha-blends with the background (which was another reason to always use RGBA everywhere so that all platforms look the same).

That's quite poor behavior and it's unfortunate that the WebGL conformance tests can't catch this. The workaround you have sounds reasonable. I've notified Apple about this bug.
 

So... if I don't actually care about alpha-composition with the webpage, do Chrome and Firefox give an actual performance advantage if I create the WebGL canvas without alpha, especially on HighDPI displays with low-end GPUs it could make a difference I guess.

It might provide a performance benefit, to be honest, because alpha blending can be disabled when compositing the WebGL-rendered canvas on top of the rest of the HTML content. The benefit is likely to be larger on lower-end GPUs, which is probably where you want it, anyway.

-Ken


 

Cheers,
-Floh.



--
You received this message because you are subscribed to the Google Groups "WebGL Dev List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webgl-dev-lis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andre Weissflog

unread,
Feb 23, 2016, 3:33:15 AM2/23/16
to WebGL Dev List
Thanks for the detailed reply, much appreciated. I'll see if I can do some tests on slower mobile devices, and if I see any difference I'll try to come up with some hack/workaround in my display setup code.

-Floh.

Dean Jackson

unread,
Feb 23, 2016, 9:08:39 PM2/23/16
to WebGL Dev List


On Saturday, February 20, 2016 at 10:32:23 PM UTC+11, Andre Weissflog wrote:
 

Also, Safari on iOS completely ignores the alpha:false, and always alpha-blends with the background (which was another reason to always use RGBA everywhere so that all platforms look the same).

I just fixed this today in WebKit trunk.

And flipping the question:

> Hi, I wonder if Chrome and Firefox do faster composition with the background if the WebGL canvas has been setup without alpha channel (alpha:false)?

Yes, it will be a performance improvement in the case of iOS. Possibly slight, but still an improvement.

Dean

Andre Weissflog

unread,
Feb 24, 2016, 3:22:00 AM2/24/16
to WebGL Dev List
Yay, thanks a thousand times :)
Reply all
Reply to author
Forward
0 new messages