PS2 Linux Programming

 

Using a Performance Timer

 

 

Introduction

 

This is a short tutorial which illustrates the use of Timer 3 within the EE core to build a performance timer. There are four 16 bit counters within the EE core but timer 3 is ideal since it is slow enough to be sampled in order to calculate “frames per second” (FPS). Timer 3 uses the horizontal blank frequency of the video circuitry to count. The frequency of the count is dependant upon the video mode being used. Details of the count frequencies and video modes are given on page 84 of the GS Users manual.

 

As a side issue, the code accompanying this tutorial illustrates the uploading of two textures to GSmem, one into each of the two buffers. This prevents the textures having to be uploaded during the render loop.

 

 

The Timer Class

 

The initialisation and control of the timer is undertaken by the CTimer class that is contained in the files timer.cpp and timer.h.

 

Within the class constructor, the video mode being used is determined – this is used in order to find the correct count frequency to be used when calculating the FPS. Note that the class constructor must be called after the video mode has been configured with the SPS2Manager.Initialise() method– if this is not convenient, the constructor can be altered to select a predefined video mode.

 

The method GetTimeDelta() returns the change in the count value since the last time this function was called or since the PrimeTimer() method was called. The count returned takes into account any wrapping of the timer.

 

The method GetFPS() calculates the current FPS of the application taking into account the video mode frequency being used.

 

The use of the timer is illustrated in the application code accompanying this tutorial.

 

 

Dr Henry S Fortuna

University of Abertay Dundee

h.s.fortuna@abertay.ac.uk