HLSL Effect-Compiler Tool
来源:互联网 发布:js click事件拦截 编辑:程序博客网 时间:2024/06/08 04:52
Effect-Compiler Tool
FXC (fxc.exe) is an offline tool for compiling HLSL shaders for all versions of Direct3D. The tool is located at:
(SDK root)\Utilities\Bin\x86\
In this section
Syntax
Here is the syntax for calling FXC.exe, the effect-compiler tool. For an example, see Offline Compiling.
Offline Compiling
The effect-compiler tool (fxc.exe) is designed for offline compilation of HLSL shaders.
Related topics
- Tools for DirectX Graphics
Syntax
Here is the syntax for calling FXC.exe, the effect-compiler tool. For an example, see Offline Compiling.
- Usage
- Arguments
- Remarks
- Profiles
- Version notes
- Related topics
Usage
fxc SwitchOptions Filenames
Arguments
- SwitchOptions
[in] Compile options. There is just one required option, and many more that are optional. Separate each with a space or colon.
Required SwitchOptions Description /T <profile>Shader model (see Profiles).New for Direct3D 12 Optional SwitchOptions Description /?, /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.
Note Support for legacy Effects profiles is deprecated.Save private data from the shader blob (compiled shader binary) to the given file. Extracts private data, previously embedded by /setprivate, from the shader blob.
You must specify the /dumpbin option with /getprivate. For example:
/GfaAvoid flow control constructs. /GfpPrefer flow control constructs. /GisForce IEEE strictness. /GppForce partial precision. /I <include>Additional include path. /LxOutput hexadecimal literals¹. /matchUAVsMatch template shader UAV slot allocations in the current shader. For more info, seeRemarks. /mergeUAVsMerge UAV slot allocations of template shader and the current shader. For more info, see Remarks. /NiOutput instruction numbers in assembly listings. /NoOutput instruction byte offset in assembly listings. 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 (deprecated). /O0 /O1, /O2, /O3Optimization levels. O1 is the default setting.fxc /getprivate ps01.private.data /dumpbin ps01.with.private.obj
- 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.
Strip the private data from 4_0+ shader bytecode. Removes private data (arbitrary sequence of bytes) from the shader blob (compiled shader binary) that you previously embedded with the /setprivate <file> option.
You must specify the /dumpbin option with /Qstrip_priv. For example:
/Qstrip_reflectStrip reflection data from shader bytecode for 4_0+ profiles.Yes/Qstrip_rootsignatureStrip root signature from shader bytecode. /res_may_aliasAssume that UAVs/SRVs may alias for cs_5_0+¹. /setprivate <file>Add private data in the given file to the compiled shader blob. 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 /Qstrip_priv /dumpbin /Fo ps01.no.private.obj ps01.with.private.obj
Or, use two commands where the second command loads a shader object and then adds private data:fxc /T ps_4_0 /Fo ps01.with.private.obj ps01.fx /setprivate ps01.private.data
Yes/setrootsignature <file>Attach root signature to shader bytecode. /shtemplate <file>Use given template shader file for merging (/mergeUAVs) and matching (/matchUAVs) resources. For more info, see Remarks. /VdDisable validation.Yes/verifyrootsignature <file>Verify shader bytecode against root signature. /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.fxc /T ps_4_0 /Fo ps01.no.private.obj ps01.fxfxc /dumpbin /Fo ps01.with.private.obj ps01.no.private.obj /setprivate ps01.private.data
- Filenames
[in] The files 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:
To align the UAV binding slots for a chain of shaders
- 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.ofxc.exe /T cs_5_0 B.fx /Fo Btmp.o /mergeUAVs /shtemplate Atmp.ofxc.exe /T cs_5_0 C.fx /Fo C.o /mergeUAVs /shtemplate Btmp.o
- 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:Note that you don't have to recompile C.fx in the second pass.
fxc.exe /T cs_5_0 B.fx /Fo B.o /matchUAVs /shtemplate C.ofxc.exe /T cs_5_0 A.fx /Fo A.o /matchUAVs /shtemplate C.o
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.
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.
- cs_4_0
- cs_4_1
- cs_5_0
- cs_5_1
- ds_5_0
- ds_5_1
- gs_4_0
- gs_4_1
- gs_5_0
- gs_5_1
- lib_4_0
- lib_4_1
- lib_4_0_level_9_1
- lib_4_0_level_9_1_vs_only
- lib_4_0_level_9_1_ps_only
- lib_4_0_level_9_3
- lib_4_0_level_9_3_vs_only
- lib_4_0_level_9_3_ps_only
- lib_5_0
For more info about shader linking, see ID3D11Linker and ID3D11FunctionLinkingGraph.
Hull Shader- hs_5_0
- hs_5_1
- ps_2_0
- ps_2_a
- ps_2_b
- ps_2_sw
- ps_3_0
- ps_3_sw
- ps_4_0
- ps_4_0_level_9_0
- ps_4_0_level_9_1
- ps_4_0_level_9_3
- ps_4_1
- ps_5_0
- ps_5_1
- rootsig_1_0
- tx_1_0
- vs_1_1
- vs_2_0
- vs_2_a
- vs_2_sw
- vs_3_0
- vs_3_sw
- vs_4_0
- vs_4_0_level_9_0
- vs_4_0_level_9_1
- vs_4_0_level_9_3
- vs_4_1
- vs_5_0
- vs_5_1
Version notes
¹ : this option requires the D3dcompiler_47.dll or a later version of the DLL.
For Direct3D 12 refer to Specifying Root Signatures in HLSL, Resource Binding in HLSL and Dynamic Indexing using HLSL 5.1.
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. TheD3DCAPS9 structure returned by those methods indicates the vertex and pixel-shader profiles supported by a device in itsVertexShaderVersion and PixelShaderVersion members.
For examples, see Compiling with the Current Compiler.
Related topics
- Effect-Compiler Tool
Offline Compiling
The effect-compiler tool (fxc.exe) is designed for offline compilation of HLSL shaders.
- Compiling with the Current Compiler
- Compiling with the Legacy Compiler
- Using the Effect-Compiler tool in a Subprocess
- Related topics
Compiling with the Current Compiler
The shader models supported by the current compiler are shown in Profiles. This example compiles a pixel shader for the shader model 5.1 target.
// For a release buildfxc /T ps_5_1 /Fo PixelShader1.fxc PixelShader1.hlsl
In this example:
- ps_5_1 is the target profile.
- PixelShader1.fxc is the output object file containing the compiled shader.
- PixelShader1.hlsl is the source.
// For a debug buildfxc /Od /Zi /T ps_5_1 /Fo PixelShader1.fxc PixelShader1.hlsl
The debug options include additional options to disable compiler optimizations (Od) and enable debug information (Zi) like line numbers and symbols.
For a full listing of the command-line options, see the Syntax page.
Compiling with the Legacy Compiler
Beginning with Direct3D 10, some shader models are no longer supported. These include pixel shader models: ps_1_1, ps_1_2, ps_1_3, and ps_1_4 which support very limited resources and are dependent on hardware. The compiler has been redesigned with shader model 2 (or greater) which allows for greater efficiencies with compilation. This of course will require that you are running on hardware that supports shader models 2 and greater.
Also note that you should consult the SDK release notes associated with your version of the FXC compiler for behavior affected by the /Gec switch.
Using the Effect-Compiler tool in a Subprocess
If fxc.exe is spawned as a subprocess by an application it is important to ensure that the application checks for and reads any data in output or error pipes passed to the CreateProcess function. If the application only waits for the subprocess to finish and one of the pipes becomes full the subprocess will never finish.
The following example code illustrates waiting on a subprocess and reading the output and error pipes attached to the subprocess. The contents of the
WaitHandles
array correspond to handles for the subprocess, the pipe for stdout and the pipe for stderr.HANDLE WaitHandles[] = { piProcInfo.hProcess, hReadOutPipe, hReadErrorPipe }; const DWORD BUFSIZE = 4096; BYTE buff[BUFSIZE]; while (1) { DWORD dwBytesRead, dwBytesAvailable; dwWaitResult = WaitForMultipleObjects(3, WaitHandles, FALSE, 60000L); // Read from the pipes... while( PeekNamedPipe(hReadOutPipe, NULL, 0, NULL, &dwBytesAvailable, NULL) && dwBytesAvailable ) { ReadFile(hReadOutPipe, buff, BUFSIZE-1, &dwBytesRead, 0); streamOut << std::string((char*)buff, (size_t)dwBytesRead); } while( PeekNamedPipe(hReadErrorPipe, NULL, 0, NULL, &dwBytesAvailable, NULL) && dwBytesAvailable ) { ReadFile(hReadErrorPipe, buff, BUFSIZE-1, &dwBytesRead, 0); streamError << std::string((char*)buff, (size_t)dwBytesRead); } // Process is done, or we timed out: if(dwWaitResult == WAIT_OBJECT_0 || dwWaitResult == WAIT_TIMEOUT) break; }
For additional information on spawning a process see the reference page for CreateProcess.
Related topics
- Effect-Compiler Tool
- HLSL Effect-Compiler Tool
- HLSL Compiler
- UE4 HLSL Cross Compiler
- Effect & HLSL Guide – Semantics(十三)
- The Complete Effect and HLSL Guide_1(转载)
- The Complete Effect and HLSL Guide_2(转载)
- The Complete Effect and HLSL Guide_8(转载)
- The Complete Effect and HLSL Guide_7(转载)
- The Complete Effect and HLSL Guide_6(转载)
- The Complete Effect and HLSL Guide_5(转载)
- The Complete Effect and HLSL Guide_4(转载)
- The Complete Effect and HLSL Guide_3(转载)
- The Complete Effect and HLSL Guide_9(转载)
- The Complete Effect and HLSL Guide_10(转载)
- The Complete Effect and HLSL Guide_11(转载)
- The Complete Effect and HLSL Guide_12(转载)
- D3D9学习笔记(九) effect (hlsl)
- uGUI-Effect-Tool 渐变效果
- 如何启动公司内部的devops运动--尤其是后端开发人员&运维
- 三十分钟掌握STL
- Hadoop多输入源、多作业链协作
- nyoj 821
- iOS 开发之UIAlertController
- HLSL Effect-Compiler Tool
- JS,Jquery获取各种屏幕的宽度和高度
- svn安装
- 原型链的原理
- Android Studio快捷键(持续更新)
- 线程同步 总结 用户模式同步对象
- 轻量级分布式 RPC 框架
- ADO.NET是什么
- intellij中有没有关于 svn的插件 Subversion