Skip to content

docs(blog): follow one RGB triangle through the PS3 and WebGL pipelines - #309

Merged
doodlewind merged 1 commit into
meshy-dev:mainfrom
doodlewind:blog/ps3-triangle-pipeline
Dec 4, 2026
Merged

doodlewind merged 1 commit into
meshy-dev:mainfrom
doodlewind:blog/ps3-triangle-pipeline

Conversation

@doodlewind

Copy link
Copy Markdown
Collaborator

Section 02 of the PS3 post (site/blog/ps3/) now draws the triangle it talks about: red, green and blue corners, shown at each stage as what it is there, with who carries it to the next stage in a browser and on a PS3.

The figures

  • Overview: the five stages as a flow (84 bytes → 3 vertices → 2 uniforms → 259,200 pixels → 1 frame on the TV), each with one line for WebGL and one for the RSX. What is the driver's job in a browser and ours on a PS3 is marked as in section 01.
  • Stage 1 · Upload: the 84 bytes (offsets, values, big-endian hex); a Float32Array going to the driver's memory, beside memcpy + eieio into GDDR3 at vb_off and the cache flush.
  • Stage 2 · Shaders: three points in clip space, with no pixels yet; one pool of unified cores beside the RSX's 8 vertex units (microcode through the FIFO) and 24 pixel pipelines (microcode in VRAM).
  • Stage 3 · Uniforms: the colours × uTint; uMVP as c[0..3], uTint as the 16 bytes at +0x10 inside the fragment program.
  • Stage 4 · Draw (interactive): the 1080p surface in 40-pixel squares, each lit in its centre pixel's colour. Pointing at a square (or tapping it, or using the arrow keys) follows that pixel: its weights, vColor, × uTint, then readPixels's RGBA bytes (rows counted from the bottom) beside the A8R8G8B8 word at fb + y × 7680 + x × 4. A toggle switches the viewport's scale.y between −540 and +540; +540 draws the triangle upside down.
  • Stage 5 · Present: the canvas, the compositor and the window, beside fb 0 / fb 1 and the flip.

Stage 4's code now also binds the colour attribute (GCM_VERTEX_ATTRIB_COLOR0, v[3], 12 bytes in, as PocketJS's rsx_driver.c does), which the vertex program reads.

The figures are static HTML and SVG, so they render without script. The RGB fill is three gradients blended with screen, one channel each, which gives exact interpolation; the pixel squares were computed with the same arithmetic the page's script uses. Only stage 4's readout and toggle use script.

Checked in Chrome at 1440 and 390 px wide; bun site/tools/build.ts builds.

🤖 Generated with Claude Code

Section 02 of the PS3 post now draws the triangle it talks about: red, green
and blue corners, at each stage as what it is there. An overview of the five
stages (84 bytes, three vertices, two uniforms, 259,200 pixels, a frame on the
TV), each with who carries it on in a browser and on a PS3, then a figure per
stage before its code:

1. the 84 bytes, little-endian in a browser and big-endian on the Cell, and
   where they go (the driver's memory, or GDDR3 at vb_off)
2. three points in clip space; one pool of unified cores against 8 vertex
   units and 24 pixel pipelines, and how each program reaches them
3. the colours times uTint; uMVP as four registers, uTint as 16 bytes inside
   the fragment program in VRAM
4. the 1080p surface in 40-pixel squares, lit in their centre pixels' colours.
   Point at one to follow it: weights, vColor, times uTint, then readPixels's
   RGBA bytes from the bottom row up beside the A8R8G8B8 word at
   fb + y * 7680 + x * 4. The viewport's Y scale toggles, so +540 shows the
   triangle upside down.
5. two colour buffers and the flip, beside the canvas and the compositor

The figures are static HTML and SVG; only stage 4's readout and toggle use
script. Stage 4's code also binds the colour attribute now (COLOR0, v[3],
12 bytes in), which the vertex program reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@doodlewind
doodlewind merged commit a8567d0 into meshy-dev:main Dec 4, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant