Usage: slangc [options...] [--]
General
=======
General options
-D[=], -D [=]: Insert a preprocessor macro.
The space between - D and is optional. If no is specified, Slang will define the macro with an empty
value.
-depfile : Save the dependency list in a file. Lists source files and any imported precompiled
.slang-module files.
Uses Makefile dependency syntax: :
When no -o is given, - is used as the make target (output goes to stdout).
-entry : Specify the name of an entry-point function.
When compiling from a single file, this defaults to main if you specify a stage using -stage.
Multiple -entry options may be used in a single invocation. When they do, the file associated with the entry point
will be the first one found when searching to the left in the command line.
If no -entry options are given, compiler will use [shader(...)] attributes to detect entry points.
-specialize : Specialize the last entrypoint with .
-emit-ir: Emit IR typically as a '.slang-module' when outputting to a container.
-h or -h : Print this message, or help in specified category.
To get a list of values that can be used for , use "slangc -h help-category"
-help-style : Help formatting style
To get a list of values that can be used for , use "slangc -h help-style"
-I, -I : Add a path to be used in resolving '#include' and 'import' operations.
-lang : Set the language for the following input files. Required when an input is '-' (standard input),
because stdin has no file extension.
To get a list of values that can be used for , use "slangc -h language"
-matrix-layout-column-major: Set the default matrix layout to column-major.
-matrix-layout-row-major: Set the default matrix layout to row-major.
-restrictive-capability-check: Many capability warnings will become an error.
-ignore-capabilities: Do not warn or error if capabilities are violated
-minimum-slang-optimization: Perform minimum code optimization in Slang to favor compilation time.
-disable-non-essential-validations: Disable non-essential IR validations such as use of uninitialized variables.
-disable-source-map: Disable source mapping in the Obfuscation.
-module-name : Set the module name to use when compiling multiple .slang source files into a single module.
-o : Specify a path where generated output should be written.
Use `-` to write generated output to stdout. If no -target or -stage is specified, one may be inferred from file
extension (see ). If multiple -target options and a single -entry are present, each -o associates
with the first -target to its left. Otherwise, if multiple -entry options are present, each -o associates with the
first -entry to its left, and with the -target that matches the one inferred from .
-profile [+...]: Specify the shader profile for code generation.
Accepted profiles are:
* sm_{4_0,4_1,5_0,5_1,6_0,6_1,6_2,6_3,6_4,6_5,6_6,6_7,6_8,6_9,6_10}
* glsl_{150,330,400,410,420,430,440,450,460}
Additional profiles that include -stage information:
* {vs,hs,ds,gs,ps}_
See -capability for information on
When multiple -target options are present, each -profile associates with the first -target to its left.
To get a list of values that can be used for , use "slangc -h capability"
-stage : Specify the stage of an entry-point function.
When multiple -entry options are present, each -stage associated with the first -entry to its left.
May be omitted if entry-point function has a [shader(...)] attribute; otherwise required for each -entry option.
To get a list of values that can be used for , use "slangc -h stage"
-target : Specifies the format in which code should be generated.
To get a list of values that can be used for , use "slangc -h target"
-v, -version: Display the build version. This is the contents of git describe --tags.
It is typically only set from automated builds(such as distros available on github).A user build will by default be
'unknown'.
-std : Specifies the language standard that should be used.
To get a list of values that can be used for , use "slangc -h language-version"
-warnings-as-errors all or -warnings-as-errors [,...]: all - Treat all warnings as errors.
[,...]: Treat specific warning ids as errors.
-warnings-disable [,...]: Disable specific warnings, given by numeric id or name. A numeric id that this
compiler version does not recognize is silently ignored, so one option value can be shared across compiler versions
that do not all define the warning; an unrecognized warning name is still reported as an error.
-notes-disable [,...]: Disable specific notes, given by numeric id or name.
-Wall | -Wextra | -Wpedantic: Enable the corresponding group of warnings (additive). The groups are independent:
-Wextra is on by default, while -Wall and -Wpedantic are off by default.
-W: Enable a warning with the specified id.
-Wno-: Disable warning with
-dump-warning-diagnostics: Dump to output list of warning diagnostic numeric and name ids.
--: Treat the rest of the command line as input files. Use '-' once to read from standard input; -lang is required,
stdin is limited to 256 MiB, and diagnostics use ``.
-report-downstream-time: Reports the time spent in the downstream compiler.
-report-perf-benchmark: Reports compiler performance benchmark results.
-report-detailed-perf-benchmark: Reports compiler performance benchmark results for each intermediate pass (implies
-report-perf-benchmark).
-report-checkpoint-intermediates: Reports information about checkpoint contexts used for reverse-mode automatic
differentiation.
-trace-coverage: Instrument the shader with per-statement line coverage counters. Statements that provably execute
together share one counter and one runtime probe, which keeps instrumented shader code small without changing
reported per-line results; the manifest therefore reports no more counters than source entries, and fewer whenever
a straight-line region is coalesced. When writing compiled output to a file, slangc also emits
`.coverage-manifest.json` mapping source coverage entries to counters.
-trace-function-coverage: Instrument the shader with per-function-entry coverage counters. Shares the synthesized
`__slang_coverage` buffer and coverage metadata path.
-trace-branch-coverage: Instrument the shader with per-branch-arm coverage counters for if/else, loop-condition,
switch case/default arms, and switch no-match default paths, and for the true/false arms of scalar `?:` conditions
and short-circuiting `&&` / `||` left operands. Shares the synthesized `__slang_coverage` buffer and coverage
metadata path.
-trace-coverage-boolean: Record boolean coverage instead of exact execution counts: each counter slot is written with
1 (via a plain non-atomic store) whenever its entry executes, rather than atomically incremented per execution.
This removes all atomic contention, so coverage is dramatically faster and avoids the GPU watchdog timeouts that
heavy per-execution counting can trigger, at the cost of exact counts (the counter is 0 or non-zero). Off by
default. Ignored when no coverage mode is enabled.
-trace-coverage-binding : Bind the synthesized `__slang_coverage` buffer at an explicit (register
index, space) instead of auto-allocating a slot. Useful when the host needs the binding fixed at compile time
before any host metadata reads run. Implies `-trace-coverage`.
-trace-coverage-bindless-index : Synthesize `__slang_coverage` as an unbounded descriptor array of structured
buffers rather than a single buffer, and index it with : `__slang_coverage[][slot]`. Many separately
compiled shaders sharing one pipeline then occupy a single descriptor binding rather than one binding each, and
each shader's buffer is sized independently by the host. Place the array with `-trace-coverage-binding
`, or leave it to auto-allocation. If the host declares the descriptor array with a VARIABLE descriptor
count, Vulkan requires it to be the highest-numbered binding in its set; a fixed descriptor count carries no such
restriction. That is the host's layout to satisfy, and the compiler cannot see it. is a compile-time
constant and so becomes part of the compiled output: a host that keys a shader cache on that output must derive
from a stable shader identity rather than from load order, or an unchanged shader recompiles whenever that
order shifts. SPIR-V and GLSL only. Implies `-trace-coverage`.
-trace-coverage-reserved-space : Reserve a descriptor set when auto-allocating the synthesized
`__slang_coverage` buffer. Use this when the host pipeline layout owns descriptor sets that are not visible in the
compiled shader IR. Repeat for multiple spaces; duplicates are idempotent. Applies to Khronos descriptor-set
targets.
-coverage-manifest-output : Write shader coverage manifest metadata to an explicit JSON sidecar path. Use this
when compiled output is written to stdout or when the build needs a stable manifest path instead of the default
`.coverage-manifest.json` sidecar. Requires at least one coverage tracing mode, is not supported for
container outputs, and is valid only when exactly one compiled artifact carries coverage metadata. The path must
not overlap any emitted artifact path.
-trace-coverage-counter-width : Per-slot bit width of the synthesized `__slang_coverage` buffer. Accepts `64`
(default) or `32`. uint64 counters effectively cannot wrap within any practical run; uint32 counters wrap silently
at 2^32 hits per slot. Use `32` when targeting a runtime driver that does not support 64-bit shader atomic add
(notably MoltenVK on Apple Silicon, which exposes `shaderBufferInt64Atomics = false`). Metal targets (`metal`,
`metallib`, `metallib-asm`): MSL provides no 64-bit atomic fetch-add, so counting-mode counters are capped to 32
bits; an explicitly requested `64` is capped with warning E45115. Boolean coverage (`-trace-coverage-boolean`)
writes plain non-atomic stores and honors the requested width on all targets. Implies `-trace-coverage` is
meaningful; ignored when no coverage mode is enabled.
-report-dynamic-dispatch-sites: Reports information about dynamic dispatch sites for interface calls.
-skip-spirv-validation: Skips spirv validation.
-source-embed-style : If source embedding is enabled, defines the style used. When enabled (with
any style other than `none`), will write compile results into embeddable source for the target language. If no
output file is specified, the output is written to stdout. If an output file is specified it is written either to
that file directly (if it is appropriate for the target language), or it will be output to the filename with an
appropriate extension.
Note for C/C++ with u16/u32/u64 types it is necessary to have "#include " before the generated file.
To get a list of values that can be used for , use "slangc -h source-embed-style"
-source-embed-name : The name used as the basis for variables output for source embedding.
-source-embed-language : The language to be used for source embedding. Defaults to C/C++. Currently only
C/C++ are supported
To get a list of values that can be used for , use "slangc -h language"
-disable-short-circuit: Disable short-circuiting for "&&" and "||" operations
-unscoped-enum: Treat enum types as unscoped by default. (Note: enum class remains scoped.)
-preserve-params: Preserve all resource parameters in the output code, even if they are not used by the shader.
-conformance :[=]: Include additional type conformance during linking for
dynamic dispatch.
-reflection-json : Emit reflection data in JSON format to a file.
-bitfield-packing-rules : Select the rules to use for packing bitfields. The value must be
one of the documented below. Cannot be combined with -msvc-style-bitfield-packing.
To get a list of values that can be used for , use "slangc -h bitfield-packing-rules"
-msvc-style-bitfield-packing: Deprecated. Uses the same packing rules as -bitfield-packing-rules
legacy-msb-first-msvc. Use -bitfield-packing-rules msvc for MSVC's bit order and type-size grouping on
little-endian platforms. Cannot be combined with -bitfield-packing-rules.
Target
======
Target code generation options
-capability [+...]: Add optional capabilities to a code generation target. See Capabilities
below.
To get a list of values that can be used for , use "slangc -h capability"
-default-image-format-unknown: Set the format of R/W images with unspecified format to 'unknown'. Otherwise try to
guess the format.
-disable-dynamic-dispatch: Disables generating dynamic dispatch code.
-disable-specialization: Disables generics and specialization pass.
-fp-mode , -floating-point-mode : Control floating point optimizations
To get a list of values that can be used for , use "slangc -h fp-mode"
-denorm-mode-fp16 : Control handling of 16-bit denormal floating point values in SPIR-V (any,
preserve, ftz)
To get a list of values that can be used for , use "slangc -h fp-denormal-mode"
-denorm-mode-fp32 : Control handling of 32-bit denormal floating point values in SPIR-V and DXIL
(any, preserve, ftz)
To get a list of values that can be used for , use "slangc -h fp-denormal-mode"
-denorm-mode-fp64 : Control handling of 64-bit denormal floating point values in SPIR-V (any,
preserve, ftz)
To get a list of values that can be used for , use "slangc -h fp-denormal-mode"
-g, -g, -g: Include debug information in the generated code, where possible.
is the amount of information, 0..3, unspecified means 2
specifies a debugging info format
It is valid to have multiple -g options, such as a and a
To get a list of values that can be used for , use "slangc -h debug-info-format"
To get a list of values that can be used for , use "slangc -h debug-level"
-line-directive-mode : Sets how the `#line` directives should be produced. Available options are:
If not specified, default behavior is to use C-style `#line` directives for HLSL and C/C++ output, and traditional
GLSL-style `#line` directives for GLSL output.
To get a list of values that can be used for , use "slangc -h line-directive-mode"
-O: Set the optimization level.
To get a list of values that can be used for , use "slangc -h optimization-level"
-obfuscate: Remove all source file information from outputs.
-force-glsl-scalar-layout, -fvk-use-scalar-layout: Make data accessed through ConstantBuffer, ParameterBlock,
StructuredBuffer, ByteAddressBuffer and general pointers follow the 'scalar' layout when targeting GLSL or SPIRV.
-fvk-use-dx-layout: Pack members using FXCs member packing rules when targeting GLSL or SPIRV.
-fvk-use-c-layout: Make data accessed through ConstantBuffer, ParameterBlock, StructuredBuffer, ByteAddressBuffer and
general pointers follow the C/C++ structure layout rules when targeting SPIRV.
-fvk--shift : For example '-fvk-b-shift ' shifts by N the inferred binding
numbers for all resources in 'b' registers of space . For a resource attached with :register(bX, )
but not [vk::binding(...)], sets its Vulkan descriptor set to and binding number to X + N. If you need to
shift the inferred binding numbers for more than one space, provide more than one such option. If more than one
such option is provided for the same space, the last one takes effect. If you need to shift the inferred binding
numbers for all sets, use 'all' as .
To get a list of values that can be used for , use "slangc -h vulkan-shift"
Links:
* DXC description: https://github.com/Microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#implicit-binding-number-assignment
* GLSL wiki: https://github.com/KhronosGroup/glslang/wiki/HLSL-FAQ#auto-mapped-binding-numbers
-fvk-bind-globals : Places the $Globals cbuffer at descriptor set and binding
.
It lets you specify the descriptor for the source at a certain register.
Links:
* DXC description: https://github.com/Microsoft/DirectXShaderCompiler/blob/main/docs/SPIR-V.rst#implicit-binding-number-assignment
-fvk-invert-y: Negates (additively inverts) SV_Position.y before writing to stage output.
-fvk-use-dx-position-w: Reciprocates (multiplicatively inverts) SV_Position.w after reading from stage input. For use
in fragment shaders only.
-fvk-use-entrypoint-name: Uses the entrypoint name from the source instead of 'main' in the spirv output.
-fvk-use-gl-layout: Use std430 layout instead of D3D buffer layout for raw buffer load/stores.
-fspv-reflect: Include reflection decorations in the resulting SPIRV for shader parameters.
-enable-effect-annotations: Enables support for legacy effect annotation syntax.
-emit-spirv-via-glsl: Generate SPIR-V output by compiling generated GLSL with glslang
-emit-spirv-directly: Generate SPIR-V output directly (default)
-spirv-core-grammar: A path to a specific spirv.core.grammar.json to use when generating SPIR-V output
-incomplete-library: Allow generating code from incomplete libraries with unresolved external functions
-bindless-space-index : Specify the space index for the system defined global bindless resource array.
-spirv-resource-heap-stride : Specify the byte stride for the resource descriptor heap when generating SPIRV
with spvDescriptorHeapEXT. Defaults to 0, which will use OpConstantSizeOfEXT(ResourceType); for
RaytracingAccelerationStructure entries, the 0 default emits a literal 8-byte ArrayStride for the uint64 device
address elements. An explicit stride value still overrides these defaults; for acceleration-structure entries it
must be at least 8 bytes.
-spirv-sampler-heap-stride : Specify the byte stride for the sampler descriptor heap when generating SPIRV
with spvDescriptorHeapEXT. Defaults to 0, which will use OpConstantSizeOfEXT(OpTypeSampler).
-spirv-unified-descriptor-heap-stride: When generating SPIRV with spvDescriptorHeapEXT, emit each resource
descriptor-heap runtime array's ArrayStride as the maximum of image and buffer descriptor sizes, so a single heap
shared by buffers and images is indexed at the device's unified stride. Only affects the default
OpConstantSizeOfEXT path (used when -spirv-resource-heap-stride is 0); mutually exclusive with a non-zero
-spirv-resource-heap-stride (combining the two is an error). Does not affect the sampler heap or
acceleration-structure entries.
-separate-debug-info: Emit debug data to a separate file, and strip it from the main output file. By default, the
debug file path is derived from the main `-o ` output as a fallback. Use `-separate-debug-info-output `
to override it or when the main artifact is written to stdout.
-separate-debug-info-output : Write separate debug information to an explicit sidecar path, overriding the
fallback path derived from `-o `. Requires `-separate-debug-info` and allows the main artifact to be written
to stdout. Use `-` to write the separate debug information to stdout when the main artifact is written to a file.
-debug-info-include-source: Embed the shader source text into the debug information, independently of the `-g` debug
level. At `-g1` the source is embedded via the core SPIR-V `OpSource` instruction (no NonSemantic extension
required); at `-g2`/`-g3` the source is already embedded so this is a no-op. Requires debug information: using it
with `-g0`, or without any `-g` option, is an error. Only affects SPIR-V output.
-emit-cpu-via-cpp: Generate CPU targets using C++ (default)
-emit-cpu-via-llvm: Generate CPU targets using LLVM
-llvm-target-triple : Sets the target triple for the LLVM target, enabling cross compilation. The
default value is the host platform.
-llvm-cpu : Sets the target CPU for the LLVM target, enabling the extensions and features of that CPU. The
default value is "generic".
-llvm-features : Sets a comma-separates list of architecture-specific features for the LLVM
targets.
Downstream
==========
Downstream compiler options
--path : Specify path to a downstream executable or library.
To get a list of values that can be used for , use "slangc -h compiler"
-get--path: Print the on-disk path of the downstream that Slang would load for that
pass-through, then continue. Reports "not found" if the compiler cannot be located, or "not available" if it has no
recoverable shared-library path. Takes no value.
To get a list of values that can be used for , use "slangc -h compiler"
-default-downstream-compiler : Set a default compiler for the given language. See -lang for the
list of languages.
To get a list of values that can be used for , use "slangc -h language"
To get a list of values that can be used for , use "slangc -h compiler"
-X -X... -X.: Pass arguments to downstream . Just -X
passes just the next argument to the downstream compiler. -X... options -X. will pass *all* of the
options inbetween the opening -X and -X. to the downstream compiler.
To get a list of values that can be used for , use "slangc -h compiler"
-pass-through : Pass the input through mostly unmodified to the existing compiler .
These are intended for debugging/testing purposes, when you want to be able to see what these existing compilers do
with the "same" input and options
To get a list of values that can be used for , use "slangc -h compiler"
Debugging
=========
Compiler debugging/instrumentation options
-dump-ast: Dump the AST to a .slang-ast file next to the input.
-dump-intermediate-prefix : File name prefix for -dump-intermediates outputs, default is no prefix
-dump-intermediates: Dump intermediate outputs for debugging.
-dump-ir: Dump the IR after every pass for debugging.
-dump-ir-ids: Dump the IDs with -dump-ir (debug builds only)
-E, -output-preprocessor: Output the preprocessing result and exit.
-no-codegen: Skip the code generation step, just check the code and generate layout.
-output-includes: Print the hierarchy of the processed source files.
-serial-ir: [REMOVED] Serialize the IR between front-end and back-end.
-skip-codegen: Skip the code generation phase.
-validate-ir: Validate the IR after select intermediate passes.
-validate-ir-detailed: Perform debug validation on IR after each intermediate pass.
-dump-ir-before : Dump IR before specified pass, may be specified more than once
-dump-ir-after : Dump IR after specified pass, may be specified more than once
-verbose-paths: When displaying diagnostic output aim to display more detailed path information. In practice this is
typically the complete 'canonical' path to the source file used.
-verify-debug-serial-ir: Verify IR in the front-end.
-dump-module: Disassemble and print the module IR.
-get-module-info: Print the name and version of a serialized IR Module
-get-supported-module-versions: Print the minimum and maximum module versions this compiler supports
Experimental
============
Experimental options (use at your own risk)
-file-system : Set the filesystem hook to use for a compile request.
To get a list of values that can be used for , use "slangc -h file-system-type"
-heterogeneous: Output heterogeneity-related code.
-no-mangle: Do as little mangling of names as possible.
-no-hlsl-binding: Do not include explicit parameter binding semantics in the output HLSL code,except for parameters
that has explicit bindings in the input source.
-no-hlsl-pack-constant-buffer-elements: Do not pack elements of constant buffers into structs in the output HLSL code.
-validate-uniformity: Perform uniformity validation analysis.
-allow-glsl: Deprecated. Treat every input translation unit as GLSL. Use a GLSL file-name extension or `-lang glsl`
for each GLSL input instead.
-enable-experimental-passes: Enable experimental compiler passes
-Gec: Enable additional backwards-compatibility features for legacy HLSL inputs. See the user guide's HLSL backwards
compatibility section for the supported behavior.
-enable-experimental-dynamic-dispatch: Enable experimental dynamic dispatch features
-embed-downstream-ir: Embed downstream IR into emitted slang IR
-experimental-feature: Enable experimental language and module features
-enable-experimental-rich-diagnostics: Enable experimental rich diagnostics with enhanced formatting and details
-enable-machine-readable-diagnostics: Enable machine-readable diagnostic output in tab-separated format
-diagnostic-format : Select diagnostic formatting. 'default' preserves normal output; 'vs' uses Visual
Studio headers and uncolored, indented source details. Machine-readable diagnostics take precedence.
-diagnostic-color : Control colored diagnostic output (auto uses color if stderr is a tty)
Deprecated
==========
Deprecated options (allowed but ignored; may be removed in future)
-parameter-blocks-use-register-spaces: Parameter blocks will use register spaces
-zero-initialize: Initialize all variables to zero.Structs will set all struct-fields without an init expression to
0.All variables will call their default constructor if not explicitly initialized as usual.
Getting Help for Specific Categories
=====================================
To get help for a specific category of options or values, use: slangc -h
can be: General, Target, Downstream, Debugging, Repro, Experimental, Internal, Deprecated, compiler,
language, language-version, archive-type, line-directive-mode, debug-info-format, fp-mode, fp-denormal-mode,
help-style, optimization-level, debug-level, file-system-type, bitfield-packing-rules, source-embed-style, target,
stage, vulkan-shift, capability, file-extension, help-category