0

GLSL and CG toolkit are simply not sufficient for my needs and it appears my only option is to write my own compiler. I basically need a diagram of the binary shader structure so I can build it myself from a script.

EDIT: Ok I think what I'm looking for is the binary structure of arb assembly.

3
  • 3
    How come they are not sufficient? + It will be really hard task, like in really hard Commented Aug 10, 2012 at 19:53
  • Desugar your own shaders into GLSL/Cg and compile using already-existing tools. Otherwise have fun wasting time. Commented Aug 10, 2012 at 19:56
  • What is it you're doing that can't be done, especially with OpenGL-OpenCL interop? I'm VERY curious to know. Commented Aug 10, 2012 at 20:09

1 Answer 1

3

How to build my own opengl shader compiler?

You don't. At least, not in the way that you mean.

OpenGL does not define a binary or assembly interchange format. OpenGL itself directly compiles GLSL into objects. And even though you can query the binary data, OpenGL does not provide a means to explain what that binary data actually stores. It is implementation-dependent. NVIDIA and AMD will store different info, and that will be different from what Intel stores. It will change for each generation of hardware. And so forth.

You can write a compiler that generates GLSL. But that's about it.

If you're willing to stick with NVIDIA, they have been good about keeping the ARB assembly language up-to-date. But obviously, any such code would be NVIDIA-only.

Sign up to request clarification or add additional context in comments.

6 Comments

If that is the case does CG compile into GLSL? If not then how does CG work?
@Steve: Define "work"? Cg can "work" in one of two ways: the NVIDIA specific way compiles it into NVIDIA's shader assembly language, which is compiled into the hardware-specific internal machine language. The "cross-platform" way is to compile it into GLSL, which you then compile with OpenGL's normal tools.
@SteveDeFacto: And you never answered the most important question: what is "not sufficient" about GLSL?
Honestly in my opinion the language is horribly designed. I need something more like fx or cgfx. cgfx would be perfect but I can't find cg toolkit binaries for android...
@Steve: I won't debate the quality or lack thereof of GLSL (though I will say that the quality rather depends on what version you're using. I find 3.30 pretty reasonable and 4.30 quite good). However, you're working on OpenGL ES, where such things are not available. If you want to use an FX format and runtime, you'll have to write one. Though there's nothing that says you can't write an FX runtime for GLSL ES.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.