That’s probably the best way to go for release version, but for development and debugging purposes it’s easier if we can change shader source just as we change the source of CPU code, easily rebuild or run, or even reload changed shader while the app is running. Shaders can be compiled offline using a command-line program (standalone executable compiler) and then bundled with your program in compiled binary form. On the other hand, shaders compiled with it require relatively recent version of Windows and graphics drivers installed, so they won’t work on systems not updated for years. We must use it if we want to use Shader Model 6 or above. Which one to choose? The new compiler, called DirectX Shader Compiler, is more modern, based on LLVM/Clang, and open source.
There are currently two shader compilers available, both from Microsoft, each outputting different binary format: We author these in high-level language called HLSL and compile them before passing to the DirectX API while creating pipeline state objects ( ID3D12Device::CreateGraphicsPipelineState).
If we write a game or other graphics application using DX12, we also need to write some shaders.