psx.wiki

Frame Buffer (VRAM)

Video memory of the GPU holding display, drawing, texture and CLUT areas.

Overview

The GPU has 1 MB of video memory (VRAM), called the frame buffer. The frame buffer is dual ported, and may be accessed for drawing while display takes place.1 It is arranged as a bitmap 1024 pixels wide by 512 pixels tall with 16 bits per pixel; the total size is therefore one megabyte (1024 x 512 pixels x 2 bytes per pixel). The same memory holds the display area, the drawing area, the texture patterns and the color lookup tables (CLUTs).2

The frame buffer is not mapped in the CPU address space. The CPU reaches it only through the GPU ports or by DMA, and the transfer commands carry the data.3 The graphics system has no special background plane, so everything shown on the screen is first drawn into the frame buffer.2

psx-spx states that the v0 GPU uses two dual-ported VRAM chips, while the v2 GPU uses ordinary DRAM on a single 32-bit bus. Some arcade boards carry 2 MB of VRAM, laid out as 1024 lines, and some PSone consoles carry a 2 MB chip of which only the first 1 MB is reachable.345

Coordinates

Pixels in the frame buffer are given by 2-dimensional coordinates: X from 0 to 1023 and Y from 0 to 511.2 An X coordinate counts halfwords, so the same row of 2048 bytes is 4096 pixels wide in 4-bit units, 2048 in 8-bit units, 1024 in 16-bit units and 682.66 in 24-bit units.3

Pixel Format

Each pixel has a 16-bit depth: 5 bits for red, 5 bits for green and 5 bits for blue, and the high-order bit is the semi-transparent flag (STP).6

Table 1: 15-bit pixel
Bits Content
0 to 4 Red, 0 to 31
5 to 9 Green, 0 to 31
10 to 14 Blue, 0 to 31
15 STP (mask flag in the frame buffer)

In the frame buffer bit 15 is the mask flag: with GP0(E6h) set to check the mask, a pixel whose bit 15 is 1 cannot be overwritten.78

In 24-bit mode a pixel occupies 3 bytes, so 6 bytes hold two pixels. Frame buffer coordinates stay in 16-bit units, and a 640 x 480 image therefore occupies 960 x 480 in the frame buffer.97 The GPU cannot draw in 24-bit mode, because drawing assumes 16 bits per pixel; 24-bit images are transferred into the frame buffer, which is the method used for MDEC movies.97

Display Area and Drawing Area

The display area is a rectangle of the frame buffer that is output as the video image. Its size depends on the display mode and ranges from 256 x 240 to 640 x 480 (709 x 488 during overscan).6 The display modes that libgpu supports are as follows:6

Table 2: Display modes
Item Values
Width 256, 320, 360, 512, 640
Height 240 (interlace off), 480 (interlace on)
Pixel mode 24-bit, 16-bit
Interlace On, off

The heights assume NTSC. A standard PAL picture has 256 lines.610 psx-spx lists the frame buffer space each resolution needs:7

Table 3: Display area size
Resolution 16-bit 24-bit
256 x 240 120 KB 180 KB
320 x 240 150 KB 225 KB
512 x 240 240 KB 360 KB
640 x 240 300 KB 450 KB
256 x 480 240 KB 360 KB
320 x 480 300 KB 450 KB
512 x 480 480 KB 720 KB
640 x 480 600 KB 900 KB

The drawing area is the rectangle into which the GPU draws. Its size is not limited as long as it lies within the frame buffer. If the drawing area overlaps the display area, the drawing appears on the screen; to avoid this, a double buffer of two areas of the same size is used, one for drawing while the other is displayed, and the two are switched during the vertical blank.6 Because a resolution above 512 KB cannot fit twice in 1 MB, a 640 x 480 picture leaves no room for a double buffer.711

In 640 x 480 interlace mode a single buffer can serve for both drawing and display instead. With the dfe flag of DRAWENV set to 0, the GPU draws only the odd lines while the even lines are displayed and the reverse. This is equivalent to double-buffer switching, provided drawing completes within 1/60 second.11

Texture Pages

Texture patterns are stored in areas outside the display and drawing areas that are called texture pages. A texture page is a 256 x 256 bitmap whose upper left X coordinate in the frame buffer must be a multiple of 64 and whose Y coordinate must be a multiple of 256. Texture pages can therefore overlap horizontally.12 Because the frame buffer is 1024 x 512, there are 16 x 2 = 32 page positions. Sony numbers them as tpage = ty/16 + tx/64.13

A polygon uses 8-bit texture coordinates, so it cannot use a texture larger than 256 x 256. The texture window of GP0(E2h) can reduce the usable area below that size.14 Each primitive may use a different texture mode:12

Table 4: Texture pattern modes
Mode Type Colors Texture page width
4-bit CLUT-based 16 64
8-bit CLUT-based 256 128
16-bit Direct RGB 32767 256

