It's Like Déjà Vu All Over Again
"You could probably waste an entire day on the preceding links alone. But why take chances? We also give you Paul Snively..." — John Wiseman, lemonodor
Cg ("C" for graphics) is a high-level graphics programming language NVIDIA has developed in cooperation with Microsoft for game developers and other 3D content developers to ease the process of bringing 3D objects to life on your computer screen
I'd be the last one to begrudge anybody their right to create their own DSL, but given that this looks like C with some domain-specific types and functions one has to wonder why they couldn't make this happen with C++ and an appropriate library.
Because writing a C++ compiler is damn hard, and what you're asking for would at the least require developing a C++ back-end, say for GCC, that targets a particular GPU such as nVidia's. Then you'd still need tools to allow the linking of the generated code into the generated code for your CPU, and a mechanism to provide the shader code to the GPU at app initialization time. etc.
Still, the impetus is a good one; see the Stanford Real-Time Programmable Shading Project for another stab at the problem. I rather strongly suspect that a good combination of C++ expression templates coupled with a good dynamic code generator for the GPU could indeed do most or all of what you want. Better still would be a system that used dynamic code generation for the GPUs that needed it, but OpenGL 2.0 shader language if it discovered that OpenGL 2.0 was available.
Systems to look at relative to these ideas might include PETE, C--, λ-RTL, or if that's too abstract, the New Jersey Machine-Code Toolkit. The idea is that expressions in a shader language embedded in C++ via PETE are compiled into calls to OpenGL 2.0 if available, or calls to C--, λ-RTL, and/or NJMCT APIs, which generate the appropriate code to give to the GPU.
11:19:35 AM
It being both my stepson's birthday and fathers' day today, I won't be writing much. (Yeah, I know I haven't been writing much the last several days anyway, but today I have an excuse.)
9:43:34 AM