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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,26 @@ follow semantic versioning as described in [CONTRIBUTING.md](CONTRIBUTING.md).

## [Unreleased]

## [0.5.1] - 2026-11-20

### Added

- Engine reports include live and peak GPU allocation bytes, with separate totals for frame slots, network buffers,
cadence scratch, and auxiliary resources.
- Browser timing reports expose the cost of first-phase setup, frame rendering, and the total on successful samples.

### Changed

- Anime cadence smoothing shares model weights and transient GPU buffers across its three plans, reducing memory use.
- Low-level Rust buffer allocation APIs now return a tracked `Buffer` that dereferences to `wgpu::Buffer`.

### Fixed

- Preserve the timing of abrupt flashes, including localized flashes during a pan and flashes immediately after a cut.
- Preserve thin repeated lines and newly visible frame edges on coherent pans at repair level 2 by aligning the
original frames. Local contrast matching keeps lines intact when the two source frames have different brightness.
- Bound concurrent GPU timestamp readbacks and resolve Metal timestamps after the GPU records them.
- Attach asynchronous cadence statistics to their original interval so a late result cannot affect playback after a seek.

## [0.5.0] - 2026-11-18

Expand Down
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ members = ["crates/flyhigh-options", "crates/flyhigh-engine", "crates/flyhigh-ca
default-members = ["crates/flyhigh-options", "crates/flyhigh-engine", "crates/flyhigh-capi", "crates/flyhigh-cli", "examples/player"]

[workspace.package]
version = "0.5.0"
version = "0.5.1"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/getflyhigh/flyhigh-engine"
Expand Down
55 changes: 44 additions & 11 deletions crates/flyhigh-engine/src/gen_tex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
use crate::gmhs::{CadenceScratch, PairStats, StatsRun};
use crate::gpu::memory::Charge;
use crate::net::build::PlanResources;
use crate::pan::PanRepair;
use crate::{gmhs, Blob, Gpu, NetOpts, SessionExt, Step, TimedRun};
use anyhow::{Context, Result};
use serde_json::Value;
use std::cell::RefCell;
use std::collections::VecDeque;
use std::rc::Rc;

Expand Down Expand Up @@ -109,6 +111,7 @@ pub struct GenTex {
order: [usize; 3],
stats: [PairStats; 3],
scratch: Option<CadenceScratch>,
pan: Option<RefCell<PanRepair>>,
slots: Vec<usize>, // last pushed input slots, newest last (<= 3)
n_pushed: u64,
pending: Option<PendingPairStats>,
Expand Down Expand Up @@ -302,6 +305,8 @@ impl GenTex {
warmed_tune = Some(choices);
}
}
let pan = (opts.repair == 2 && !opts.protection_mask)
.then(|| RefCell::new(PanRepair::new(gpu, opts.w, opts.h, &sess)));
let scratch = if cadence {
Some(CadenceScratch::new(gpu, &sess[0]).context("cadence: GMHS maps missing")?)
} else {
Expand All @@ -316,6 +321,7 @@ impl GenTex {
order: [0, 1, 2],
stats: [PairStats::default(); 3],
scratch,
pan,
slots: Vec::new(),
n_pushed: 0,
pending: None,
Expand Down Expand Up @@ -386,6 +392,29 @@ impl GenTex {
self.scratch.is_some()
}

fn pair_steps(&self, gpu: &Gpu, pair: usize, a: usize, b: usize) -> Vec<Step> {
let (a, b) = ((a, &self.ins[a].1), (b, &self.ins[b].1));
let mut steps = self.sess[pair].pair_steps_views(gpu, a, b);
if let Some(pan) = &self.pan {
pan.borrow_mut().search(gpu, pair, a, b, &mut steps);
}
steps
}

fn repair_pan(&self, gpu: &Gpu, steps: &mut Vec<Step>, pair: usize, slots: (usize, usize), out: usize, t: f32) {
if let Some(pan) = &self.pan {
let (a, b) = slots;
steps.push(pan.borrow_mut().render(
gpu,
pair,
(a, &self.ins[a].1),
(b, &self.ins[b].1),
(out, &self.outs[out].1),
t,
));
}
}

/// The host wrote the newest source frame into input slot `slot`: run its pair. Video + cadence: the pair's
/// statistics readback is started; call `take_stats()` (native) or await it (browser) before generating.
pub fn push_slot(&mut self, gpu: &Gpu, slot: usize) -> Result<PushInfo> {
Expand All @@ -412,14 +441,14 @@ impl GenTex {
};
match self.opts.mode {
TexMode::Realtime => {
let steps = self.sess[0].pair_steps_views(gpu, (prev, &self.ins[prev].1), (slot, &self.ins[slot].1));
let steps = self.pair_steps(gpu, 0, prev, slot);
let run = run(gpu, &steps, timed);
Ok((PushInfo { ready: true, base_slot: prev, real_replaced: false }, run))
}
TexMode::Video => {
self.order.rotate_left(1);
let sn = self.order[2];
let steps = self.sess[sn].pair_steps_views(gpu, (prev, &self.ins[prev].1), (slot, &self.ins[slot].1));
let steps = self.pair_steps(gpu, sn, prev, slot);
let run = run(gpu, &steps, timed);
self.stats.rotate_left(1);
self.stats[2] = PairStats::default();
Expand Down Expand Up @@ -506,13 +535,14 @@ impl GenTex {
let s = &self.sess[0];
let (sa, sb) = (self.slots[self.slots.len() - 2], self.slots[self.slots.len() - 1]);
let (a, b, o) = ((sa, &self.ins[sa].1), (sb, &self.ins[sb].1), (out, &self.outs[out].1));
let steps = if s.is_fast() && self.opts.linear_t {
let mut steps = if s.is_fast() && self.opts.linear_t {
vec![s.render_tex_step(gpu, a, b, o, Some(0.5))]
} else if s.is_fast() {
s.mid_steps_fast(gpu, a, b, o)
} else {
s.mid_steps(gpu, out, o.1)
};
self.repair_pan(gpu, &mut steps, 0, (sa, sb), out, 0.5);
Some(gpu.gpu_time_ms_n(&steps, 5))
}
/// GPU time (ms) of the pair stage for the current pair (realtime mode), measured by running it again.
Expand All @@ -522,7 +552,7 @@ impl GenTex {
return None;
}
let (sa, sb) = (self.slots[self.slots.len() - 2], self.slots[self.slots.len() - 1]);
let steps = self.sess[0].pair_steps_views(gpu, (sa, &self.ins[sa].1), (sb, &self.ins[sb].1));
let steps = self.pair_steps(gpu, 0, sa, sb);
Some(gpu.gpu_time_ms_n(&steps, 3))
}
/// Synthesise phase `t` of the current interval into output slot `out`. Returns false when nothing was written
Expand All @@ -547,8 +577,8 @@ impl GenTex {
}
anyhow::ensure!(self.slots.len() >= 2, "realtime mode: push two frames first");
let s = &self.sess[0];
let run = if s.is_fast() {
let (sa, sb) = (self.slots[self.slots.len() - 2], self.slots[self.slots.len() - 1]);
let (sa, sb) = (self.slots[self.slots.len() - 2], self.slots[self.slots.len() - 1]);
let (setup, mut steps) = if s.is_fast() {
let (a, b) = ((sa, &self.ins[sa].1), (sb, &self.ins[sb].1));
if self.opts.linear_t {
// the network's t-dependent stage once per pair; each phase is then only a render
Expand All @@ -559,16 +589,17 @@ impl GenTex {
self.half_done = true;
setup
};
gpu.submit_optional_timing(&setup, &[s.render_tex_step(gpu, a, b, (out, view), Some(t))], timed)
(setup, vec![s.render_tex_step(gpu, a, b, (out, view), Some(t))])
} else {
s.set_t(gpu, t);
run(gpu, &s.mid_steps_fast(gpu, a, b, (out, view)), timed)
(Vec::new(), s.mid_steps_fast(gpu, a, b, (out, view)))
}
} else {
s.set_t(gpu, t);
run(gpu, &s.mid_steps(gpu, out, view), timed)
(Vec::new(), s.mid_steps(gpu, out, view))
};
Ok((true, run))
self.repair_pan(gpu, &mut steps, 0, (sa, sb), out, t);
Ok((true, gpu.submit_optional_timing(&setup, &steps, timed)))
}
TexMode::Video => {
anyhow::ensure!(self.slots.len() >= 3, "video mode: push three frames first");
Expand All @@ -592,7 +623,9 @@ impl GenTex {
}
let s = &self.sess[sc_];
s.set_t(gpu, t);
Ok((true, run(gpu, &s.mid_steps(gpu, out, view), timed)))
let mut steps = s.mid_steps(gpu, out, view);
self.repair_pan(gpu, &mut steps, sc_, (self.slots[0], self.slots[1]), out, t);
Ok((true, run(gpu, &steps, timed)))
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions crates/flyhigh-engine/src/gpu/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ const KERNELS: &[&str] = &[
"near_k",
"near_t",
"near_apply",
"pan_search",
"pan_select",
"pan_apply",
];

/// The kernel's name as the cache holds it, or None for a name that is not a kernel.
Expand Down Expand Up @@ -181,6 +184,9 @@ pub(crate) fn kernel_source(name: &str) -> Option<(String, &'static str)> {
"tex_in" => plain(include_str!("../../../../shaders/tex_in.wgsl"), "main"),
"tex_out" => plain(include_str!("../../../../shaders/tex_out.wgsl"), "main"),
"classify" => plain(include_str!("../../../../shaders/classify.wgsl"), "main"),
"pan_search" => plain(include_str!("../../../../shaders/pan_search.wgsl"), "main"),
"pan_select" => plain(include_str!("../../../../shaders/pan_select.wgsl"), "main"),
"pan_apply" => plain(include_str!("../../../../shaders/pan_apply.wgsl"), "main"),
"implicit2" => plain(include_str!("../../../../shaders/conv_implicit2.wgsl"), "main"),
"epilogue" => plain(include_str!("../../../../shaders/conv_epilogue.wgsl"), "main"),
"fused" => plain(include_str!("../../../../shaders/conv_fused.wgsl"), "main"),
Expand Down
1 change: 1 addition & 0 deletions crates/flyhigh-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ pub mod api;
pub mod gen_tex;
pub mod gmhs;
pub mod pacer;
mod pan;
pub mod stream;
pub mod warp;
6 changes: 6 additions & 0 deletions crates/flyhigh-engine/src/net/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,12 @@ pub(crate) fn build_network_with(
env.insert(names(op, "out")[0].clone(), o);
}
if let Some(age) = &static_age {
if net.repair == 2 {
env.insert(
"static:age".into(),
Tensor { buf: age.clone(), c: 1, h: hp, w: wp, c0: 0, scale: static_frames as f32 },
);
}
// the whole padded plane: the padding replicates the frame's edge, so the neighbourhood test stays valid there
let r = &env["render"];
assert!(r.c0 == 0 && (r.h, r.w) == (hp, wp), "keep_static: render is not a full-resolution plain tensor");
Expand Down
Loading
Loading