1. Architectural Role & Engine Purpose
The CMD (Compiled Mesh Command Stream) format represents pre-compiled GPU draw packets and primitive assembly streams embedded within 3D mesh assets in Project I.G.I. 1.
CMD files compile high-level geometry into tightly-packed 8-byte command tokens (cmd_item_s)
that map directly to Direct3D 7 DrawIndexedPrimitive execution buffers, eliminating CPU driver state parsing.
2. Binary File Layout & Memory Map Diagram
A CMD stream contains a packet count header followed by sequential 8-byte GPU execution commands:
3. Direct3D Command Dispatch Pipeline Diagram
During mesh rendering, the engine executes the CMD token stream in a tight loop:
4. Architectural Mechanics & Engine Implementation Details
The 8-byte CMD design achieved maximum graphics throughput on early 3D graphics cards:
- State Sorting: Commands are pre-sorted offline by material and texture index, minimizing Direct3D texture swaps and pipeline flushes during the render loop.
- Triangle Strip Maximization: Over 80% of commands in IGI 1 utilize Triangle Strips (
D3DPT_TRIANGLESTRIP), sharing two vertices between adjacent triangles to minimize AGP bus bandwidth.
5. C++ Struct Definitions
#pragma pack(push, 1)
struct CmdHeader {
char magic[4]; // "CMD "
uint32_t command_count; // Total draw command packets
uint32_t vertex_count; // Referenced vertices
uint32_t index_count; // Referenced triangle indices
};
// IGI 1 8-Byte Command Packet
struct cmd_item_s {
uint16_t prim_type; // 0=TriStrip, 1=TriList, 2=TriFan
uint16_t material_id; // Index to material / texture state
uint16_t vertex_offset; // Base vertex start index
uint16_t prim_count; // Number of primitives to render
};
static_assert(sizeof(cmd_item_s) == 8, "cmd_item_s must be 8 bytes");
#pragma pack(pop)