# GS: the Graphics Synthesizer Sources: Sony's *GS User's Manual* 6.0 and its supplement ("GSUM", DOC, facts only, cited by section); ps2tek "Graphics Synthesizer (GS)" (tier 3); judges: ps2autotests `gs/label` and `gs/signal` (TEST ROM, two programs only). **No hardware-captured picture judge is in hand**: the PS2 has no equivalent of the NES/PlayStation test suites with photographed outputs among the pinned sources, so the GS's pixel rules rest on GSUM (tier 2) and FITTED choices where it is silent. ## Chip rule The GS is used by the PS2 only (and the PS2-based arcade boards, which are ps2-python machines). It is not a CPU. **It stays in the board** as `ps2_python.gs`, behind a pin-shaped interface (the GIF's 64-bit register stream in, privileged registers, local memory, PCRTC out), as the charter's chip rule says. The PSX GPU is a different chip; nothing is shared with psx-python. ## What it is (GSUM ch. 1) - **Drawing**: points, lines, line strips, triangles, strips, fans, sprites; flat and Gouraud shading; perspective-correct texture mapping (STQ) or UV; bilinear, trilinear, MIPMAP (up to 7 levels: MIPTBP1/2); wrap/clamp/region modes; fogging; alpha blending with a programmable equation (ALPHA: (A - B) x C >> 7 + D), dithering, colour clamp; pixel tests (scissor, alpha test, destination alpha test, depth test); anti-aliasing for lines and triangle edges; two drawing contexts (_1/_2 registers) (GSUM §1.1.1, ch. 3, ch. 7). - **Local memory**: 4 MB embedded DRAM holding frame buffers, Z buffers, textures and CLUTs together; a 1024-bit read and a 1024-bit write port for frame and Z, a 512-bit texture port, 8 KB page buffers for each (GSUM §1.1.2, §1.2.1). - **Memory organisation** (GSUM ch. 8): 512 pages of 8 KB = 16,384 blocks of 256 bytes = 65,536 columns of 64 bytes; a page is 64 x 32 pixels in PSMCT32, 64 x 64 in PSMCT16, 128 x 64 in PSMT8, 128 x 128 in PSMT4, with **swizzled block and column orders that differ per pixel format** (GSUM §8.1-8.3). Writing in one format and reading in another is how games do palette tricks and channel shuffles; the specification must model the layouts exactly, as tables (decision P6). - **Transfers**: host to local, local to host (via VIF1/PATH2 with BUSDIR), local to local, set up with BITBLTBUF, TRXPOS, TRXREG, TRXDIR; data through HWREG; restrictions on drawing right after a transfer (GSUM ch. 4). - **PCRTC**: two read circuits with their own buffer, format, position and magnification, a merge circuit with alpha and BGCOLOR, a feedback write circuit (EXTBUF/EXTDATA/ EXTWRITE) with RGB to YCbCr; NTSC, PAL and VESA (up to 135 MHz video clock) (GSUM ch. 5). - **Signals and events**: SIGNAL, FINISH and LABEL registers raise events visible in CSR and as an interrupt (INT_GS) masked by IMR; SIGLBLID reads the IDs (GSUM ch. 6, §7.2). `gs/signal` and `gs/label` are the hardware-captured tests of exactly this. - **Privileged registers** at 12000000h: PMODE, SMODE1, SMODE2, SRFSH, SYNCH1/2, SYNCV, DISPFB1/2, DISPLAY1/2, EXTBUF, EXTDATA, EXTWRITE, BGCOLOR, CSR, IMR, BUSDIR, SIGLBLID (GSUM §7.2, §7.3; ps2tek). ## Rates (GSUM §1.3) 16 pixels a cycle untextured, 8 textured (32-bit pixels, Z and alpha on): **2.4 G and 1.2 G pixels/s**; setup from 1 cycle a point to 9 cycles a fogged, anti-aliased Gouraud triangle (150 M points/s to 16 M triangles/s). Those are stated at 150 MHz (C1 in memory-map.md). A Z range above 2^16 within one primitive costs a penalty. ## Modelling (decisions P5-P7) - **Pixels at functional level, exact**: every pixel's colour, alpha, Z and the tests are integer rules (8-bit channels, the blend equation's shift, dither matrix DIMX, colour clamp, the texture filter's fixed-point weights). GSUM states most of them; the filter's fraction bits, the LOD computation's precision and the perspective divide's precision are **U15-U17**, FITTED until a judge exists. - **Rasterisation rules** (which pixels a triangle covers, the top-left rule, sprite edges, the 12.4 fixed-point vertex format with XYOFFSET) are DOC in GSUM ch. 3 at the level of "pixel centres"; edge cases are U18. - **Timing at transaction level**: a front end that knows each primitive's setup cycles (GSUM §1.3's table), its pixel count by the 16- or 8-pixel rate, page-buffer breaks (GSUM §8.1: an access within a page "does not result in a page break"), and gives the GIF its back-pressure and CSR its FINISH time. **Whether that busy time depends on pixel results** (Z or alpha tests that skip writes) is the PS2's version of n64-python's X3 and psx-python's P2: **U19**, decision P7. - **The texture page buffer** (8 KB; "TEXFLUSH" invalidates it) means a texture rewritten without TEXFLUSH may be read stale from the buffer (GSUM §3.4.2 "Texture Page Buffer", TEXFLUSH register). Games that forget TEXFLUSH show the stale texture on hardware. The specification keeps the buffer and its invalidation, because it changes pixels. - **Self-reference**: a texture that is the frame buffer being drawn (channel shuffle, ps2tek "GS Special Effects"; feedback effects) reads what is in local memory at the moment of the read, through the page buffers. This is the GS's internal RAW hazard, the single hardest thing for any parallel or GPU back end (execution-architecture.md). ## Unknowns U15 bilinear weight precision; U16 LOD computation; U17 STQ divide precision; U18 edge rules at sub-pixel extremes and for very large primitives; U19 data-dependent busy time; U20 the page-buffer timing (how many cycles a page break costs); U21 interlaced field handling in SMODE2/FFMD with the PCRTC's two circuits; U22 what CSR.FIELD and the V-sync interrupt timings are, per mode, in BUSCLK.