GPU Video Timing
Video clocks, scanline and dot timing, refresh rates and NTSC and PAL display of the GPU.
Overview
The GPU continuously reads the display area of the frame buffer to create the video signal, and by rewriting the frame buffer up to 60 times per second it produces moving images.1 The timing of that signal is set by the video clock and by the display mode of GP1(08h). Several CPU timers count GPU timing signals, and the vertical blank raises the IRQ0 interrupt.23
Video Clock
psx-spx gives the nominal video clock of each region:4
| Region | Video clock |
|---|---|
| NTSC | 53.693175 MHz |
| PAL | 53.203425 MHz |
A console always uses the video clock of its own region, whether the GPU is set to NTSC or PAL output, because an NTSC console has no PAL reference clock and the reverse. Without an added oscillator, a console showing content of the other region may therefore drift over time.4
The earlier notes by nocash, kept in psx-spx, give the PSone and PAL video clock as the CPU clock times 11/7: the CPU clock is 33.868800 MHz (44100 Hz x 300h) and the video clock 53.222400 MHz (44100 Hz x 300h x 11/7).5 Sony gives the CPU clock as 33.8688 MHz.6
Scanlines
The number of scanlines per field depends on the video standard and on interlace:7
| Mode | Scanlines |
|---|---|
| NTSC non-interlaced | 263 |
| NTSC interlaced | 262.5 |
| PAL non-interlaced | 314 |
| PAL interlaced | 312.5 |
The horizontal and vertical blanking of the video output follow the NTSC and PAL standards. They are not necessarily the same as the HBLANK and VBLANK signals that the timers and interrupts see.7 Timer 1 can count the horizontal blank signal and so count scanlines; the signal is generated even during vertical blanking.5
Dot Clock
The dot clock is the video clock divided by a value that depends on the horizontal resolution. The nocash notes give the following dot clocks for the 53.222400 MHz clock:5
| Horizontal resolution | Divider | Dot clock |
|---|---|---|
| 256 | 10 | 5.322240 MHz |
| 320 | 8 | 6.652800 MHz |
| 368 | 7 | 7.603200 MHz |
| 512 | 5 | 10.644480 MHz |
| 640 | 4 | 13.305600 MHz |
The same notes give a scanline as 3406 video cycles on PAL and 3413 on NTSC. The number of dots per scanline is therefore the cycle count divided by the divider: in 320-pixel mode 3406/8 = 425.75 dots on PAL and 3413/8 = 426.625 dots on NTSC.5 These values include the dots and scanlines hidden in the blanking periods.5
Timer 0 can count the dot clock, but it ignores the fractions. In most cases the count is rounded down, so with 340.6 dots per line the timer advances 340 times; the only value rounded up is 425.75. The dot clock runs during horizontal and vertical blanking as well.5
Refresh Rates
psx-spx gives the following field rates for each combination of mode and clock:8
| Mode | Clock | Interlaced | Non-interlaced |
|---|---|---|---|
| NTSC | NTSC | 59.940 Hz | 59.826 Hz |
| PAL | PAL | 50.000 Hz | 49.761 Hz |
| NTSC | PAL | 59.393 Hz | 59.280 Hz |
| PAL | NTSC | 50.460 Hz | 50.219 Hz |
NTSC and PAL
Sony describes the libgpu display in terms of NTSC and lists the differences for PAL:9
| Video format | NTSC | PAL |
|---|---|---|
| Field rate | 60Hz | 50Hz |
| Standard vertical resolution | 240 | 256 |
Because the PAL field rate is 50 Hz, the maximum display rate is 50 frames per second. Programs that use VSync() for timing therefore run at 5/6 of the NTSC speed, and their timing must be adjusted by 6/5. The larger PAL picture also needs a larger display area for a full screen; with the NTSC display area the top or bottom of a PAL screen appears dark.910
To support PAL a program must enable PAL mode with SetVideoMode() and adjust the display starting position. Adjusting the timing and the display area is optional and depends on the application. On the DTL-H2000 the DIP switch of the main unit must also be set.910
Interlace
In interlace mode the display updates the odd and the even lines of the buffer in alternate frames of 1/60 second. In effect the odd lines are redisplayed every 1/30 second, and the same holds for the even lines.11 Interlace must be on for all lines of a 480-line picture to be seen.12
In this mode the odd and even fields are switched every 1/60 second under the NTSC standard, so all processing must finish within 1/60 second. If drawing takes too long, it can be cancelled with ResetGraph(1), which leaves a partly drawn polygon. If the CPU is late, the previous OT can be drawn again until the CPU has built the next one.13 GPUSTAT bit 31 shows which lines the GPU is drawing.14
Frame Rate
Switching the double buffer is generally synchronized with the vertical sync. If the time to build a frame is sometimes slightly less and sometimes slightly more than 1/60 second, the frame rate jitters between 60 and 30 frames per second, and objects move unnaturally. The frame rate can instead be fixed at the slower rate with the VSync counter. VSync(2) gives 30 frames per second, VSync(3) gives 20 and VSync(4) gives 15.1015
An application whose frame rate varies should not base its internal clock on the frame count, because objects would then change speed with the frame rate. It can use an absolute counter such as VSync(-1) or root counter 3 instead, which keeps motion steady even when frames are skipped.15
Synchronization in libgpu
VSync() detects the vertical blank and reports timing:16
| Call | Action |
|---|---|
| VSync(0) | Blocks until the next vertical blank period begins |
| VSync(1) | Returns the number of horizontal sync units since the previous VSync(0) or VSync(n) call |
| VSync(n), n > 0 | Waits for the nth vertical blank period |
| VSync(-n), n < 0 | Returns the number of vertical blank periods since the program was started |
VSyncCallback() registers a function called at the start of each vertical blank, and DrawSyncCallback() one called when a non-blocking drawing operation completes.16 A call to VSync(1) right after VSync(0) may not return a value near 0, because sound callbacks and controller drivers run during the vertical blank.17
References
-
^ Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-4.
-
^ psx-spx. Graphics Processing Unit (GPU), GPU Timers / Synchronization. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-io-ports-dma-channels-commands-vram
-
^ psx-spx. Graphics Processing Unit (GPU), GP1(07h) - Vertical Display range (on Screen). https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-display-control-commands-gp1
-
^ a b psx-spx. Graphics Processing Unit (GPU), Nominal Video Clock. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-timings
-
^ a b c d e f psx-spx. Graphics Processing Unit (GPU), GPU Timings, Nocash's original GPU Timings notes. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-timings
-
^ Sony Computer Entertainment Inc. PlayStation Hardware. August 1998. Page 2-3, Table 2-1.
-
^ a b psx-spx. Graphics Processing Unit (GPU), Vertical Video Timings. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-timings
-
^ psx-spx. Graphics Processing Unit (GPU), Vertical Refresh Rates. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-timings
-
^ a b c Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-39, Table 8-21.
-
^ a b c Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-40.
-
^ Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-8.
-
^ psx-spx. Graphics Processing Unit (GPU), GP1(08h) - Display mode. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-display-control-commands-gp1
-
^ Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-43.
-
^ psx-spx. Graphics Processing Unit (GPU), GPU Status Register. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-status-register
-
^ a b Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-41.
-
^ a b Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-18, Table 8-9.
-
^ Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-42.