Using precompiled shaders?

I was thinkin’ about using glslang in a 64kb intro and haven’t found any good information about precompiling a shader. In all documentaion I’ve found it seems like that the shader code is supposed to be loaded from a text file. I would like to compile this text file and then save the compiled data for loading since it would be smaller in size. Is this possible?

There is no precompiled format of GLSL shaders, because every hardware needs a specific machine code.
You don’t need to load a shader from a file. You can also put it into a string constant in your application’s source.
It’s possible to compile GLSL shaders to vertex and fragment program assembly with NVIDIA’s Cg compiler, but assembly source is generally not smaller than highlevel sources.

ok, thanks Relic.
I had a notion about different vendors compiling things on different ways to work with their hardware.
But if the compiled data isn’t much smaller then the original text file then perhaps it doesn’t matter really. The exe-packer will atleast kill some of the text size.


I’m using GLGL for the next 64K too. UPX packs ASCII strings really nice. I’m playing around a bit with MTF and other algorithms to squeeze the size, but it isn’t really neccesary.

The only “space-eater” is the extension loading. Btw, maybe you might find this usefull:

It’s just a fast hacked C# program that generates .h and .c file for extension loading. Microsoft .NET framework required.
C++ style comments work… simply comment out the functions you don’t need.

Cheers, E1.

The only “space-eater” is the extension loading.
If you only load the necessary entry points for defining and using programs, and standardize on a single way of specifying uniforms, and a single way of specifying vertex data, I don’t think you need all that many extension functions. The strings of the function names are the worst, really – but if you need lots, then calculating 32-bit checksums of the symbol names, and walking the symbol table of the GL driver, and loading functions whose names match the checksums might save you a bit :wink:

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