GLSLANG(1)

✨ NAME ✨

glslang β€” the OpenGL (ES) Shading Language Reference Compiler πŸ’…βœ¨


πŸ¦‹ SYNOPSIS πŸ¦‹

glslang [OPTION]... [FILE]...

πŸ’– DESCRIPTION πŸ’–

okay so bestie, glslang is the official reference compiler front end for the OpenGL ES and OpenGL shading languages πŸŽ€. It implements a strict interpretation of the specs for those languages. It's open and free for literally anyone to use β€” from a command line or programmatically, your call 🫢. And the OpenGL and OpenGL ES working groups are committed to keeping consistency between the reference compiler and the corresponding shading language specifications. iconic behavior, honestly.

The whole point of the reference compiler is to sniff out shader portability issues πŸ•΅οΈβ™€οΈ. Like: if glslang accepts a shader with zero errors, then every OpenGL and OpenGL ES implementation claiming to support that shader's language version should also accept it with zero errors. Fr fr. And flip side β€” if glslang reports an error while compiling a shader, then all OpenGL and OpenGL ES implementations for that language version should report errors too, unless the glslang errors come from differences in implementation-defined limits or extension support. iykyk 😌

glslang can also generate SPIR-V from GLSL 🌈. But heads up: this feature is experimental and non-optimized πŸ’€. Not me warning you twice, it's in the spec.


🌸 FILE 🌸

the file extension of FILE decides the auto-stage classification for you, no cap:

  • .conf β€” to provide a config file that replaces the default configuration (peep the -c option below for generating a template πŸŽ€)
  • .vert β€” for a vertex shader
  • .tesc β€” for a tessellation control shader
  • .tese β€” for a tessellation evaluation shader
  • .geom β€” for a geometry shader
  • .frag β€” for a fragment shader
  • .comp β€” for a compute shader

