kronos_compute/implementation/
mod.rs

1//! Actual implementation of Kronos compute APIs
2
3use std::sync::Mutex;
4use log::warn;
5
6pub mod error;
7pub mod instance;
8pub mod device;
9pub mod memory;
10pub mod buffer;
11pub mod pipeline;
12pub mod descriptor;
13pub mod sync;
14pub mod icd_loader;
15pub mod forward;
16pub mod persistent_descriptors;
17pub mod barrier_policy;
18pub mod timeline_batching;
19pub mod pool_allocator;
20
21#[cfg(test)]
22mod tests;
23
24// Re-export all implementation functions
25pub use instance::*;
26pub use device::*;
27pub use memory::*;
28pub use buffer::*;
29pub use pipeline::*;
30pub use descriptor::*;
31pub use sync::*;
32
33// ICD initialization state
34lazy_static::lazy_static! {
35    pub static ref ICD_INITIALIZED: Mutex<bool> = Mutex::new(false);
36}
37
38/// Initialize Kronos (loads ICD if available)
39pub fn initialize_kronos() -> Result<(), error::KronosError> {
40    let mut initialized = ICD_INITIALIZED.lock()?;
41    if *initialized {
42        return Ok(());
43    }
44    
45    // Try to load ICD, but don't fail if unavailable
46    // Functions will return ErrorInitializationFailed when called without ICD
47    match icd_loader::initialize_icd_loader() {
48        Ok(()) => {
49            *initialized = true;
50            log::info!("Kronos initialized successfully with ICD forwarding");
51            Ok(())
52        }
53        Err(e) => {
54            // Log the error but don't fail initialization
55            warn!("Failed to initialize Vulkan ICD loader: {}", e);
56            *initialized = true; // Mark as initialized even without ICD
57            Ok(())
58        }
59    }
60}
61