Tutorial

## 7 - Performance

In this section we add a sequence playback and performance meter to nu2, and indicate how to make efficient use of a triple frame buffer. We also explain stack splitting. The source can be found in the nu5 directory below the sample directory.

### 7.1 Triple Frame Buffer

Upon execution, the stage number, frame buffer mode (double or triple), and frame/second rate is displayed in the upper left corner of the screen. When double buffer mode is indicated (2 FrameBuffer) here, it does not mean that the frame buffer is actually doubled. It simply means that, of the three frame buffers, only two can be used at the same time. To learn the procedure for really doubling the frame buffer, please refer to INSIDE NuSystem.

The performance meter is displayed at the bottom of the screen, showing (in order from the top) the audio task process time, the RSP graphic task process time, and the RDP process time.

The performance meter can be displayed with the following function.

>     nuDebTaskPerfBar0(1,200,NU_SC_NOSWAPBUFFER);

In the same way, the debug console can use this function internally to set the RDP and to create a display list and activate a graphics task. (Be careful that the function is only inserted into the libnusys_d.a debug library.)

Only one square shape appears on the screen, but the graphic spans around 1.2 frames because it comprises a stack of 25 overlaid drawings.

If you push the Z trigger here, the mode changes to triple frame buffer mode. The number of frames processed per second increases a little and, at the same time, the timing of task starts changes significantly.

A change in the value checked by the stage00() callback function "pendingGfx" causes the frame buffer to swap between double/triple mode.

>     void stage00(int pendingGfx)
>     {
>       if(pendingGfx < 3+pendflag)
>         {
>           makeDL00();
>           dsp++;
>         }

>       /* advance game process */
>       updateGame00();

When the value of pendflag is changed from 0 to 1 by the Z trigger, makeDL() is executed even if there are three tasks. By making efficient use of the triple frame buffer, RCP tasks can be processed without interruption.

### 7.2 Graphic Task Division

Pushing the START button swaps to stage 1. In stage 1, graphic processes are divided into a screen clearing process and a drawing process.

Clearing the screen takes a long time in an RDP process. So instead of running the process as a single task, you can clear the screen as a separate task and thereby slightly increase the RSP’s free time.

However, in cases like the sample we use here, you do not always get better results from dividing the task.