Can Stage3d be used to perform parallel calculations?

411 views Asked by At

I used to program maps in AS3 like you, but then I took a Pixel Bender in the knee. Since then I have been using Pixel Bender to do parallel calculations on arrays. Can Stage3D be used for this?

Example of using Pixel Bender for calculation:

http://wonderfl.net/c/eFp0/

My goal is to get a vector of [x1, y1, x2, y,2 , . . ., xn, yn] and return a vector of [f(x1), f(y1), f(x2), f(y2), . . . ,f(xn), f(yn)]. More like f(x1, y1).x , f(x1,y1).y. I am sure you get the general idea.

What we normally call a map. Here is a thorough explaination.

http://en.wikipedia.org/wiki/Map_%28higher-order_function%29

I noticed that with Pixel Bender I can accomplish this with a speed boost of 10x. Is there any way to do the same thing with Stage3D.

1

There are 1 answers

4
Jason Sturges On BEST ANSWER

Unlike other languages such as c++, I'm not aware of a way to direct assembly instructions to the GPU beyond Program3D Shaders with Adobe Graphics Assembly Language.

Program bytecode can be created using the Pixel Bender 3D offline tools. It can also be created dynamically. The AGALMiniAssembler class is a utility class that compiles AGAL assembly language programs to AGAL bytecode. The class is not part of the runtime. When you upload the shader programs, the bytecode is compiled into the native shader language for the current device (for example, OpenGL or Direct3D). The runtime validates the bytecode on upload.

The programs run whenever the Context3D drawTriangles() method is invoked. The vertex program is executed once for each vertex in the list of triangles to be drawn. The fragment program is executed once for each pixel on a triangle surface.

Not approaching the performance you are obtaining with Pixel Bender, it should be noted that you could leverage ActionScript Workers to parallelize your functors.

A Worker object represents a worker, which is a virtual instance of the Flash runtime. Each Worker instance controls and provides access to the lifecycle and shared data of a single worker.

This capability of simultaneously executing multiple sets of code instructions is known as concurrency.

With Adobe Premium Features, Alchemy / FlasCC, XC APIs, Pixel Bender, and ActionScript Next on the way, it's an exciting time for the rapidly progressing Flash platform.