refactor(tauri): use magnotia_core::hardware::vulkan_loader_available
Delete the local duplicate fn and libloading dependency from src-tauri; import the canonical implementation from magnotia-core::hardware instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -57,11 +57,6 @@ serde_json = "1"
|
|||||||
tokio = { version = "1", features = ["rt", "sync"] }
|
tokio = { version = "1", features = ["rt", "sync"] }
|
||||||
arboard = "3.6.1"
|
arboard = "3.6.1"
|
||||||
|
|
||||||
# Runtime shared-library probe for the Vulkan loader (active compute
|
|
||||||
# device detection, brief item #1). We do not call any vulkan symbols
|
|
||||||
# — we only need to answer "is libvulkan resolvable from the loader's
|
|
||||||
# default search path right now?".
|
|
||||||
libloading = "0.8"
|
|
||||||
|
|
||||||
# SqlitePool is named directly from src-tauri/src/lib.rs (the AppState
|
# SqlitePool is named directly from src-tauri/src/lib.rs (the AppState
|
||||||
# stores it). Must be unconditional, not Linux-only — naming a type from
|
# stores it). Must be unconditional, not Linux-only — naming a type from
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use tauri::Emitter;
|
|||||||
use crate::commands::security::ensure_main_window;
|
use crate::commands::security::ensure_main_window;
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
use magnotia_core::constants::WHISPER_SAMPLE_RATE;
|
use magnotia_core::constants::WHISPER_SAMPLE_RATE;
|
||||||
use magnotia_core::hardware::{self, CpuFeatures};
|
use magnotia_core::hardware::{self, vulkan_loader_available, CpuFeatures};
|
||||||
use magnotia_core::model_registry::{self, Engine, LanguageSupport, ModelEntry};
|
use magnotia_core::model_registry::{self, Engine, LanguageSupport, ModelEntry};
|
||||||
use magnotia_core::types::{AudioSamples, ModelId, TranscriptionOptions};
|
use magnotia_core::types::{AudioSamples, ModelId, TranscriptionOptions};
|
||||||
#[cfg(feature = "whisper")]
|
#[cfg(feature = "whisper")]
|
||||||
@@ -319,35 +319,6 @@ pub struct LanguageSupportInfo {
|
|||||||
pub language_count: u16,
|
pub language_count: u16,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Best-effort probe for the Vulkan loader shared library.
|
|
||||||
///
|
|
||||||
/// whisper.cpp's Vulkan backend refuses to initialise if `vulkan-1.dll`
|
|
||||||
/// (Windows) / `libvulkan.so.1` (Linux) / the MoltenVK bundle (macOS)
|
|
||||||
/// is missing at runtime. We probe via `libloading::Library::new`;
|
|
||||||
/// failure means whisper.cpp will silently drop back to CPU, and the
|
|
||||||
/// user deserves to know before they start wondering why a 14-second
|
|
||||||
/// clip takes two minutes.
|
|
||||||
fn vulkan_loader_available() -> bool {
|
|
||||||
#[cfg(target_os = "linux")]
|
|
||||||
let candidates: &[&str] = &["libvulkan.so.1", "libvulkan.so"];
|
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
let candidates: &[&str] = &["vulkan-1.dll"];
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let candidates: &[&str] = &["libvulkan.1.dylib", "libMoltenVK.dylib"];
|
|
||||||
#[cfg(not(any(target_os = "linux", target_os = "windows", target_os = "macos")))]
|
|
||||||
let candidates: &[&str] = &[];
|
|
||||||
|
|
||||||
for name in candidates {
|
|
||||||
// SAFETY: libloading::Library::new loads a shared library and returns
|
|
||||||
// a handle that is dropped at the end of this iteration. No symbols
|
|
||||||
// from it are called, so we just need the open-for-probe semantics.
|
|
||||||
match unsafe { libloading::Library::new(*name) } {
|
|
||||||
Ok(_lib) => return true,
|
|
||||||
Err(_) => continue,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Compile-time target signalling used by `compose_accelerators`.
|
/// Compile-time target signalling used by `compose_accelerators`.
|
||||||
/// Split out so the pure-function behaviour is testable without `cfg!`
|
/// Split out so the pure-function behaviour is testable without `cfg!`
|
||||||
|
|||||||
Reference in New Issue
Block a user