diff options
Diffstat (limited to 'client/src/render/scene/mod.rs')
-rw-r--r-- | client/src/render/scene/mod.rs | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/client/src/render/scene/mod.rs b/client/src/render/scene/mod.rs index ad7e0ce..16eecfc 100644 --- a/client/src/render/scene/mod.rs +++ b/client/src/render/scene/mod.rs @@ -21,16 +21,21 @@ pub mod pipelines; pub mod textures; pub mod vertex_buffers; -use super::{shaders::SceneShaders, GraphicsConfig}; +use super::{GraphicsConfig, shaders::SceneShaders}; use crate::{armature::RArmature, download::Downloader}; use anyhow::Result; use bytemuck::{Pod, Zeroable}; use demand_map::DemandMap; use egui::{Grid, Widget}; use glam::{UVec3, UVec4, Vec2, Vec3, Vec3A, uvec3, uvec4}; -use log::{debug, trace}; +use log::{debug, info, trace}; use pipelines::SceneBgLayouts; -use std::{hash::Hash, marker::PhantomData, sync::Arc, time::Instant}; +use std::{ + hash::Hash, + marker::PhantomData, + sync::{Arc, RwLock}, + time::Instant, +}; use textures::MipGenerationPipeline; use weareshared::{ Affine3A, @@ -49,7 +54,7 @@ pub struct ScenePreparer { layouts: SceneBgLayouts, shaders: SceneShaders, render_format: TextureFormat, - config: GraphicsConfig, + config: RwLock<GraphicsConfig>, downloader: Arc<Downloader>, textures: DemandMap<TextureSpec, (Arc<Texture>, Arc<BindGroup>)>, @@ -143,7 +148,7 @@ impl ScenePreparer { ) -> Self { Self { render_format, - config, + config: config.into(), layouts: SceneBgLayouts::load(&device), shaders: SceneShaders::load(&device), device, @@ -163,6 +168,22 @@ impl ScenePreparer { mip_generation_pipelines: DemandMap::new(), } } + pub fn reconfigure(&self, config: &GraphicsConfig) { + let mut cc = self.config.write().unwrap(); + if cc.max_anisotropy != config.max_anisotropy || cc.max_mip_count != config.max_mip_count { + info!("clear all scene textures"); + self.textures.clear(); + self.mesh_parts.clear(); + self.prefabs.clear(); + } + if cc.sample_count != config.sample_count { + info!("clear all scene pipelines"); + self.pipelines.clear(); + self.mesh_parts.clear(); + self.prefabs.clear(); + } + *cc = config.clone(); + } pub fn update(&self) -> Result<usize> { let mut num_done = 0; @@ -204,7 +225,12 @@ impl ScenePreparer { for spec in self.pipelines.needed() { self.pipelines.insert( spec.clone(), - Arc::new(spec.create(&self.device, &self.layouts, &self.shaders, &self.config)), + Arc::new(spec.create( + &self.device, + &self.layouts, + &self.shaders, + &self.config.read().unwrap().clone(), + )), 0, ); } |