log pipeline cache errors earlier (#6115)

# Objective

- Currently, errors aren't logged as soon as they are found, they are logged only on the next frame. This means your shader could have an unreported error that could have been reported on the first frame.

## Solution

- Log the error as soon as they are found, don't wait until next frame

## Notes

I discovered this issue because I was simply unwrapping the `Result` from `PipelinCache::get_render_pipeline()` which caused it to fail without any explanations. Admittedly, this was a bit of a user error, I shouldn't have unwrapped that, but it seems a bit strange to wait until the next time the pipeline is processed to log the error instead of just logging it as soon as possible since we already have all the info necessary.
This commit is contained in:
Charles 2022-09-28 04:04:55 +00:00
parent d22d310ad5
commit 018509c3a1

View File

@ -609,28 +609,8 @@ impl PipelineCache {
for id in waiting_pipelines {
let pipeline = &mut pipelines[id];
match &pipeline.state {
CachedPipelineState::Ok(_) => continue,
CachedPipelineState::Queued => {}
CachedPipelineState::Err(err) => {
match err {
PipelineCacheError::ShaderNotLoaded(_)
| PipelineCacheError::ShaderImportNotYetAvailable => { /* retry */ }
// shader could not be processed ... retrying won't help
PipelineCacheError::ProcessShaderError(err) => {
error!("failed to process shader: {}", err);
continue;
}
PipelineCacheError::AsModuleDescriptorError(err, source) => {
log_shader_error(source, err);
continue;
}
PipelineCacheError::CreateShaderModule(description) => {
error!("failed to create shader module: {}", description);
continue;
}
}
}
if matches!(pipeline.state, CachedPipelineState::Ok(_)) {
continue;
}
pipeline.state = match &pipeline.descriptor {
@ -642,8 +622,27 @@ impl PipelineCache {
}
};
if let CachedPipelineState::Err(_) = pipeline.state {
self.waiting_pipelines.insert(id);
if let CachedPipelineState::Err(err) = &pipeline.state {
match err {
PipelineCacheError::ShaderNotLoaded(_)
| PipelineCacheError::ShaderImportNotYetAvailable => {
// retry
self.waiting_pipelines.insert(id);
}
// shader could not be processed ... retrying won't help
PipelineCacheError::ProcessShaderError(err) => {
error!("failed to process shader: {}", err);
continue;
}
PipelineCacheError::AsModuleDescriptorError(err, source) => {
log_shader_error(source, err);
continue;
}
PipelineCacheError::CreateShaderModule(description) => {
error!("failed to create shader module: {}", description);
continue;
}
}
}
}