Reverts the addition of LabeledContextError

Removed as discussed, moving them to wgpu-rs side
This commit is contained in:
Mikko Lehtonen 2020-09-14 22:45:10 +03:00
parent d423d3d5d7
commit 8252758674
3 changed files with 36 additions and 84 deletions

View File

@ -2597,7 +2597,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
implicit_pipeline_ids: Option<ImplicitPipelineIds<G>>, implicit_pipeline_ids: Option<ImplicitPipelineIds<G>>,
) -> Result< ) -> Result<
(id::RenderPipelineId, pipeline::ImplicitBindGroupCount), (id::RenderPipelineId, pipeline::ImplicitBindGroupCount),
crate::LabeledContextError<pipeline::CreateRenderPipelineError>, pipeline::CreateRenderPipelineError,
> { > {
span!(_guard, INFO, "Device::create_render_pipeline"); span!(_guard, INFO, "Device::create_render_pipeline");
@ -2607,8 +2607,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let samples = { let samples = {
let sc = desc.sample_count; let sc = desc.sample_count;
if sc == 0 || sc > 32 || !conv::is_power_of_two(sc) { if sc == 0 || sc > 32 || !conv::is_power_of_two(sc) {
return Err(pipeline::CreateRenderPipelineError::InvalidSampleCount(sc) return Err(pipeline::CreateRenderPipelineError::InvalidSampleCount(sc));
.with_label(&desc.label));
} }
sc as u8 sc as u8
}; };
@ -2641,8 +2640,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
return Err(pipeline::CreateRenderPipelineError::UnalignedVertexStride { return Err(pipeline::CreateRenderPipelineError::UnalignedVertexStride {
index: i as u32, index: i as u32,
stride: vb_state.stride, stride: vb_state.stride,
} });
.with_label(&desc.label));
} }
vertex_buffers.alloc().init(hal::pso::VertexBufferDesc { vertex_buffers.alloc().init(hal::pso::VertexBufferDesc {
binding: i as u32, binding: i as u32,
@ -2659,8 +2657,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
pipeline::CreateRenderPipelineError::InvalidVertexAttributeOffset { pipeline::CreateRenderPipelineError::InvalidVertexAttributeOffset {
location: attribute.shader_location, location: attribute.shader_location,
offset: attribute.offset, offset: attribute.offset,
} },
.with_label(&desc.label),
); );
} }
attributes.alloc().init(hal::pso::AttributeDesc { attributes.alloc().init(hal::pso::AttributeDesc {
@ -2716,16 +2713,15 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
}; };
let (device_guard, mut token) = hub.devices.read(&mut token); let (device_guard, mut token) = hub.devices.read(&mut token);
let device = device_guard.get(device_id).map_err(|_| { let device = device_guard
pipeline::CreateRenderPipelineError::from(DeviceError::Invalid).with_label(&desc.label) .get(device_id)
})?; .map_err(|_| DeviceError::Invalid)?;
if rasterization_state.clamp_depth if rasterization_state.clamp_depth
&& !device.features.contains(wgt::Features::DEPTH_CLAMPING) && !device.features.contains(wgt::Features::DEPTH_CLAMPING)
{ {
return Err(pipeline::CreateRenderPipelineError::MissingFeature( return Err(pipeline::CreateRenderPipelineError::MissingFeature(
wgt::Features::DEPTH_CLAMPING, wgt::Features::DEPTH_CLAMPING,
) ));
.with_label(&desc.label));
} }
if rasterization_state.polygon_mode != wgt::PolygonMode::Fill if rasterization_state.polygon_mode != wgt::PolygonMode::Fill
&& !device && !device
@ -2734,8 +2730,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
{ {
return Err(pipeline::CreateRenderPipelineError::MissingFeature( return Err(pipeline::CreateRenderPipelineError::MissingFeature(
wgt::Features::NON_FILL_POLYGON_MODE, wgt::Features::NON_FILL_POLYGON_MODE,
) ));
.with_label(&desc.label));
} }
let (raw_pipeline, layout_id, layout_ref_count, derived_bind_group_count) = { let (raw_pipeline, layout_id, layout_ref_count, derived_bind_group_count) = {
@ -2797,21 +2792,17 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let shader_module = let shader_module =
shader_module_guard shader_module_guard
.get(desc.vertex_stage.module) .get(desc.vertex_stage.module)
.map_err(|_| { .map_err(|_| pipeline::CreateRenderPipelineError::Stage {
pipeline::CreateRenderPipelineError::Stage {
flag, flag,
error: validation::StageError::InvalidModule, error: validation::StageError::InvalidModule,
}
.with_label(&desc.label)
})?; })?;
if let Some(ref module) = shader_module.module { if let Some(ref module) = shader_module.module {
let group_layouts = match desc.layout { let group_layouts = match desc.layout {
Some(pipeline_layout_id) => Device::get_introspection_bind_group_layouts( Some(pipeline_layout_id) => Device::get_introspection_bind_group_layouts(
pipeline_layout_guard.get(pipeline_layout_id).map_err(|_| { pipeline_layout_guard
pipeline::CreateRenderPipelineError::InvalidLayout .get(pipeline_layout_id)
.with_label(&desc.label) .map_err(|_| pipeline::CreateRenderPipelineError::InvalidLayout)?,
})?,
&*bgl_guard, &*bgl_guard,
), ),
None => validation::IntrospectionBindGroupLayouts::Derived( None => validation::IntrospectionBindGroupLayouts::Derived(
@ -2826,10 +2817,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
flag, flag,
interface, interface,
) )
.map_err(|error| { .map_err(|error| pipeline::CreateRenderPipelineError::Stage { flag, error })?;
pipeline::CreateRenderPipelineError::Stage { flag, error }
.with_label(&desc.label)
})?;
validated_stages |= flag; validated_stages |= flag;
} }
@ -2850,15 +2838,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
flag, flag,
error: validation::StageError::InvalidModule, error: validation::StageError::InvalidModule,
} }
.with_label(&desc.label)
})?; })?;
let group_layouts = match desc.layout { let group_layouts = match desc.layout {
Some(pipeline_layout_id) => Device::get_introspection_bind_group_layouts( Some(pipeline_layout_id) => Device::get_introspection_bind_group_layouts(
pipeline_layout_guard.get(pipeline_layout_id).map_err(|_| { pipeline_layout_guard
pipeline::CreateRenderPipelineError::InvalidLayout .get(pipeline_layout_id)
.with_label(&desc.label) .map_err(|_| pipeline::CreateRenderPipelineError::InvalidLayout)?,
})?,
&*bgl_guard, &*bgl_guard,
), ),
None => validation::IntrospectionBindGroupLayouts::Derived( None => validation::IntrospectionBindGroupLayouts::Derived(
@ -2877,7 +2863,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
) )
.map_err(|error| { .map_err(|error| {
pipeline::CreateRenderPipelineError::Stage { flag, error } pipeline::CreateRenderPipelineError::Stage { flag, error }
.with_label(&desc.label)
})?; })?;
validated_stages |= flag; validated_stages |= flag;
} }
@ -2905,8 +2890,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
return Err( return Err(
pipeline::CreateRenderPipelineError::IncompatibleOutputFormat { pipeline::CreateRenderPipelineError::IncompatibleOutputFormat {
index: i as u8, index: i as u8,
} },
.with_label(&desc.label),
); );
} }
} }
@ -2916,10 +2900,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
None => wgt::ShaderStage::VERTEX, None => wgt::ShaderStage::VERTEX,
}; };
if desc.layout.is_none() && !validated_stages.contains(last_stage) { if desc.layout.is_none() && !validated_stages.contains(last_stage) {
Err(pipeline::CreateRenderPipelineError::from( Err(pipeline::ImplicitLayoutError::ReflectionError(last_stage))?
pipeline::ImplicitLayoutError::ReflectionError(last_stage),
)
.with_label(&desc.label))?
} }
let primitive_assembler = hal::pso::PrimitiveAssemblerDesc::Vertex { let primitive_assembler = hal::pso::PrimitiveAssemblerDesc::Vertex {
@ -2938,22 +2919,18 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
let (pipeline_layout_id, derived_bind_group_count) = match desc.layout { let (pipeline_layout_id, derived_bind_group_count) = match desc.layout {
Some(id) => (id, 0), Some(id) => (id, 0),
None => self None => self.derive_pipeline_layout(
.derive_pipeline_layout(
device, device,
device_id, device_id,
implicit_pipeline_ids, implicit_pipeline_ids,
derived_group_layouts, derived_group_layouts,
&mut *bgl_guard, &mut *bgl_guard,
&mut *pipeline_layout_guard, &mut *pipeline_layout_guard,
) )?,
.map_err(|e| {
pipeline::CreateRenderPipelineError::from(e).with_label(&desc.label)
})?,
}; };
let layout = pipeline_layout_guard.get(pipeline_layout_id).map_err(|_| { let layout = pipeline_layout_guard
pipeline::CreateRenderPipelineError::InvalidLayout.with_label(&desc.label) .get(pipeline_layout_id)
})?; .map_err(|_| pipeline::CreateRenderPipelineError::InvalidLayout)?;
let mut render_pass_cache = device.render_passes.lock(); let mut render_pass_cache = device.render_passes.lock();
let pipeline_desc = hal::pso::GraphicsPipelineDesc { let pipeline_desc = hal::pso::GraphicsPipelineDesc {
@ -2970,10 +2947,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
main_pass: match render_pass_cache.entry(rp_key) { main_pass: match render_pass_cache.entry(rp_key) {
Entry::Occupied(e) => e.into_mut(), Entry::Occupied(e) => e.into_mut(),
Entry::Vacant(e) => { Entry::Vacant(e) => {
let pass = device.create_compatible_render_pass(e.key()).or(Err( let pass = device
pipeline::CreateRenderPipelineError::from(DeviceError::OutOfMemory) .create_compatible_render_pass(e.key())
.with_label(&desc.label), .or(Err(DeviceError::OutOfMemory))?;
))?;
e.insert(pass) e.insert(pass)
} }
}, },
@ -2987,10 +2963,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
.raw .raw
.create_graphics_pipeline(&pipeline_desc, None) .create_graphics_pipeline(&pipeline_desc, None)
.map_err(|err| match err { .map_err(|err| match err {
hal::pso::CreationError::OutOfMemory(_) => { hal::pso::CreationError::OutOfMemory(_) => DeviceError::OutOfMemory,
pipeline::CreateRenderPipelineError::from(DeviceError::OutOfMemory)
.with_label(&desc.label)
}
_ => panic!("failed to create graphics pipeline: {}", err), _ => panic!("failed to create graphics pipeline: {}", err),
})? })?
}; };

View File

@ -238,11 +238,3 @@ fn test_default_limits() {
let limits = wgt::Limits::default(); let limits = wgt::Limits::default();
assert!(limits.max_bind_groups <= MAX_BIND_GROUPS as u32); assert!(limits.max_bind_groups <= MAX_BIND_GROUPS as u32);
} }
#[derive(Clone, Debug, thiserror::Error)]
#[error("{description} (label: {label:?})")]
pub struct LabeledContextError<E: std::error::Error + 'static> {
source: E,
description: &'static str,
label: Option<String>,
}

View File

@ -191,19 +191,6 @@ pub enum CreateRenderPipelineError {
}, },
} }
impl CreateRenderPipelineError {
pub(crate) fn with_label<'a>(
self,
label: &Option<Cow<'a, str>>,
) -> crate::LabeledContextError<CreateRenderPipelineError> {
crate::LabeledContextError {
source: self,
description: "Creating render pipeline",
label: label.as_ref().map(|inner| inner.to_string()),
}
}
}
bitflags::bitflags! { bitflags::bitflags! {
#[repr(transparent)] #[repr(transparent)]
pub struct PipelineFlags: u32 { pub struct PipelineFlags: u32 {