Seregon/StratoSDK

StratoSDK is a framework with a declarative approach similar to Flutter/React, written and designed entirely for Rust.

Rust/27.3 KB/No license
crates/strato-renderer/src/lib.rs
1//! StratoUI Renderer
2//!
3//! A high-performance, GPU-accelerated 2D renderer built on wgpu.
4//! Designed for modern UI frameworks with a focus on performance and flexibility.
5//!
6//! ## Features
7//! - Advanced GPU device management with multi-adapter support
8//! - Intelligent resource management with automatic pooling and deframmentation
9//! - Sophisticated memory management with multi-tier allocation
10//! - Dynamic shader compilation with hot-reload support
11//! - Modular pipeline system with render graph optimization
12//! - Efficient buffer management with lock-free operations
13//! - Comprehensive performance profiling and monitoring
14//! - Enterprise-grade error handling and recovery
15 
16pub mod batch;
17pub mod buffer;
18pub mod device;
19pub mod font_config;
20pub mod font_system;
21pub mod glyph_atlas;
22pub mod gpu; // Modular GPU pipeline
23pub mod memory;
24pub mod pipeline;
25pub mod profiler;
26pub mod resources;
27pub mod shader;
28pub mod text;
29pub mod texture;
30pub mod vertex;
31 
32pub mod backend;
33 
34pub mod integration;
35 
36// Re-export commonly used types
37pub use backend::commands::RenderCommand;
38pub use backend::Backend;
39pub use batch::RenderBatch;
40pub use buffer::{BufferManager, BufferPool, DynamicBuffer};
41pub use device::{AdapterInfo, DeviceManager, ManagedDevice};
42pub use integration::{IntegratedRenderer, RenderContext, RenderStats, RendererBuilder};
43pub use memory::{AllocationStrategy, MemoryManager, MemoryPool};
44pub use pipeline::{PipelineManager, RenderGraph, RenderNode};
45pub use profiler::{FrameStats, PerformanceReport, Profiler};
46pub use resources::{ResourceHandle, ResourceManager, ResourceType};
47pub use shader::{CompiledShader, ShaderManager, ShaderSource};
48 
49/// Renderer configuration
50#[derive(Debug, Clone)]
51pub struct RendererConfig {
52 /// Enable MSAA
53 pub msaa_samples: u32,
54 /// Enable vsync
55 pub vsync: bool,
56 /// Maximum texture atlas size
57 pub max_texture_size: u32,
58 /// Enable GPU validation (debug mode)
59 pub validation: bool,
60}
61 
62impl Default for RendererConfig {
63 fn default() -> Self {
64 Self {
65 msaa_samples: 4,
66 vsync: true,
67 max_texture_size: 4096,
68 validation: cfg!(debug_assertions),
69 }
70 }
71}
72 
73/// Initialize the renderer
74pub fn init(config: RendererConfig) -> anyhow::Result<()> {
75 tracing::info!("Initializing StratoUI Renderer with config: {:?}", config);
76 Ok(())
77}
78 
79#[cfg(test)]
80mod tests {
81 use super::*;
82 
83 #[test]
84 fn test_default_config() {
85 let config = RendererConfig::default();
86 assert_eq!(config.msaa_samples, 4);
87 assert!(config.vsync);
88 }
89}
90