GLSL Compiler


Simple question:

is there a way to compile my shader outside my program? so that I can ship it with the bytecode of the shader and not the sourcecode? I mean, even crypting the shader a) slows down my prog and b) can be worked arround with a modified opengl32.dll …

thanks for help!


Try Cg 1.3 beta 2. You can use cgc.exe and pass the -oglsl flag to indicate you are giving the compiler GLSL code.

For example:

cgc -oglsl -strict -profile arbfp1 input.glsl

GLSL is expected to be eaten directly by the driver, there is no user visible bytecode. The compiled result sent to the card by the driver is most certainly hardware dependant anyway.

It was done that way to give more freedom to the hardware design.

You can use CG to compile offline from GLSL to whatever asm profile, but this is no more GLSL.

I would not recommend using Cg instead of GLSL since it doesn’t give you any advantage at all in this case. Not only that, but it’s likely going to be a good deal slower than using GLSL on all non-nVidia hardware.

means, theres no way at the moment to ship something like bytecode instead of uncompiled code…
I don’t want to use workarounds like the cg-one. because this makes it more hardware-dependend.

thanks for help.

  1. No, it’s not possible to send bytecode, although this issue was discussed by the ARB.

  2. All machine code can be reversed engineered, unless some kind of high encryption method is implemented. Maybe PKE (public key encryption) between driver and your app.
    That can be suggested in the other forum.

  3. “modified opengl32.dll” can be easily detected. They will be present in the folder of your exe.

How about obfuscating your shader code before you ship your app?

– Tom

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.