FoxMcCloud
Newcomer
TL;DR: BSD licensed parser frontend for a very Cg-like shader language with a WIP GLSL 3.3 backend. Frontend allows AST access for operations like translation (to GLSL, HLSL, GL ES etc.) and code analysis / transformations like refactoring.
The TL:
I've been using a variant of Cg internally which gained the name "LiteGraph Shader Language" - it's mostly Cg with some syntactic sugar and very slight differences (things like bitwise_cast<>() instead of floatToRawIntBits()) and a simple translation layer would work on input shaders before passing them to Cg with another offline translator that would generate modern GLSL code when cgc would fall behind. The solution was hacky and fragile and I have been wanting to replace it for a long time - so I did.
I built a parser, a frontend that would go around annotating the parse tree and I'm working on proper transformation-pass based conversion to GLSL 3.3 - here's a sample input and output:
http://pastebin.com/fwfbr46E
It's designed to preserve formatting and generate human-readable code (as opposed to cgc's GLSL output) and the front-end preserves the location of tokens in files which can be used for showing error / warning messages and for better refactoring.
The passes responsible for the conversion of the posted sample are under 500 lines of C++11 code but they have not yet been tested in anger but I'll be working on them for the next few weeks since I plan to use that internally.
For the runtime part the older version used to just fall-through to the Cg runtime, but for OpenGL 3.2+ core profiles the Cg runtime fails and I'm working on a core profile runtime for that case - the ability to inspect the program's parse tree while compiling is hugely helpful here. I plan to release everything (parser, backend, runtime) under the BSD License.
So, here's the source code I'm releasing so far:
Parser library: https://bitbucket.org/sherief/semparse-library
Parse tree YAML serialization: https://bitbucket.org/sherief/semparse-yaml-serialization
Python code to read serialized parse trees (YAML): https://bitbucket.org/sherief/semparse-library-python
An OS X app to view parse trees graphically: https://bitbucket.org/sherief/semantic-graph-editor
Shader parser / GLSL translator (library, embeddable): https://bitbucket.org/sherief/litegraph-shader-compiler
Shader compiler driver (thin cli app to wrap the library): https://bitbucket.org/sherief/litegraph-shader-compiler-driver
If anyone's interested in using the libraries or adapting the front-end to convert, say, HLSL to GLSL drop me a line - I'd be interested in working with you.
Feedback, comments and criticism welcome etc. - would like to hear everyone's $0.02.
The TL:
I've been using a variant of Cg internally which gained the name "LiteGraph Shader Language" - it's mostly Cg with some syntactic sugar and very slight differences (things like bitwise_cast<>() instead of floatToRawIntBits()) and a simple translation layer would work on input shaders before passing them to Cg with another offline translator that would generate modern GLSL code when cgc would fall behind. The solution was hacky and fragile and I have been wanting to replace it for a long time - so I did.
I built a parser, a frontend that would go around annotating the parse tree and I'm working on proper transformation-pass based conversion to GLSL 3.3 - here's a sample input and output:
http://pastebin.com/fwfbr46E
It's designed to preserve formatting and generate human-readable code (as opposed to cgc's GLSL output) and the front-end preserves the location of tokens in files which can be used for showing error / warning messages and for better refactoring.
The passes responsible for the conversion of the posted sample are under 500 lines of C++11 code but they have not yet been tested in anger but I'll be working on them for the next few weeks since I plan to use that internally.
For the runtime part the older version used to just fall-through to the Cg runtime, but for OpenGL 3.2+ core profiles the Cg runtime fails and I'm working on a core profile runtime for that case - the ability to inspect the program's parse tree while compiling is hugely helpful here. I plan to release everything (parser, backend, runtime) under the BSD License.
So, here's the source code I'm releasing so far:
Parser library: https://bitbucket.org/sherief/semparse-library
Parse tree YAML serialization: https://bitbucket.org/sherief/semparse-yaml-serialization
Python code to read serialized parse trees (YAML): https://bitbucket.org/sherief/semparse-library-python
An OS X app to view parse trees graphically: https://bitbucket.org/sherief/semantic-graph-editor
Shader parser / GLSL translator (library, embeddable): https://bitbucket.org/sherief/litegraph-shader-compiler
Shader compiler driver (thin cli app to wrap the library): https://bitbucket.org/sherief/litegraph-shader-compiler-driver
If anyone's interested in using the libraries or adapting the front-end to convert, say, HLSL to GLSL drop me a line - I'd be interested in working with you.
Feedback, comments and criticism welcome etc. - would like to hear everyone's $0.02.
Last edited by a moderator: