Michael
Michael

Reputation: 1762

Would optimizing a CSS3 animation without H/W acceleration off make it run faster on GPU afterwards?

It sounds like a strange question at first - but bear with me.

I wrote a setTimeout-based benchmark (similar to stats.js) - the idea was to have something to compare how an animation is performing under different conditions (like adding to it different CSS3 properties). For (simple) example I'd have something with rotation and box-shadow animated, then I'd remove rotation in the second run and box-shadow in the third run. Afterwards I'd have 3 benchmark numbers to compare how each of those animations is performing.

This works well as long as the animation is not GPU-accelerated (for obvious reasons i.e. H/W acceleration removes the animation from the page's single-process structure).

But that also brings me to the million dollar question - if I optimize something to run better without GPU-acceleration does that mean that same optimized animation would run better (either faster or with less memory usage) with GPU-acceleration turned on? Or do different rules apply?

Let me give you a simpler example. CSS3 box-shadow will kill performance in almost any animation. In simpler cases you can augment performance by replacing CSS3 box-shadow with a rasterized (PNG?) image of a similar shadow. However with GPU-on, the benefits of that are not as apparent to the naked eye because both animations would appear run almost equally fast (because again - I can't track performance changed with GPU-on). So again - do the same rules apply with GPU-on and -off?

My initial impulse was - once something is optimized - it runs better no matter GPU-on or -off. But like I mentioned in a comment below (and please correct me if I understand this wrong), but a hardware-accelerated element is cached as a pre-rendered raster texture on the GPU. If thats true - why would it then make any difference if my shadow is a CSS3 box shadow or an image-base PNG shadow? I mean both of these elements would with GPU-on just be turned into a rasterized texture anyway right? So my optimization would not make any more sense with GPU-on? (unless if there is a difference somehow in memory usage again...)

Upvotes: 1

Views: 598

Answers (1)

Phillip Schmidt
Phillip Schmidt

Reputation: 8818

Yes, absolutely. Look here for a little bit about what GPU acceleration does and does not affect. But the general idea is, yes, it will keep most of your optimizations. Now, how much a given optimization will affect performance after GPU offloading, in a relative sense.. That's a tough question to answer.

Upvotes: 1

Related Questions