4
votes

Flash Player 11 introduced the AGAL unified shader assembly language, which is able to compile into OpenGL GLSL shaders and DirectX HLSL shaders transparently to the Flash developer.

Pretty much every program that uses AGAL is packaged with the AGALMiniAssembler (written in AS3), which takes AGAL source code as a string and compiles it into the AGAL binary format, at run time (ie. Just In Time). This binary data is then fed into Flash Player for it to then feed it into the graphics hardware

But why does AGAL source code have to be published and included in your app in the first place? Couldn't you run the AGAL assembler on your dev. PC and simply include the AGAL ByteArray? Do AGAL shaders need to be compiled just-in-time? Please note I'm not asking for benefits, I'm just asking if its really necessary to include AGAL source code and have it compile JIT instead of AOT (Ahead of Time).

1
Probably you'll have to do AOT compiling for too many possible video card configurations, this will in turn bloat your SWF.Vesper
Thats incorrect because the generated assembly does not change by any system configuration. JIT compilation is unconditional and done purely in AS3, note that the AGALMiniAssembler does not compile your source code into a GLSL/HLSL shader, instead it compiles it into AGAL bytecode, which is then simply passed to Flash Player for further processing.Robin Rodricks
What is your concern with creating AGAL bytecode during program execution? If it's a matter of execution time, I wouldn't be too worried - I've nearly maxed out the instruction count in a couple of my shader programs and the code still takes (practically) no time to assemble with AGALMiniAssembler.Conduit
Of course I'm not asking about time and performance and the benefits of either. I'm only asking, is it possible? (to compile it AOT and include the final AGAL bytearray into the SWF)Robin Rodricks

1 Answers

1
votes

Yes, it's possible. When you compile shaders with miniassembler you get bytearray. So you can just use this bytearray - embed it or load.