Introduction
A .cso file is a compiled shader object: an HLSL
shader compiled ahead of time for Microsoft’s
Direct3D.
Visual Studio writes one per shader when it builds a project, and a program reads the
file and passes its bytes to Direct3D, which hands them to the graphics driver to turn
into code for the particular GPU.
Shaders for shader model 5 and earlier, compiled with fxc, hold DXBC
bytecode. Shader model 6 shaders, compiled with dxc, hold DXIL, a form of
LLVM bitcode. Both use the same container.
Structure
The file starts with the four characters DXBC, a 16-byte checksum of the
rest of the file, a version number, the total size and the number of
chunks, followed by a table of offsets to each chunk. Every chunk has a four-character
name and a size. Typical chunks are RDEF (resources the shader uses),
ISGN and OSGN (input and output signatures),
SHDR or SHEX (DXBC bytecode), DXIL (DXIL
bytecode) and STAT (statistics). All numbers are little-endian.
0magicDXBC4 bytes4hash16 bytes20version, total size, chunk count12 bytes32chunk offsets4 bytes each…chunks, each a name, a size and its datavaries
Links
Software
- DirectX Shader Compiler (
dxc), which also disassembles them (Windows, Linux) fxc, in the Windows SDK, which compiles and disassembles DXBC shaders (Windows)- Visual Studio, which writes them when building (Windows)
- RenderDoc, which shows the shaders of a running program (Windows, Linux)