Programming the PS2
E N D
Presentation Transcript
Programming the PS2 Programming the PS2 Daryl Cooper Daryl Cooper SCEE Technology Group SCEE Technology Group February 20-22, 2004, Moscow 1 Programming the PS2 - SCEE Technology Group
Topics Topics • A Comparison of PSOne and PS2 • Processing Units • Learn step-by-step • Programming the DMAC • Network Adaptor and EyeToy • Development tools for everyone 2 Programming the PS2 - SCEE Technology Group
PlayStation Generations PlayStation Generations PlayStation (Dec. 1994) PlayStation 2 (Mar. 2000) Frequency 300Mhz 33Mhz Bus Bandwidth 32bit 128bit Main Memory 2MB 32MB VRAM 1MB 4MB Display Priority Z Sorting Z Buffer Media CD-ROM CD/DVD-ROM 3 Programming the PS2 - SCEE Technology Group
PSOne Architecture PSOne Architecture SPU CD ROM MDEC 32bit Bus Memory 2MB GPU 1MB MIPS R3000 GTE Comms 4 Programming the PS2 - SCEE Technology Group
PS2 Architecture PS2 Architecture SPU2 IOP EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 5 Programming the PS2 - SCEE Technology Group
Getting started Getting started • Steep learning curve • Sample code and templates available to get you started • Takes care of basic tasks • Leaves you to focus on low level programming 6 Programming the PS2 - SCEE Technology Group
EE Core EE Core EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 • Small caches • Dynamic data is not in the cache for long periods of time I$ D$ 8K SPR 16K 16K EE CORE 7 Programming the PS2 - SCEE Technology Group
Graphic Synthesiser Graphic Synthesiser EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 • Draws primitives • Texture Mapping • Gouraud Shading • Alpha blending 8 Programming the PS2 - SCEE Technology Group
GS Fill Rate GS Fill Rate EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 • DRAM Bandwidth : 48GB/sec • Frame buffer : 38.4GB/sec • Texture : 9.6GB/sec 9 Programming the PS2 - SCEE Technology Group
GS Fill Rate GS Fill Rate EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 • Fill rate: • 2.4Giga pixel/sec for untextured polygons • 1.2Giga pixel/sec for textured polygons 10 Programming the PS2 - SCEE Technology Group
GIF GIF EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 • Connects DMA to GS • GIF codes used to set GS registers – Set GS state – Perform operations • Also connects VU1 to GS 11 Programming the PS2 - SCEE Technology Group
Vector Units Vector Units EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 • 2 FP Vector Units • 4 Multiplies + 4 adds per instruction • 36M verts/sec possible • Independent of other devices 12 Programming the PS2 - SCEE Technology Group
Vector Unit 0 Vector Unit 0 EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 • Can reduce load from EE Core • Runs micro mode in parallel to EE core • Helps reduce I$ misses 13 Programming the PS2 - SCEE Technology Group
Vector Unit 1 Vector Unit 1 EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 • Direct connection to GIF • Fast transformation and output to GS • More memory for double buffering 14 Programming the PS2 - SCEE Technology Group
VIF Data VIF Data Compression/Decompression Compression/Decompression EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 8bit • VIF can decompress models • Reduces memory use and bandwidth X Y Z X Y Z 1.0 32bit 15 Programming the PS2 - SCEE Technology Group
IOP and SPU IOP and SPU CD, HDD, Pad, USB, I-link, TCP/IP SPU2 2MB IOP 2MB 32bit Bus EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 16 Programming the PS2 - SCEE Technology Group
Overview Overview • Code templates available to help get started • EE Core general purpose CPU • VUs for intensive maths operations • GS for drawing • IOP for input/output • Next: DMA, and learning step-by-step 17 Programming the PS2 - SCEE Technology Group
Rendering Pipeline Rendering Pipeline Calculate Animation • CPU + Coprocessor VU0 +-*/ Traverse Scene • Traverse DMA list Transform to 2D +-*/ • VU1 Rasterisation • GS 18 Programming the PS2 - SCEE Technology Group
DMA Controller DMA Controller EE SIF IPU DMAC 128bit Bus Memory 32MB GS 4MB cache EE CORE VIF VU0 VIF GIF FPU VU1 • The DMAC controls all data transfers • Transfers in parallel to CPU • Total bandwidth 2.4GB/sec 19 Programming the PS2 - SCEE Technology Group
DMA Transfers DMA Transfers Device 1 Device 2 Device 3 Device 4 Device 5 DMA Controller • Channels used to transfer between devices • Set DMAC registers • Issue start signal • DMAC arbitrates bus usage 20 Programming the PS2 - SCEE Technology Group
Display Lists and DMA Chains Display Lists and DMA Chains DMA Chain Texture Matrix Ref Ref Call Vertices Object Matrix Matrix Instance Texture Ret Vertices Instance Instance Instance Instance Instance 21 Programming the PS2 - SCEE Technology Group
1st Attempt at PS2 Coding 1st Attempt at PS2 Coding Memory DMA Bus: 2.4GB/sec Geometry and Texture VU0 CPU VU1 GS Transformation + Lighting 22 Programming the PS2 - SCEE Technology Group
2nd Attempt at PS2 Coding 2nd Attempt at PS2 Coding Memory DMA Bus: 2.4GB/sec Geometry and Texture VU0 CPU VU1 GS Transformation + Lighting 23 Programming the PS2 - SCEE Technology Group
Utilising Full Power of PS2 Utilising Full Power of PS2 Memory DMA Bus: 2.4GB/sec Geometry Texture VU0 CPU VU1 GS Animation, Physics, A.I. Transformation and Lighting 24 Programming the PS2 - SCEE Technology Group
DMA and Getting Started DMA and Getting Started • DMA fast and flexible • Programmable data structures • Deferred rendering • Stages of implementing efficient code • Next: Network Adaptor and EyeToy 25 Programming the PS2 - SCEE Technology Group
Network Gaming on PS2 Network Gaming on PS2 • Network Adaptor • HDD interface & 100/10 Ethernet port – Modem in USA • TCP/IP • High level middleware 26 Programming the PS2 - SCEE Technology Group
EyeToy Hardware EyeToy Hardware • Platform for video- input games • USB Camera – Compresses data in PS2 IPU format – Normally 320x240 50/60Hz 27 Programming the PS2 - SCEE Technology Group
EyeToy Driver EyeToy Driver • Two drivers available – 1stparty driver from SCE – 3rdparty from Logitech • Gets data from camera – Hardware IPU decompression for real-time – JPEG for stills 28 Programming the PS2 - SCEE Technology Group
EyeToy Vision Library EyeToy Vision Library • Image processing • Motion detection • Colour tracking • Background subtraction • Face detection • Torso tracking • T-shirt tracking 29 Programming the PS2 - SCEE Technology Group
Alternative Technologies Alternative Technologies • Online play with Network Adaptor • EyeToy different approach to games • Powerful Vision library for games • Finally: Development environments for everyone 30 Programming the PS2 - SCEE Technology Group
PS2 Development Environment PS2 Development Environment The TOOL The TOOL • TOOL = PS2 + more RAM TV TV Controllers Controllers • Connects to PC over network • Linux-based tools provided, 3rd-party Windows tools available LAN LAN PC PC 31 Programming the PS2 - SCEE Technology Group
PS2 Development Environment PS2 Development Environment The Performance Analyser The Performance Analyser • Low level profiling of program efficiency TV TV Controllers Controllers • Programmer can view system activity graphically LAN LAN • Easy to identify bottlenecks in program design PC PC 32 Programming the PS2 - SCEE Technology Group
PS2 Performance Analyser PS2 Performance Analyser • CPU efficiency • Cache misses • DMA transfers • GIF usage • VU0 • VU1 33 Programming the PS2 - SCEE Technology Group
PS2 Development Environment PS2 Development Environment Programming Tool LT Programming Tool LT • Low cost development on Test Station – €675 TV TV Controllers Controllers • Uses special Memory Card • Bundle includes Test Station LAN LAN PC PC 34 Programming the PS2 - SCEE Technology Group
PS2 Development Environment PS2 Development Environment Programming Tool LT Programming Tool LT • Works with standard tools TV TV Controllers Controllers • Standard PS2 RAM • Useful for Artists and Programmers who don’t need extra TOOL features LAN LAN PC PC 35 Programming the PS2 - SCEE Technology Group
Linux for PlayStation 2 Linux for PlayStation 2 • Complete Linux Distribution • Development Environment • Access to low level hardware • Runs on consumer PS2 • Used in Universities 36 Programming the PS2 - SCEE Technology Group
Summary Summary • The PS2 is flexible and powerful • Parallel processing is essential for good performance • DMA is the key to unlocking the PS2 • With a little thought and some kit… • You can develop for PS2 37 Programming the PS2 - SCEE Technology Group
Questions Questions • Want to become a PS2 Developer? – www.technology.scee.net • Want PS2 Linux? – www.playstation2-linux.com • Thank you! 38 Programming the PS2 - SCEE Technology Group