Difference between revisions of "Rockstar PS2 pipelines"

From GTAMods Wiki
Jump to navigation Jump to search
m (fixed a pipeline id)
(Corrected information about the VU code.)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
In GTA San Andreas for PS2 Rockstar used RenderWare's Pipeline Delivery System (RpPDS)
 
In GTA San Andreas for PS2 Rockstar used RenderWare's Pipeline Delivery System (RpPDS)
that was introduced with RW 3.5 to create custom pipelines.
+
that was introduced with RW 3.5 to create custom pipelines. However not all custom pipelines are created with RpPDS,
 +
the grass, water and seven sprite piplines are not (TODO: describe them here as well).
 
This page is about Rockstar's custom pipelines specifically,
 
This page is about Rockstar's custom pipelines specifically,
 
PS2 pipelines in general are described here: [[PS2All]].
 
PS2 pipelines in general are described here: [[PS2All]].
Line 9: Line 10:
  
 
All object pipelines have even IDs, material pipelines have odd IDs.
 
All object pipelines have even IDs, material pipelines have odd IDs.
 +
None of the object pipelines have grouped material pipelines (a forced pipeline for all materials of an atomic) even though it looks like Rockstar tried to set them up that way; their code has no effect.
  
 
==PDS Templates==
 
==PDS Templates==
  
 
===Building Pipelines===
 
===Building Pipelines===
 
All of these pipelines use the building VU1 code.
 
  
 
==== CVBuildingPipe ====
 
==== CVBuildingPipe ====
  
 
   53F20080 (template @ 8A3000)
 
   53F20080 (template @ 8A3000)
    matGroup: 53F20081
 
  
 
   53F20081 (template @ 8A2F70)
 
   53F20081 (template @ 8A2F70)
Line 29: Line 28:
 
     primCount:  0x1B
 
     primCount:  0x1B
 
     vifOffset:  0xF3
 
     vifOffset:  0xF3
 +
 +
VU code [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingPipeline.bin binary], [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingPipeline.vu disassembly]
  
 
==== CVBuildingDNPipe ====
 
==== CVBuildingDNPipe ====
  
 
   53F20082 (template @ 8A30B0)
 
   53F20082 (template @ 8A30B0)
    matGroup: 53F20083
 
  
 
   53F20083 (template @ 8A3020)
 
   53F20083 (template @ 8A3020)
Line 43: Line 43:
 
     primCount:  0x1B
 
     primCount:  0x1B
 
     vifOffset:  0xF3
 
     vifOffset:  0xF3
 +
 +
VU code [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingDNPipeline.bin binary], [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingDNPipeline.vu disassembly]
  
 
==== CVBuildingEnvMapPipe ====
 
==== CVBuildingEnvMapPipe ====
  
 
   53F2008C (unused by DFFs, template @ 8A3160)
 
   53F2008C (unused by DFFs, template @ 8A3160)
    matGroup: 53F2008D
 
  
 
   53F2008D (used with 53F20080, template @ 8A30D0)
 
   53F2008D (used with 53F20080, template @ 8A30D0)
Line 58: Line 59:
 
     primCount:  0x12
 
     primCount:  0x12
 
     vifOffset:  0xE0
 
     vifOffset:  0xE0
 +
 +
VU code [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingEnvMapPipeline.bin binary], [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingEnvMapPipeline.vu disassembly]
  
 
==== CVBuildingDNEnvMapPipe ====
 
==== CVBuildingDNEnvMapPipe ====
  
 
   53F2008E (unused by DFFs, template @ 8A3210)
 
   53F2008E (unused by DFFs, template @ 8A3210)
    matGroup: 53F2008F
 
  
 
   53F2008F (used with 53F20082, template @ 8A3180)
 
   53F2008F (used with 53F20082, template @ 8A3180)
Line 73: Line 75:
 
     primCount:  0x12
 
     primCount:  0x12
 
     vifOffset:  0xE0
 
     vifOffset:  0xE0
 +
 +
VU code [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingDNEnvMapPipeline.bin binary], [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingDNEnvMapPipeline.vu disassembly]
  
 
==== CVBuildingUVAPipe ====
 
