Skip to content

Latest commit

 

History

History
359 lines (309 loc) · 20.9 KB

gpu-raster-benchmarks.md

File metadata and controls

359 lines (309 loc) · 20.9 KB

GPU raster benchmarks

Technical documentation

The frame-rate targets these workloads are measured against, and the reference hardware for each tier, are in Performance targets.

Paths under artifacts/ refer to ignored local outputs, not files shipped in this repository. See publication notes.

What is measured

layer-bench submits 15 legacy, 11 painter-focused and 3 sculpt (Liquify Pinch, Expand and Crystals) 4096×4096 workloads through CanvasEngine. Every scenario has at least 32 visible paint layers and every frame contains eight simulated coalesced pen samples.

Names, feature labels, groups, underpaint and strokes are defined together in SCENARIOS in layer-bench.

The current diagnostic factory uses GTK's native integer-backed SDR renderer with Float32 working tiles. Select --space srgb|p3|adobe-rgb|prophoto, --depth 8|16 and the document's Blending with --blending linear|perceptual; defaults are sRGB8 in linear light. Generated reports identify the mode. Reports from before this replacement used the older sRGB8 working renderer and cannot qualify the current native editing path.

It reports two time boundaries:

  • submit: event queueing, shared brush dynamics/contact generation, wgpu command encoding, uploads, and queue submission. Call-return time includes any internal capacity/dependency wait; it is not necessarily nonblocking. Thread CPU time, where recorded, distinguishes computation from waiting;
  • completed: the same work plus a benchmark-only wait for that exact GPU submission, including changed-tile capture copies and any backing-capacity delay needed to consume the measured input. Compression finishes asynchronously.

Deferred input is drained before completion is recorded. CPU frame creation is reported separately from capacity/GPU waits. The capture allocated/reserved peak adds pending staging reservations, reusable spares and active CPU scratch; it is separate from the older canvas-residency counter and excludes source/history and driver allocations. A returned buffer can remain charged in its pending capture reservation until that job finishes, so the capture counter is conservative.

The report names the GPU adapter, backend and device type. PNG output uses the renderer's explicit sRGB readback buffer directly. The Windows GPU workload diagnostic records the current D3D12 run and its separation from desktop presentation.

Normal scenario reports also write a sibling *.frames.csv containing every measured frame: scenario, color-space code (0 sRGB, 1 P3, 2 Adobe RGB, 3 ProPhoto), integer depth, one-based repetition/stroke/frame indices, pen-up flag, CPU and completed-work microseconds, and capture reserved bytes. Serialization runs after all measurements, using the samples already collected by the timing loop. Use these records to compare matching strokes and inspect tail distributions; the Markdown summary alone can hide which workload produced an outlier.

Quantiles select the nearest sample, rounding half indices up. Move and pen-up samples are summarized separately.

Initialization, shader/pipeline creation, target allocation, brush selection, layer creation, and PNG export stay outside the measurement. Each repetition creates a fresh canvas, runs the complete scenario and undoes its strokes to prime all required pipelines and GPU clocks, then contributes every measured frame to the aggregate distribution. The release painter record uses three repetitions per brush. Warming only the first stroke can leave the native page-copy pipeline cold until later strokes evict and revisit paint pages. Native hosts prepare that pipeline before accepting input; its compilation belongs outside the measured painting window here too.

Workloads

raster_workloads --calibrate --output-dir PATH measures RGBA32Float copies, source-over blending, area reduction at 4×/8×/16× footprints and horizontal neighborhood kernels. Gaussian horizontal and vertical kernels use paired taps and the production Float32 sampler at sigma 3, 8 and 21. They retain the same weights and footprint as the filter; preparation is outside the timed loop. The runner retains thirty samples after four warmups at five sizes, from one pixel to 4248 × 2832. calibration.csv separates command encoding and submission, queue completion, and optional GPU pass timestamps. The same run measures the production linear and area resamplers at three output sizes, including the 1062 × 708 display level used by the low-tier Fit view, from inputs twice as wide and high. Resampler sample counts are bilinear operations; their byte column counts distinct input and output texels. Timestamp mapping and CSV output happen after the timed completion boundary.

The byte column is minimum distinct input/output traffic; cache reuse means texture sample count is not DRAM traffic. The blur kernel uses equal weights to calibrate raw sampling costs. gaussian_h and gaussian_v include weighting and Float32 interpolation; their sample counts represent the equivalent integer taps. They exclude the filter graph, color conversion and native capture. Use matching-size results to estimate a journey's fixed and per-pixel costs, then check held-out workloads. These serialized kernel measurements exclude source preparation, UI scheduling and presentation; they are not frame rates. Record thermal state and repeat when clock changes affect the fitted range.

