![]() |
![]() |
![]() |
High-level shader language (HLSL) shaders can be compiled from the command line using the following executable:
(SDK root)\Utilities\fxc.exe
The usage is:
fxc options filename |
---|
Where:
options can be the following compiler switch options:
Switch Option | Description |
---|---|
/D id= text | Define a macro |
/E name | Identify the entry point |
/Fc file | Generate assembly code listing file |
/Fh file | Generate header containing object code |
/Fo file | Generate object file |
/Fx file | Generate assembly code and hex listing file |
/Gpp | Force partial precision |
/nologo | Suppress copyright message |
/Od | Disable optimizations |
/T profile | Identify the target profile, which is one of the following:
|
/Vd | Disable validation |
/Zi | Enable debugging information |
/Zpc | Pack matrices in column-major order |
/Zpr | Pack matrices in row-major order |
Using the HLSLwithoutEffects Sample, here's an example of compiling the HLSL shader in the file HLSLwithoutEffects.vsh for a vs_2_0 target profile:
// For a release build fxc /T vs_2_0 /Fo HLSLwithoutEffects.fxo HLSLwithoutEffects.vsh // For a debug build fxc /Od /Zi /T vs_2_0 /Fo HLSLwithoutEffects.fxo HLSLwithoutEffects.vsh
The debug options include additional options to disable compiler optimizations and enable debug information like line numbers, symbols, and so on. The binary representation of the shader is written to a file called HLSLwithoutEffects.fxo which is an arbitrary abbreviation for the fxc output file.
The command line compiler can also be used to compile a shader within an effect. This can be seen in the CompiledEffect Sample.