PS2 Linux Programming

 

Sending Geometry Data Via Path 2 (VIF1)

 

 

Introduction

 

Thus far in the tutorial series all data has been sent to the Graphics Interface (GIF) via Path 3. To unleash the true power of the Playstation 2, vector unit 1 (VU1) must be used for vertex transformation processing and this entails the use of Path 1 and (possibly) Path 2 transfer of data to the GIF. In this tutorial Path 2, which links the vector unit 1 interface (VIF1) and the GIF will be investigated.

 

 

Background

 

By way of a refresher, the internal structure of the PS2 is given in figure 1 below.

 

 

Figure 1

 

 

As can be seen, Path 2 links VIF1 with the GIF. Also, all data that is to be transferred to VU1 passes through VIF1.

 

 

Vector Unit Interface 1 (VIF1)

 

The VIF1 is the interface unit which decompresses the data transferred to it by the DMAC and transfers this data either to the VU or the GIF. The VIF is an intelligent interface which can be controlled by 32bit VIF codes that are included in the packet sent to the VIF. The VIF has about twenty or so instructions and a number of registers which can be investigated in chapter 6 of the EE Users manual.

 

Transferring data to VIF1 is over DMA Channel 1 and is much the same as for DMA Channel 2 to the GIF. VIF1 is bi-directional however, so the DIR field of the channel control register must be set to 1 to indicate that transfer is going FROM main memory to the VIF.

 

 

The Example Code

 

This example demonstrates how to send data directly over VIF1 to the GIF. This is called PATH 2 transferring, and is a slightly higher priority than PATH 3. The only VIF codes used are NOP (No operation, this does nothing) and DIRECT(QWC) (Sends QWC of

data directly to the GIF). The data send via DIRECT must be quad word aligned, therefore the DIRECT VIF code must be in bits 96-127 of a quad word so that the following data is properly aligned.

 

Note: VU1 is never activated at all in this example so this method is no faster than sending data via PATH3. One reason why this method is useful is that it allows the programmer to synchronise data transfers to the GIF with the activation of VU1. For example, a DMA chain can be built to sends a texture to the GIF first, then render some polygons using VU1. The texture is guaranteed to be uploaded before rendering starts. This is not so easily done with PATH3 and it is possible for the rendered textures to get corrupted due to synchronisation and timing problems.

 

The DMA Chain is transferred with TTE (Transfer Tag Enabled) set to 1. This means that the 128 bits that holds the DMA tag is transferred as well as the QWC of data that follow. Since a DMA tag is only 64-bits this means that two 32-bit VIF code can be inserted into the qword, straight after the DMA tag. These VIF codes are sent directly to the VIF.

 

Some other details to note about the example code are as follows:

 

·        The texture is sent to GSmem as before over path 3;

·        The VU devices are opened to prevent them from being used by other applications;

·        A single DMAC End  tag is used to transfer the DMAC packet;

·        DMA channel 1 to VIF1 is being used;

·        A textured sprite is being rendered.

 

 

Conclusions

 

This tutorial and accompanying code illustrated the transfer of data to the GIF via Path 2. This lays the foundations necessary for using the VUs.

 

Dr Henry S Fortuna

University of Abertay Dundee

h.s.fortuna@abertay.ac.uk