![]() |
![]() |
CompiledEffect Sample
Path
Sample Overview Large-scale projects may contain dozens or even hundreds of shader and effect files. Compiling these files at run time can cause a noticeable delay during initialization, and this delay is incurred each and every time the project is run; instead, these files can be compiled as part of your project build process, eliminating the need for any further compilation during program execution. Since these files will only need to be compiled when changes are made, no additional build time is spent on effect files which have already been compiled. Note that when developing or debugging effect files it's still beneficial to compile at run time, which allows more debugging flexibility. Note that the process illustrated in this sample is identical whether compiling a complete effect object or individual shaders. All that would change would be the target profile command line passed to the compiler. How does the sample work? The code is virtually identical to the BasicHLSL sample except for a couple important differences:
The program used to compile shaders at build time is fxc. This command-line utility ships with the SDK, and wraps the ID3DXEffectCompiler calls used to perform the compilation. It's interesting to note that you could create your own shader compiler fairly easily using the ID3DXEffectCompiler interface, but fxc should be flexible enough for most needs. The commands used to build release and debug versions of a hypothetical MyEffect.fx file are:
Run fxc without any arguments for usage information. Build Environment Configuration Here are the steps taken to configure the build environment. These steps should be performed for every effect file you wish to be compiled as part of the build process:
|