Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export interface BitmapFiniteScene {
readonly fontFixture: BenchmarkFontFixture;
}

export interface BitmapTextConformanceCapture {
/** Exact finite-scene readback and CPU atlas reference, independent of its conformance consumer. */
export interface BitmapFiniteSceneCapture {
readonly width: number;
readonly height: number;
readonly candidate: Uint8Array;
Expand Down Expand Up @@ -177,7 +178,7 @@ export async function createBitmapFiniteScene({
}
}

export async function captureBitmapFiniteScene(resources: BitmapFiniteScene): Promise<BitmapTextConformanceCapture> {
export async function captureBitmapFiniteScene(resources: BitmapFiniteScene): Promise<BitmapFiniteSceneCapture> {
const width = Math.round(BITMAP_FINITE_WIDTH * resources.dpr);
const height = Math.round(BITMAP_FINITE_HEIGHT * resources.dpr);
const rendered = await renderBitmapFiniteFrame(resources, width, height);
Expand Down
17 changes: 17 additions & 0 deletions apps/benchmarks/src/benchmark/target-boundary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,17 @@ describe('benchmark target boundaries', () => {
const execution = await readFile(new URL('./execution.ts', import.meta.url), 'utf8');
const conformance = await readFile(new URL('./targets/conformance/index.ts', import.meta.url), 'utf8');
const product = await readFile(new URL('./targets/product/index.ts', import.meta.url), 'utf8');
const bitmapCapture = await readFile(
new URL('./targets/conformance/raster/bitmap-capture.ts', import.meta.url),
'utf8',
);
const mtsdfAdapter = await readFile(new URL('./targets/conformance/raster/mtsdf.ts', import.meta.url), 'utf8');
const slugAdapter = await readFile(new URL('./targets/conformance/raster/slug.ts', import.meta.url), 'utf8');
const runtimeFallback = await readFile(
new URL('./targets/conformance/raster/runtime-fallback.ts', import.meta.url),
'utf8',
);
const finiteCaptureSurface = await readFile(new URL('../surfaces/conformance/capture.ts', import.meta.url), 'utf8');
const slugCaptureProbes = await Promise.all(
['slug-adaptive32-quality', 'slug-external-render-parity', 'slug-fixed32-quality', 'slug-role-scenes'].map(
(name) => readFile(new URL(`../../vitexec/${name}.probe.ts`, import.meta.url), 'utf8'),
Expand All @@ -66,8 +75,10 @@ describe('benchmark target boundaries', () => {
expect(execution).toContain('await loadRegisteredTarget(request.targetId)');
expect(conformance).toContain("import('./advanced-shaping')");
expect(conformance).toContain("import('./raster/runtime-fallback')");
expect(conformance).toContain("import('./raster/bitmap-capture')");
expect(conformance).not.toContain('renderer/advanced-shaping-conformance');
expect(conformance).not.toContain('renderer/runtime-fallback-conformance');
expect(conformance).not.toContain('renderer/bitmap-text');
expect(product).toContain("import('./external-raster-proof')");
expect(product).toContain("import('./react-text')");
expect(product).toContain("import('./mtsdf-text')");
Expand All @@ -82,6 +93,12 @@ describe('benchmark target boundaries', () => {
expect(mtsdfAdapter).not.toContain('renderer/mtsdf-text');
expect(slugAdapter).toContain("import { createSlugConformanceSession } from './slug-capture'");
expect(slugAdapter).not.toContain('renderer/slug-text');
expect(bitmapCapture).toContain('createBitmapFiniteScene');
expect(bitmapCapture).not.toContain('renderer/bitmap-text');
expect(runtimeFallback).toContain("from './bitmap-capture'");
expect(runtimeFallback).not.toContain('renderer/bitmap-text');
expect(finiteCaptureSurface).toContain("import('../../benchmark/targets/conformance/raster/bitmap-capture')");
expect(finiteCaptureSurface).not.toContain('renderer/bitmap-text');
expect(
slugCaptureProbes.every((probe) => probe.includes('/benchmark/targets/conformance/raster/slug-capture.ts')),
).toBe(true);
Expand Down
2 changes: 1 addition & 1 deletion apps/benchmarks/src/benchmark/targets/conformance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function sourceOutlineFidelityTarget(technique: Technique, backend: Backend): Be
load: async () => undefined,
run: async (input, _sampleIndex, controls, context) => {
const fontFixture = input.fontFixture ?? configuredInput.fontFixture ?? 'inter';
const capture = await import('../../../renderer/bitmap-text').then(({ captureBitmapSourceOutlineFidelity }) =>
const capture = await import('./raster/bitmap-capture').then(({ captureBitmapSourceOutlineFidelity }) =>
captureBitmapSourceOutlineFidelity({
backend,
dpr: controls.dpr,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { conformanceText, type BenchmarkFontFixture, type SelectableFontFixture } from '../../../font-fixtures';
import {
captureBitmapFiniteScene,
BITMAP_FINITE_HEIGHT,
BITMAP_FINITE_WIDTH,
createBitmapFiniteScene,
disposeBitmapFiniteScene,
renderBitmapFiniteFrame,
type BitmapFiniteSceneCapture,
} from '../../../low-level/raster/bitmap-finite-scene';
import {
captureSourceOutlineFidelity,
type SourceOutlineFidelityCapture,
} from '../../../low-level/raster/source-outline-reference';
import type { FontDelivery } from '../../../url-state';
import type { PersistentRenderSceneRenderer } from '../../../../renderer/persistent-render-host';
import type { RendererBackend } from '../../../../renderer/webgpu-renderer';

/** Bitmap finite conformance output, produced with a leased persistent renderer when supplied. */
export type BitmapTextConformanceCapture = BitmapFiniteSceneCapture;

export async function captureBitmapTextConformance(options: {
readonly backend: RendererBackend;
readonly delivery?: FontDelivery;
readonly dpr: number;
readonly fontFixture?: BenchmarkFontFixture;
readonly renderer?: PersistentRenderSceneRenderer;
readonly signal?: AbortSignal;
}): Promise<BitmapTextConformanceCapture> {
options.signal?.throwIfAborted();
const resources = await createBitmapFiniteScene(options);
try {
options.signal?.throwIfAborted();
const capture = await captureBitmapFiniteScene(resources);
options.signal?.throwIfAborted();
return capture;
} finally {
await disposeBitmapFiniteScene(resources);
}
}

export async function captureBitmapSourceOutlineFidelity(options: {
readonly backend: RendererBackend;
readonly dpr: number;
readonly fontFixture: SelectableFontFixture;
readonly renderer?: PersistentRenderSceneRenderer;
readonly signal?: AbortSignal;
}): Promise<SourceOutlineFidelityCapture> {
options.signal?.throwIfAborted();
const resources = await createBitmapFiniteScene({ ...options, delivery: 'baked' });
try {
const width = Math.round(BITMAP_FINITE_WIDTH * options.dpr);
const height = Math.round(BITMAP_FINITE_HEIGHT * options.dpr);
const rendered = await renderBitmapFiniteFrame(resources, width, height);
options.signal?.throwIfAborted();
return await captureSourceOutlineFidelity({
candidate: rendered.bytes,
width,
height,
dpr: options.dpr,
fontFixture: options.fontFixture,
fontSize: resources.line.cssFontSize,
direction: 'ltr',
layout: resources.line.layout,
originX: resources.line.object.position.x,
originY: resources.line.object.position.y,
text: conformanceText(),
renderSubmitMs: rendered.renderMs,
});
} finally {
await disposeBitmapFiniteScene(resources);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { BenchmarkFontFixture } from '../../../font-fixtures';
import type { RasterTechnique } from '../../../url-state';
import { captureBitmapTextConformance } from '../../../../renderer/bitmap-text';
import type { PersistentRenderSceneRenderer } from '../../../../renderer/persistent-render-host';
import type { RendererBackend } from '../../../../renderer/webgpu-renderer';
import { captureBitmapTextConformance } from './bitmap-capture';
import { captureMtsdfTextConformance } from './mtsdf-capture';

export interface RuntimeFallbackCapture {
Expand Down
69 changes: 1 addition & 68 deletions apps/benchmarks/src/renderer/bitmap-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,8 @@ import {
} from '@pmndrs/text/raster/bitmap';
import * as THREE from 'three/webgpu';

import { conformanceText, type BenchmarkFontFixture, type SelectableFontFixture } from '../benchmark/font-fixtures';
import type { BenchmarkFontFixture } from '../benchmark/font-fixtures';
import type { FontDelivery } from '../benchmark/url-state';
import {
captureBitmapFiniteScene,
BITMAP_FINITE_HEIGHT,
BITMAP_FINITE_WIDTH,
createBitmapFiniteScene,
disposeBitmapFiniteScene,
renderBitmapFiniteFrame,
type BitmapTextConformanceCapture,
} from '../benchmark/low-level/raster/bitmap-finite-scene';
import { createCanvasSurface } from './canvas-surface';
import { finiteCanvasDelta } from './canvas-view';
import { createGpuFrameTimer, type GpuFrameTimer } from './gpu-frame-timer';
Expand All @@ -37,10 +28,6 @@ import {
type RetainedFontFixtureController,
} from './retained-font-fixture';
import { benchmarkContentWidth, liveTextPosition, type LiveTextAnchor } from '../workloads/shared/text-style';
import {
captureSourceOutlineFidelity,
type SourceOutlineFidelityCapture,
} from '../benchmark/low-level/raster/source-outline-reference';
import {
createConfiguredRenderer,
disposeConfiguredRenderer,
Expand All @@ -51,7 +38,6 @@ import {
type PersistentRenderFrameContext,
type PersistentRenderScene,
type PersistentRenderSceneContext,
type PersistentRenderSceneRenderer,
type PersistentRenderViewport,
} from './persistent-render-host';
import { createPersistentSceneActivation } from './persistent-scene-activation';
Expand Down Expand Up @@ -1237,59 +1223,6 @@ export async function createBitmapTextPreview(options: BitmapTextPreviewOptions)
}
}

export async function captureBitmapTextConformance(options: {
readonly backend: RendererBackend;
readonly delivery?: FontDelivery;
readonly dpr: number;
readonly fontFixture?: BenchmarkFontFixture;
readonly renderer?: PersistentRenderSceneRenderer;
readonly signal?: AbortSignal;
}): Promise<BitmapTextConformanceCapture> {
options.signal?.throwIfAborted();
const resources = await createBitmapFiniteScene(options);
try {
options.signal?.throwIfAborted();
const capture = await captureBitmapFiniteScene(resources);
options.signal?.throwIfAborted();
return capture;
} finally {
await disposeBitmapFiniteScene(resources);
}
}

export async function captureBitmapSourceOutlineFidelity(options: {
readonly backend: RendererBackend;
readonly dpr: number;
readonly fontFixture: SelectableFontFixture;
readonly renderer?: PersistentRenderSceneRenderer;
readonly signal?: AbortSignal;
}): Promise<SourceOutlineFidelityCapture> {
options.signal?.throwIfAborted();
const resources = await createBitmapFiniteScene({ ...options, delivery: 'baked' });
try {
const width = Math.round(BITMAP_FINITE_WIDTH * options.dpr);
const height = Math.round(BITMAP_FINITE_HEIGHT * options.dpr);
const rendered = await renderBitmapFiniteFrame(resources, width, height);
options.signal?.throwIfAborted();
return await captureSourceOutlineFidelity({
candidate: rendered.bytes,
width,
height,
dpr: options.dpr,
fontFixture: options.fontFixture,
fontSize: resources.line.cssFontSize,
direction: 'ltr',
layout: resources.line.layout,
originX: resources.line.object.position.x,
originY: resources.line.object.position.y,
text: conformanceText(),
renderSubmitMs: rendered.renderMs,
});
} finally {
await disposeBitmapFiniteScene(resources);
}
}

function positiveViewportSize(value: number, name: string): number {
if (!Number.isFinite(value) || value <= 0) throw new RangeError(`${name} must be positive`);
return value;
Expand Down
10 changes: 5 additions & 5 deletions apps/benchmarks/src/surfaces/conformance/capture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { MtsdfTextConformanceCapture } from '../../benchmark/targets/confor
import type { SlugTextConformanceCapture } from '../../benchmark/targets/conformance/raster/slug-capture';
import type { ConformanceWorkloadId } from '../../benchmark/workloads';
import type { GraphicsBackend, RasterTechnique } from '../../benchmark/url-state';
import type { BitmapTextConformanceCapture } from '../../benchmark/low-level/raster/bitmap-finite-scene';
import type { BitmapTextConformanceCapture } from '../../benchmark/targets/conformance/raster/bitmap-capture';
import type { PersistentRenderSceneRenderer } from '../../renderer/persistent-render-host';
import type { SourceOutlineFidelityCapture } from '../../benchmark/low-level/raster/source-outline-reference';
import type { RuntimeFallbackCapture } from '../../benchmark/targets/conformance/raster/runtime-fallback';
Expand All @@ -25,8 +25,8 @@ interface FiniteConformanceCaptureOptions {
readonly workload: ConformanceWorkloadId;
}

function loadBitmapTextRenderer() {
return import('../../renderer/bitmap-text');
function loadBitmapCapture() {
return import('../../benchmark/targets/conformance/raster/bitmap-capture');
}

function loadMtsdfCapture() {
Expand Down Expand Up @@ -73,7 +73,7 @@ export async function captureFiniteConformance({
value: await captureMtsdfSourceOutlineFidelity({ backend, dpr, fontFixture, renderer, signal }),
};
}
const { captureBitmapSourceOutlineFidelity } = await loadBitmapTextRenderer();
const { captureBitmapSourceOutlineFidelity } = await loadBitmapCapture();
return {
kind: 'source-outline',
value: await captureBitmapSourceOutlineFidelity({ backend, dpr, fontFixture, renderer, signal }),
Expand All @@ -93,7 +93,7 @@ export async function captureFiniteConformance({
value: await captureMtsdfTextConformance({ backend, dpr, fontFixture, renderer, signal }),
};
}
const { captureBitmapTextConformance } = await loadBitmapTextRenderer();
const { captureBitmapTextConformance } = await loadBitmapCapture();
return {
kind: 'bitmap',
value: await captureBitmapTextConformance({ backend, dpr, fontFixture, renderer, signal }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type PointerEvent as ReactPointerEvent,
} from 'react';

import type { BitmapTextConformanceCapture } from '../../benchmark/low-level/raster/bitmap-finite-scene';
import type { BitmapTextConformanceCapture } from '../../benchmark/targets/conformance/raster/bitmap-capture';
import type { MtsdfTextConformanceCapture } from '../../benchmark/targets/conformance/raster/mtsdf-capture';
import type { SlugTextConformanceCapture } from '../../benchmark/targets/conformance/raster/slug-capture';
import { usePersistentRenderHost } from '../../renderer/persistent-render-host-context';
Expand Down
1 change: 1 addition & 0 deletions docs/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 2026-08-03

- **Bitmap conformance target ownership** — Moved the remaining finite Bitmap and source-outline wrappers from the live renderer into `benchmark/targets/conformance/raster/bitmap-capture`, retaining the renderer-neutral finite scene and exact atlas reference under `benchmark/low-level/raster`. Conformance targets, runtime fallback, and the React finite surface now import only the target wrapper; boundary tests reject every old renderer capture path. The complete 314-test benchmark gate and production build passed, and all 19 isolated browser scenarios—including exact Bitmap product and source-outline captures—remained deterministic.
- **Target-owned raster conformance captures** — Moved finite MTSDF and Slug resource creation, standard/source-outline capture, CPU comparison, borrowed-renderer state restoration, and disposal from live renderer modules into `benchmark/targets/conformance/raster`. Both techniques now implement the same warm session contract directly; Slug's external-resource, large/extreme/complex/clipped, affine, and projection-zoom proofs moved with the shared finite resource graph. Conformance surfaces, runtime fallback, and URL-loaded probes import the target modules directly. The complete 314-test benchmark gate and production build passed, all 19 isolated browser scenarios remained deterministic, retained comparison capture/navigation recovery passed on WebGPU and forced WebGL2, and both complete Slug role and external-resource probes passed on both backends.
- **Finite product target ownership** — Moved the Bitmap, MTSDF, and Slug finite public-`Text` product lifecycles from renderer implementation files into lazy `benchmark/targets/product` modules. Extracted Bitmap line construction, the reusable finite Bitmap scene, exact CPU-reference capture, and renderer-neutral RGBA8 readback into explicit renderer/low-level modules; conformance surfaces consume the neutral capture contract without importing an executable product target. The complete 314-test benchmark gate and production build passed, all 19 isolated headless scenarios remained deterministic, the external raster and retained comparison probes recovered on WebGPU and forced WebGL2, all 42 sequential Presentation cells rendered with one renderer, both timed demos returned to Off-axis / 3D at 60.02 FPS, and React Doctor reported 100/100 with no issues.
- **Explicit low-level target hierarchy** — Moved the external raster and React reconciliation product proofs under `benchmark/targets/product`; moved the realtime MTSDF/Slug comparison, runtime fallback, and their target tests under `benchmark/targets/conformance/raster`; and placed shared CPU raster/source-outline oracles under `benchmark/low-level/raster`. Conformance surfaces retain literal lazy target imports, while a boundary regression rejects renderer imports of executable targets. The complete 311-test benchmark gate and production build passed, all 19 isolated headless scenarios remained deterministic, and the moved realtime comparison and external raster proof recovered on both WebGPU and forced WebGL2.
Expand Down
Loading
Loading