# The GPU Sources: psx-spx `graphicsprocessingunitgpu.md` at `6d7d1bc` (tier 3, facts only); psxdev `wiki_eng/gpu.md` (CC0); test programs: ps1-tests `gpu/*` (MIT, 18 tests with `vram.png` expected pictures), amidog `psxtest_gpu` 1.7 and the cache demos, PeterLemon `GPU/` EXEs (run only). ## The chip, by revision (DOC psx-spx "GPU Versions") | | v0 | v1 | v2 | | --- | --- | --- | --- | | Chip | CXD8514Q | CXD8538Q (arcade only) | CXD8561Q/BQ/CQ, CXD9500Q | | Boards | EARLY-PU-8 and before | arcade | LATE-PU-8 on, PSone | | VRAM | dual-ported VRAM | dual-ported | ordinary DRAM | | Shaded textures | ((colour/8) x texel)/2: banding | ? | (colour x texel)/16 | | X/Y texture flip (E1h bits 12-13) | no | no | yes | | GP1(10h) version | none | 1 | 2 | The board's first GPU is **v2** (every console from LATE-PU-8, and the SCPH-1001's later boards), with v0 as a later switch (Open decisions). ## Interfaces - GP0 (1F801810h write): rendering and VRAM-transfer commands and parameters, through a **16-word command FIFO** (psx-spx); GP0(E3h-E5h) do not occupy FIFO space and act at once (so they can change the drawing area under commands still queued). - GP1 (1F801814h write): display control (reset, DMA direction, display start, ranges, mode, read internal registers). GPUREAD (1F801810h read): VRAM-to-CPU data and GP1(10h) answers. GPUSTAT (1F801814h read): ready bits, DMA request, interlace field, display settings. - DMA2 (GPU) in block and linked-list modes; DMA6 builds the ordering table (OTC). - Signals out: VBLANK (IRQ0), GPU IRQ1 (GP0(1Fh)), the dot clock (timer 0's source) and HBLANK (timer 1's source) (psxdev cpu.md pins TCLK0/TCLK1). ## What the specification must model - **Rasterisation**: triangles (quads as two), lines and polylines (Bresenham variant), rectangles and sprites; flat/Gouraud; textured with 4/8/15-bit textures and CLUTs; texture window; semi-transparency's four modes; dithering (4x4 table); mask bit set and check; draw area clipping and offset; fill rules (ps1-tests `quad`, `triangle`, `rectangles`, `lines`, `uv-interpolation` judge these per pixel against their `vram.png`). The PlayStation has no sub-pixel precision or perspective correction (psx-spx "GPU (MISC)"): integer vertices, affine texturing. - **The texture cache and the CLUT cache**: observable (ps1-tests `clut-cache`; amidog psxtest_gpu "texture cache tests" and the `irq`/`pipe_line` demos abuse them). psx-spx "GPU Texture Caching" describes 2 KB in cache blocks per texture mode. In the spec, because it changes pictures when VRAM is written under it. - **Timing**: how long each command keeps the GPU busy (GPUSTAT ready bits, FIFO back-pressure, DMA pacing). psx-spx has no table; ps1-tests `gpustat`, `bandwidth`, `benchmark` measure parts of it. **U1: the rendering cost model has no documented source**; the spec starts FITTED to ps1-tests' measurements and says so. - **Video timing**: video clock 53.693175 MHz (NTSC) / 53.203425 MHz (PAL), 3413 / 3406 video clocks per line, 263 / 314 lines (non-interlaced), dot clock = video clock / 10, 8, 7, 5 or 4 for 256, 320, 368, 512, 640 pixels (psx-spx "GPU Timings"; nocash's notes give the PSone PAL clock as CPU x 11/7 = 53.2224 MHz, **C1** against 53.203425 MHz: different units or a rounding; judge: the timer-0 counts in ps1-tests `timers`). - **Mid-line display register writes** take effect mid-line: amidog's Tajmiing (2016, tested on SCPH-7002, SCPH-102, SCPH-7501) disables display mid-line and stretches pixels by changing the horizontal resolution counter's match value. That is a per-dot output model at least for the display side, an argument for the GPU's display output to be cycle-level while rasterisation is transaction-level (U2: the exact dot-counter mechanism comes only from amidog's description). ## Modelling level (proposal) Display output and VRAM reads for scan-out: **cycle level** (dot clock). Rasterisation: **transaction level** (each command's pixels written in the order the hardware writes them, with its busy time), since what software sees is the VRAM result and the busy time, not the order of pixel writes within a command, except where a command reads VRAM it writes (semi-transparency over itself, the mask bit, the texture cache): the spec writes pixels in the hardware's scan order, which the tests pin. ## Unknowns - U1 Rendering cycle costs per primitive (no document; fit to ps1-tests measurements). - U2 The display dot counter (Tajmiing's mechanism) beyond amidog's prose. - U3 v0's VRAM-to-display contention and its timing differences (psx-spx: "unknown"). - U4 GP0(03h) (takes FIFO space, "unknown/unused"). - C1 PAL video clock: 53.203425 MHz (psx-spx nominal table) vs 53.2224 MHz (nocash's 11/7 derivation).