4

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.

AturSams
  • 7,568
  • 18
  • 64
  • 98

1 Answers1

2

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.

Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
  • Hi Jason, Pixel Bender 3D is what I needed. I wish to thank you sincerely. – AturSams Oct 26 '12 at 13:23
  • I tested pixel bender 3d and I cannot seem to find a quick way to get the data back from the stage and into a vector? Do you happen to know any way to accomplish that? – AturSams Oct 29 '12 at 23:08
  • @ArthurWulfWhite I'm not sure, but perhaps [FlasCC](http://gaming.adobe.com/technologies/flascc/) (formerly Alchemy) may be more inline with things you wish to accomplish. – Jason Sturges Nov 07 '12 at 06:29
  • pixel bender 3d is designed to make writing AGAL shader kernels easier. The only output from these kernels is to a framebuffer. You _can_ provide a BitmapData as a frameBuffer prior to the Context3D::drawTriangles call, and then access the pixels as color, but that will only get you integer precision... – jordancpaul Jan 19 '13 at 10:22