Export (0) Print
Expand All

Syntax

Here is the syntax for calling FXC.exe, the effect-compiler tool. For an example, see Offline Compiling.

fxc SwitchOptions Filename

Arguments

SwitchOptions

[in] Compile options. This is a list of 2 (required) or more (optional) options with a space between each.

Required SwitchOptionsDescription
/E <name>Shader entry point
/T <profile>Shader model (see profiles)

 

Optional SwitchOptionsDescription
/?, /helpPrint help for FXC.exe.
@<command.option.file>File that contains additional compile options.
  • This option can be mixed with other command line compile options.
  • The command.option.file must contain only one option per line.
  • The command.option.file cannot contain any blank lines.
  • Options specified in the file must not contain any leading or trailing spaces.
/CcOutput color-coded assembly.
/compressCompress DX10 shader bytecode from files.
/D <id>=<text>Define macro.
/decompressDecompress DX10 shader bytecode from first file. Output files should be listed in the order they were in during compression.
/dumpbinLoads a binary file rather than compiling a shader.
/Fc <file>Output assembly code listing file.
/Fd <file>Extract shader program database (PDB) info and write to the given file.

Note  Only supported starting with the Windows SDK version of FXC.

When you compile the shader, use /Fd to generate a PDB file with shader debugging info.
/Fe <file>Output warnings and errors to the given file.
/Fh <file>Output header file containing object code.
/Fl <file>Output a library.

Note  This option requires the D3dcompiler_47.dll or a later version of the DLL.

/Fo <file>Output object file.
/Fx <file>Output assembly code and hex listing file.
/GchCompile as a child effect for fx_4_x profiles.

Note  Support for legacy Effects profiles is deprecated.

/GdpDisable effect performance mode.
/GecEnable backwards compatibility mode.
/GesEnable strict mode.
/getprivate <file>Save private data from the shader blob (compiled shader binary) to the given file.

Note  Only supported starting with the Windows SDK version of FXC.

Extracts private data, previously embedded by /setprivate, from the shader blob.

Note  You must specify the /dumpbin option with /getprivate. For example:



fxc /getprivate ps01.private.data 
    /dumpbin ps01.with.private.obj

/GfaAvoid flow control constructs.
/GfpPrefer flow control constructs.
/GisForce IEEE strictness.
/GppForce partial precision.
/I <include>Additional include path.
/LDCompile using the DirectX 9 HLSL compiler. See the limitations in Compiling for Legacy Shader Models.

Note  Only supported by the legacy DirectX SDK version of FXC, not the Windows SDK version.

/LxOutput hexadecimal literals.

Note  This option requires the D3dcompiler_47.dll or a later version of the DLL.

/matchUAVsMatch template shader UAV allocations in the current shader. For more info, see Remarks.

Note  Only supported starting with the Windows SDK version of FXC.

/mergeUAVsMerge UAV allocations of template shader and the current shader. For more info, see Remarks.

Note  Only supported starting with the Windows SDK version of FXC.

/NiEnables the numbering of instructions in assembly listings.
/NoOutput instruction byte offset in assembly listings.

Note  Only supported starting with the Windows SDK version of FXC.

When you produce assembly, use /No to annotate it with the byte offset for each instruction.
/nologoSuppress copyright message.
/OdDisable optimizations. /Od implies /Gfp though output may not be identical to /Od /Gfp.
/OpDisable preshaders.

Note  Preshaders are only supported by the legacy fx_2_0 profile.

Note  Support for legacy Effects profiles is deprecated.

/O0 /O1, /O2, /O3Optimization levels. O1 is the default setting.
  • O0 - Disables instruction reordering. This helps reduce register load and enables faster loop simulation.
  • O1 - Disables instruction reordering for ps_3_0 and up.
  • O2 - Same as O1. Reserved for future use.
  • O3 - Same as O1. Reserved for future use.
/P <file>Preprocess to file (must be used alone).
/Qstrip_debugStrip debug data from shader bytecode for 4_0+ profiles.
/Qstrip_privStrip the private data from 4_0+ shader bytecode.

Note  Only supported starting with the Windows SDK version of FXC.

Removes private data (arbitrary sequence of bytes) from the shader blob (compiled shader binary) that you previously embedded with the /setprivate <file> option.

Note  You must specify the /dumpbin option with /Qstrip_priv. For example:



fxc /Qstrip_priv /dumpbin /Fo ps01.no.private.obj 
    ps01.with.private.obj

/Qstrip_reflectStrip reflection data from shader bytecode for 4_0+ profiles.
/res_may_aliasAssume that UAVs/SRVs may alias for cs_5_0+.

Note  This option requires the D3dcompiler_47.dll or a later version of the DLL.

/setprivate <file>Add private data in the given file to the compiled shader blob.

