ADR-0075: three r187 — the renderer carries an unreleased upstream fix as a patch, and the release that ships it deletes it

1,401 words

Status: accepted · 25 Nov 2026. Amends ADR-0030: the renderer carries a patch where upstream has merged a fix and not released it. Amends ADR-0044's draw order: three's own painter sorts stand.

Context

The clouds take their renderer from three-clouds-webgpu, and every release of it since 0.1.0-alpha.7 declares three >=0.187.0 <0.188.0; alpha.9 carries the temporal-upscale fixes the plan's grain waits on. The game was on r185.1. The bump is four lines in two manifests and two tarballs. On r187 the GPU suite failed 70 of 672 tests, and every failure traced to one of eight things r187 does differently.

compileAsync is not reentrant. r187 keeps a compile's precompilation state in one renderer field, _precompilationState. Two compiles in flight overwrite each other's, and the second throws in _finishPreCompile (mrdoob/three.js#35315). warmCompile swallows a rejection by design, so what reached the page was quieter than the throw: the second compile's pipeline is registered in the backend's cache and never built, Pipelines.isReady answers false for it, and the object it was for draws nothing for the life of the page. The warm-up issues compiles concurrently on purpose (ADR-0030), so this is every boot. Upstream fixed it for r188 by rewriting compileAsync to build each render object synchronously again (#35359, merged as 7d4a7890), which also closes #35352 and #35327.

A compute kernel built with compute(count) refuses a size at dispatch. renderer.compute(kernel, size) throws for it, naming computeKernel(). The terrain tile producer, the star reduce and warmCompute dispatched a size that way, so on r187 the terrain stopped producing tiles.

A readback is tight. readRenderTargetPixelsAsync strips WebGPU's 256-byte row alignment before it returns. readGalaxyCube strode by the padded row and read a wrong face at every size but a multiple of 32 texels.

QuadMesh.render lends its material a vertex node. For the length of a draw the material's vertexNode is three's fullscreen triangle, indexed by vertexIndex with no vertex buffer. A compile of the quad sees the geometry's position attribute and builds a program no draw uses, so every quad pass built its real pipeline on its first frame.

The scissor's enable flag is the target's. Into a render target, three reads target.scissorTest where r185 read the renderer's. The cloud cube atlas and the clipmap bake a face or a level through a scissor set only on the renderer, so every face covered the whole atlas.

The draw list is not reversed. r185 reversed the sorted list for a reversed-depth camera, authored renderOrder included, and sceneOrder.ts negated the group order, the render order and the id beforehand to cancel it. r187 negates the projected depth key instead and leaves authored order alone, so the compensation inverted it: the cloud composite, ordered first among the over-cloud opaques, drew after a marked mesh and veiled it.

The ACES fit is Hill's. r187's RRTAndODTFit has v·(0.983729·v + 0.4329510) + 0.238081 below the line, the form in selfshadow's ltc_blit.fs. r185 multiplied 0.983729 into the middle term as well. The Natural curve cites the same source, carried r185's form, and is held to three's fit by tonemap.gpu.test.ts.

TempNode is deprecated, and warns once per construction. r187 moved its caching into Node, which caches any node used more than once.

@types/three 0.187 also requires QuadMesh's material, resolves ReturnType<typeof texture> to TextureNode<unknown>, and declares NodeLibrary.addToneMapping. Those are type changes and are made where they fail.

Decision

The renderer is three r187, the cloud port alpha.9 on fork release 8, and an upstream fix that three has merged and not released is carried as a patch until the release that ships it.

  • A patch is upstream's code, named, and temporary. patches/three@0.187.0.patch is #35359's diff, applied to the sources it was written against and to the bundles the game loads: build/three.webgpu.js, build/three.tsl.js and build/three.webgpu.nodes.js. Only two import-line hunks have no counterpart in a bundle. pnpm-workspace.yaml names each patched dependency beside the pull request it carries, and the upgrade to the release that contains it deletes the patch in the same change. A fix of our own is not a patch: it is a pull request upstream, and until it lands the code works round the defect where the defect is met.
  • A kernel's size is lent, not passed. render/dispatch.ts sets the node's own dispatchSize for one call and gives it back. The backend dispatches dispatchSize ahead of count, and the kernel's bounds guard reads count, so the guard the terrain and star kernels rely on stands.
  • A readback is read as tight. readGalaxyCube and the GPU harness's Pixels check the length against width × height × 4 and refuse anything else.
  • A quad compiles with the vertex node its draw lends. warmCompile reads the node by asking a quad to render into a recorder, lends it to the material for the compile, and gives it back when the compile settles.
  • runQuadPasses sets a scissored draw's target flag for the length of that draw, so no pass sets one for itself.
  • Three's painter sorts stand. sceneOrder.ts is gone, and createRenderer.test.ts holds that no sort is installed.
  • The Natural curve is Hill's fit, and the shoulder's solve is its inverse; a GPU test grades the solved luminance back through the fit.
  • Every node class extends Node.

Alternatives considered

  • Serialize our own compiles. One queue per renderer, each waiting compile replaying the target, MRT, tone mapping, visibility and material state its synchronous half reads. Declined: it is new code of ours whose whole job is to hide a defect upstream has already fixed, and the replay is a second account of the renderer's state that drifts from three's.
  • Stay on r185. Declined: the port's peer range starts at r187, and its fixes to the temporal upscale are what the clouds plan's phase B is for.
  • Wait for r188. Declined: it is not published, and the port pins <0.188.0, so r188 waits on a port release as well.
  • Patch src/ only. Declined: three/webgpu resolves to the bundle, and a patch the game does not load fixes the documentation of the defect.
  • Route narrow targets through warmByDrawing. Before the patch, an RG target's warm-up compiled a scalar output against whatever target was bound after a yield, the device refused it, and the first draw reused the refused pipeline. With #35359 every render object builds inside the compile's own state, and warmSensorPass builds what an R8 or RG8 slice's first draw uses.

Consequences

  • On the Mac mini's production build, cornerstone weather-g1-fair, the clouds cost what they cost on r185 within a millisecond at high and ultra at 1080p (19.93 and 54.60 ms against 19.82 and 54.89), and the native march is 2.4 ms cheaper. The build log's entry of 25 Nov 2026 has both sizes, every preset and the rows that measure §5.5's run-time defects rather than the clouds.
  • Every preset compiles on its own first frame. low, medium and lowEnd failed there on r185 and the adapter builds every context at high for that reason; on r187 they build and draw with no TSL error. Navigation to first light is 4.0 to 4.3 s below high, 14.9 s at high and 13.6 s at ultra, where r185 took 34 s at high and more than 90 at ultra.
  • The cloud port, both takram forks and @pmndrs/upscaler still extend TempNode, and each warns once per page.
  • pnpm presets:compare --all on the tree before the plates were taken again moved eight of thirteen past the 200 px floor, tau-ceti-dusk the most at 931 px (0.61%), every difference spread evenly over its frame. The split between r187 and the corrected fit was not measured. No difference image singles out the star's granulation, the r186 MaterialXNoise rewrite the frame named as the known risk.
  • The upgrade to r188 deletes patches/three@0.187.0.patch and reads its release notes for DenoiseNode and bumpScale, which the game sets neither of.
  • postprocessing is 6.39.6, the first release whose peer range admits r187; the port's README names 6.39.4 and its peer warning.
  • Every reach into a renderer private that r187 kept is where it was: _bindings, _pipelines, _currentRenderObjectFunction, _handleObjectFunction and _callDepth. A kernel's builder made outside a dispatch is made the way three makes one, over no object with the kernel as its compute. A builder over a renderer that has not run init() finds _bindings null, where three's guard skips only undefined, so the WebGL builder test sets it.