Drain pending hot-reload events and rebuild affected pipelines. Logs failures and keeps the previous pipeline in place — never kills the running game.
(&mut self)
| 13327 | /// Logs failures and keeps the previous pipeline in place — never |
| 13328 | /// kills the running game. |
| 13329 | pub fn poll_material_hot_reload(&mut self) { |
| 13330 | let pending = self.material_hot_reload.drain_pending(); |
| 13331 | for (handle, desc) in pending { |
| 13332 | let source = match std::fs::read_to_string(&desc.path) { |
| 13333 | Ok(s) => s, |
| 13334 | Err(e) => { |
| 13335 | eprintln!("[hot_reload] read {:?} failed: {e}", desc.path); |
| 13336 | continue; |
| 13337 | } |
| 13338 | }; |
| 13339 | // Compile fresh; on success, replace the slot. On failure, |
| 13340 | // log and keep the old pipeline running. |
| 13341 | match self.material_system.compile( |
| 13342 | &self.device, &source, |
| 13343 | desc.profile, desc.bucket, desc.reads_scene, |
| 13344 | desc.wants_instancing, |
| 13345 | formats::HDR_FORMAT, |
| 13346 | formats::MATERIAL_FORMAT, |
| 13347 | formats::VELOCITY_FORMAT, |
| 13348 | wgpu::TextureFormat::Rgba8Unorm, |
| 13349 | formats::DEPTH_FORMAT, |
| 13350 | ) { |
| 13351 | Ok(new_handle) => { |
| 13352 | // material_system.compile pushes a NEW slot. |
| 13353 | // Move the new pipeline into the original slot |
| 13354 | // and clear the trailing one so handles don't |
| 13355 | // leak. |
| 13356 | let new_idx = (new_handle - 1) as usize; |
| 13357 | let old_idx = (handle - 1) as usize; |
| 13358 | if let Some(p) = self.material_system.pipelines.get_mut(new_idx).and_then(|s| s.take()) { |
| 13359 | if let Some(slot) = self.material_system.pipelines.get_mut(old_idx) { |
| 13360 | *slot = Some(p); |
| 13361 | } |
| 13362 | } |
| 13363 | eprintln!("[hot_reload] reloaded {:?} (handle {handle})", desc.path); |
| 13364 | } |
| 13365 | Err(e) => { |
| 13366 | eprintln!("[hot_reload] compile {:?} failed: {e:?} — keeping previous", desc.path); |
| 13367 | } |
| 13368 | } |
| 13369 | } |
| 13370 | } |
| 13371 | |
| 13372 | /// Submit a material draw against a cached mesh. `mesh_handle` is |
| 13373 | /// the value returned by `cache_model_if_static` (same as the |
no test coverage detected