The contents of the parts of a shader
container, as Microsoft’s DirectXShaderCompiler headers and the LLVM project’s
DirectX Container document describe them. All numbers are little-endian. Parts written
only by the older fxc compiler (RDEF, ISGN,
OSGN, OSG5, PCSG, SHDR,
SHEX) and the STAT part are not described in those sources; a
reverse-engineered account of RDEF, ISGN, OSGN,
SHDR and STAT for shader model 4 is in
FXC parts. RDAT, PDBI, OSG5
and PCSG are not covered.
DXIL and ILDB: program header
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 4 | ProgramVersion | Shader kind in bits 16–31, shader model major version in bits 4–7, minor in bits 0–3. |
4 | 4 | SizeInUint32 | Size of the program in 32-bit words, including this header. |
8 | 4 | DxilMagic | 0x4C495844, the text DXIL. |
12 | 4 | DxilVersion | DXIL version. |
16 | 4 | BitcodeOffset | Offset of the LLVM bitcode, counted from the start of DxilMagic (the bitcode header). |
20 | 4 | BitcodeSize | Size of the LLVM bitcode. |
The bitcode is an LLVM 3.7 IR module (see LLVM
bitcode). ILDB has the same layout but keeps debug information, which
the stripped DXIL part leaves out.
| Shader kind | Value | Shader kind | Value |
|---|---|---|---|
| Pixel | 0 | Intersection | 8 |
| Vertex | 1 | AnyHit | 9 |
| Geometry | 2 | ClosestHit | 10 |
| Hull | 3 | Miss | 11 |
| Domain | 4 | Callable | 12 |
| Compute | 5 | Mesh | 13 |
| Library | 6 | Amplification | 14 |
| RayGeneration | 7 | Node | 15 |
Value 16 is Invalid. For example a shader model 6.5 compute shader has
ProgramVersion 0x00050065.
ISG1, OSG1 and PSG1: signatures
A signature part starts with a header, then an array of 32-byte elements, then a string table holding the semantic names.
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 4 | ParamCount | Number of elements. |
4 | 4 | ParamOffset | Offset of the first element from the start of the part data. |
| Offset | Size | Field | Meaning |
|---|---|---|---|
0 | 4 | Stream | Stream index; elements appear in non-decreasing stream order. |
4 | 4 | SemanticName | Offset of the name string from the start of the part data; 0 means no name. |
8 | 4 | SemanticIndex | Semantic index. |
12 | 4 | SystemValue | System-value semantic; see below. |
16 | 4 | CompType | Component type; see below. |
20 | 4 | Register | Register (row) index. |
24 | 1 | Mask | Components (columns) the element uses. |
25 | 1 | NeverWrites_Mask / AlwaysReads_Mask | For an output signature, components the shader never writes; for an input signature, components it always reads. |
26 | 2 | Pad | Padding. |
28 | 4 | MinPrecision | Minimum precision; see below. |
| SystemValue | Name | SystemValue | Name |
|---|---|---|---|
| 0 | Undefined | 14 | FinalTriInsideTessfactor |
| 1 | Position | 15 | FinalLineDetailTessfactor |
| 2 | ClipDistance | 16 | FinalLineDensityTessfactor |
| 3 | CullDistance | 23 | Barycentrics |
| 4 | RenderTargetArrayIndex | 24 | ShadingRate |
| 5 | ViewPortArrayIndex | 25 | CullPrimitive |
| 6 | VertexID | 64 | Target |
| 7 | PrimitiveID | 65 | Depth |
| 8 | InstanceID | 66 | Coverage |
| 9 | IsFrontFace | 67 | DepthGE |
| 10 | SampleIndex | 68 | DepthLE |
| 11 | FinalQuadEdgeTessfactor | 69 | StencilRef |
| 12 | FinalQuadInsideTessfactor | 70 | InnerCoverage |
| 13 | FinalTriEdgeTessfactor |
The header file notes that these values correspond to Direct3D’s
D3D_NAME and D3D10_SB_NAME codes.
| CompType | Name | MinPrecision | Name |
|---|---|---|---|
| 0 | Unknown | 0x00 | Default |
| 1 | UInt32 | 0x01 | Float16 |
| 2 | SInt32 | 0x02 | Float2_8 |
| 3 | Float32 | 0x03 | Reserved |
| 4 | UInt16 | 0x04 | SInt16 |
| 5 | SInt16 | 0x05 | UInt16 |
| 6 | Float16 | 0xF0 | Any16 |
| 7 | UInt64 | 0xF1 | Any10 |
| 8 | SInt64 | ||
| 9 | Float64 |
SFI0: feature flags
One 64-bit mask of optional features the shader needs.
| Bit value | Name | Since |
|---|---|---|
0x0001 | Doubles | |
0x0002 | ComputeShadersPlusRawAndStructuredBuffersViaShader4X | |
0x0004 | UAVsAtEveryStage | |
0x0008 | 64UAVs | |
0x0010 | MinimumPrecision | |
0x0020 | 11_1_DoubleExtensions | |
0x0040 | 11_1_ShaderExtensions | |
0x0080 | LEVEL9ComparisonFiltering | |
0x0100 | TiledResources | |
0x0200 | StencilRef | |
0x0400 | InnerCoverage | |
0x0800 | TypedUAVLoadAdditionalFormats | |
0x1000 | ROVs | |
0x2000 | ViewportAndRTArrayIndexFromAnyShaderFeedingRasterizer | |
0x4000 | WaveOps | |
0x8000 | Int64Ops | |
0x10000 | ViewID | SM 6.1 |
0x20000 | Barycentrics | SM 6.1 |
0x40000 | NativeLowPrecision | SM 6.2 |
0x80000 | ShadingRate | SM 6.4 |
0x100000 | Raytracing_Tier_1_1 | SM 6.5 |
0x200000 | SamplerFeedback | SM 6.5 |
0x400000 | AtomicInt64OnTypedResource | SM 6.6 |
0x800000 | AtomicInt64OnGroupShared | SM 6.6 |
0x1000000 | DerivativesInMeshAndAmpShaders | SM 6.6 |
0x2000000 | ResourceDescriptorHeapIndexing | SM 6.6 |
0x4000000 | SamplerDescriptorHeapIndexing | SM 6.6 |
0x8000000 | Reserved | experimental SM 6.9 |
0x10000000 | AtomicInt64OnHeapResource | SM 6.6 |
0x20000000 | AdvancedTextureOps | SM 6.7 |
0x40000000 | WriteableMSAATextures | SM 6.7 |
0x80000000 | SampleCmpGradientOrBias | SM 6.8 |
0x100000000 | ExtendedCommandInfo | SM 6.8 |
0x200000000 | LinearAlgebra | SM 6.10 |
These are the container’s feature bits; the DXIL module itself carries a separate
64-bit “shader flags” value in its metadata, documented in DXC’s
DXIL.rst.
HASH, ILDN and VERS
| Part | Offset | Size | Field | Meaning |
|---|---|---|---|---|
HASH | 0 | 4 | Flags | 0 none; 1 IncludesSource: the hash takes source information into account (-Zss). |
4 | 16 | Digest | MD5 hash of the shader. | |
ILDN | 0 | 2 | Flags | Reserved, zero. |
2 | 2 | NameLength | Length of the name, without its NUL. | |
4 | NameLength + 1 | name | UTF-8 name of the debug file (by default <MD5>.pdb) and a NUL, then 0–3 zero bytes to a 4-byte boundary. | |
VERS | 0 | 2 | Major | Compiler major version. |
2 | 2 | Minor | Compiler minor version. | |
4 | 4 | Flags | 0 default, 1 debug, 2 internal. | |
8 | 4 | CommitCount | LLVM always writes 0. | |
12 | 4 | ContentSizeInBytes | Size of the strings that follow. | |
16 | — | strings | The commit SHA and a custom version string, each ending in NUL. |
SRCI: source information
A header (a 32-bit aligned size, 16-bit flags and a 16-bit section count, which must be 3), then three sections, each with its own header and 4-byte aligned entries:
| Section type | Contents |
|---|---|
| 0 | Source contents; may be compressed with zlib (compression type 1). |
| 1 | Source file names. |
| 2 | Compiler arguments, as NUL-terminated name and value string pairs. |
RTS0: root signature
| Structure | Size | Fields |
|---|---|---|
| Header | 24 bytes | Six 32-bit values: Version, NumParameters, ParametersOffset, NumStaticSamplers, StaticSamplerOffset, Flags. |
| Parameter header | 12 bytes | ParameterType, ShaderVisibility, ParameterOffset. |
| Root constants | 12 bytes | — |
| Root descriptor | 8 bytes (version 1.0), 12 bytes (1.1, adds flags) | — |
| Descriptor range | 20 bytes (1.0), 24 bytes (1.1) | — |
| Static sampler | 52 bytes | — |
The field lists of the smaller structures and the code values they use are defined in
LLVM’s DXContainerConstants.def and Direct3D 12’s root signature
documentation, which were not among the sources read for this page.
PSV0: pipeline state validation
A versioned set of structures, told apart by their encoded size rather than a version
number. In order: a RuntimeInfo structure; the resource bindings (a count,
then the element size when the count is not zero); the signature elements (a string
table, an index table and lists per kind); and mask vectors, which pack 8 elements into
each 32-bit word starting from the least significant bit. Output, patch-constant and
input-to-output dependency tables follow depending on the shader stage and whether it
uses the view ID. The inner layouts are not given in the sources read.
FXC parts: RDEF, ISGN, OSGN, SHDR, STAT
Microsoft has not published these layouts; the container holds them in the same
part wrapper (FourCC, size, data). What follows is from Tim Jones’s write-up of the
SlimShader parser (2015), which works out shader model 4.0 files by
comparing compiled shaders, and from Microsoft’s own
d3d11TokenizedProgramFormat.hpp (Windows Driver Kit), which documents
the SHDR token stream. Offsets “from chunk data” count from the first
byte after the part size. All values are 32-bit unless a width is given.
RDEF: resource definitions
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | Constant buffer count. |
| 4 | 4 | Offset to the first constant buffer description. |
| 8 | 4 | Resource binding count. |
| 12 | 4 | Offset to the first resource binding description. |
| 16 | 1, 1 | Minor, then major version number. |
| 18 | 2 | Program type; 0xFFFE means vertex shader in the example (other values are not listed in the source). |
| 20 | 4 | Flags; 256 means “NoPreshader” in the example. |
| 24 | 4 | Offset to the creator string (a null-terminated text such as “Microsoft (R) HLSL Shader Compiler 6.3.9600.16384”). |
Shader model 5 adds data after this that the source does not describe.
| Structure | Fields, in order (each 4 bytes unless noted) |
|---|---|
| Constant buffer description (24 bytes) | offset to name; variable count; offset to the first variable description; size in bytes; flags (D3D_SHADER_CBUFFER_FLAGS); type (D3D11_CBUFFER_TYPE). |
| Variable description (24 bytes) | offset to name; offset in the buffer (bytes); size (bytes); flags (D3D10_SHADER_VARIABLE_FLAGS, 2 = used); offset to the variable’s type; offset to the default value (0 for none). |
| Variable type (2 bytes each) | class (D3D10_SHADER_VARIABLE_CLASS, 3 = column-major matrix in the example); type (D3D10_SHADER_VARIABLE_TYPE, 3 = float); rows; columns; array element count; member count; offset to the first member. |
| Resource binding (32 bytes) | offset to name; shader input type (0 = constant buffer); resource return type; resource view dimension; sample count; bind point; bind count; shader input flags. |
ISGN, OSGN: signatures
The same layout for inputs and outputs (OSG5, PCSG and ISG1 variants are not described in the sources). A header of two 32-bit values, the element count and a second value, 8 in the example, whose purpose the source says it does not know (it equals the offset of the first element in that file); then the elements.
| Offset in element | Size | Field |
|---|---|---|
| 0 | 4 | Offset (from chunk data) to the null-terminated semantic name. |
| 4 | 4 | Semantic index. |
| 8 | 4 | System value type. |
| 12 | 4 | Component type; 3 means float. |
| 16 | 4 | Register. |
| 20 | 1 | Mask of components present (bit per x, y, z, w; 7 is xyz, 3 is xy). |
| 21 | 1 | Read-write mask: the components the shader actually uses. |
| 22 | 2 | Not described in the source. |
SHDR (shader model 4) and SHEX (shader model 5): the program
| Offset | Size | Field |
|---|---|---|
| 0 | 4 | Version token: bits 0–3 minor version, bits 4–7 major version, bits 16–31 program type. |
| 4 | 4 | Length token: number of 32-bit words in the program, including the version and length tokens. |
| 8 | … | Opcode tokens and operands, to the end. |
Program types: 0 pixel, 1 vertex, 2 geometry, 3 hull, 4 domain, 5 compute (0xFFF0 reserved). The first token of each instruction (OpcodeToken0): bits 0–10 the opcode; if the opcode is CUSTOMDATA, a custom-data block follows; otherwise bits 11–23 are opcode-specific controls, bits 24–30 the instruction length in words including this token, and bit 31 is 1 if an extended opcode token follows. The operand and per-instruction layouts (several thousand lines of the header) are not reproduced here.
| Opcodes | Names (value = position in the header’s enumeration) |
|---|---|
| 0–9 | ADD AND BREAK BREAKC CALL CALLC CASE CONTINUE CONTINUEC CUT |
| 10–19 | DEFAULT DERIV_RTX DERIV_RTY DISCARD DIV DP2 DP3 DP4 ELSE EMIT |
| 20–29 | EMITTHENCUT ENDIF ENDLOOP ENDSWITCH EQ EXP FRC FTOI FTOU GE |
| 30–39 | IADD IF IEQ IGE ILT IMAD IMAX IMIN IMUL INE |
| 40–49 | INEG ISHL ISHR ITOF LABEL LD LD_MS LOG LOOP LT |
| 50–59 | MAD MIN MAX CUSTOMDATA MOV MOVC MUL NE NOP NOT |
| 60–69 | OR RESINFO RET RETC ROUND_NE ROUND_NI ROUND_PI ROUND_Z RSQ SAMPLE |
| 70–79 | SAMPLE_C SAMPLE_C_LZ SAMPLE_L SAMPLE_D SAMPLE_B SQRT SWITCH SINCOS UDIV ULT |
| 80–89 | UGE UMUL UMAD UMAX UMIN USHR UTOF XOR DCL_RESOURCE DCL_CONSTANT_BUFFER |
| 90–99 | DCL_SAMPLER DCL_INDEX_RANGE DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY DCL_GS_INPUT_PRIMITIVE DCL_MAX_OUTPUT_VERTEX_COUNT DCL_INPUT DCL_INPUT_SGV DCL_INPUT_SIV DCL_INPUT_PS DCL_INPUT_PS_SGV |
| 100–109 | DCL_INPUT_PS_SIV DCL_OUTPUT DCL_OUTPUT_SGV DCL_OUTPUT_SIV DCL_TEMPS DCL_INDEXABLE_TEMP DCL_GLOBAL_FLAGS (107 reserved, end of D3D10.0) LOD GATHER4 |
| 110–119 | SAMPLE_POS SAMPLE_INFO (112 reserved, end of D3D10.1) HS_DECLS HS_CONTROL_POINT_PHASE HS_FORK_PHASE HS_JOIN_PHASE EMIT_STREAM CUT_STREAM EMITTHENCUT_STREAM |
| 120–129 | INTERFACE_CALL BUFINFO DERIV_RTX_COARSE DERIV_RTX_FINE DERIV_RTY_COARSE DERIV_RTY_FINE GATHER4_C GATHER4_PO GATHER4_PO_C RCP |
| 130–139 | F32TOF16 F16TOF32 UADDC USUBB COUNTBITS FIRSTBIT_HI FIRSTBIT_LO FIRSTBIT_SHI UBFE IBFE |
| 140–149 | BFI BFREV SWAPC DCL_STREAM DCL_FUNCTION_BODY DCL_FUNCTION_TABLE DCL_INTERFACE DCL_INPUT_CONTROL_POINT_COUNT DCL_OUTPUT_CONTROL_POINT_COUNT DCL_TESS_DOMAIN |
| 150–159 | DCL_TESS_PARTITIONING DCL_TESS_OUTPUT_PRIMITIVE DCL_HS_MAX_TESSFACTOR DCL_HS_FORK_PHASE_INSTANCE_COUNT DCL_HS_JOIN_PHASE_INSTANCE_COUNT DCL_THREAD_GROUP DCL_UNORDERED_ACCESS_VIEW_TYPED DCL_UNORDERED_ACCESS_VIEW_RAW DCL_UNORDERED_ACCESS_VIEW_STRUCTURED DCL_THREAD_GROUP_SHARED_MEMORY_RAW |
| 160–169 | DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED DCL_RESOURCE_RAW DCL_RESOURCE_STRUCTURED LD_UAV_TYPED STORE_UAV_TYPED LD_RAW STORE_RAW LD_STRUCTURED STORE_STRUCTURED ATOMIC_AND |
| 170–179 | ATOMIC_OR ATOMIC_XOR ATOMIC_CMP_STORE ATOMIC_IADD ATOMIC_IMAX ATOMIC_IMIN ATOMIC_UMAX ATOMIC_UMIN IMM_ATOMIC_ALLOC IMM_ATOMIC_CONSUME |
| 180–189 | IMM_ATOMIC_IADD IMM_ATOMIC_AND IMM_ATOMIC_OR IMM_ATOMIC_XOR IMM_ATOMIC_EXCH IMM_ATOMIC_CMP_EXCH IMM_ATOMIC_IMAX IMM_ATOMIC_IMIN IMM_ATOMIC_UMAX IMM_ATOMIC_UMIN |
| 190–199 | SYNC DADD DMAX DMIN DMUL DEQ DGE DLT DNE DMOV |
| 200–209 | DMOVC DTOF FTOD EVAL_SNAPPED EVAL_SAMPLE_INDEX EVAL_CENTROID DCL_GS_INSTANCE_COUNT ABORT DEBUG_BREAK (209 reserved, end of D3D11.0) |
| 210–219 | DDIV DFMA DRCP MSAD DTOI DTOU ITOD UTOD (218 reserved, end of D3D11.1) GATHER4_FEEDBACK |
| 220–230 | GATHER4_C_FEEDBACK GATHER4_PO_FEEDBACK GATHER4_PO_C_FEEDBACK LD_FEEDBACK LD_MS_FEEDBACK LD_UAV_TYPED_FEEDBACK LD_RAW_FEEDBACK LD_STRUCTURED_FEEDBACK SAMPLE_L_FEEDBACK SAMPLE_C_LZ_FEEDBACK SAMPLE_CLAMP_FEEDBACK |
| 231–235 | SAMPLE_B_CLAMP_FEEDBACK SAMPLE_D_CLAMP_FEEDBACK SAMPLE_C_CLAMP_FEEDBACK CHECK_ACCESS_FULLY_MAPPED (235 reserved, end of WDDM 1.3) |
The header does not write the numbers, so these come from counting its enumeration by hand. The one value the Tim Jones article states, DCL_CONSTANT_BUFFER = 89, agrees with the count; the others rest on the count alone. Names carry the prefixes D3D10_SB_OPCODE_, D3D10_1_SB_OPCODE_, D3D11_SB_OPCODE_, D3D11_1_SB_OPCODE_ and D3DWDDM1_3_SB_OPCODE_ by generation.
STAT: statistics
Counts, one 32-bit value each, in this order for the example: instruction count, temp register count, define count, declaration count, float instruction count, int instruction count, unsigned instruction count, static flow control count, then further values whose meaning the source does not give. The source says some are guesses and some unknown; the layout is not settled.
Other FXC parts the source lists: ICFE (interfaces), SDGB and SPDB (old and new debug information), SFI0 (a double-precision flag; the DXC side of that part is on this page).
PRIV
Opaque bytes, such as an embedded PDB. It must be the last part, there may be only one, and its size need not be a multiple of four.
Sources
- DxilContainer.h – Microsoft: program and bitcode headers, signature structures and their enums,
HASHandILDNstructures, version helpers - DxilConstants.h – Microsoft:
ShaderFeatureInfoflags and theShaderKindvalues - DirectX Container – LLVM:
VERS,SRCI,RTS0,PSV0,PRIVand the bitcode version - DXIL.rst – Microsoft: the DXIL module’s own shader flags
- Parsing Direct3D shader bytecode – Tim Jones, 2 September 2015: the
RDEF,ISGN,OSGN,SHDRandSTATlayouts for shader model 4, worked out by comparing compiled shaders (not an official source; read 13 November 2026) d3d11TokenizedProgramFormat.hpp– Microsoft, Windows Driver Kit 10.0.10240.0, read from the tpn/winsdk-10 mirror on GitHub: program types, version, length and opcode tokens, and the opcode enumeration