A 16-bit word holds fewer texels the deeper the mode. Consequently a texture page occupies 256 x 256 of the frame buffer in 16-bit mode but only 64 x 256 in 4-bit mode. The sizes for each mode are shown below:1214

Table 5: Texture page size
Mode Texels per 16-bit word Area in the frame buffer Bytes
4-bit 4 64 x 256 32 KB
8-bit 2 128 x 256 64 KB
16-bit 1 256 x 256 128 KB
Table 6: Texel packing
Mode Pixel 0 (left) Pixel 1 Pixel 2 Pixel 3 (right)
4-bit Bits 0 to 3 Bits 4 to 7 Bits 8 to 11 Bits 12 to 15
8-bit Bits 0 to 7 Bits 8 to 15
16-bit Bits 0 to 15

When 4-bit and 8-bit textures are loaded with LoadImage(), their (u, v) coordinates do not map directly to frame buffer coordinates. The rectangle is given in 16-bit pixels, so its width is the texture width divided by 4 or by 2.15

CLUT

The 4-bit and 8-bit texture modes use a color lookup table (CLUT) to give the actual colors. Sony also calls the CLUT a palette. Each texel is an index into the CLUT, which is a row of 16-bit pixel values in the frame buffer: 16 entries for a 4-bit texture and 256 entries for an 8-bit texture.12 One entry has the same structure as a 15-bit pixel.13

The CLUT of each primitive can be chosen independently of its texture. Several textures may use the same CLUT, and a 4-bit texture can use any 16 entries of a larger CLUT.15 A CLUT starts at an X coordinate that is a multiple of 16 and may be on any line from 0 to 511.16 The CBA parameter of a drawing command gives its position.13

Transparent Pixels

Bit 15 of each texel, or of the CLUT entry in 4-bit and 8-bit mode, is the semi-transparent (STP) bit. A texel value of 0x0000 (STP, R, G and B all zero) is transparent and is not drawn. A texel with STP set is drawn semi-transparent if its primitive is set to semi-transparent mode with SetSemiTrans(), and a texel with STP clear and a nonzero color is always opaque.17

Table 7: Transparent and semi-transparent pixels
STP, B, G, R (0, 0, 0, 0) (1, 0, 0, 0) (0, n, n, n) (1, n, n, n)
Non-transparent primitive Transparent Black Non-transparent Non-transparent
Semi-transparent primitive Transparent Semi-transparent black Non-transparent Semi-transparent

A texture therefore cannot hold black as 0000h. An opaque primitive can use 8000h as black, but a semi-transparent primitive draws 8000h semi-transparent. The only way to get opaque black in a semi-transparent primitive is a near-black color such as 0001h or 0400h, which can look brighter than black on a monitor with high gamma.18

References


  1. ^ Sony Computer Entertainment Inc. PlayStation Hardware. August 1998. Page 3-3.

  2. ^ a b c Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-4.

  3. ^ a b c psx-spx. Graphics Processing Unit (GPU), VRAM Overview / VRAM Addressing. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-io-ports-dma-channels-commands-vram

  4. ^ psx-spx. Graphics Processing Unit (GPU), Memory/Rendering Timings. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-versions

  5. ^ psx-spx. Graphics Processing Unit (GPU), X/Y-Flip and PSone 2 MB VRAM. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-versions

  6. ^ a b c d e Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-5, Figure 8-3, Table 8-1.

  7. ^ a b c d e psx-spx. Graphics Processing Unit (GPU), Framebuffer. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-video-memory-vram

  8. ^ psx-spx. Graphics Processing Unit (GPU), GP0(E6h) - Mask Bit Setting. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-rendering-attributes

  9. ^ a b Sony Computer Entertainment Inc. PlayStation Hardware. August 1998. Page 3-4.

  10. ^ Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-39, Table 8-21.

  11. ^ a b Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-8.

  12. ^ a b c d Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-22, Table 8-10, Figure 8-10.

  13. ^ a b c Sony Computer Entertainment Inc. PlayStation Hardware. August 1998. Page 3-6, Figure 3-4, Figure 3-5.

  14. ^ a b psx-spx. Graphics Processing Unit (GPU), Texture Bitmaps. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-video-memory-vram

  15. ^ a b Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-23.

  16. ^ psx-spx. Graphics Processing Unit (GPU), Texture Palettes - CLUT (Color Lookup Table). https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-video-memory-vram

  17. ^ Sony Computer Entertainment Inc. Run-Time Library Overview. January 1999. Page 8-24, Table 8-11.

  18. ^ psx-spx. Graphics Processing Unit (GPU), Texture Color Black Limitations. https://psx-spx.consoledev.net/graphicsprocessingunitgpu/#gpu-video-memory-vram

Categories: Hardware · GPU