Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is there a way to validate GLSL syntax build-time instead of run-time? My application takes a long time to start and I want to know at the earliest possible stage that my shaders are ok. I'm using Visual Studio/Xcode. The solution probably involves running a tool as a part of build process, but I'm looking for such a tool.

share|improve this question

2 Answers 2

up vote 4 down vote accepted

NVIDIA's Cg Toolkit should be able to compile (or translate) shaders offline and spit errors. Another option is to create a tiny executable yourself that takes in a shader file and tries to compile it with your GPU driver's compiler (or perhaps such a compiler is already provided for you by the vendor). Though I think at least in the latter cases many compilers are too forgiving to catch all errors.

Related question: Multiplatform GLSL shader validator?

share|improve this answer
    
Writing your own command line EXE to test during the build process is a great idea. –  Patrick Hughes Jun 25 '12 at 14:38

This is a pretty late reply, but some new options have shown up recently to address this.

Khronos released a reference compiler called glslangValidator that can perform syntax validation (and more) on GLSL shader files. If there are any issues with your shader, it will print them out with line number information.

You can set up a custom pre build step or the like in Visual Studio or XCode to run this tool on your shader files.

I also wrote a Property Sheet for Visual Studio that makes use of glslangValidator to do build time validation of shader files. You can find it here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.