Note  Only supported starting with the Windows SDK version of FXC.

Embeds the given file, which is treated as a raw buffer, to the shader blob. Use /setprivate to add private data when you compile a shader. Or, use the /dumpbin option with /setprivate to load an existing shader object, and then after the object is in memory, to add the private data blob. For example, use either a single command with /setprivate to add private data to a compiled shader blob:


fxc /T ps_4_0 /Fo ps01.with.private.obj ps01.fx 
    /setprivate ps01.private.data

Or, use two commands where the second command loads a shader object and then adds private data:


fxc /T ps_4_0 /Fo ps01.no.private.obj ps01.fx
fxc /dumpbin /Fo ps01.with.private.obj ps01.no.private.obj 
    /setprivate ps01.private.data

/shtemplate <file>Use given template shader file for merging (/mergeUAVs) and matching (/matchUAVs) resources. For more info, see Remarks.

Note  Only supported starting with the Windows SDK version of FXC.

/VdDisable validation.
/ViDisplay details about the include process.
/Vn <name>Use name as variable name in header file.
/WXTreat warnings as errors.
/ZiEnable debugging information.
/ZpcPack matrices in column-major order.
/ZprPack matrices in row-major order.

 

Filename

[in] The file that contains the shader(s) and/or the effect(s).

Remarks

Use the /mergeUAVs, /matchUAVs, and /shtemplate options to align the UAV binding slots for a chain of shaders.

Suppose you have shaders A.fx, B.fx, and C.fx. To align the UAV binding slots for this chain of shaders, you need two passes of compilation:

Bb509709.wedge(en-us,VS.85).gifTo align the UAV binding slots for a chain of shaders

  1. Use /mergeUAVs to compile shaders, and specify a previously-compiled shader blob with /shtemplate. For example:
    
    
    fxc.exe /T cs_5_0 A.fx /Fo Atmp.o
    fxc.exe /T cs_5_0 B.fx /Fo Btmp.o /mergeUAVs /shtemplate Atmp.o
    fxc.exe /T cs_5_0 C.fx /Fo C.o /mergeUAVs /shtemplate Btmp.o
    
    
    
  2. Use /matchUAVs to compile shaders, and specify the last shader blob from the first pass with /shtemplate. You can compile in any order. For example:
    
    
    fxc.exe /T cs_5_0 B.fx /Fo B.o /matchUAVs /shtemplate C.o
    fxc.exe /T cs_5_0 A.fx /Fo A.o /matchUAVs /shtemplate C.o
    
    
    
    Note that you don't have to recompile C.fx in the second pass.

After you perform the preceding two compilation passes, you can use A.o, B.o, and C.o as final shader blobs with aligned UAV slots.

Note  While most options with arguments do not require a separator (space or colon) for historical reasons, we recommend that you use either a space or a colon for consistency and future support.

Profiles

Each shader model is labeled with an HLSL profile. To compile a shader against a particular shader model, choose the appropriate shader profile from the following table.

Shader TypeProfiles
Vertex Shadervs_1_1, vs_2_0, vs_2_a, vs_2_sw, vs_3_0, vs_3_sw, vs_4_0, vs_4_1
Pixel Shaderps_2_0, ps_2_a, ps_2_b, ps_2_sw, ps_3_0, ps_3_sw, ps_4_0, ps_4_1
Texture Shadertx_1_0
Geometry Shadergs_4_0, gs_4_1
HLSL shader linkinglib_4_0, lib_4_1, lib_4_0_level_9_1, lib_4_0_level_9_3, lib_5_0

Note  Requires the D3dcompiler_47.dll or a later version of the DLL.

For more info about shader linking, see ID3D11Linker and ID3D11FunctionLinkingGraph.

Effect (may contain any combination of vertex, pixel and geometry shaders)fx_2_0, fx_4_0, fx_4_1, fx_5_0

Note  Support for these legacy Effects profiles is deprecated.

 

In Direct3D 10 use the API to get the vertex, geometry, and pixel-shader profile best suited to a given device by calling these functions: D3D10GetVertexShaderProfile, D3D10GetPixelShaderProfile, and D3D10GetGeometryShaderProfile.

In Direct3D 9 use the GetDeviceCaps or GetDeviceCaps methods to retrieve the vertex and pixel-shader profiles supported by a device. The D3DCAPS9 structure returned by those methods indicates the vertex and pixel-shader profiles supported by a device in its VertexShaderVersion and PixelShaderVersion members.

For examples using the current compiler, see Current. To use the legacy compiler for older shader models, see Legacy.

Note  TextureCubeArrays are not usable with the fx_4_1 profile on Vista SP1.

Related topics

Effect-Compiler Tool

 

 

Community Additions

ADD
Show:
© 2014 Microsoft