Store or update a named shader source. If the source changed compared to the previously stored value, the old compiled material is evicted from the cache so the next render pass recompiles automatically. No-ops if the source is unchanged.
(&mut self, name: &str, fragment: &str)
| 521 | /// compiled material is evicted from the cache so the next render pass |
| 522 | /// recompiles automatically. No-ops if the source is unchanged. |
| 523 | pub fn set_source(&mut self, name: &str, fragment: &str) { |
| 524 | if let Some(old_source) = self.shader_storage.get(name) { |
| 525 | if old_source == fragment { |
| 526 | return; // Unchanged — nothing to do |
| 527 | } |
| 528 | // Evict stale material keyed by the old source |
| 529 | self.materials.remove(old_source.as_str()); |
| 530 | } |
| 531 | self.shader_storage.insert(name.to_string(), fragment.to_string()); |
| 532 | } |
| 533 | |
| 534 | /// Look up a stored shader source by name. |
| 535 | pub fn get_source(&self, name: &str) -> Option<&str> { |
no test coverage detected