mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Reverts the addition of LabeledContextError
Removed as discussed, moving them to wgpu-rs side
This commit is contained in:
parent
d423d3d5d7
commit
8252758674
@ -2597,7 +2597,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
implicit_pipeline_ids: Option<ImplicitPipelineIds<G>>,
|
||||
) -> Result<
|
||||
(id::RenderPipelineId, pipeline::ImplicitBindGroupCount),
|
||||
crate::LabeledContextError<pipeline::CreateRenderPipelineError>,
|
||||
pipeline::CreateRenderPipelineError,
|
||||
> {
|
||||
span!(_guard, INFO, "Device::create_render_pipeline");
|
||||
|
||||
@ -2607,8 +2607,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
let samples = {
|
||||
let sc = desc.sample_count;
|
||||
if sc == 0 || sc > 32 || !conv::is_power_of_two(sc) {
|
||||
return Err(pipeline::CreateRenderPipelineError::InvalidSampleCount(sc)
|
||||
.with_label(&desc.label));
|
||||
return Err(pipeline::CreateRenderPipelineError::InvalidSampleCount(sc));
|
||||
}
|
||||
sc as u8
|
||||
};
|
||||
@ -2641,8 +2640,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
return Err(pipeline::CreateRenderPipelineError::UnalignedVertexStride {
|
||||
index: i as u32,
|
||||
stride: vb_state.stride,
|
||||
}
|
||||
.with_label(&desc.label));
|
||||
});
|
||||
}
|
||||
vertex_buffers.alloc().init(hal::pso::VertexBufferDesc {
|
||||
binding: i as u32,
|
||||
@ -2659,8 +2657,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
pipeline::CreateRenderPipelineError::InvalidVertexAttributeOffset {
|
||||
location: attribute.shader_location,
|
||||
offset: attribute.offset,
|
||||
}
|
||||
.with_label(&desc.label),
|
||||
},
|
||||
);
|
||||
}
|
||||
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 = device_guard.get(device_id).map_err(|_| {
|
||||
pipeline::CreateRenderPipelineError::from(DeviceError::Invalid).with_label(&desc.label)
|
||||
})?;
|
||||
let device = device_guard
|
||||
.get(device_id)
|
||||
.map_err(|_| DeviceError::Invalid)?;
|
||||
if rasterization_state.clamp_depth
|
||||
&& !device.features.contains(wgt::Features::DEPTH_CLAMPING)
|
||||
{
|
||||
return Err(pipeline::CreateRenderPipelineError::MissingFeature(
|
||||
wgt::Features::DEPTH_CLAMPING,
|
||||
)
|
||||
.with_label(&desc.label));
|
||||
));
|
||||
}
|
||||
if rasterization_state.polygon_mode != wgt::PolygonMode::Fill
|
||||
&& !device
|
||||
@ -2734,8 +2730,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
{
|
||||
return Err(pipeline::CreateRenderPipelineError::MissingFeature(
|
||||
wgt::Features::NON_FILL_POLYGON_MODE,
|
||||
)
|
||||
.with_label(&desc.label));
|
||||
));
|
||||
}
|
||||
|
||||
let (raw_pipeline, layout_id, layout_ref_count, derived_bind_group_count) = {
|
||||
@ -2797,21 +2792,17 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
let shader_module =
|
||||
shader_module_guard
|
||||
.get(desc.vertex_stage.module)
|
||||
.map_err(|_| {
|
||||
pipeline::CreateRenderPipelineError::Stage {
|
||||
flag,
|
||||
error: validation::StageError::InvalidModule,
|
||||
}
|
||||
.with_label(&desc.label)
|
||||
.map_err(|_| pipeline::CreateRenderPipelineError::Stage {
|
||||
flag,
|
||||
error: validation::StageError::InvalidModule,
|
||||
})?;
|
||||
|
||||
if let Some(ref module) = shader_module.module {
|
||||
let group_layouts = match desc.layout {
|
||||
Some(pipeline_layout_id) => Device::get_introspection_bind_group_layouts(
|
||||
pipeline_layout_guard.get(pipeline_layout_id).map_err(|_| {
|
||||
pipeline::CreateRenderPipelineError::InvalidLayout
|
||||
.with_label(&desc.label)
|
||||
})?,
|
||||
pipeline_layout_guard
|
||||
.get(pipeline_layout_id)
|
||||
.map_err(|_| pipeline::CreateRenderPipelineError::InvalidLayout)?,
|
||||
&*bgl_guard,
|
||||
),
|
||||
None => validation::IntrospectionBindGroupLayouts::Derived(
|
||||
@ -2826,10 +2817,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
flag,
|
||||
interface,
|
||||
)
|
||||
.map_err(|error| {
|
||||
pipeline::CreateRenderPipelineError::Stage { flag, error }
|
||||
.with_label(&desc.label)
|
||||
})?;
|
||||
.map_err(|error| pipeline::CreateRenderPipelineError::Stage { flag, error })?;
|
||||
validated_stages |= flag;
|
||||
}
|
||||
|
||||
@ -2850,15 +2838,13 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
flag,
|
||||
error: validation::StageError::InvalidModule,
|
||||
}
|
||||
.with_label(&desc.label)
|
||||
})?;
|
||||
|
||||
let group_layouts = match desc.layout {
|
||||
Some(pipeline_layout_id) => Device::get_introspection_bind_group_layouts(
|
||||
pipeline_layout_guard.get(pipeline_layout_id).map_err(|_| {
|
||||
pipeline::CreateRenderPipelineError::InvalidLayout
|
||||
.with_label(&desc.label)
|
||||
})?,
|
||||
pipeline_layout_guard
|
||||
.get(pipeline_layout_id)
|
||||
.map_err(|_| pipeline::CreateRenderPipelineError::InvalidLayout)?,
|
||||
&*bgl_guard,
|
||||
),
|
||||
None => validation::IntrospectionBindGroupLayouts::Derived(
|
||||
@ -2877,7 +2863,6 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
)
|
||||
.map_err(|error| {
|
||||
pipeline::CreateRenderPipelineError::Stage { flag, error }
|
||||
.with_label(&desc.label)
|
||||
})?;
|
||||
validated_stages |= flag;
|
||||
}
|
||||
@ -2905,8 +2890,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
return Err(
|
||||
pipeline::CreateRenderPipelineError::IncompatibleOutputFormat {
|
||||
index: i as u8,
|
||||
}
|
||||
.with_label(&desc.label),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -2916,10 +2900,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
None => wgt::ShaderStage::VERTEX,
|
||||
};
|
||||
if desc.layout.is_none() && !validated_stages.contains(last_stage) {
|
||||
Err(pipeline::CreateRenderPipelineError::from(
|
||||
pipeline::ImplicitLayoutError::ReflectionError(last_stage),
|
||||
)
|
||||
.with_label(&desc.label))?
|
||||
Err(pipeline::ImplicitLayoutError::ReflectionError(last_stage))?
|
||||
}
|
||||
|
||||
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 {
|
||||
Some(id) => (id, 0),
|
||||
None => self
|
||||
.derive_pipeline_layout(
|
||||
device,
|
||||
device_id,
|
||||
implicit_pipeline_ids,
|
||||
derived_group_layouts,
|
||||
&mut *bgl_guard,
|
||||
&mut *pipeline_layout_guard,
|
||||
)
|
||||
.map_err(|e| {
|
||||
pipeline::CreateRenderPipelineError::from(e).with_label(&desc.label)
|
||||
})?,
|
||||
None => self.derive_pipeline_layout(
|
||||
device,
|
||||
device_id,
|
||||
implicit_pipeline_ids,
|
||||
derived_group_layouts,
|
||||
&mut *bgl_guard,
|
||||
&mut *pipeline_layout_guard,
|
||||
)?,
|
||||
};
|
||||
let layout = pipeline_layout_guard.get(pipeline_layout_id).map_err(|_| {
|
||||
pipeline::CreateRenderPipelineError::InvalidLayout.with_label(&desc.label)
|
||||
})?;
|
||||
let layout = pipeline_layout_guard
|
||||
.get(pipeline_layout_id)
|
||||
.map_err(|_| pipeline::CreateRenderPipelineError::InvalidLayout)?;
|
||||
|
||||
let mut render_pass_cache = device.render_passes.lock();
|
||||
let pipeline_desc = hal::pso::GraphicsPipelineDesc {
|
||||
@ -2970,10 +2947,9 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
main_pass: match render_pass_cache.entry(rp_key) {
|
||||
Entry::Occupied(e) => e.into_mut(),
|
||||
Entry::Vacant(e) => {
|
||||
let pass = device.create_compatible_render_pass(e.key()).or(Err(
|
||||
pipeline::CreateRenderPipelineError::from(DeviceError::OutOfMemory)
|
||||
.with_label(&desc.label),
|
||||
))?;
|
||||
let pass = device
|
||||
.create_compatible_render_pass(e.key())
|
||||
.or(Err(DeviceError::OutOfMemory))?;
|
||||
e.insert(pass)
|
||||
}
|
||||
},
|
||||
@ -2987,10 +2963,7 @@ impl<G: GlobalIdentityHandlerFactory> Global<G> {
|
||||
.raw
|
||||
.create_graphics_pipeline(&pipeline_desc, None)
|
||||
.map_err(|err| match err {
|
||||
hal::pso::CreationError::OutOfMemory(_) => {
|
||||
pipeline::CreateRenderPipelineError::from(DeviceError::OutOfMemory)
|
||||
.with_label(&desc.label)
|
||||
}
|
||||
hal::pso::CreationError::OutOfMemory(_) => DeviceError::OutOfMemory,
|
||||
_ => panic!("failed to create graphics pipeline: {}", err),
|
||||
})?
|
||||
};
|
||||
|
||||
@ -238,11 +238,3 @@ fn test_default_limits() {
|
||||
let limits = wgt::Limits::default();
|
||||
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>,
|
||||
}
|
||||
|
||||
@ -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! {
|
||||
#[repr(transparent)]
|
||||
pub struct PipelineFlags: u32 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user