Posts Tagged graphics

Lightspark 0.4.4 released

Archi­tec­ture of the pro­posed upcom­ing Advanced Graph­ics Engine

Lightspark 0.4.4 has been released today. Thanks a lot to all the peo­ple that made this release pos­si­ble. Beside the usual amount of bug fixes sev­eral new fea­tures have been included

  • Local­iza­tion sup­port (using gettext)
  • Action­Script excep­tion han­dling support
  • More robust net­work handling
  • Streams con­trols (Play/Pause/Stop)

It should be noted that, although now video streams con­trols are sup­ported they’ll be not usable in most YouTube videos as mouse event dis­patch­ing to con­trols is still clob­bered by miss­ing mask­ing support.

Lightspark now sup­ports local­ized error mes­sages, but we miss trans­la­tions! So I’d like to invite any user (non devel­op­ers included) will­ing to help Lightspark to con­tribute the trans­la­tion for his/her native language.

I’d also like to give some insight what is being worked on for the next release (0.4.5). First of all the plug­inized audio back­end is now mature enough to be merged upstream, this is the first step toward sup­port for mul­ti­ple audio back­ends. That said any­way Lightspark will always focus on func­tion­al­ity and not on the amount of back­ends offered. We’ll work to offer a very small num­ber of fully work­ing backends.

In the mean time we’re also dis­cussing a new faster and more pow­er­ful graph­ics archi­tec­ture. My pro­posal is a mixed software/hardware ren­der­ing pipeline, some­how inspired by mod­ern com­posit­ing win­dow mangers. Sta­tic (defined in the SWF file) and dynamic (gen­er­ated using Action­Script code) geome­tries will be ren­dered in soft­ware using cairo and exploit­ing the thread pool to be scal­able on multi core archi­tec­tures. The result­ing sur­faces and decoded video frames (if any) will be uploaded using Pixel Buffer Objects to offload the work to the video card (this usu­ally involves a DMA trans­fer). OpenGL will then be used to blit the var­i­ous ren­dered com­po­nents on screen, while apply­ing fil­ters, effects and blending.

That’s all folks. As always test­ing from as many peo­ple as pos­si­ble is crit­i­cal for the suc­cess of the project, so please try out this release and report any crashes/weird issues and any­thing you don’t like. I’d like to put an empha­sis about this: never assume a bug is already known. If you hit a crash take a look at launch­pad bug tracker. If your issue is not already reported, please do it!


Flattr this

, , ,

11 Comments

The quest for graphics performance: part I

lightspark-tech-demo2-revamp

Devel­op­ing and opti­miz­ing Lightspark, the mod­ern Flash player, I’m greatly expand­ing my knowl­edge and under­stand­ing of GPU inter­nals. In the last few days I’ve man­aged to find out a cou­ple of nice tricks that boosted up per­for­mance and, as nice side effects, saved CPU time and added features :-)

First of all, I’d like to intro­duce a bit of the Lightspark graph­ics architecture

The project is designed from the ground up to make use of the fea­tures offered by mod­ern graph­ics hard­ware. Namely 3D accel­er­a­tion and pro­gram­ma­ble shaders. The Flash file for­mat encodes the geome­tries to be drawn as set of edges. This rep­re­sen­ta­tion is quite dif­fer­ent from the one under­stood by GPUs. So the geome­tries are first tri­an­gu­lated (reduced to a set of tri­an­gles). This oper­a­tion is done on the CPU and is quite com­pu­ta­tion­ally inten­sive, but the results are cached, so over­all this does not hit performance.

More­over Flash offer sev­eral dif­fer­ent fill styles that should be applied on geom­e­try, for exam­ple solid color and var­i­ous kind of gra­di­ents. Lightspark han­dles all those pos­si­bil­i­ties using a sin­gle frag­ment shader, a lit­tle piece of code that is invoked on every pixel to com­pute the desired color. Of course the shader has to know about the cur­rent fill style. This infor­ma­tion along with sev­eral other para­me­ters could be passed with dif­fer­ent meth­ods. More on this on the next issue.

There is one pecu­liar thing about the shader though, let’s look at a sim­ple pseudo code:
gl_FragColor=solid_color()*selector[0]+linear_gradient()*selector[1]+circular_gradient()*selector[2]...;

Selec­tor is a binary array, the only allowed val­ues are zero or one. More­over only one value is one. This means that the cur­rent frag­ment (pixel) color is com­puted for every pos­si­ble fill style and only after­ward the cor­rect result is selected. This may look like  a waste of com­put­ing power, but it is actu­ally more effi­cient than some­thing like this:

if(selector[0])
       gl_FragColor=solid_color();
else if(selector[1])
       gl_FragColot=linear_gradient();
...

This counter intu­itive fact comes from the nature of the graph­ics hard­ware. GPUs are very dif­fer­ent from CPUs and are capa­ble of cruch­ing tons of vec­to­r­ial oper­a­tions blind­ingly fast. But they totally fall down on their knees when encoun­ter­ing branches in the code. This is actu­ally quite com­mon on deeply pipelined archi­tec­ture which misses com­plex branch pre­dic­tion cir­cuitry, not only GPUs but also num­ber crunch­ing devices and mul­ti­me­dia mon­sters such as IBM Cell. Keep this in mind when work­ing on such platforms.

, , , , , , ,

2 Comments