如何将FX编译成二进制文件,用哪个函数装入
如何将FX编译成二进制文件,用哪个函数装入
[解决办法]
SDK中的资料(Tools/Effect-Compiler Tool/):
The shader models supported by the current compiler are shown in Profiles. This example compiles an effect from the BasicHLSL10.fx file (see BasicHLSL10 Sample) for the shader model 4 target.
// For a release build
fxc /T fx_4_0 /Fo BasicHLSL10.fxo BasicHLSL10.fx
In this example:
fx_4_0 is the target profile.
BasicHLSL10.fxo is the output-object file containing the compiled effect.
BasicHLSL10.fx is the input effect file.
// For a debug build
fxc /Od /Zi /T fx_4_0 /Fo BasicHLSL10.fxo BasicHLSL10.fx
The debug options include additional options to disable compiler optimizations and enable debug information like line numbers and symbols. The binary representation of the shader is written to a file called BasicHLSL10.fxo, which is an arbitrary abbreviation for the fxc output file.
For a full listing of the command-line options, see the syntax page.
Effects can be compiled into object files using the fxc.exe tool with a target of fx_2_0 or fx_4_0. The object file can then be used to create an effect directly using D3DXCreateEffect(Direct3D 9) or D3D10CreateEffectFromMemory (Direct3D 10).
但是听说这么做不太好,比如不同的硬件下面有时候会什么问题等等。
[解决办法]
就是说,编译要用到外部工具,名为fxc的编译器,这个编译器在(SDK root)\Utilities\Bin\x86\文件夹里面。
编译Release版本的例子:
fxc /T fx_4_0 /Fo BasicHLSL10.fxo BasicHLSL10.fx
编译debug版本的例子:
fxc /Od /Zi /T fx_4_0 /Fo BasicHLSL10.fxo BasicHLSL10.fx
加载的函数:
D3DXCreateEffect(Direct3D 9)
D3D10CreateEffectFromMemory (Direct3D 10).
[解决办法]
编译的时候把fx_4_0改成fx_2_0试试,4_0好像是DX10/11里面用的。
然后D3DXCreateEffect的Flags参数不能使用D3DXSHADER里面的标志。
[解决办法]
mark