fix(qbz-qt): hide native scopes on software renderer

cx
This commit is contained in:
vicrodh committed 2026-08-25 23:17:33 -06:00
1 parent ae175f3403
commit d0654f77bd
10 files changed
+125 -19

No files matched your search

@@ -5,6 +5,11 @@ import "../theme"
Item {
id: root
// ScopeTraceItem is a native scene-graph line strip. Software/Null can
// paint the guide rectangles below but not the trace; hide the complete
// instrument instead of leaving axes that look like a dead visualizer.
visible: QbzShell.gpuTier
QbzTheme { id: theme }
// 0 = goniometer, 1 = pitch-locked oscilloscope.
@@ -207,8 +207,11 @@ Item {
}
Repeater {
// FOCUS owner order: the two reading surfaces sit directly below
// Coverflow; the reactive visualizers follow them.
model: [
// Coverflow; the reactive visualizers follow them. The two native
// scopes are appended only on the GPU tier: Software can draw
// their QML axes but not the scene-graph trace.
model: {
var rows = [
{ "vm": 0, "m": 0, "sp": -1, "entry": "",
"label": QbzSession.tr("Album Reactive", QbzSession.trRev) },
{ "vm": 0, "m": 1, "sp": -1, "entry": "",
@@ -223,11 +226,15 @@ Item {
"label": QbzSession.tr("Spectrum", QbzSession.trRev) },
{ "vm": 0, "m": 6, "sp": -1, "entry": "",
"label": QbzSession.tr("Wave Bed", QbzSession.trRev) },
{ "vm": 0, "m": 7, "sp": -1, "entry": "",
"label": QbzSession.tr("Goniometer", QbzSession.trRev) },
{ "vm": 0, "m": 8, "sp": -1, "entry": "",
"label": QbzSession.tr("Oscilloscope", QbzSession.trRev) },
]
]
if (QbzShell.gpuTier) {
rows.push({ "vm": 0, "m": 7, "sp": -1, "entry": "",
"label": QbzSession.tr("Goniometer", QbzSession.trRev) })
rows.push({ "vm": 0, "m": 8, "sp": -1, "entry": "",
"label": QbzSession.tr("Oscilloscope", QbzSession.trRev) })
}
return rows
}
delegate: menuRow
}
Repeater {
@@ -307,6 +307,7 @@ Item {
Loader {
anchors.fill: parent
active: QbzShaderScene.scene === 0
&& QbzShell.gpuTier
&& QbzImmersive.viewMode === 0 && QbzImmersive.mode === 7
visible: active
sourceComponent: Item {
@@ -338,6 +339,7 @@ Item {
Loader {
anchors.fill: parent
active: QbzShaderScene.scene === 0
&& QbzShell.gpuTier
&& QbzImmersive.viewMode === 0 && QbzImmersive.mode === 8
visible: active
sourceComponent: Item {
@@ -41,7 +41,8 @@ Item {
property bool ambientOn: false
readonly property bool bandOn: QbzShell.largeVisualizerOn
readonly property int bandHeight: QbzShell.largeSpectrumMode >= 3
readonly property int bandHeight: QbzShell.gpuTier
&& QbzShell.largeSpectrumMode >= 3
? Math.round(root.width) : 42
readonly property int padTop: 9
readonly property int bandGap: 10
+13 -6
View File
@@ -101,6 +101,12 @@ Rectangle {
// Mirrors the dock's capture gate: false = the stream is frozen, so the
// interpolator must park too.
property bool capturing: false
// A stored scope choice survives a Software session, but the live band
// resolves it to Bars. The Rust renderer report publishes the same
// fallback; keeping it here makes the drawing arm safe during that
// report's event-loop turn too.
readonly property int effectiveMode: !QbzShell.gpuTier
&& QbzShell.largeSpectrumMode >= 3 ? 0 : QbzShell.largeSpectrumMode
visible: band.shown
radius: theme.radiusMd
@@ -133,7 +139,7 @@ Rectangle {
// FFT leaves {1, 15} empty; SpectrumPanel.slint parity).
Loader {
anchors.fill: parent
active: band.shown && QbzShell.largeSpectrumMode === 0
active: band.shown && band.effectiveMode === 0
sourceComponent: Item {
id: barsMode
readonly property var activeBins: [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
@@ -233,7 +239,7 @@ Rectangle {
// vertical centre (the L half is samples 0..255).
Loader {
anchors.fill: parent
active: band.shown && QbzShell.largeSpectrumMode === 1
active: band.shown && band.effectiveMode === 1
sourceComponent: Item {
id: waveMode
readonly property real slot: band.width / 48
@@ -363,7 +369,7 @@ Rectangle {
// Mode 2 — Energy: the 5 semantic bands (sub-bass .. air).
Loader {
anchors.fill: parent
active: band.shown && QbzShell.largeSpectrumMode === 2
active: band.shown && band.effectiveMode === 2
sourceComponent: Item {
id: energyMode
readonly property real slot: band.width / 5
@@ -442,7 +448,7 @@ Rectangle {
// that scope's DSP bit.
Loader {
anchors.fill: parent
active: band.shown && QbzShell.largeSpectrumMode === 3
active: band.shown && band.effectiveMode === 3
sourceComponent: ScopePanel {
compact: true
scopeMode: 0
@@ -451,7 +457,7 @@ Rectangle {
}
Loader {
anchors.fill: parent
active: band.shown && QbzShell.largeSpectrumMode === 4
active: band.shown && band.effectiveMode === 4
sourceComponent: ScopePanel {
compact: true
scopeMode: 1
@@ -459,7 +465,8 @@ Rectangle {
}
}
// Click the band → cycle all five modes (persisted).
// Click the band → cycle all five modes on GPU, the three compatible
// modes on Software (persisted by the Rust handler).
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
+30
View File
@@ -241,6 +241,18 @@ fn pinned_view(default_key: &str) -> Option<(i32, i32)> {
}
}
/// The two stereo scopes are native scene-graph traces. On Qt's Software and
/// Null backends only their QML guide axes survive, so a remembered or stale
/// request must land on the compatible Spectrum panel instead. This is a live
/// resolution only: the remembered mode remains stored and returns on GPU.
fn focus_mode_for_tier(view_mode: i32, mode: i32, gpu_tier: bool) -> i32 {
if view_mode == 0 && !gpu_tier && matches!(mode, 7 | 8) {
3
} else {
mode
}
}
/// The single funnel behind every `open` write (contract §3/D3). Holds the
/// store + notify, the §3.1 apply-default-view on the false→true edge, and
/// the §3.3a viz keep-alive on both edges.
@@ -298,6 +310,12 @@ fn apply_open(mut this: Pin<&mut QbzImmersive>, value: bool) {
this.as_mut().set_mode(m);
}
// Unknown key: Slint's `_ => {}` — leave the current view alone.
let live_mode =
focus_mode_for_tier(this.view_mode, this.mode, crate::renderer_qt::gpu_tier());
if live_mode != this.mode {
log::info!("[qbz-qt] immersive: native scope unavailable on renderer tier -> Spectrum");
this.as_mut().set_mode(live_mode);
}
crate::viz_qt::immersive_opened();
crate::viz_qt::set_immersive_view(this.view_mode, this.mode);
// Shader scenes (block A1): the open edge decides the scene. Under
@@ -356,6 +374,7 @@ impl qbz_immersive::QbzImmersive {
/// "remember"; a pinned default wins on the next open, so it must not be
/// overwritten (main.rs:10339-10357 parity).
pub fn set_view(mut self: Pin<&mut Self>, view_mode: i32, mode: i32, split_panel: i32) {
let mode = focus_mode_for_tier(view_mode, mode, crate::renderer_qt::gpu_tier());
self.as_mut().set_view_mode(view_mode);
self.as_mut().set_mode(mode);
self.as_mut().set_split_panel(split_panel);
@@ -443,6 +462,17 @@ mod tests {
assert_eq!(pinned_view("wavebed"), None); // pinned never lands on WaveBed
}
#[test]
fn software_tier_falls_back_from_scopes_to_spectrum() {
assert_eq!(focus_mode_for_tier(0, 7, false), 3);
assert_eq!(focus_mode_for_tier(0, 8, false), 3);
assert_eq!(focus_mode_for_tier(0, 7, true), 7);
assert_eq!(focus_mode_for_tier(0, 8, true), 8);
assert_eq!(focus_mode_for_tier(0, 6, false), 6);
// FOCUS mode is irrelevant in Split; do not rewrite stored state.
assert_eq!(focus_mode_for_tier(1, 8, false), 8);
}
#[test]
fn search_doc_default_is_full_shape() {
let doc: serde_json::Value = serde_json::from_str(IMM_SEARCH_EMPTY).unwrap();
+8 -2
View File
@@ -2056,9 +2056,15 @@ pub(crate) fn large_toggle_visualizer() {
}
/// Large dock, band click: cycle Bars -> Waveform -> Energy -> Goniometer ->
/// Oscilloscope.
/// Oscilloscope on the GPU tier. Qt's software scene graph cannot draw the
/// two native scope traces, so that tier cycles only the three compatible
/// modes instead of landing on guide axes with no signal.
pub(crate) fn large_cycle_spectrum() {
let mode = settings_qt::set_large_spectrum_mode((settings_qt::large_spectrum_mode() + 1) % 5);
let gpu_tier = renderer_qt::gpu_tier();
let current =
settings_qt::large_spectrum_mode_for_tier(settings_qt::large_spectrum_mode(), gpu_tier);
let mode_count = if gpu_tier { 5 } else { 3 };
let mode = settings_qt::set_large_spectrum_mode((current + 1) % mode_count);
let height = shell_bridge::large_dock_height(settings_qt::large_visualizer_on());
log::info!("[qbz-qt] large spectrum mode -> {mode}");
// Point the drain at the new stream BEFORE the UI switches, so the first
+27
View File
@@ -875,6 +875,22 @@ pub fn large_spectrum_mode() -> i32 {
.unwrap_or(0)
}
/// Resolve a stored Large-NPB mode against the renderer that actually won.
///
/// Goniometer and Oscilloscope are native scene-graph line strips. Qt's
/// Software/Null backend can still draw their QML guide axes, but cannot draw
/// the trace; exposing either mode there leaves a convincing-looking empty
/// instrument. Keep the stored preference untouched so returning to a GPU
/// restores it, and use Bars as the live fallback on the no-GPU tier.
pub fn large_spectrum_mode_for_tier(mode: i32, gpu_tier: bool) -> i32 {
let mode = mode.clamp(0, 4);
if gpu_tier || mode < 3 {
mode
} else {
0
}
}
/// Persist the band mode (clamped 0-4); returns the stored index.
pub fn set_large_spectrum_mode(mode: i32) -> i32 {
let mode = mode.clamp(0, 4);
@@ -3302,4 +3318,15 @@ mod local_tab_order_tests {
assert_eq!(local_genre_filters_position_from("future-edge"), "top");
assert_eq!(local_genre_filters_position_from(""), "top");
}
#[test]
fn software_tier_hides_native_scope_modes_without_touching_legacy_modes() {
for mode in 0..=2 {
assert_eq!(large_spectrum_mode_for_tier(mode, false), mode);
}
assert_eq!(large_spectrum_mode_for_tier(3, false), 0);
assert_eq!(large_spectrum_mode_for_tier(4, false), 0);
assert_eq!(large_spectrum_mode_for_tier(3, true), 3);
assert_eq!(large_spectrum_mode_for_tier(4, true), 4);
}
}
+17 -1
View File
@@ -964,7 +964,11 @@ pub(crate) const DOCK_BAND_GAP: f32 = 10.0;
pub(crate) fn large_dock_height(visualizer_on: bool) -> f32 {
let base = DOCK_PAD_TOP + DOCK_ART_SIZE + DOCK_PAD_BOTTOM;
if visualizer_on {
let band_height = if crate::settings_qt::large_spectrum_mode() >= 3 {
let mode = crate::settings_qt::large_spectrum_mode_for_tier(
crate::settings_qt::large_spectrum_mode(),
crate::renderer_qt::gpu_tier(),
);
let band_height = if mode >= 3 {
DOCK_ART_SIZE
} else {
DOCK_BAND_HEIGHT
@@ -1099,6 +1103,18 @@ impl qbz_shell::QbzShell {
self.as_mut().set_gpu_tier(tier);
self.as_mut().set_shader_scenes_available(tier);
self.as_mut().set_app_background_available(tier);
// The two scope modes are QSG-native traces. On Software their QML
// guides still draw, which used to leave an empty instrument in the
// Large NPB. Publish a LIVE Bars fallback without overwriting the
// stored scope choice; a later GPU session restores it.
let live_mode = crate::settings_qt::large_spectrum_mode_for_tier(
crate::settings_qt::large_spectrum_mode(),
tier,
);
self.as_mut().set_large_spectrum_mode(live_mode);
crate::viz_qt::set_mode(live_mode);
self.as_mut()
.set_large_dock_height(large_dock_height(crate::settings_qt::large_visualizer_on()));
let kiosk = crate::kiosk_profile_qt::active();
self.as_mut()
.set_reduce_motion(crate::renderer_qt::reduce_motion(kiosk));
+7 -2
View File
@@ -710,14 +710,19 @@ pub(crate) fn immersive_opened() {
/// untouched — trap 4/20), single-stream marshalling resumes, and
/// `ACTIVE_MODE` is restored from the dock's persisted pref (dock mode-cycles
/// while immersive was open already updated it via
/// `settings_qt::set_large_spectrum_mode`).
/// `settings_qt::set_large_spectrum_mode`). The renderer-tier resolution is
/// repeated here so closing Immersive on Software cannot quietly re-enable a
/// hidden scope producer.
pub(crate) fn immersive_closed() {
IMMERSIVE_PANEL_SCOPE_MASK.store(0, Ordering::Relaxed);
IMMERSIVE_SCOPE_MASK.store(0, Ordering::Relaxed);
apply_scope_mask();
set_enabled_source(VizSource::Immersive, false);
MARSHAL_ALL.store(false, Ordering::Relaxed);
set_mode(crate::settings_qt::large_spectrum_mode());
set_mode(crate::settings_qt::large_spectrum_mode_for_tier(
crate::settings_qt::large_spectrum_mode(),
crate::renderer_qt::gpu_tier(),
));
}
/// Point the drain at the stream the band is actually rendering. Called at