The OpenGL 2.0 compiler challenge

By now most of you probably saw that we put up the source code for the OpenGL 2.0 compiler on our website. See http://www.3dlabs.com/support/developer/ogl2/sourcecode/index.htm if you want to download it.

The OpenGL 2.0 compiler we posted will parse the source of an OpenGL 2.0 vertex or fragment program, convert it into a high level intermediate format, and then call a back-end. This back-end is meant to be filled out by IHVs to generate object code that fits their specific hardware. The back-end included in this project traverses the intermediate format, and prints out what it finds. It is there just as a quick example. For more details take a look at the readme, and the code itself of course.

Now here is your challenge. We would love to see a back-end that generates DirectX 8.1 code, as well as code for NV_vertex_program and the new ARB_vertex_program (still under discussion by the ARB). This generated DirectX or vertex_program code can then be run on any compatible device. We think it very important for OpenGL 2.0 to have the shading language be compatible with as many different targets as possible. This will help spur shader development, proof that the OpenGL2 shading language is robust and complete, and that the code we have provided indeed does help others develop their OpenGL 2.0 implementation.

Of course DirectX8.1 and the vertex_program extensions do not support some features the OpenGL 2.0 shading language has. Like, for example, loops and function calls. That is quite OK, try to implement as much as possible for the target. If you’re interested in starting such a project, please let the development community and us know you’re doing this. It could be a good idea to make this a sourceforge project, for example.

If you’re reading this and work for an IHV, you should be taking a close look at what we’ve provided. If at all possible please share your experiences with how the OpenGL2 shading language maps onto your hardware with the ARB.

Have fun playing with it!

Barthold
3Dlabs

We would love to see a back-end that generates DirectX 8.1 code, as well as code for NV_vertex_program and the new ARB_vertex_program (still under discussion by the ARB).

I’ll assume you simply forgot about EXT_vertex_shader.

Yup, I did. Sorry. No bad intention on my part :slight_smile:

Barthold

Originally posted by barthold:

Of course DirectX8.1 and the vertex_program extensions do not support some features the OpenGL 2.0 shading language has. Like, for example, loops and function calls…

Sometimes the loops can be done using multipass or just by unfolding the loop. Or both. It would be nice if the future OpenGL 2.0 implementations implement such functionality for hardware that does not support loops.And of course the function calls can be inlined.

Yes, those are good suggestions. Of course, doing that you might run out of instruction space sooner than if it is natively available. Just be creative and get as much of the OpenGL 2.0 shading language implemented as possible.

Barthold

Barthold,

can you post a big bunch of sample scripts that test all the language keywords, constants, intrinsics etc… . Its hard getting to grips with a language specification from the yacc / lex source code.

thanks

Leo

Leo,

What exactly are you trying to do?
The OpenGL 2.0 shading language white paper describes the whole language. Using that is much easier to learn the language and get example shaders, you can then run to the compiler. http://www.3dlabs.com/support/developer/ogl2/whitepapers/index.htm

Barthold

barthold,

what I’m looking for is a collection of scripts that will enable me to walk through all the compilers frontend functions so that I can begin to get a grip of hoew the back end would work.

Cutting and pasting examples from a .pdf file is not really the best way to get started.

thanks

Leo

Leo,

Can you email me your email address?

Thanks,
Barthold