Commit Graph
11 Commits
Author SHA1 Message Date
Jeremy HookeandClaude Opus 5.5 622c288621 LR-EDIT-EFFECTS-GRAIN: review fix (a draft waits when nothing can stand in)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 11:06:06 +11:00
Jeremy HookeandClaude Opus 5.5 ed10d4486c Merge main into crystal-grain; the crystal grain moves to process V7
v0.19.0 shipped V4 to V6 with value-noise grain, so those stay frozen and
the crystal grain becomes a process of its own. V7 is V6 plus the grain:
without grain it renders as V6 (`without_grain_v7_renders_as_v6`), and the
GPU equivalence cases now cover V6's value noise.

Merged with main's float output (`deep`, `hdr`): the value noise keeps its
clamped luminance; the crystal grain already clamps, and fades out at and
above SDR white. The finish kernel's failed-render check stays ahead of
the aux upload.

The test of unknown process numbers now takes one past the latest: 7 was
hard-coded, and is a known process now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:53:18 +11:00
Jeremy HookeandClaude Opus 5.5 a850d05fe4 LR-EDIT-EFFECTS-GRAIN: review fixes (crystal grain unit tests)
Direct tests for what was only covered through whole renders, or not at
all: slider clamping and NaN fallbacks, interp, normal_quantile, the
Poisson draws, the emulsion's mix of sizes per seed, the summed-area
table and box sums against brute force (seams, negative coordinates,
other periods) and the footprint limit.

A tile redrawn is now compared with the first one directly:
seed_picks_the_pattern compared a cached tile with itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:31:14 +11:00
Jeremy HookeandClaude Opus 5.5 3b23f25c1c Merge main into crystal-grain; the crystal grain moves to process V4
Main took V3 (sharpening) and V4 (calibrated Contrast and Blacks) while this was
open. Neither is in a release yet (v0.18.1's latest is V2), so the grain joins V4
rather than adding a process: V1 to V3 keep the value noise, V4 draws crystals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 21:16:35 +11:00
Jeremy HookeandClaude Opus 5.5 b908538a16 LR-EDIT-EFFECTS-GRAIN: review fixes (shared grain tables, own test cache, per-pixel preview check)
- Gpu::grain_tables returns the resident buffer it copied from as an Arc that the render keeps
  until it submits: replacing the tables on another thread no longer hands the buffer back to
  the pool while a recorded copy from it is unsubmitted (regression test).
- The drag test uses a tile cache of its own, so other V3 tests can't evict its stand-in.
- small_render_matches_the_downscaled_large_render compares the grain pixel by pixel (measured
  0.003 of 255 levels apart), not only its strength.
- GPU equivalence covers V1 and V2 grain again.
- docs/grain.md: the drag benchmark command sets FRAMES=100; the rotated-frame footprint is an
  axis-aligned square (documented, also in crystal.rs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 12:08:45 +11:00
Jeremy HookeandClaude Opus 5.5 1acedc81ee LR-EDIT-EFFECTS-GRAIN: M2 Max export timings for main, #1060 and this model from clean builds
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 11:31:19 +11:00
Jeremy HookeandClaude Opus 5.5 e909f7f78e LR-EDIT-EFFECTS-GRAIN: grain drag benchmark on the M2 Max for main, #1060 and this model
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 11:19:34 +11:00
Jeremy HookeandClaude Opus 5.5 50e6422a72 LR-EDIT-EFFECTS-GRAIN: grain drag benchmark; Ryzen numbers for main and #1060
`grain_drag_bench` (lightcraft-gpu example): GPU draft renders of a 2.5 MP
preview while Amount or Size is dragged, ms per frame. It doesn't depend on
the grain model, so it runs unchanged on other branches. docs/grain.md gets
its results on the Ryzen 5 7545U / Radeon 740M for main, #1060 and this
model, and the whole-render grain cost of main and #1060 there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 11:11:55 +11:00
Jeremy HookeandClaude Opus 5.5 4ea6a811b4 LR-EDIT-EFFECTS-GRAIN: grain pattern and export timings re-measured on the M2 Max
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 09:27:38 +11:00
Jeremy HookeandClaude Opus 5.5 fe6e064975 LR-EDIT-EFFECTS-GRAIN: crystal grain keeps slider drags in budget on slower machines
Measured on a Ryzen 5 7545U with a Radeon 740M (RADV), where grain cost what
the M2 Max hid:

- The tables stay on the GPU between renders (Gpu::grain_tables) and are
  copied into the finish kernel's aux buffer on the device, instead of being
  appended to aux and uploaded (12 MB) on every render. Amount drag, 2.5 MP
  preview: 16.9 -> 11-15 ms a frame (no grain: 8 ms).
- A draft render (a drag) doesn't wait for a tile it hasn't got: the last tile
  of the seed stands in while the new one is drawn in the background, on a
  pool of half the cores; the full render when the drag ends waits for the
  exact tile. Size drag: 62-66 -> 13-14 ms a frame. wasm drafts still wait.
- Stamps draw each row as a 64-bit mask, a fixed number of rows per layer,
  rows outside the band landing in scratch rows around it: no branch per row.
  Tiles 10-20 % faster at every setting, bit-identical.

Tests: GPU grain patterns in turn (same, new size, new roughness, new seed,
back) match the CPU; a drag takes the last tile while the next is drawn, then
the exact one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 08:59:46 +11:00
Jeremy HookeandClaude Opus 5.5 c81368470b LR-EDIT-EFFECTS-GRAIN: film grain from crystal layers (process V3)
Grain under the new process V3 is drawn from a simulated emulsion of crystal
layers, after Aurélien Pierre's crystallographic grain model (implemented from
the article's description). It fades out towards black and white as on a print,
is applied symmetrically in the display-encoded domain (no shadow darkening, no
grey specks in blown highlights), and matches Lightroom Classic's strength and
grain width at mid grey.

The emulsion is drawn once per Size / Roughness / seed on two periodic tiles in
frame coordinates and kept as summed-area tables, so each output pixel takes
the exact mean of the emulsion under its footprint: a preview is the export's
grain box-downscaled. CPU and GPU read the same tables (the GPU from the finish
kernel's aux buffer). V1 and V2 keep their value-noise grain exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 23:30:16 +11:00