Add config option to increase GPU max buffer size

This commit is contained in:
Connor Slade
2025-02-08 13:30:52 -05:00
parent 903f8b8876
commit 9c0bc437e0
3 changed files with 27 additions and 17 deletions

View File

@@ -7,7 +7,7 @@ use std::{
use anyhow::Result;
use eframe::Theme;
use serde::{Deserialize, Serialize};
use tracing::info;
use tracing::{info, warn};
use crate::render::pipelines::model::RenderStyle;
@@ -15,7 +15,6 @@ use crate::render::pipelines::model::RenderStyle;
#[serde(default)]
pub struct Config {
pub render_style: RenderStyle,
pub show_normals: bool,
pub grid_size: f32,
pub theme: Theme,
pub recent_projects: Vec<PathBuf>,
@@ -26,9 +25,23 @@ pub struct Config {
pub http_status_proxy: bool,
pub network_timeout: f32,
pub network_broadcast_address: IpAddr,
// Advanced Settings
pub show_normals: bool,
pub max_buffer_size: u64,
}
impl Config {
pub fn load_or_default(config_dir: &Path) -> Self {
match Self::load(config_dir) {
Ok(config) => config,
Err(err) => {
warn!("Failed to load config, using defaults: {}", err);
Config::default()
}
}
}
pub fn load(config_dir: &Path) -> Result<Self> {
let config_file = config_dir.join("config.toml");
Ok(if config_file.exists() {
@@ -57,7 +70,6 @@ impl Default for Config {
fn default() -> Self {
Self {
render_style: RenderStyle::Rended,
show_normals: false,
grid_size: 12.16,
theme: Theme::Dark,
@@ -68,6 +80,9 @@ impl Default for Config {
http_status_proxy: false,
network_timeout: 5.0,
network_broadcast_address: IpAddr::V4(Ipv4Addr::new(192, 168, 1, 255)),
max_buffer_size: 512 << 20,
show_normals: false,
}
}
}

View File

@@ -66,7 +66,7 @@ pub struct FpsTracker {
}
impl App {
pub fn new(event_collector: EventCollector) -> Self {
pub fn new(config_dir: PathBuf, config: Config, event_collector: EventCollector) -> Self {
let mut dock_state = DockState::new(vec![Tab::Viewport, Tab::Logs]);
let surface = dock_state.main_surface_mut();
let [_old_node, new_node] = surface.split_left(NodeIndex::root(), 0.20, vec![Tab::Models]);
@@ -74,15 +74,6 @@ impl App {
surface.split_below(new_node, 0.5, vec![Tab::SliceConfig, Tab::Supports]);
surface.split_below(new_node, 0.5, vec![Tab::Workspace, Tab::RemotePrint]);
let config_dir = dirs::config_dir().unwrap().join("mslicer");
let config = match Config::load(&config_dir) {
Ok(config) => config,
Err(err) => {
warn!("Failed to load config, using defaults: {}", err);
Config::default()
}
};
Self {
dock_state,
popup: PopupManager::new(),

View File

@@ -15,7 +15,7 @@ mod plugins;
mod render;
mod ui;
mod windows;
use app::App;
use app::{config::Config, App};
const ICON: &[u8] = include_bytes!("assets/icon.png");
@@ -34,6 +34,10 @@ fn main() -> Result<()> {
.with(collector.clone())
.init();
let config_dir = dirs::config_dir().unwrap().join("mslicer");
let config = Config::load_or_default(&config_dir);
let max_buffer_size = config.max_buffer_size;
let icon = image::load_from_memory(ICON)?;
eframe::run_native(
"mslicer",
@@ -50,11 +54,11 @@ fn main() -> Result<()> {
stencil_buffer: 8,
multisampling: 4,
wgpu_options: WgpuConfiguration {
device_descriptor: Arc::new(|_adapter| DeviceDescriptor {
device_descriptor: Arc::new(move |_adapter| DeviceDescriptor {
label: None,
required_features: Features::POLYGON_MODE_LINE,
required_limits: Limits {
max_buffer_size: 512 << 20,
max_buffer_size,
..Limits::default()
},
}),
@@ -70,7 +74,7 @@ fn main() -> Result<()> {
egui_phosphor::add_to_fonts(&mut fonts, egui_phosphor::Variant::Regular);
cc.egui_ctx.set_fonts(fonts);
Box::new(App::new(collector))
Box::new(App::new(config_dir, config, collector))
}),
)
.unwrap();