1251: Don't panic on pipeline creation errors r=kvark a=kvark

**Connections**
Related to Gecko crashes.

**Description**
We shouldn't ever panic in `wgpu`. The panic can only occur if there is internal inconsistency. For any invalid workloads, submitted by the user, we should produce errors instead.

**Testing**
Not tested

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
This commit is contained in:
bors[bot]andDzmitry Malyshau authored and GitHub committed 2021-03-10 03:29:52 +00:00
commit 6f49f041d3
1 file changed
+19 -16
+19 -16
View File
@@ -1932,15 +1932,16 @@ impl<B: GfxBackend> Device<B> {
parent,
};
let raw = match unsafe { self.raw.create_compute_pipeline(&pipeline_desc, None) } {
Ok(pipeline) => pipeline,
Err(hal::pso::CreationError::OutOfMemory(_)) => {
return Err(pipeline::CreateComputePipelineError::Device(
DeviceError::OutOfMemory,
))
}
other => panic!("Compute pipeline creation error: {:?}", other),
};
let raw =
unsafe { self.raw.create_compute_pipeline(&pipeline_desc, None) }.map_err(|err| {
match err {
hal::pso::CreationError::OutOfMemory(_) => DeviceError::OutOfMemory,
_ => {
tracing::error!("failed to create compute pipeline: {}", err);
DeviceError::OutOfMemory
}
}
})?;
let pipeline = pipeline::ComputePipeline {
raw,
@@ -2366,14 +2367,16 @@ impl<B: GfxBackend> Device<B> {
parent,
};
// TODO: cache
let raw = unsafe {
self.raw
.create_graphics_pipeline(&pipeline_desc, None)
.map_err(|err| match err {
let raw =
unsafe { self.raw.create_graphics_pipeline(&pipeline_desc, None) }.map_err(|err| {
match err {
hal::pso::CreationError::OutOfMemory(_) => DeviceError::OutOfMemory,
_ => panic!("failed to create graphics pipeline: {}", err),
})?
};
_ => {
tracing::error!("failed to create graphics pipeline: {}", err);
DeviceError::OutOfMemory
}
}
})?;
let pass_context = RenderPassContext {
attachments: AttachmentData {