D3DCOMPILE Constants

The D3DCOMPILE constants specify how the compiler compiles the HLSL code.

Constant Description Note
D3DCOMPILE_DEBUG
/Zi
Directs the compiler to insert debug file/line/type/symbol information into the output code. See D3DXSHADER_DEBUG
D3DCOMPILE_SKIP_VALIDATION
/Vd
Directs the compiler not to validate the generated code against known capabilities and constraints. We recommend that you use this constant only with shaders that have been successfully compiled in the past. DirectX always validates shaders before it sets them to a device. See D3DXSHADER_SKIPVALIDATION
D3DCOMPILE_SKIP_OPTIMIZATION
/Od
Directs the compiler to skip optimization steps during code generation. We recommend that you set this constant for debug purposes only. See D3DXSHADER_SKIPOPTIMIZATION
D3DCOMPILE_PACK_MATRIX_ROW_MAJOR
/Zpr
Directs the compiler to pack matrices in row-major order on input and output from the shader. See D3DXSHADER_PACKMATRIX_ROWMAJOR
D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR
/Zpc
Directs the compiler to pack matrices in column-major order on input and output from the shader. This type of packing is generally more efficient because a series of dot-products can then perform vector-matrix multiplication. See D3DXSHADER_PACKMATRIX_COLUMNMAJOR
D3DCOMPILE_PARTIAL_PRECISION
/Gpp
Directs the compiler to perform all computations with partial precision. If you set this constant, the compiled code might run faster on some hardware. See D3DXSHADER_PARTIALPRECISION
D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT
Directs the compiler to compile a vertex shader for the next highest shader profile. This constant turns debugging on and optimizations off. This flag was applicable only to Direct3D 9. See D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT
D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT
Directs the compiler to compile a pixel shader for the next highest shader profile. This constant also turns debugging on and optimizations off. This flag was applicable only to Direct3D 9. See D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT
D3DCOMPILE_NO_PRESHADER
/Op
Directs the compiler to disable Preshaders. If you set this constant, the compiler does not pull out static expression for evaluation. This flag was only applicable to legacy Direct3D 9 and Direct3D 10 Effects (FX). See D3DXSHADER_NO_PRESHADER
D3DCOMPILE_AVOID_FLOW_CONTROL
/Gfa
Directs the compiler to not use flow-control constructs where possible. See D3DXSHADER_AVOID_FLOW_CONTROL
D3DCOMPILE_ENABLE_STRICTNESS
/Ges
Forces strict compile, which might not allow for legacy syntax. By default, the compiler disables strictness on deprecated syntax.
D3DCOMPILE_IEEE_STRICTNESS
/Gis
Forces the IEEE strict compile which avoids optimizations that may break IEEE rules. See D3DXSHADER_IEEE_STRICTNESS
D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY
/Gec
Directs the compiler to enable older shaders to compile to 5_0 targets. See D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY
D3DCOMPILE_OPTIMIZATION_LEVEL0
/O0
Directs the compiler to use the lowest optimization level. If you set this constant, the compiler might produce slower code but produces the code more quickly. Set this constant when you develop the shader iteratively. See D3DXSHADER_OPTIMIZATION_LEVEL0
D3DCOMPILE_OPTIMIZATION_LEVEL1
/O1
Directs the compiler to use the second lowest optimization level. See D3DXSHADER_OPTIMIZATION_LEVEL1
D3DCOMPILE_OPTIMIZATION_LEVEL2
/O2
Directs the compiler to use the second highest optimization level. See D3DXSHADER_OPTIMIZATION_LEVEL2
D3DCOMPILE_OPTIMIZATION_LEVEL3
/O3
Directs the compiler to use the highest optimization level. If you set this constant, the compiler produces the best possible code but might take significantly longer to do so. Set this constant for final builds of an application when performance is the most important factor. See D3DXSHADER_OPTIMIZATION_LEVEL3
D3DCOMPILE_WARNINGS_ARE_ERRORS
/WX
Directs the compiler to treat all warnings as errors when it compiles the shader code. We recommend that you use this constant for new shader code, so that you can resolve all warnings and lower the number of hard-to-find code defects.
D3DCOMPILE_RESOURCES_MAY_ALIAS
/res_may_alias
Directs the compiler to assume that unordered access views (UAVs) and shader resource views (SRVs) may alias for cs_5_0. Only applies to DirectX 12 / Shader Model 5.1
D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES
/enable_unbounded_descriptor_tables
Directs the compiler to enable unbounded descriptor tables. Only applies to DirectX 12 / Shader Model 5.1
D3DCOMPILE_ALL_RESOURCES_BOUND
/all_resources_bound
Directs the compiler to ensure all resources are bound. Only applies to DirectX 12 / Shader Model 5.1
D3DCOMPILE_DEBUG_NAME_FOR_SOURCE
/Zss
When generating debug PDBs this makes use of the source file and binary for the hash.
D3DCOMPILE_DEBUG_NAME_FOR_BINARY
/Zsb
When generating debug PDBs this makes use of the binary file name only for the hash.

Note

The D3DCOMPILE_RESOURCES_MAY_ALIAS, D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES, and D3DCOMPILE_ALL_RESOURCES_BOUND compiler constants are new starting with the D3dcompiler_47.dll that ships with the Windows 8.1 SDK or later.

Note

The D3DCOMPILE_DEBUG_NAME_FOR_SOURCE and D3DCOMPILE_DEBUG_NAME_FOR_BINARY compiler constants are new starting with the D3dcompiler_47.dll that ships with the Windows 10 Fall Creator's Update SDK (version 16299) or later. See this blog post.

Note

For DirectX 12, Shader Model 5.1, the D3DCompile API, and FXC are all deprecated. Use Shader Model 6 via DXIL instead. See GitHub.

Requirements

Requirement Value
Header
D3DCompiler.h

See also

D3DCompiler Constants