# Holly's PowerVR2 (CLX2): the tile accelerator, the renderer, the display Sources: Comstedt *pvr* (register descriptions "partly based on research done by bITmASTER and maiwe"), KOS `pvr.h`, `pvr/pvr_regs.h`, `pvr/*.h`, `asic.h` (tier 3); MAME's `powervr2` as a closed box (tier 5). No Sega or NEC document was used. ## How it works (Comstedt *pvr*) Deferred, tile-based rendering in two stages that run in parallel on different frames: 1. **Binning (the TA).** Software feeds primitives to the TA "either using DMA or directly by the CPU using the Store Queues or direct writes". The TA compiles them into an internal format in VRAM and records, in per-tile **object lists** ("tile bins"), which tiles each primitive may touch. Tiles are 32 x 32 pixels. 2. **Rendering (the ISP/TSP, "CORE").** For each tile, the ISP resolves visibility and the TSP textures and shades, into an on-chip 32 x 32 tile buffer that is written to the VRAM frame buffer when the tile is done. "No texel data is actually fetched from texture VRAM until the tile is copied to the frame buffer", so overdraw does not cost texture fill. 3. The display controller scans a frame buffer out of VRAM to the RAMDAC. With double sets of bins and buffers there is a two-frame latency: binning frame N+1 while rendering frame N while showing frame N-1 (Comstedt's table). ## The TA's input (KOS `pvr.h`) A stream of 32-byte (or 64-byte) parameters written to 10000000. The first word's top bits give the parameter type: `PVR_CMD_USERCLIP` (20000000h), polygon/modifier headers (`PVR_CMD_POLYHDR` 80840000h, `PVR_CMD_MODIFIER` 80000000h), `PVR_CMD_SPRITE` (A0000000h), vertices (`PVR_CMD_VERTEX` E0000000h, with the end-of-strip bit `PVR_CMD_VERTEX_EOL` F0000000h), and an end-of-list control parameter. Five **lists**: opaque, opaque modifier volumes, translucent, translucent modifier volumes, punch-through; each list's end raises its own interrupt (buses-dma-interrupts.md, register A bits 7-10, 21). Vertex formats depend on the header (packed or floating colour, textured or not, intensity, 16-bit UVs, two-volume forms for modifier volumes): the full set of formats, the header fields and their exact meaning are the TA's largest documentation gap without Sega's documents (U5). Registers that set the TA up (KOS `pvr_regs.h`): `PVR_TA_OPB_START`/`END`/`POS` (object pointer buffer), `PVR_TA_VERTBUF_START`/`END`/`POS` (parameter buffer), `PVR_TILEMAT_CFG`, `PVR_OPB_CFG` (which lists are active and their block sizes), `PVR_TA_INIT` (write 80000000h to latch), `PVR_TA_LIST_CONT`, `PVR_TA_OPB_INIT`. Overflows raise the error events 0202h, 0203h, 0204h, 0205h. ## The renderer (ISP/TSP) Started by writing `PVR_ISP_START` (005F8014) after setting `PVR_ISP_VERTBUF_ADDR`, `PVR_ISP_TILEMAT_ADDR`, `PVR_RENDER_ADDR`, `PVR_RENDER_MODULO`, clip registers, the background plane (`PVR_BGPLANE_Z`, `_CFG`), fog (`PVR_FOG_*`, a 128-entry fog table at 005F8200), palettes (005F9000, `PVR_PALETTE_CFG`), and the translucent sort mode (`PVR_ISP_FEED_CFG`: per-pixel sorting or presorted). Done is signalled by events 0, 1, 2. Behaviours the specification must define and that no document we hold fixes bit for bit (U6-U10): depth comparison modes and the 1/w depth format; per-pixel translucency sorting (the "auto-sort" mode) and its limits; modifier volumes (shadow/cheap-shadow inclusion and exclusion); texture formats (KOS `PVR_TXRFMT_*`: ARGB1555, RGB565, ARGB4444, YUV422, bump, 4- and 8-bit palette, twiddled or not, VQ-compressed, strided, mipmapped) and the filtering arithmetic (bilinear, trilinear, mipmap selection); colour combining (the TSP's shading and blending modes, specular "offset" colour), fog (table/vertex/linear), the dither and the frame-buffer pixel packing (RGB555, RGB565, RGB888, ARGB8888, Comstedt *pvr*). Render time per tile is unknown: FITTED. ## The display controller (Comstedt *pvr*) Registers at 005F8040-005F80F4: border colour, frame-buffer read address for each field (`PVR_FB_ADDR`, `PVR_FB_IL_ADDR`), the read size and modulo (`PVR_FB_SIZE`), colour mode and the clock-double bit for VGA (`C`), scan-double, the display-enable bit; raster event lines (two programmable interrupt lines); sync totals and polarities; border windows; horizontal and vertical start positions; `PVR_VIDEO_CFG` (low-res pixel doubling); `PVR_SYNC_STATUS` (V/H blank status); `PVR_SCALER_CFG`. Comstedt gives the totals: "For 50Hz (PAL), set V=624 H=863. For 60Hz (NTSC/VGA), set V=524 H=857." ## The YUV converter Writes to 10800000 convert YUV420 macroblocks to YUV422 texture data at `PVR_YUV_ADDR` (`PVR_YUV_CFG`, `PVR_YUV_STAT`; event 6 when done). Used by video playback (Sofdec). ## Contradiction - C2. The pixel clock. Comstedt's 60 Hz totals as register values (V=524, H=857) read as "count minus one" give 858 x 525 = 450,450 clocks a frame; at 59.94 Hz that is 27.0 MHz (13.5 MHz for interlaced TV with the clock-double bit off: HYPOTHESIS). MAME's screen is 26.91 MHz, which is 857 x 524 x 59.94 = 26.92 MHz: as if the values were the counts themselves. Which is right decides the line and frame periods every raster interrupt is timed from. Follow the minus-one reading (the CCIR 601 27 MHz family: HYPOTHESIS), keep MAME's in a comment, settle with a timing test on hardware or a document. ## Who uses which Every commercial game uses the TA and ISP/TSP. Windows CE titles drive the same hardware through Microsoft's Direct3D-like layer (no difference to the board). The 2D BIOS menus also render through the PVR2 (MAME's picture of the Set Date/Time screen is a TA scene).