mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
[wgpu-core] use Fallible
for ComputePipeline
This commit is contained in:
parent
b42500ee40
commit
82ce2ea747
@ -8,7 +8,7 @@ static PIPELINE_DEFAULT_LAYOUT_BAD_MODULE: GpuTestConfiguration = GpuTestConfigu
|
||||
.parameters(
|
||||
TestParameters::default()
|
||||
// https://github.com/gfx-rs/wgpu/issues/4167
|
||||
.expect_fail(FailureCase::always().panic("Pipeline is invalid")),
|
||||
.expect_fail(FailureCase::always().panic("Error reflecting bind group")),
|
||||
)
|
||||
.run_sync(|ctx| {
|
||||
ctx.device.push_error_scope(wgpu::ErrorFilter::Validation);
|
||||
|
@ -1003,6 +1003,8 @@ pub enum GetBindGroupLayoutError {
|
||||
InvalidPipeline,
|
||||
#[error("Invalid group index {0}")]
|
||||
InvalidGroupIndex(u32),
|
||||
#[error(transparent)]
|
||||
InvalidResource(#[from] InvalidResourceError),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Error, Eq, PartialEq)]
|
||||
|
@ -134,8 +134,6 @@ pub enum ComputePassErrorInner {
|
||||
InvalidParentEncoder,
|
||||
#[error("Bind group index {index} is greater than the device's requested `max_bind_group` limit {max}")]
|
||||
BindGroupIndexOutOfRange { index: u32, max: u32 },
|
||||
#[error("ComputePipelineId {0:?} is invalid")]
|
||||
InvalidPipelineId(id::ComputePipelineId),
|
||||
#[error(transparent)]
|
||||
DestroyedResource(#[from] DestroyedResourceError),
|
||||
#[error("Indirect buffer uses bytes {offset}..{end_offset} which overruns indirect buffer of size {buffer_size}")]
|
||||
@ -1016,8 +1014,8 @@ impl Global {
|
||||
let hub = &self.hub;
|
||||
let pipeline = hub
|
||||
.compute_pipelines
|
||||
.get(pipeline_id)
|
||||
.map_err(|_| ComputePassErrorInner::InvalidPipelineId(pipeline_id))
|
||||
.strict_get(pipeline_id)
|
||||
.get()
|
||||
.map_pass_err(scope)?;
|
||||
|
||||
base.commands.push(ArcComputeCommand::SetPipeline(pipeline));
|
||||
|
@ -74,7 +74,7 @@ impl ComputeCommand {
|
||||
hub: &crate::hub::Hub,
|
||||
commands: &[ComputeCommand],
|
||||
) -> Result<Vec<ArcComputeCommand>, super::ComputePassError> {
|
||||
use super::{ComputePassError, ComputePassErrorInner, PassErrorScope};
|
||||
use super::{ComputePassError, PassErrorScope};
|
||||
|
||||
let buffers_guard = hub.buffers.read();
|
||||
let bind_group_guard = hub.bind_groups.read();
|
||||
@ -114,12 +114,12 @@ impl ComputeCommand {
|
||||
}
|
||||
}
|
||||
ComputeCommand::SetPipeline(pipeline_id) => ArcComputeCommand::SetPipeline(
|
||||
pipelines_guard
|
||||
.get_owned(pipeline_id)
|
||||
.map_err(|_| ComputePassError {
|
||||
pipelines_guard.strict_get(pipeline_id).get().map_err(|e| {
|
||||
ComputePassError {
|
||||
scope: PassErrorScope::SetPipelineCompute,
|
||||
inner: ComputePassErrorInner::InvalidPipelineId(pipeline_id),
|
||||
})?,
|
||||
inner: e.into(),
|
||||
}
|
||||
})?,
|
||||
),
|
||||
|
||||
ComputeCommand::SetPushConstant {
|
||||
|
@ -1547,13 +1547,13 @@ impl Global {
|
||||
}
|
||||
}
|
||||
|
||||
let id = fid.assign(pipeline);
|
||||
let id = fid.assign(Fallible::Valid(pipeline));
|
||||
api_log!("Device::create_compute_pipeline -> {id:?}");
|
||||
|
||||
return (id, None);
|
||||
};
|
||||
|
||||
let id = fid.assign_error();
|
||||
let id = fid.assign(Fallible::Invalid(Arc::new(desc.label.to_string())));
|
||||
|
||||
// We also need to assign errors to the implicit pipeline layout and the
|
||||
// implicit bind group layouts.
|
||||
@ -1583,9 +1583,9 @@ impl Global {
|
||||
let hub = &self.hub;
|
||||
|
||||
let error = 'error: {
|
||||
let pipeline = match hub.compute_pipelines.get(pipeline_id) {
|
||||
let pipeline = match hub.compute_pipelines.strict_get(pipeline_id).get() {
|
||||
Ok(pipeline) => pipeline,
|
||||
Err(_) => break 'error binding_model::GetBindGroupLayoutError::InvalidPipeline,
|
||||
Err(e) => break 'error e.into(),
|
||||
};
|
||||
|
||||
let id = match pipeline.layout.bind_group_layouts.get(index as usize) {
|
||||
@ -1614,9 +1614,11 @@ impl Global {
|
||||
|
||||
let hub = &self.hub;
|
||||
|
||||
if let Some(_pipeline) = hub.compute_pipelines.unregister(compute_pipeline_id) {
|
||||
#[cfg(feature = "trace")]
|
||||
if let Some(t) = _pipeline.device.trace.lock().as_mut() {
|
||||
let _pipeline = hub.compute_pipelines.strict_unregister(compute_pipeline_id);
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
if let Ok(pipeline) = _pipeline.get() {
|
||||
if let Some(t) = pipeline.device.trace.lock().as_mut() {
|
||||
t.add(trace::Action::DestroyComputePipeline(compute_pipeline_id));
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ pub struct Hub {
|
||||
pub(crate) command_buffers: Registry<Arc<CommandBuffer>>,
|
||||
pub(crate) render_bundles: Registry<Arc<RenderBundle>>,
|
||||
pub(crate) render_pipelines: Registry<Arc<RenderPipeline>>,
|
||||
pub(crate) compute_pipelines: Registry<Arc<ComputePipeline>>,
|
||||
pub(crate) compute_pipelines: Registry<Fallible<ComputePipeline>>,
|
||||
pub(crate) pipeline_caches: Registry<Arc<PipelineCache>>,
|
||||
pub(crate) query_sets: Registry<Fallible<QuerySet>>,
|
||||
pub(crate) buffers: Registry<Fallible<Buffer>>,
|
||||
|
Loading…
Reference in New Issue
Block a user