Display resampling uses the production sampling and mapped-source WGSL with the device's Float32 filtering capability. Projective sampling runs as a fragment pass; affine area sampling runs as compute. The windowless calibration test validates both sampling variants, entrypoint stages and the reflected uniform size before the hardware run.

cargo build --locked --release -p layer-render-wgpu --example raster_workloads
target/release/examples/raster_workloads --calibrate --output-dir artifacts/calibration

The raster_workloads example separately exercises tiled native photos. Build with cargo build -p layer-render-wgpu --example raster_workloads --release and run the resulting executable with 24mp, 45mp, 60mp, or multiple. --space and --depth use the modes above; this example defaults to ProPhoto U16.

Add --photo --output-dir PATH for masked Exposure, White Balance, Levels, Hue/Saturation and Color Balance, slider previews, cyclic pan/zoom, simultaneous native save and profiled ProPhoto U16 PNG export, full-resolution histograms, Gaussian blur and exact native paint/mask undo restoration. multiple retains all three adjusted documents and edits the 60 MP document while save/export run. Use explicit 61mp --photo-capture for 9504 × 6336; --photo-bands separately records awaited export-band wall time, including GPU execution and readback, without PNG encoding or concurrent saving. The synthetic source includes low-order U16 variation; it is a reproducible resource workload, not a photographic accuracy corpus.

Frame and worker CSVs share one monotonic clock. Use their overlap fields to select frames actually concurrent with save/export, and separate source misses from warm frames. Whole-operation durations include worker setup, file sync and GPU renderer destruction; separate setup and cleanup intervals identify those costs. These are offscreen CPU/GPU completion measurements, not native presentation latency. Optional allocator observations occur outside frame timings and at capture allocation boundaries. Capture workers reuse the active canvas device with private pixels and nonblocking completion waits. Its allocator report covers all live owners: take the maximum reported peak for that device, then add peaks for other canvas devices. Do not add the same device's reservation twice. This is a conservative overlap estimate; record process RSS high-water and driver memory separately. Three histogram repetitions are individual observations, not a well-sampled p99 distribution.

--photo-capture omits the variable-length editing interval, slider/navigation loops and blur. It supplies identical snapshots to capture comparison arms; decoded PNG sample checksums and histogram bin/endpoint checksums must agree. Archive reopen compares retained source/profile, editable effects, and exact native paint and mask digests. Serialize hardware runs and retain exact executables, source hashes, environment and raw output for each arm.

--photo-navigation isolates unchanged-image pan/zoom/rotation on the adjusted 24/45/60 MP photographs. Each size runs two 96-frame revolutions at fit, 50%, 100% and 200% zoom, then two revolutions with continuously varying zoom. The 1600×1000 managed Float16 presentation target matches the reference viewport size. CSV rows include camera scale/angle, frame CPU time, total CPU time through presentation submission, completed queue time, recomposited pixels, source misses and display storage. It waits for the presenter's submission too; waiting only for the engine would omit presentation work. This remains an offscreen workload, so native GTK frame delivery must be measured separately. Every frame preserves artwork revision, and the run verifies unchanged native paint/mask roots. The first navigation frame and cache misses stay in the results. multiple uses the existing --photo worker fixture instead.

Shared workload setup drains pending renderer work and requires a presentable frame before timing begins. Raster readiness alone does not establish that the scene has been published. Every navigation sample requires a presentable frame and preserves both authored document and renderer composition revisions; an empty presentation submission cannot count as fast navigation. This setup does not warm the navigation trajectory or discard its first-frame cost.

The native counterpart is the ignored GTK test workspace::tests::native_navigation::native_large_photo_navigation. Build the release test executable first, then run it alone with gtk-raster.sh and LAYER_NAVIGATION_PHOTO=24mp, 45mp, 60mp or 61mp (9504×6336). It maximizes the editor on the private 1600×1000@120 display and records the actual canvas viewport. It generates 960 camera requests on an absolute 120 Hz schedule through the shared gesture API and GTK change/wake path, without waiting for each render. This measures software camera-request-to-presentation, not physical input delivery. The native source has five pointwise adjustments and 32 paint layers; unlike the offscreen fixture it has no painted stroke or adjustment mask. LAYER_NAVIGATION_LAYERS replaces them with the blended or pass_through layers of native_frame_pacing below.

