From c5254f6c47e1722a84d343f66dac0eb8da97a5d8 Mon Sep 17 00:00:00 2001 From: Jakob Hellermann Date: Fri, 10 Dec 2021 17:45:10 +0100 Subject: [PATCH] show error on unresolved custom shader import --- .../bevy_render/src/render_resource/pipeline_cache.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index 77f892b9aa9024..4b3868da0f29ca 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -54,7 +54,16 @@ impl ShaderCache { .get(handle) .ok_or_else(|| RenderPipelineError::ShaderNotLoaded(handle.clone_weak()))?; let data = self.data.entry(handle.clone_weak()).or_default(); - if shader.imports().len() != data.resolved_imports.len() { + let n_asset_imports = shader + .imports() + .filter(|import| matches!(import, ShaderImport::AssetPath(_))) + .count(); + let n_resolved_asset_imports = data + .resolved_imports + .keys() + .filter(|import| matches!(import, ShaderImport::AssetPath(_))) + .count(); + if n_asset_imports != n_resolved_asset_imports { return Err(RenderPipelineError::ShaderImportNotYetAvailable); }