Skip to content

SGD2 shader databases

RAGEShadersApplies toGTA V

Enhanced stores compiled programs in common/shaders/fxdb/sga_win32_60_final.awc inside update/update2.rpf, with an _init sibling. Despite the .awc suffix, these files begin with SGD2 and contain DXIL program containers and effect records. Proven

Both inspected databases parse to their final byte: eight program groups followed by a count and that many effect records, with no unexplained trailing bytes. This establishes the outer framing, not the meaning of every byte inside a retained table. Proven · both complete databases

Group index Stage Programs in sga_win32_60_final.awc Confidence
0 Vertex 3,707 Proven
1 Pixel 7,594 Proven
2 Geometry 0 Proven
3 Domain 458 Proven
4 Hull 406 Proven
5 Compute 240 Proven
6–7 Empty in both inspected files; stage meaning unknown 0 Unknown

The main database therefore holds 12,405 programs, followed by 388 effect records. Proven · complete main database

Each group begins with a little-endian u32 program count. Programs have length-prefixed NUL-terminated names, a tag byte, a sized DXIL container with DXBC magic, a fixed 152-byte table and another sized table. Proven

A program’s name does not identify it: programs of different effects share a name, such as PS_DeferredTextured_0174add1_Wrapped; the programs drawn around one downtown street area are 36 programs under 10 names. The bytecode, not the name, tells programs apart. Observed · programs drawn in one street area, compared by bytecode hash

SGD2 program recordvariable100% known
ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x01u8name byte lengthProven
0x1name byte lengthstringname including NULProven
after name1u8unknown tagUnknown0x32, 0x41 or 0x42
after tag4u32container lengthProven
after container lengthcontainer lengthbytesDXIL containerProven
after container152bytesunknown fixed tableUnknown
after fixed table4u32binding table lengthProven
after binding table lengthbinding table lengthbytesbinding tableProven

A census of the main database’s programs finds the following. Observed · census of the main database’s programs

  • 1,275 programs belong to tessellation pipelines, named VS_…, HS_… and DS_…_PNTri_*_Wrapped: the 406 hull and 458 domain programs, and 411 vertex programs, none of which writes SV_Position.
  • 5,697 pixel programs index an unbounded sampler array (register s0, space 2) with a dynamic index.
  • 30 programs use ray queries; three use quad operations.
  • 35 programs read the wave lane index (WaveGetLaneIndex) in a thread group of more than one dimension.

The game’s effect list common/shaders/preload.list, also in update/update2.rpf, names every effect that the install’s drawables use. Observed

An effect record starts with a length-prefixed NUL-terminated name, then a u32 word and six lists of program indices, in vertex/pixel/geometry/domain/hull/compute order. Each list is a u32 count followed by u32 indices into that stage’s database group. Proven

The word after the name is not the record’s byte size; its complete purpose is unresolved. The record ends structurally: proplst\0, a u32 section count, sized sections, then a u32-sized NUL-terminated name block. Proven The root-signature interpretation of the proplst sections is not fully decoded here. Unknown

Every program’s binding table in the main database parses with complete resource/constant ownership counts and name-hash resolution. This proves the stored table structure across all programs. The interface comparison below has narrower scope because an interface can be unavailable and unbounded arrays are treated separately. Proven · every main-database program table

The per-program binding table begins with u16 resource count, u32 constant count and an unnamed u16. Resource records are followed by constant records and NUL-terminated ASCII names. Proven

Program resource binding28 bytes61% known
ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x02u16tagUnknown
0x22u16registerProven
0x41u8owned constant countProven
0x51u8class byteUnknown
0x62u16register spaceProven
0x86bytesunknownUnknown
0xE4u32buffer sizeProven
0x122u16unknownUnknown
0x144u32program name hashProven
0x184u32current material name hashProven
Program constant binding24 bytes58% known
ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x04u32flags and typeProvenlow byte identifies the value type; remaining bits are not fully named
0x42u16byte offset in bufferProven
0x62u16IDUnknown
0x88bytesunknown wordsUnknown
0x104u32program name hashProven
0x144u32current material name hashProven