workspace::tests::native_frame_pacing with LAYER_PACING_WORKSPACE=photo24 opens a 24 MP photo and runs the brush, Pan, Hand, Transform and Crop scenarios; LAYER_PACING_BRUSH selects one. LAYER_PACING_PHOTO_LAYERS=photo keeps only the photo, layered puts it between painted strokes and a second photo, and blended also makes the strokes Screen and adds a Color copy of them and a Soft Light copy of the second photo above the photo, so strokes on the photo recompose through three non-Normal layers. pass_through puts those three layers and a Hue/Saturation adjustment in a Pass Through group, so the adjustment and the modes act on the photos below the group. The photo blends in linear light; LAYER_PHOTO_BLENDING=perceptual makes it a Perceptual document, here and in native_large_photo_navigation.

For the high-DPI large-photo case, set LAYER_TEST_MONITOR=3840x2160@120 and LAYER_TEST_SCALE=2. The harness applies and verifies the private Mutter monitor's scale; GDK_SCALE alone is insufficient on Wayland. Set LAYER_NAVIGATION_MAXIMIZE=0 for a 1200×900 logical window (2400×1800 physical at scale 2). LAYER_NAVIGATION_PHYSICAL=1 adds a Gaussian blur evaluated at native photo resolution before display reduction. LAYER_NAVIGATION_COMPLETE=1 additionally requires zero recomposited pixels and zero source-tile misses in camera frames, qualifying the complete display-pyramid path on devices with sufficient reported memory headroom. The fixture fails if any gesture is rejected or the GPU worker stops. Reports include actual monitor scale, viewport, per-frame composition counters and display bytes. The fifth camera_work column counts source misses within the timed canvas frame; the fourth retains cumulative misses, including separately scheduled thumbnail work. Presentation timing includes any interference from those background jobs.

tools/performance/photo-navigation-report.py REPORT.json counts distinct Wayland presentation timestamps inside the recorded motion interval, including cached canvas publications whose frame ID is zero. It reports full-contact rate, refresh-slot gaps and cadence separately from worker CPU/GPU and GTK frame-handler time. Cached publications have no camera attribution. instrumented_camera matches exact matrices and nonzero worker frame IDs to feedback, retaining unmatched requests by phase, discarded feedback, request-to-enqueue, enqueue-to-present and first attributed response. These metrics cover instrumented frames, not every camera publication or the first actual navigation response. Repeated poses count once for input attribution while distinct publications remain in cadence. Do not infer input latency from cadence alone. Keep builds and other performance workloads out of the interval. Inspect distinct attributed requests alongside refresh cadence. Optional LAYER_NAVIGATION_SETTLE_MS separates a ready-window run from the default cold first interaction; retain both, including first response and lost requests. The first-response measurement includes initial coalesced requests; the ordinary request-latency distribution can only contain requests matched to presentation.

For scheduling investigations, LAYER_NAVIGATION_PHASE_NS selects the first request's offset from the current display-clock prediction. The clock continues to update from feedback; this is an initial offset, not a phase lock. Release test executables only accept LAYER_PACING_LEAD_NS to override the lead before predicted presentation. Production retains its three-quarter-refresh drawing deadline; unchanged-camera bursts use the separately qualified input/presentation phase policy. These controls compare scheduling without changing source pixels or rendering.

Scenario Workload
G‑Pen inking Two long pressure-varying analytic strokes
Pencil shading Twelve textured hatching strokes
Large eraser 360/620 px analytic erase over textured underpaint
Large paintbrush Three 520–880 px rotating textured strokes
Soft airbrush Low-flow analytic coverage
Anchored-grain chalk Mask tip plus canvas-locked grain
Flat marker Directional high-aspect coverage
Scatter spray Seven particles/contact with spatial and count jitter
Dual texture Two transformed tips plus anchored grain
Multiply glaze Destination-read blend mode over underpaint
Smudge pickup Pull, blur, and zero loaded paint over underpaint
Wet round Oklab Pickup, dilution, deposition, jitter, and perceptual mix
Liquify push/twirl Inverse-mapped deformation over underpaint
Layered composite 34 paint layers with opacity, ink, texture, and wash

The painter suite uses four large, pressure-varying strokes in one coherent coral/indigo/gold/teal palette over localized color swatches:

Scenario State path exercised
Textured Flat Filbert advanced dry build-up
Dry Scumble stroke-uniform coverage only, thresholded grain
Pastel Block advanced dry build-up with dense paper grain
Transparent Glaze stroke-uniform coverage
Opaque Gouache spatial reservoir
Watercolor Wash coverage + wetness + capillary transport + live edge
Wet Watercolor coverage + stronger wet transport + wetness live edge
Loaded Oil Mixer spatial reservoir
Palette Knife spatial reservoir
Natural Blender ordered smudge advection
Dither Blender three 512 px strokes redistributing the same layer's RGBA samples

