Compiling Shaders
Compiling Shaders
There are two ways to compile shaders and effects with the HLSL compiler.
Internally, the HLSL compiler implements two versions: the new version that was first introduced in Direct3D 10 (with the DirectX December 2006 SDK) and the legacy compiler that was introduced in Direct3D 9. It is not recommended that you use the legacy compiler to compile shaders; it is much more complex due to hardware restrictions in early pixel shaders. However, it is possible to use either the default compiler or the legacy compiler when compiling your shaders or effects.
The default compiler no longer directly supports shader model 1 (specifically ps_1_x shader targets) which simplifies the code that was very hardware dependent. To avoid the need to modify shader targets to shader model 2 or higher in existing code, use the /Gec switch which tells the compiler to promote all ps_1_x targets to ps_2_0 targets.
If you need to compile shaders with the legacy compiler, you may do so by supplying the appropriate flags to the API or command-line switches to the shader-compiler tool.
Effects that specify ps_1_x targets will instead compile to ps_2_0 targets because this is the minimum shader version supported by the DirectX 10 HLSL compiler. This switch has no effect when used with higher level compile targets.
To compile a shader with the DirectX 9 HLSL compiler using an API call, use the D3DXSHADER_USE_LEGACY_D3DX9_31_DLL flag. Applications must make sure to include the OCT2006_d3dx9_31_x86.cab or OCT2006_d3dx9_31_x64.cab in their redistributable packages if they are planning on using this flag. See Installing DirectX with DirectSetup for more details.
See Also
HLSL