Skip to content

felixpalmer/glsl-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GLSL Validator

The GLSL validator is a tool for validating WebGL shaders, with support for adding prefixes to your shaders, leading to compatibility with libraries such as THREE.js, which automatically pass in variables into your shaders.

For more details, see post here

Usage

Add the directory containing the glsl-validate.py command to your path, then invoke using glsl-validate.py FILE [FILE ...]

Example output

If there any errors in the passed in shader files, they will be displayed along with the line they occured on:

The tool can also be used to generate the shader assembly instructions to give you an idea of how compute intensive it is. Note this is just a guide, actual instruction will be driver dependent.

Prefix files

In order to keep the ANGLE compiler happy, we prepend prefix files to the GLSL files being checked, which contain the code that a library will pass in.

The prefix files that the validator will use are prefix/prefix.frag and prefix/prefix.vert for fragment and vertex shaders, respectively. Example prefix files for various libraries can also be found in the prefix directory, e.g. prefix.threejs.vert.

To not load the prefix files, use the --raw flag.

Validation engine

To validate the GLSL code, the ANGLE compiler is used. Binaries have been taken from the Sublime Text GL Validator

CGC compiler

The tool uses the Cg Toolkit to get an estimate (it is driver dependant) of the shader instructions a given shader will output. The required binary for this to function is: cgc, which (on OSX) can be obtained by downloading the Cg Toolkit from https://developer.nvidia.com/cg-toolkit-download and then using Show package contents to extract the cgc binary from Cg-3.1.0013.app/Contents/Resources/Installer Items/NVIDIA_Cg.tgz (the installer did not work for me). l

About

Command line tool for validating GLSL files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published