This gives every new state primitive an independent path: coverage-only, spatial reservoir, same-layer watercolor advection, and smudge advection are timed directly. The watercolor cases also time the bounded conductance-gated transport pass. Watercolor's edge is part of ordinary composition; the older optional post-stroke edge remains in the pen-up distribution only for non-watercolor brushes that request it.

Run

On a multi-GPU benchmark host, LAYER_GPU_INDEX=N selects the enumerated adapter used by the offscreen harness. Production frontends instead pass their platform-selected adapter and device to the renderer.

cargo run --release -p layer-bench -- \
  --scenario painter --repeats 3 \
  --output-dir artifacts/painter-brushes \
  --report artifacts/benchmarks/painter-brushes-4k.md

cargo run --release -p layer-bench -- \
  --scenario legacy --repeats 3 \
  --output-dir /tmp/layer-legacy-regression \
  --report artifacts/benchmarks/gpu-4k-paint-state-regression.md

The first command writes eleven explicit-export PNGs and a labeled HTML gallery. The generated contact sheet provides a compact montage. Use --scenario sculpt for the Liquify Pinch, Expand and Crystals workloads, --scenario all for all 29 workloads, or a scenario name to isolate one brush.

--scenario dither_blender uses three pressure-varying strokes at nominal 512 px over opaque and translucent multicolor underpaint on the same layer. Its PNG checks the resulting paint; completion timing includes retained stroke-start pages and exposure state, as well as the color-selection kernel.

GTK native pen-up and following strokes

The ignored workspace::tests::native_penup::native_penup_and_following_strokes benchmark uses a validated 4096² ProPhoto U16 project with 32 paint layers and a 720 px palette knife. It warms and undoes one contact, then draws twelve 800 ms contacts by default (LAYER_PENUP_STROKES=4..100). Run a captured release test executable with tools/performance/gtk-raster.sh on its private 120 Hz compositor. Build separately from measurement and compare variants at one staged executable pathname. The fixture validates its project before opening, so autosave/recovery exercise a legal allocator and document.

The JSON records pen-up event timestamps, corresponding native-publication frame IDs, worker elapsed/thread CPU and GPU timestamps, actual child-surface presentation feedback, and the first observation of each host-backed revision. Host backing is observed at approximately 2 ms event-loop intervals; this is an upper-bound observation of completion, not a precise compression service time. A missing/discarded presentation must remain visible in the report, rather than being silently excluded from the pen-up denominator. Subsequent strokes begin as soon as the preceding stroke is admitted and can overlap its backing work. Queued-frame-to-present timing for movement excludes input-to-queue delay; pen-up event-to-present includes that delay. Keep these boundaries distinct.

Web and Android tablet photo navigation

Use an isolated release benchmark package, preserving normal application data. BrushBenchmarkInstrumentation -e mode pinch sends real two-finger OS touch input over the 9504×6336 Sony JPEG:

ANDROID_HOME="$HOME/Android/Sdk" apps/layer-android/gradlew -p apps/layer-android \
  :app:assembleBenchmark -PcapyAbi=arm64-v8a -PcapyOptimize \
  -PcapyApplicationId=art.capycanvas.pinchprobe
adb install -r apps/layer-android/app/build/outputs/apk/benchmark/app-benchmark.apk
adb push "$HOME/Downloads/sony_a7r_v_29.jpg" /data/local/tmp/capy-brush-photo.jpg
adb shell am instrument -w \
  -e brushBenchmark true -e mode pinch -e label pinch -e durationMs 30000 \
  art.capycanvas.pinchprobe/art.capycanvas.BrushBenchmarkInstrumentation

Reports stay in the package's external files/brush-benchmark. A test finishing successfully does not by itself pass the 120 Hz gate: inspect delivered-frame counts, callback cadence and each CPU field. Do not count expected-presentation timestamps as measured presentation feedback.

For Chrome, serve the 9504×6336 photo at /pkg/proof-photo61mp.jpg (or set LAYER_PHOTO_URL), forward its debug socket and open the dedicated test page at LAYER_WEB_URL:

adb forward tcp:9228 localabstract:chrome_devtools_remote
node apps/layer-web/device.test.mjs --proof-performance

The harness opens the photo, requests fullscreen, uses ordinary app frame scheduling and records three 361-request runs before and after Print proof preparation: CPU frame time, RAF cadence, camera, viewport and renderer storage, written to LAYER_TEST_ARTIFACTS. It never changes Chrome flags or launches/closes user tabs. This injects camera commands, not hardware touch; it is not an input-to-photon test. Run tablet native and Web workloads separately, with other test photos released. Account for browser refresh throttling independently of GPU rendering time.