PS2 Linux Programming
Sending Texture Data Via Path 2
The code supplied in this
example is an extension of the tutorial “2D Texture Mapping”. It illustrates
the uploading of texture data via Path 2, which is via VIF1 to the GIF. This
technique is useful for synchronising the uploading of texture data with
geometry that is to be rendered by VU1 over Path 1. If both the texture and the
geometry are sent via VIF1 (with the texture being sent first), then it is
guaranteed that the correct texture is in GSmem before the rendering of the
geometry is started.
Examining the Ctexture
class it can be seen that there are three methods to manipulate the texture
data:
CTexture::LoadBitmap() – This method reads the bmp image file from disk,
performs some pre-configuration and stores the data in SPS2 memory.
CTexture::InitDmaChain() – This method builds the DMA chain that is used to
upload the texture data to the GS. The DMA chain is stored in SPS2 memory.
CTexture::Upload() – This method loads the appropriate DMAC channel
control registers, starts the image upload and waits for the transfer to
complete.
On examination of the
InitDmaChain() method it can be seen that a DIRECT VIF code is combined with
each DMATag as illustrated below.
*pDMATag++ = DMACnt.i64;
*pDMATag++ = (DIRECT(6)
<< 32) | NOP;
The VIF codes are in the
top 64 bits of the qword, with the lower 64 bits containing the DMATag. In this
case, the DIRECT(6) VIF code tells the VIF to transfer the following 6 qword
directly to the GIF.
In order for this to
operate correctly, the channel control register must be configures with the “Transfer
Tag Enable” bit set to one (chcr.s.TTE = 1) to ensure that the DMATag is sent
during the transfer, and the “Direction” bit set to one (chcr.s.DIR = 1).to set
the transfer direction FROM main memory TO VIF1.
Also note that DMAC
channel 1 is being used, which is the channel to VIF1.
Dr Henry S Fortuna
University
of Abertay Dundee