GLSL Compiler Rewrite

Things have been slow recently on the main branch due to work on a massive rewrite of the compiler. Currently, the compiler was mostly a proof of concept, doing a direct translation of the parsed syntax tree into a corresponding javascript representation. While this approach produces a pretty good result, there are some things which would not have worked or would have been extremely difficult to implement as such (e.g. LHS swizzles). Furthermore, a full rewrite would have been necessary anyway to output different targets, such as when Flash Stage3D/AGAL support is built in. This rewrite should be complete in the next week or two.

When done, the new compiler will function as a GLSL->ARB compiler, meaning that it could in theory be used to produce real ARB assembly code, though most likely the output will be very unoptimized.
On the back-end will be a set of translators from ARB to other output formats. At first, it will be limited to an ARB->Javascript translator, but an AGAL translator should be extremely easy to implement afterwards. This leads to all sorts of interesting usage possibilities, such as the ability to debug production shaders in javascript using a virtual GPU/debugger, even if the required level of performance is too great to use the library for software emulation. Also of interest will be the eventual integration of Flash, and for pure-flash developers/applications, the ability to compile GLSL down to AGAL without having to pay for or install external software might be very appealing.

Does anyone have any other ideas?

This entry was posted in cWebGL. Bookmark the permalink.

3 Responses to GLSL Compiler Rewrite

  1. Dan Brickley says:

    I’ve been learning GLSL, and just got that sinking feeling as it’s quite hard to know what’s going on inside the GPU (beyond signaling back out with colors). Then suddenly I remembered “hey, didn’t someone make a pure .js WebGL implementation” and tracked the link down from planet-webgl to here. Sure enough, you’re thinking in that direction. So a big +1 on ‘ such as the ability to debug production shaders in javascript’ :) I’d love to see that…

  2. Jason says:

    An GLSL Compiler to LLVM would be good.

  3. skrat says:

    Amazing, I just had a need to do some single frame rendering, and this (if works) will enable IE and mobile WebKit. I suppose this should mostly be run in web worker (if not debugging).