Skip to content

Commit

Permalink
show error on unresolved custom shader import
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobhellermann committed Dec 21, 2021
1 parent d183a8c commit c5254f6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/bevy_render/src/render_resource/pipeline_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit c5254f6

Please sign in to comment.