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
11 changes: 8 additions & 3 deletions crates/pf-nx-app/src/platform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,18 @@ pub trait Display {
}

/// Draws one frame and presents it at the next vblank: the newest due stream picture
/// (when [`Self::set_stream`] is on), then `ui` over it on a transparent layer. Blocks
/// until a swapchain image is free, so this paces the main loop.
/// (when [`Self::set_stream`] is on), then `ui` over it on a transparent layer while
/// [`Self::set_ui_layer`] has it on. Blocks until a swapchain image is free, so this paces
/// the main loop.
fn frame(&mut self, ui: &mut dyn FnMut(&skia_safe::Canvas)) -> Result<FrameReport>;

/// Whether the stream layer shows. Off, the UI draws over black.
/// Whether the stream layer shows. Off, the UI draws over black and the UI layer is on.
fn set_stream(&mut self, on: bool, fit: Fit);

/// Whether [`Self::frame`] draws and blends the UI layer. A stream turns it off while its
/// overlay is empty, which spares a full-screen clear, flush and blend each frame.
fn set_ui_layer(&mut self, _on: bool) {}

/// The last presented frame as tightly packed RGBA, for test-run bundles.
fn read_back(&mut self) -> Result<Option<Rgba>>;
}
Expand Down
3 changes: 3 additions & 0 deletions crates/pf-nx-app/src/runtime/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ fn stream(
)];
let dt = last_frame.elapsed().as_secs_f64();
last_frame = Instant::now();
// Stats off and the dial out of sight draw nothing: the layer is skipped, not blended.
app.display
.set_ui_layer(hud.tier != StatsVerbosity::Off || ring.damage() != 0);
let result = app.display.frame(&mut |canvas| {
if let Some(fonts) = &fonts {
hud.draw(canvas, fonts, scale);
Expand Down
4 changes: 4 additions & 0 deletions crates/pf-nx-platform/src/console/display_nvk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ impl Display for NvkDisplay {
self.presenter.set_stream(on, fit);
}

fn set_ui_layer(&mut self, on: bool) {
self.presenter.set_ui_layer(on);
}

fn read_back(&mut self) -> Result<Option<Rgba>> {
self.presenter.read_back()
}
Expand Down
13 changes: 12 additions & 1 deletion crates/pf-nx-platform/src/console/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const DATA_DIR: &str = "sdmc:/switch/punktfunk";
/// A file of this name in [`DATA_DIR`], read at start, turns the straight VIC route on, so one
/// build A/Bs both routes.
const STRAIGHT_MARKER: &str = "vic-direto";
/// A file of this name keeps pictures on the VIC route instead of in place, for the same A/B.
const VIC_MARKER: &str = "vic-copia";

/// The Mesa pin NVK was built from, for the log and the About screen.
const MESA_PIN: &str = match option_env!("PF_MESA_PIN") {
Expand Down Expand Up @@ -53,6 +55,11 @@ fn operation_mode() -> OperationMode {
}
}

/// On mains power: NVDEC may hold its top clock. Handheld keeps nvtegra's scaling.
fn docked() -> bool {
applet::operation_mode() == applet::OperationMode::Docked
}

/// The stream and swapchain size each mode calls for (plan D11).
fn mode_size(mode: OperationMode) -> (u32, u32) {
match mode {
Expand Down Expand Up @@ -96,10 +103,14 @@ pub fn platform(kind: DisplayKind) -> Result<Platform> {
let presenter = Presenter::new(dev.clone(), slot.clone()).context("bring up the display")?;
let gpu = format!("NVK {MESA_PIN} ({})", dev.name);
let ui = presenter.ui();
let marker = |name: &str| Path::new(DATA_DIR).join(name).exists();
(
Box::new(display_nvk::NvkDisplay::new(presenter, mode)),
Arc::new(
crate::video::NxVideo::gpu(dev, slot).straight(Path::new(DATA_DIR).join(STRAIGHT_MARKER).exists()),
crate::video::NxVideo::gpu(dev, slot)
.straight(marker(STRAIGHT_MARKER))
.in_place(!marker(VIC_MARKER))
.top_clock(docked),
),
gpu,
ui,
Expand Down
Loading
Loading