Archive for May, 2008

Flash Uses The GPU

A much clamored-for feature (right after native 64-bit, wmode/transparency, and V4L2) is Flash GPU (graphical processing unit) acceleration, sometimes founded in a belief that it’s a magic solution for making things fast without any side effects or ill consequences. I just wanted to make it known that the Adobe Flash Player is GPU accelerated, even on Linux. However, this comes with some qualifications.

Starting in version, the Flash Player was able to display fullscreen content with GPU assistance. This is done via OpenGL facilities.

Starting in the most recent Astro Beta, Flash Player supports new GPU acceleration modes. This acceleration doesn’t automatically speed up legacy content. Instead, new SWF content has to be authored specifically to take advantage of this. Tinic Uro has an excellent overview of the capabilities and limitations of this new feature in his blog post, “What does GPU acceleration mean?”

Tinic’s post mentions the lofty GPU requirements for Windows: “You will need at least a DirectX 9 class card. We essentially have the exact same hardware requirements as Windows Vista with Aero Glass enabled.” Obviously, the Linux version isn’t going the DirectX route. It uses OpenGL and we require the following features before we consider honoring the new SWF GPU features:

  • GL_ARB_multitexture
  • GL_EXT_framebuffer_object
  • GL_ARB_shader_objects
  • GL_ARB_shading_language_100
  • GL_ARB_fragment_shader

Also, for fullscreen OpenGL acceleration, the Flash Player requires that the client glx vendor string be something besides “SGI”. Official drivers from, e.g., ATI and Nvidia hopefully do not have “SGI” in this field (check the ‘glxinfo’ command, for this string and for the extensions listed above). We have this logic in place to detect whether software rendering is in place and fall back on our own software fullscreen in that case. There are more robust ways to detect software rendering but we have seen crash problems on a number of distributions, possibly with outdated libraries.

Another important note: Compiz and GPU-accelerated Flash on Linux do not mix. The Flash Player still works if you have Compiz as your window manager; you just won’t be able to make use of GPU-accelerated features. This is a shame since Compiz is coming with the basic installation of various Linux distributions. Unfortunately, things get unstable when trying to do GPU acceleration in SWFs running under Compiz.

  • FAQ regarding hardware acceleration: Why doesn’t the Flash Player on Linux user the X video extension (Xv)?
  • Answer: Because Xv scales YUV data. Flash Player operates on RGB data.

For the uninitiated, many video codecs operate in a YUV colorspace. Unix/X11 has an extension called X video that allows hardware scaling of YUV images. This is a very mature system on Linux which has allowed seamless, low CPU usage, fullscreen video playback on Linux for many years. Unfortunately, the Flash Player can not easily make use of this since Sorenson, On2, or H.264 video data — even though it is decoded as YUV — has to be converted to RGB and possibly combined with other graphical elements. This is why RGB scaling via OpenGL is the future of Flash.

Except if Compiz is acting as window manager.

Astro Beta

We just released a public beta of the next Flash Player, version 10. As is now customary, Linux is invited to the cross-platform party and is available alongside the Mac and Windows binaries. Go get it here. And go report bugs here.

There are plenty of nifty new features covered in the labs link. More interesting for Linux users is that we have been addressing the graphical performance issues that manifesting starting in 9r115, the version where we had to rework the graphical system due to the new XEmbed support (trying to remember what that bought us… oh yeah: context menus consistent with the desktop). The key to performance? Move away from recommended APIs and use unrecommended ones (without resorting to deprecated APIs).

Anyway, I can certify that this version is notably faster. I have been testing the FP10 beta on my special profiling tool, a.k.a. Asus Eee PC. But I would still like to hear whether you experience measurable performance improvements as well.