πŸ”₯ OPTIONS πŸ”₯

  • -C β€” cascading errors; risk crash from accumulation of error recoveries πŸ’€ be careful bestie
  • -D β€” input is HLSL
  • -D<macro=def>, -D<macro> β€” define a pre-processor macro ✨
  • -E β€” print pre-processed GLSL; cannot be used with -l; errors will appear on stderr.
  • -G[ver] β€” create SPIR-V binary, under OpenGL semantics; turns on -l; default file name is <stage>.spv (-o overrides this). ver, when present, is the version of the input semantics, which will appear in #define GL_SPIRV ver. --client opengl100 is the same as -G100, and --target-env for OpenGL will also imply -G πŸ‘‘
  • -H β€” print human readable form of SPIR-V; turns on -V
  • -I<dir> β€” add dir to the include search path; the includer's directory is searched first, followed by left-to-right order of -I πŸ”
  • -Od β€” disables optimization. May cause illegal SPIR-V for HLSL. πŸ’€
  • -Os β€” optimizes SPIR-V to minimize size 🌱
  • -S <stage> β€” uses the specified stage rather than parsing the file extension. choices for stage are vert, tesc, tese, geom, frag, or comp
  • -U<macro> β€” undefine a pre-processor macro πŸ™ˆ
  • -V[ver] β€” create SPIR-V binary, under Vulkan semantics; turns on -l; default file name is <stage>.spv (-o overrides this). ver, when present, is the version of the input semantics, which will appear in #define VULKAN ver. --client vulkan100 is the same as -V100, and --target-env for Vulkan will also imply -V πŸ”₯
  • -c β€” configuration dump; creates the default configuration file (redirect it to a .conf file πŸŽ€)
  • -d β€” default to desktop (#version 110) when there is no shader #version (default is ES version 100)
  • -e <name> β€” specify name as the entry-point name ✨
  • -g β€” generate debug information πŸ›
  • -h β€” print this usage message
  • -i β€” intermediate tree (glslang AST) is printed out 🌳
  • -l β€” link all input files together to form a single module 🫢
  • -m β€” memory leak mode
  • -o <file> β€” save binary to file, requires a binary option (e.g., -V) πŸ’Ύ
  • -q β€” dump reflection query database
  • -r β€” synonym for --relaxed-errors
  • -s β€” silence syntax and semantic error reporting 🀫
  • -t β€” multi-threaded mode 🧡
  • -v β€” print version strings
  • -w β€” synonym for --suppress-warnings
  • -x β€” save binary output as text-based 32-bit hexadecimal numbers πŸ”’
  • --auto-map-bindings β€” automatically bind uniform variables without explicit bindings ✨
  • --amb β€” synonym for --auto-map-bindings
  • --auto-map-locations β€” automatically locate input/output lacking location (fragile, not cross stage) 😬
  • --aml β€” synonym for --auto-map-locations
  • --client {vulkan<ver>|opengl<ver>} β€” see -V and -G
  • --flatten-uniform-arrays β€” flatten uniform texture/sampler arrays to scalars 🫠
  • --fua β€” synonym for --flatten-uniform-arrays
  • --hlsl-offsets β€” allow block offsets to follow HLSL rules. Works independently of source language
  • --hlsl-iomap β€” perform IO mapping in HLSL register space
  • --keep-uncalled β€” don't eliminate uncalled functions 🫢
  • --ku β€” synonym for --keep-uncalled
  • --no-storage-format β€” use Unknown image format
  • --nsf β€” synonym for --no-storage-format
  • --relaxed-errors β€” relaxed GLSL semantic error-checking mode 😌
  • --resource-set-binding [stage] name set binding β€” set descriptor set and binding for individual resources
  • --resource-set-binding [stage] set β€” set descriptor set for all resources
  • --rsb [stage] type set binding β€” synonym for --resource-set-binding
  • --shift-image-binding [stage] num β€” base binding number for images (uav)
  • --shift-image-binding [stage] [num set]... β€” per-descriptor-set shift values
  • --sib [stage] num β€” synonym for --shift-image-binding
  • --shift-sampler-binding [stage] num β€” base binding number for samplers
  • --shift-sampler-binding [stage] [num set]... β€” per-descriptor-set shift values
  • --ssb [stage] num β€” synonym for --shift-sampler-binding
  • --shift-ssbo-binding [stage] num β€” base binding number for SSBOs
  • --shift-ssbo-binding [stage] [num set]... β€” per-descriptor-set shift values
  • --sbb [stage] num β€” synonym for --shift-ssbo-binding
  • --shift-texture-binding [stage] num β€” base binding number for textures
  • --shift-texture-binding [stage] [num set]... β€” per-descriptor-set shift values
  • --stb [stage] num β€” synonym for --shift-texture-binding
  • --shift-uav-binding [stage] num β€” base binding number for UAVs
  • --shift-uav-binding [stage] [num set]... β€” per-descriptor-set shift values
  • --suavb [stage] num β€” synonym for --shift-uav-binding
  • --shift-UBO-binding [stage] num β€” base binding number for UBOs
  • --shift-UBO-binding [stage] [num set]... β€” per-descriptor-set shift values
  • --shift-cbuffer-binding [stage] num β€” synonym for --shift-UBO-binding
  • --shift-cbuffer-binding [stage] [num set]... β€” synonym for --shift-UBO-binding
  • --sub [stage] num β€” synonym for --shift-UBO-binding
  • --source-entrypoint <name> β€” the given shader source function is renamed to be the name given in -e πŸ”„
  • --sep β€” synonym for --source-entrypoint
  • --stdin β€” read from stdin instead of from a file. You'll have to provide the shader stage using -S. 🫢
  • --suppress-warnings β€” suppress GLSL warnings (except as required by #extension : warn) 🀫
  • --target-env {vulkan1.0|opengl} β€” set the execution environment code will execute in (as opposed to language semantics selected by --client). defaults: 'vulkan1.0' under --client vulkan<ver>, 'opengl' under --client opengl<ver>
  • --variable-name <name> β€” creates a C header file that contains a uint32_t array named name initialized with the shader binary code πŸŽ€
  • --vn <name> β€” synonym for --variable-name <name>

πŸ‘‘ ALSO SEE πŸ‘‘


and that's the whole page bestie πŸ’– this one's from the glslang manual, dated December 2017, straight out of the General Commands Manual β€” go compile something gorgeous 🌈✨πŸ’