==== CVBuildingUVAPipe ====
  
 
   53F20090 (unused by DFFs, template @ 8A32C0)
 
   53F20090 (unused by DFFs, template @ 8A32C0)
    matGroup: 53F20091
 
  
 
   53F20091 (unused by DFFs, template @ 8A3230)
 
   53F20091 (unused by DFFs, template @ 8A3230)
Line 87: Line 90:
 
     primCount:  0x1A
 
     primCount:  0x1A
 
     vifOffset:  0xF0
 
     vifOffset:  0xF0
 +
 +
VU code [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingUVAPipeline.bin binary], [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingUVAPipeline.vu disassembly]
  
 
==== CVBuildingDNUVAPipe ====
 
==== CVBuildingDNUVAPipe ====
  
 
   53F20092 (unused by DFFs, template @ 8A3370)
 
   53F20092 (unused by DFFs, template @ 8A3370)
    matGroup: 53F20093
 
  
 
   53F20093 (unused by DFFs, template @ 8A32E0)
 
   53F20093 (unused by DFFs, template @ 8A32E0)
Line 101: Line 105:
 
     primCount:  0x1A
 
     primCount:  0x1A
 
     vifOffset:  0xF0
 
     vifOffset:  0xF0
 +
 +
VU code [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingDNUVAPipeline.bin binary], [http://aap.papnet.eu/gta/RE/ps2/CCustomCVBuildingDNUVAPipeline.vu disassembly]
  
 
===Vehicle Pipelines===
 
===Vehicle Pipelines===
 
All of these pipelines use the vehicle VU1 code.
 
  
 
==== CVCarPipe ====
 
==== CVCarPipe ====
  
 
   53F20084 (template @ 8A2F50)
 
   53F20084 (template @ 8A2F50)
    matGroup: 53F20085
 
  
 
This pipeline does not render any reflection effects:
 
This pipeline does not render any reflection effects:
Line 122: Line 125:
 
     primCount:  0x17
 
     primCount:  0x17
 
     vifOffset:  0x114
 
     vifOffset:  0x114
 +
 +
VU code [http://aap.papnet.eu/gta/RE/ps2/CCustomCarPipeline.bin binary], [http://aap.papnet.eu/gta/RE/ps2/CCustomCarPipeline.vu disassembly]
  
 
==== CVCarEnvMapPipe ====
 
==== CVCarEnvMapPipe ====
  
 
   53F20086 (unused by DFFs, template @ 8A2E00)
 
   53F20086 (unused by DFFs, template @ 8A2E00)
    matGroup: -
 
  
 
This pipeline renders environment maps (and specular maps):
 
This pipeline renders environment maps (and specular maps):
Line 139: Line 143:
 
     primCount:  0x12
 
     primCount:  0x12
 
     vifOffset:  0xE0
 
     vifOffset:  0xE0
 +
 +
VU code [http://aap.papnet.eu/gta/RE/ps2/CCustomCarEnvMapPipeline.bin binary], [http://aap.papnet.eu/gta/RE/ps2/CCustomCarEnvMapPipeline.vu disassembly]
  
 
This pipeline renders x-environment maps (and specular maps):
 
This pipeline renders x-environment maps (and specular maps):
Line 153: Line 159:
 
     primCount:  0x12
 
     primCount:  0x12
 
     vifOffset:  0xE0
 
     vifOffset:  0xE0
 +
 +
VU code same as above.
  
 
===Skin Pipelines===
 
===Skin Pipelines===
 
This pipeline uses the skin VU1 code.
 
  
 
==== CVSkinPedPipe ====
 
==== CVSkinPedPipe ====
  
 
   53F20088 (template @ 6275A0)
 
   53F20088 (template @ 6275A0)
    matGroup: 53F20089
 
  
 
   53F20089 (template @ 627510)
 
   53F20089 (template @ 627510)
Line 172: Line 177:
 
     primCount:  0x10
 
     primCount:  0x10
 
     vifOffset:  0xC0
 
     vifOffset:  0xC0
 +
 +
VU code [http://aap.papnet.eu/gta/RE/ps2/CCustomSkinPedPipeline.bin binary], [http://aap.papnet.eu/gta/RE/ps2/CCustomSkinPedPipeline.vu disassembly]
  
 
==Data format and VU1 code==
 
==Data format and VU1 code==
Line 184: Line 191:
 
The bone matrix offset can be converted to a bone index like this: <code>i = off == 0 ? 0 : off/4 - 1</code>
 
The bone matrix offset can be converted to a bone index like this: <code>i = off == 0 ? 0 : off/4 - 1</code>
 
(Actually all 32 bits are interpreted as IEEE floats, bone transformation isn't sensitive to little changes in the lower bits. Also all lower 16 bits are used as the bone offset but since the VU1 memory has only 16kb and the memory is qword-addressed, an address is only 10 bits long and the upper bits are ignored. The offsets are added to the start of the bone matrix array (which starts at 0x2d0) -4: so they're added to 0x2cc)
 
(Actually all 32 bits are interpreted as IEEE floats, bone transformation isn't sensitive to little changes in the lower bits. Also all lower 16 bits are used as the bone offset but since the VU1 memory has only 16kb and the memory is qword-addressed, an address is only 10 bits long and the upper bits are ignored. The offsets are added to the start of the bone matrix array (which starts at 0x2d0) -4: so they're added to 0x2cc)
 
VU code binary:
 
[http://aap.papnet.eu/gta/RE/ps2/sa_building.bin Building]
 
[http://aap.papnet.eu/gta/RE/ps2/sa_vehicle.bin Vehicle]
 
[http://aap.papnet.eu/gta/RE/ps2/sa_skin.bin Skin]
 
 
VU code disassembled:
 
[http://aap.papnet.eu/gta/RE/ps2/sa_building.vu Building]
 
[http://aap.papnet.eu/gta/RE/ps2/sa_vehicle.vu Vehicle]
 
[http://aap.papnet.eu/gta/RE/ps2/sa_skin.vu Skin]
 
 
(NB: the disassembler has a bug and always disassembles div instructs as 'div q,vf00w,vf00x')
 
  
 
[[Category:Documentation]]
 
[[Category:Documentation]]

Latest revision as of 19:22, 21 March 2017

In GTA San Andreas for PS2 Rockstar used RenderWare's Pipeline Delivery System (RpPDS) that was introduced with RW 3.5 to create custom pipelines. However not all custom pipelines are created with RpPDS, the grass, water and seven sprite piplines are not (TODO: describe them here as well). This page is about Rockstar's custom pipelines specifically, PS2 pipelines in general are described here: PS2All.

All of these pipelines are initialized in init.pm/nm (see PS2 Code Overlay) so the addresses below are only valid if the init code has been loaded into memory. Addresses refer to SLES_525.41 and init.pm.

All object pipelines have even IDs, material pipelines have odd IDs. None of the object pipelines have grouped material pipelines (a forced pipeline for all materials of an atomic) even though it looks like Rockstar tried to set them up that way; their code has no effect.

PDS Templates

Building Pipelines

CVBuildingPipe

 53F20080 (template @ 8A3000)
 53F20081 (template @ 8A2F70)
   clusters: 6 6D00000D (R* xyzw)
             7 6500000D (R* uv)
             8 6E00400D (R* rgba)
   stride: 3
   vertexCount: 0x51
   primCount:   0x1B
   vifOffset:   0xF3

VU code binary, disassembly

CVBuildingDNPipe

 53F20082 (template @ 8A30B0)
 53F20083 (template @ 8A3020)
   clusters: 6 6D00000D (R* xyzw)
             7 6500000D (R* uv)
             8 6D00400D (R* rgba2)
   stride: 3
   vertexCount: 0x51
   primCount:   0x1B
   vifOffset:   0xF3

VU code binary, disassembly

CVBuildingEnvMapPipe

 53F2008C (unused by DFFs, template @ 8A3160)
 53F2008D (used with 53F20080, template @ 8A30D0)
   clusters: 6 6D00000D (R* xyzw)
             7 6500000D (R* uv)
             8 6E00400D (R* rgba)
             9 6E00000D (R* normal)
   stride: 4
   vertexCount: 0x38
   primCount:   0x12
   vifOffset:   0xE0

VU code binary, disassembly

CVBuildingDNEnvMapPipe

 53F2008E (unused by DFFs, template @ 8A3210)
 53F2008F (used with 53F20082, template @ 8A3180)
   clusters: 6 6D00000D (R* xyzw)
             7 6500000D (R* uv)
             8 6D00400D (R* rgba2)
             9 6E00000D (R* normal)
   stride: 4
   vertexCount: 0x38
   primCount:   0x12
   vifOffset:   0xE0

VU code binary, disassembly

CVBuildingUVAPipe

 53F20090 (unused by DFFs, template @ 8A32C0)
 53F20091 (unused by DFFs, template @ 8A3230)
   clusters: 6 6D00000D (R* xyzw)
             7 6500000D (R* uv)
             8 6E00400D (R* rgba)
   stride: 3
   vertexCount: 0x50
   primCount:   0x1A
   vifOffset:   0xF0

VU code binary, disassembly

CVBuildingDNUVAPipe

 53F20092 (unused by DFFs, template @ 8A3370)
 53F20093 (unused by DFFs, template @ 8A32E0)
   clusters: 6 6D00000D (R* xyzw)
             7 6500000D (R* uv)
             8 6D00400D (R* rgba2)
   stride: 3
   vertexCount: 0x50
   primCount:   0x1A
   vifOffset:   0xF0

VU code binary, disassembly

Vehicle Pipelines

CVCarPipe

 53F20084 (template @ 8A2F50)

This pipeline does not render any reflection effects:

 53F20085 (template @ 8A2EC0)
   clusters: 6 6D00000D (R* xyzw)
             7 6500000D (R* uv)
             8 6E00401C (not instanced)
             9 6E00000D (R* normal)
   stride: 4
   vertexCount: 0x45
   primCount:   0x17
   vifOffset:   0x114

VU code binary, disassembly

CVCarEnvMapPipe

 53F20086 (unused by DFFs, template @ 8A2E00)

This pipeline renders environment maps (and specular maps):

 53F20087 (use with 53F20084, template @ 8A2CE0)
   clusters: 6 6D00000D (R* xyzw)
             7 6500000D (R* uv)
             8 6E00401C (not instanced)
             9 6E00000D (R* normal)
   stride: 4
   vertexCount: 0x38
   primCount:   0x12
   vifOffset:   0xE0

VU code binary, disassembly

This pipeline renders x-environment maps (and specular maps):

CVCarEnvMapUV2Pipe

 53F2008B (use with 53F20084, template @ 8A2D70)
   clusters: 6 6D00000D (R* xyzw)
             7 6D00000D (R* uv2)
             8 6E00401C (not instanced)
             9 6E00000D (R* normal)
   stride: 4
   vertexCount: 0x38
   primCount:   0x12
   vifOffset:   0xE0

VU code same as above.

Skin Pipelines

CVSkinPedPipe

 53F20088 (template @ 6275A0)
 53F20089 (template @ 627510)
   clusters: 6 6D00000D (R* xyzw)
             7 6500000D (R* uv)
             8 6E00000D (R* normal)
             9 6C00000D (skin data)
   stride: 4
   vertexCount: 0x2e
   primCount:   0x10
   vifOffset:   0xC0

VU code binary, disassembly

Data format and VU1 code

Normals are scaled by 128, UV coordinates by 4096.

Vertices are scaled by 128 in the building code, otherwise by 1024.

The W field of the xyzw cluster is 0x0000 or 0x8000 and written to the ADC field of the XYZF register. 0x8000 inhibits the draw kick for this vertex.

For each vertex skin value the lower 10 bits are the bone matrix offset, the upper 22 bits are the upper part of an IEEE-float. The bone matrix offset can be converted to a bone index like this: i = off == 0 ? 0 : off/4 - 1 (Actually all 32 bits are interpreted as IEEE floats, bone transformation isn't sensitive to little changes in the lower bits. Also all lower 16 bits are used as the bone offset but since the VU1 memory has only 16kb and the memory is qword-addressed, an address is only 10 bits long and the upper bits are ignored. The offsets are added to the start of the bone matrix array (which starts at 0x2d0) -4: so they're added to 0x2cc)