The first name hash resolves to a name in the table, with exact-case or lowercase joaat. The second links an older program identifier, such as specularFresnel, to a material identifier such as Fresnel; engine constants can use zero or repeat the first hash instead. Proven

The whole-database interface comparison checks each declared constant buffer, texture and sampler against a record at the same class/register/space. Buffer sizes are rounded up to 16 bytes; root-constant records can state size zero, and unbounded resource arrays need separate handling. Constant ownership counts sum to the constant-table count. Observed · program-interface comparison

Every technique-bearing effect in the main database decodes with valid program and state-table references and no unread technique table. Effects without this structure, including post-processing and lighting effects, are counted separately rather than forced into the layout. The proven pass and state fields below apply to all technique-bearing effects; the outer framing proof also covers records without techniques. Proven · all technique-bearing effects

Effects with a technique table have name-offset/pass-count entries and a count-prefixed list of 24-byte passes. Post-processing and lighting effects can lack this table. Proven

Technique pass24 bytes38% known
ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x06u8[6]programs by stageProven1-based position in the effect's stage list; 0 means absent
0x62bytesunknown zero bytesUnknownzero in inspected records
0x81u8rasterizer state indexProven
0x91u8depth-stencil state indexProven
0xA1u8blend state indexProven
0xB13bytesunknown tailUnknown

State tables use Direct3D 12 enumeration values. Their record sizes are rasterizer 16, depth-stencil 24, blend 68 and sampler 36 bytes. The blend record holds four leading bytes followed by eight 8-byte render-target descriptions. Proven

Rasterizer state16 bytes44% known
ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x01u8fill modeProven2 wireframe, 3 solid
0x11u8cull modeProven1 none, 2 front, 3 back
0x21u8front counterclockwiseProven
0x35bytesunknownUnknown
0x84f32polygon offsetProvennonzero in the two inspected foam effects
0xC4bytesunknown tailUnknown
Depth-stencil state24 bytes58% known
ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x01u8depth enableProven
0x11u8depth write maskProven
0x21u8depth comparisonProven
0x31u8stencil enableProven
0x41u8stencil read maskProven
0x51u8stencil write maskProven
0x64u8[4]front stencil operations and comparisonProvenfail, depth-fail, pass, comparison
0xA4u8[4]back stencil operations and comparisonProven
0xE10bytesunknown tailUnknown
Blend state68 bytes94% known
ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x04bytesunknown prefixUnknown
0x464RenderTargetBlend[8]target blend descriptionsProven
RenderTargetBlend8 bytes100% known
ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x01u8blend enableProven
0x11u8source factorProven
0x21u8destination factorProven
0x31u8operationProven
0x41u8alpha source factorProven
0x51u8alpha destination factorProven
0x61u8alpha operationProven
0x71u8write maskProven
Sampler state36 bytes39% known
ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x01u8filterProven
0x13u8[3]U-V-W address modesProven1 wrap, 2 mirror, 3 clamp
0x44f32mip LOD biasProven
0x81u8maximum anisotropyProven
0x91u8comparison functionProven
0xA22bytesretained fieldsUnknownincludes border colour and minimum LOD; not individually decoded
0x204f32maximum LODProven

Known-effect controls support the interpretation: default includes depth comparison GREATER (reversed Z); decal includes source-alpha/inverse-source-alpha blending; emissive_additive_alpha includes source-alpha/destination-one blending. These checks establish concrete states, rather than deriving state only from effect names. Observed

What do the program tags and retained state-table bytes mean?

Outer framing and named fields are decoded, but the three program-tag values and unnamed table fields have no established semantic meaning. Unknown

Read as raw words, the effect bytes after the program lists hold seven u32 words at offset 0x18 with the values 6, 6, 2, 0, 2, 3, 2. A flags word follows them: 0x1002 in default, emissive and cloth, 0x10 in glass and decal effects, and 0x2 in cutout_fence. A further word varies by effect (0x11000011, 0x11000111 with the 0x100 bit in glass, 0x13000011). The values are observed on those effects; how these words relate to the decoded state tables and to the flag-8 classification of cloth_* effects on deferred decals is not established. Unknown