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
19 changes: 8 additions & 11 deletions crates/flyhigh-engine/src/gen_tex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,14 @@ impl GenTex {
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
if !self.half_done {
s.mid_maps_half(gpu);
let setup = if self.half_done {
Vec::new()
} else {
let setup = s.mid_map_steps_half(gpu);
self.half_done = true;
}
run(gpu, &[s.render_tex_step(gpu, a, b, (out, view), Some(t))], timed)
setup
};
gpu.submit_optional_timing(&setup, &[s.render_tex_step(gpu, a, b, (out, view), Some(t))], timed)
} else {
s.set_t(gpu, t);
run(gpu, &s.mid_steps_fast(gpu, a, b, (out, view)), timed)
Expand Down Expand Up @@ -516,11 +519,5 @@ impl GenTex {
/// Runs `steps`; with `timed` and timestamp queries they go out under a timestamp pair instead and the run is
/// returned to await for the GPU milliseconds.
fn run(gpu: &Gpu, steps: &[Step], timed: bool) -> Option<TimedRun> {
if timed {
if let Some(r) = gpu.begin_timed(steps) {
return Some(r);
}
}
gpu.replay(steps);
None
gpu.submit_optional_timing(&[], steps, timed)
}
1 change: 1 addition & 0 deletions crates/flyhigh-engine/src/gpu/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ impl Gpu {
bgra_storage: caps.bgra_storage,
timestamps: caps.timestamps,
ts_inside: caps.ts_inside,
timing: Default::default(),
shader_compiler,
arena: std::cell::RefCell::new(None),
arena_ids: std::cell::RefCell::new(HashMap::new()),
Expand Down
15 changes: 12 additions & 3 deletions crates/flyhigh-engine/src/gpu/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ impl Gpu {
// with `qs`: pass-level timestamps (the WebGPU-standard kind) at the beginning of the first compute pass
// (query 0) and the end of the last one (query 1) — the whole plan's GPU time without encoder-level queries
pub fn encode_plan_ts(&self, enc: &mut wgpu::CommandEncoder, plan: &[Step], qs: Option<&wgpu::QuerySet>) {
self.encode_plan_query_range(enc, plan, qs.map(|q| (q, 0)))
}

pub(crate) fn encode_plan_query_range(
&self,
enc: &mut wgpu::CommandEncoder,
plan: &[Step],
qs: Option<(&wgpu::QuerySet, u32)>,
) {
let last_c = plan.iter().rposition(|s| matches!(s, Step::Compute { .. }));
let split = self.pass_split.get();
let mut first = true;
Expand All @@ -24,10 +33,10 @@ impl Gpu {
let end = if split > 0 { j.min(i + split) } else { j }; // this pass = plan[i..end)
let is_last = last_c.is_some_and(|l| l < end);
let tw = match qs {
Some(q) if first || is_last => Some(wgpu::ComputePassTimestampWrites {
Some((q, start)) if first || is_last => Some(wgpu::ComputePassTimestampWrites {
query_set: q,
beginning_of_pass_write_index: if first { Some(0) } else { None },
end_of_pass_write_index: if is_last { Some(1) } else { None },
beginning_of_pass_write_index: first.then_some(start),
end_of_pass_write_index: is_last.then_some(start + 1),
}),
_ => None,
};
Expand Down
1 change: 1 addition & 0 deletions crates/flyhigh-engine/src/gpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct Gpu {
pub bgra_storage: bool, // BGRA8UNORM_STORAGE: canvases that prefer bgra8unorm can be written directly
pub timestamps: bool, // TIMESTAMP_QUERY: gpu_time_ms works (pass-level timestamps, WebGPU-standard)
pub ts_inside: bool, // + TIMESTAMP_QUERY_INSIDE_ENCODERS (native): per-step profile_plan
pub(crate) timing: std::cell::RefCell<timing::TimingState>,
pub shader_compiler: Option<dxc::ShaderCompiler>, // DX12: the HLSL compiler wgpu loaded (None on other backends)
// buffer arena (Some while a plan is being built): tensors whose last reader has been built release their
// buffer here and later tensors of the same plan reuse it — a static in-order plan makes this safe
Expand Down
Loading
Loading