Repository navigation
LR-EDIT-EFFECTS-GRAIN: film grain from crystal layers (process V4), resolution independent, no GPU cost #3630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
c813684
LR-EDIT-EFFECTS-GRAIN: film grain from crystal layers (process V3)
jeremyh 0c6cd98
LR-EDIT-EFFECTS-GRAIN: crystal grain a row at a time on the CPU
jeremyh fe6e064
LR-EDIT-EFFECTS-GRAIN: crystal grain keeps slider drags in budget on …
jeremyh 4ea6a81
LR-EDIT-EFFECTS-GRAIN: grain pattern and export timings re-measured o…
jeremyh 50e6422
LR-EDIT-EFFECTS-GRAIN: grain drag benchmark; Ryzen numbers for main a…
jeremyh e909f7f
LR-EDIT-EFFECTS-GRAIN: grain drag benchmark on the M2 Max for main, #…
jeremyh 1acedc8
LR-EDIT-EFFECTS-GRAIN: M2 Max export timings for main, #1060 and this…
jeremyh b908538
LR-EDIT-EFFECTS-GRAIN: review fixes (shared grain tables, own test ca…
jeremyh 2038ebc
LR-EDIT-EFFECTS-GRAIN: review fixes (one draw per missed tile, table …
jeremyh 7f637be
LR-EDIT-EFFECTS-GRAIN: review fix (renders that miss a tile together …
jeremyh 6b59774
LR-EDIT-EFFECTS-GRAIN: review fix (a drawer hands its tile to the ren…
jeremyh 21a235f
LR-EDIT-EFFECTS-GRAIN: review fixes (crystal tile waiter tests)
jeremyh 3b23f25
Merge main into crystal-grain; the crystal grain moves to process V4
jeremyh a850d05
LR-EDIT-EFFECTS-GRAIN: review fixes (crystal grain unit tests)
jeremyh ed10d44
Merge main into crystal-grain; the crystal grain moves to process V7
jeremyh 622c288
LR-EDIT-EFFECTS-GRAIN: review fix (a draft waits when nothing can sta…
jeremyh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| //! Grain slider drags on the GPU: the time per frame of the draft renders the loupe makes while | ||
| //! Amount or Size is dragged, on a ~2.5 MP preview (1936 × 1290, the procedural demo photo). | ||
| //! `cargo run --release -p lightcraft-gpu --example grain_drag_bench` (`FRAMES=n`, default 40). | ||
| //! | ||
| //! The same source, settings and request on every build, so it can be copied unchanged into | ||
| //! another branch to compare grain models (see `docs/grain.md` → Performance). Each drag first | ||
| //! renders four frames that aren't counted (stage cache, GPU pipelines), then moves the slider one | ||
| //! step a frame; prints the median, fastest and slowest frame. | ||
| #![allow(clippy::unwrap_used, clippy::expect_used)] | ||
|
|
||
| use std::sync::Arc; | ||
| use std::time::Instant; | ||
|
|
||
| use lightcraft_develop::DevelopSettings; | ||
| use lightcraft_pipeline::{Quality, RenderRequest, SourceInfo, StageCache}; | ||
|
|
||
| fn main() { | ||
| let frames: usize = std::env::var("FRAMES").ok().and_then(|v| v.parse().ok()).unwrap_or(40).max(1); | ||
| let (w, h) = (1936, 1290); | ||
| let src = Arc::new(lightcraft_scenes::demo_library()[3].render(w, h)); | ||
| let info = SourceInfo { raw: true, ..Default::default() }; | ||
| let draft = RenderRequest { quality: Quality::Draft, ..RenderRequest::fit(w, h) }; | ||
| let Some(adapter) = lightcraft_gpu::adapter_name() else { | ||
| eprintln!("no GPU adapter: nothing to measure"); | ||
| return; | ||
| }; | ||
| println!("gpu: {adapter}; {w}×{h} draft renders, {frames} frames per drag"); | ||
| let mut s = DevelopSettings::default(); | ||
| s.light.exposure = 0.3; | ||
| let mut drag = |label: &str, step: &dyn Fn(&mut DevelopSettings, usize)| { | ||
| let cache = StageCache::default(); | ||
| let mut ms = Vec::with_capacity(frames); | ||
| for i in 0..frames + 4 { | ||
| step(&mut s, i); | ||
| let t = Instant::now(); | ||
| assert!(lightcraft_gpu::render(&src, &info, &s, &draft, Some(&cache)).is_some(), "GPU render failed"); | ||
| if i >= 4 { | ||
| ms.push(t.elapsed().as_secs_f64() * 1e3); | ||
| } | ||
| } | ||
| ms.sort_by(f64::total_cmp); | ||
| println!("{label:<30} median {:5.1} ms min {:5.1} max {:5.1}", ms[ms.len() / 2], ms[0], ms[ms.len() - 1]); | ||
| }; | ||
| drag("exposure drag, no grain", &|s, i| { | ||
| s.grain.amount = 0.0; | ||
| s.light.exposure = 0.3 + i as f64 * 0.01; | ||
| }); | ||
| drag("Amount drag (20 → 100)", &|s, i| { | ||
| s.grain.size = 25.0; | ||
| s.grain.amount = 20.0 + (i * 2 % 80) as f64; | ||
| }); | ||
| drag("Size drag (amount 50, 0 → 100)", &|s, i| { | ||
| s.grain.amount = 50.0; | ||
| s.grain.size = (i * 2 % 100) as f64; | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.