Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:D3D9 shader bytecode

From ReverseEngineering.wiki
Format
Vendor Microsoft
Magic version token 0xFFFExxxx (vertex) or 0xFFFFxxxx (pixel)
Endianness little
On this wiki Facts · Code · Notes · Topics

Direct3D 8/9 shader model 1-3 token stream: the first dword is a version token (0xFFFE0300 for vs_3_0, 0xFFFF0300 for ps_3_0), followed by instruction tokens whose low 16 bits are the opcode, and ends with the token 0x0000FFFF.

Overview

Shaders for Direct3D 9 games are passed to CreateVertexShader / CreatePixelShader as arrays of DWORD tokens: found as .vso/.pso files, inside effects (.fx compiled, 'fx_2_0' with a different container), or as byte arrays in executables.

Version token

D3DVS_VERSION(major, minor) = 0xFFFE0000 | major << 8 | minor; D3DPS_VERSION likewise with 0xFFFF0000 (d3d9types.h). So vs_3_0 is 0xFFFE0300, ps_3_0 is 0xFFFF0300, ps_2_0 is 0xFFFF0200.

Instruction tokens

The low 16 bits are the opcode (D3DSI_OPCODE_MASK 0x0000FFFF). D3DSIO_COMMENT is 0xFFFE: the comment size in dwords sits in bits 16-30 (D3DSI_COMMENTSIZE_MASK 0x7FFF0000), and the comment data follows. Compilers put the constant table ('CTAB' comment) there, with the compiler string and constant names and registers. D3DSIO_END is 0xFFFF: the stream ends with the token 0x0000FFFF.

Notes

  • For shader model 2.0+ the bits 24-27 of an instruction token give the length in dwords after the opcode; for SM 1.x the length is implied by the opcode. Unverified: not read in the cited files.
  • D3D10+ shaders are Format:DXBC, not this format.

See Technique:Compiled GPU shader formats.

Code & repositories

  • https://github.com/wine-mirror/wine @ 7298a818b79446bae153b8d5aa27235ab3703bf9 · license: LGPL-2.1-or-later (declared by the contributor; GitHub's detector did not recognize COPYING.LIB)
    Wine mirror; dlls/d3dcompiler_43 implements DXBC blob handling and D3D9 shader assembly, include/d3d9types.h has the token macros.
    Tested on: source read, not run: read only · checked 2026-10-19; last activity 2026-10-16