Tools3 min read

CLI Reference

Complete reference for the bwslc command-line compiler.

Reading Time
3 min
Word Count
416
Sections
20
Try It Live

Turn the guide into code

Take the key idea from this page into the playground and validate it in a real shader instead of leaving it as theory.

Open Playground

The bwslc command compiles .bwsl shader files to SPIR-V and can additionally emit Metal, HLSL, GLSL, and GLSL ES output.

Examples below use bwslc. In a source checkout, that binary is typically ./build/bwslc.

Basic Usage

bash
bwslc <input.bwsl> [options]

Options

Core Options

OptionDescription
-o <dir>Output directory (default: current directory)
-modules <dir>Add a module search path (repeatable)
-variant <k=v>Specialize one named shader variant (repeatable)
-dump-variant-spacePrint variant reflection JSON and exit
-pass <name>Compile a specific pass (default: all passes)
-stage <name>Compile a specific stage: vertex, fragment, or compute

Output Format Flags

SPIR-V is always generated. Use these flags to add more outputs:

FlagDescription
-metalGenerate Metal Shading Language output
-hlslGenerate HLSL output
-glslGenerate GLSL 450 output
-glesGenerate GLSL ES 300 output
-gles-directGenerate GLSL ES directly from BWSL IR
-webglAlias for -gles
-bindingsEmit resolved resource binding JSON
-allGenerate all supported outputs

Debug Options

OptionDescription
-vVerbose output
-timingPrint timing information
-dump-irDump BWSL IR
-debug-namesEmit debug names in SPIR-V output
-no-validateSkip SPIR-V validation
-internalsWrite SPIR-V disassembly and IR dump to JSON
-h, --helpShow help

Examples

SPIR-V Only

bash
bwslc shader.bwsl

SPIR-V + Metal

bash
bwslc shader.bwsl -metal

Multiple Output Formats

bash
bwslc shader.bwsl -metal -hlsl -gles

All Outputs

bash
bwslc shader.bwsl -all

Source-Declared Resources

bash
bwslc shader.bwsl -all -bindings

Resources are declared in the shader with resources {} and selected per pass with use resources { ... }. The -bindings flag emits the resolved host binding metadata for those source-declared resources.

Specialize Shader Variants

bash
bwslc shader.bwsl -variant skinning=true -variant lighting=Clustered -metal

Boolean variants accept true, false, 1, or 0. Enum variants accept either a bare member name or a qualified name such as LightingMode::Clustered.

Dump Variant Reflection

bash
bwslc shader.bwsl -dump-variant-space

This prints JSON describing declared variants, implicit variants, legality rules, and the current selected values. See Shader Variants for the language-side model.

Custom Output Directory

bash
bwslc shader.bwsl -o dist/shaders -all

Compile a Specific Pass

bash
bwslc shader.bwsl -pass MainPass

Compile a Specific Stage

bash
bwslc shader.bwsl -pass Simulate -stage compute

Add Module Search Paths

bash
bwslc shader.bwsl -modules ./modules -modules ./lib/shaders

Emit Internal Debug Data

bash
bwslc shader.bwsl -internals -o build/shaders

Output Notes

Each compiled pass emits one output per selected stage and target format into the chosen output directory. Graphics passes produce vertex and fragment outputs; compute passes produce compute outputs.

See Also