diff --git a/deno_webgpu/device.rs b/deno_webgpu/device.rs index 211cdc513..7a1248246 100644 --- a/deno_webgpu/device.rs +++ b/deno_webgpu/device.rs @@ -651,7 +651,7 @@ impl GPUDevice { let (id, err) = self.instance - .device_create_compute_pipeline(self.id, &wgpu_descriptor, None, None); + .device_create_compute_pipeline(self.id, &wgpu_descriptor, None); self.error_handler.push_error(err); @@ -818,7 +818,7 @@ impl GPUDevice { let (id, err) = self.instance - .device_create_render_pipeline(self.id, &wgpu_descriptor, None, None); + .device_create_render_pipeline(self.id, &wgpu_descriptor, None); self.error_handler.push_error(err); diff --git a/player/src/lib.rs b/player/src/lib.rs index 90f3fd882..4b805e9d4 100644 --- a/player/src/lib.rs +++ b/player/src/lib.rs @@ -298,20 +298,8 @@ impl GlobalPlay for wgc::global::Global { Action::DestroyShaderModule(id) => { self.shader_module_drop(id); } - Action::CreateComputePipeline { - id, - desc, - implicit_context, - } => { - let implicit_ids = - implicit_context - .as_ref() - .map(|ic| wgc::device::ImplicitPipelineIds { - root_id: ic.root_id, - group_ids: &ic.group_ids, - }); - let (_, error) = - self.device_create_compute_pipeline(device, &desc, Some(id), implicit_ids); + Action::CreateComputePipeline { id, desc } => { + let (_, error) = self.device_create_compute_pipeline(device, &desc, Some(id)); if let Some(e) = error { panic!("{e}"); } @@ -319,20 +307,8 @@ impl GlobalPlay for wgc::global::Global { Action::DestroyComputePipeline(id) => { self.compute_pipeline_drop(id); } - Action::CreateRenderPipeline { - id, - desc, - implicit_context, - } => { - let implicit_ids = - implicit_context - .as_ref() - .map(|ic| wgc::device::ImplicitPipelineIds { - root_id: ic.root_id, - group_ids: &ic.group_ids, - }); - let (_, error) = - self.device_create_render_pipeline(device, &desc, Some(id), implicit_ids); + Action::CreateRenderPipeline { id, desc } => { + let (_, error) = self.device_create_render_pipeline(device, &desc, Some(id)); if let Some(e) = error { panic!("{e}"); } diff --git a/wgpu-core/src/device/global.rs b/wgpu-core/src/device/global.rs index 92d0ea54b..0fc9da4aa 100644 --- a/wgpu-core/src/device/global.rs +++ b/wgpu-core/src/device/global.rs @@ -30,7 +30,7 @@ use crate::{ use wgt::{BufferAddress, TextureFormat}; -use super::{ImplicitPipelineIds, UserClosures}; +use super::UserClosures; impl Global { pub fn adapter_is_surface_supported( @@ -1228,7 +1228,6 @@ impl Global { device_id: DeviceId, desc: &pipeline::RenderPipelineDescriptor, id_in: Option, - implicit_pipeline_ids: Option>, ) -> ( id::RenderPipelineId, Option, @@ -1237,18 +1236,9 @@ impl Global { let hub = &self.hub; - let missing_implicit_pipeline_ids = - desc.layout.is_none() && id_in.is_some() && implicit_pipeline_ids.is_none(); - let fid = hub.render_pipelines.prepare(id_in); - let implicit_context = implicit_pipeline_ids.map(|ipi| ipi.prepare(hub)); let error = 'error: { - if missing_implicit_pipeline_ids { - // TODO: categorize this error as API misuse - break 'error pipeline::ImplicitLayoutError::MissingImplicitPipelineIds.into(); - } - let device = self.hub.devices.get(device_id); #[cfg(feature = "trace")] @@ -1256,7 +1246,6 @@ impl Global { trace.add(trace::Action::CreateRenderPipeline { id: fid.id(), desc: desc.clone(), - implicit_context: implicit_context.clone(), }); } @@ -1357,40 +1346,6 @@ impl Global { Err(e) => break 'error e, }; - if let Some(ids) = implicit_context.as_ref() { - let group_count = pipeline.layout.bind_group_layouts.len(); - if ids.group_ids.len() < group_count { - log::error!( - "Not enough bind group IDs ({}) specified for the implicit layout ({})", - ids.group_ids.len(), - group_count - ); - // TODO: categorize this error as API misuse - break 'error pipeline::ImplicitLayoutError::MissingIds(group_count as _) - .into(); - } - - let mut pipeline_layout_guard = hub.pipeline_layouts.write(); - let mut bgl_guard = hub.bind_group_layouts.write(); - pipeline_layout_guard.insert(ids.root_id, Fallible::Valid(pipeline.layout.clone())); - let mut group_ids = ids.group_ids.iter(); - // NOTE: If the first iterator is longer than the second, the `.zip()` impl will still advance the - // the first iterator before realizing that the second iterator has finished. - // The `pipeline.layout.bind_group_layouts` iterator will always be shorter than `ids.group_ids`, - // so using it as the first iterator for `.zip()` will work properly. - for (bgl, bgl_id) in pipeline - .layout - .bind_group_layouts - .iter() - .zip(&mut group_ids) - { - bgl_guard.insert(*bgl_id, Fallible::Valid(bgl.clone())); - } - for bgl_id in group_ids { - bgl_guard.insert(*bgl_id, Fallible::Invalid(Arc::new(String::new()))); - } - } - let id = fid.assign(Fallible::Valid(pipeline)); api_log!("Device::create_render_pipeline -> {id:?}"); @@ -1399,17 +1354,6 @@ impl Global { 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. - if let Some(ids) = implicit_context { - let mut pipeline_layout_guard = hub.pipeline_layouts.write(); - let mut bgl_guard = hub.bind_group_layouts.write(); - pipeline_layout_guard.insert(ids.root_id, Fallible::Invalid(Arc::new(String::new()))); - for bgl_id in ids.group_ids { - bgl_guard.insert(bgl_id, Fallible::Invalid(Arc::new(String::new()))); - } - } - (id, Some(error)) } @@ -1467,7 +1411,6 @@ impl Global { device_id: DeviceId, desc: &pipeline::ComputePipelineDescriptor, id_in: Option, - implicit_pipeline_ids: Option>, ) -> ( id::ComputePipelineId, Option, @@ -1476,18 +1419,9 @@ impl Global { let hub = &self.hub; - let missing_implicit_pipeline_ids = - desc.layout.is_none() && id_in.is_some() && implicit_pipeline_ids.is_none(); - let fid = hub.compute_pipelines.prepare(id_in); - let implicit_context = implicit_pipeline_ids.map(|ipi| ipi.prepare(hub)); let error = 'error: { - if missing_implicit_pipeline_ids { - // TODO: categorize this error as API misuse - break 'error pipeline::ImplicitLayoutError::MissingImplicitPipelineIds.into(); - } - let device = self.hub.devices.get(device_id); #[cfg(feature = "trace")] @@ -1495,7 +1429,6 @@ impl Global { trace.add(trace::Action::CreateComputePipeline { id: fid.id(), desc: desc.clone(), - implicit_context: implicit_context.clone(), }); } @@ -1545,40 +1478,6 @@ impl Global { Err(e) => break 'error e, }; - if let Some(ids) = implicit_context.as_ref() { - let group_count = pipeline.layout.bind_group_layouts.len(); - if ids.group_ids.len() < group_count { - log::error!( - "Not enough bind group IDs ({}) specified for the implicit layout ({})", - ids.group_ids.len(), - group_count - ); - // TODO: categorize this error as API misuse - break 'error pipeline::ImplicitLayoutError::MissingIds(group_count as _) - .into(); - } - - let mut pipeline_layout_guard = hub.pipeline_layouts.write(); - let mut bgl_guard = hub.bind_group_layouts.write(); - pipeline_layout_guard.insert(ids.root_id, Fallible::Valid(pipeline.layout.clone())); - let mut group_ids = ids.group_ids.iter(); - // NOTE: If the first iterator is longer than the second, the `.zip()` impl will still advance the - // the first iterator before realizing that the second iterator has finished. - // The `pipeline.layout.bind_group_layouts` iterator will always be shorter than `ids.group_ids`, - // so using it as the first iterator for `.zip()` will work properly. - for (bgl, bgl_id) in pipeline - .layout - .bind_group_layouts - .iter() - .zip(&mut group_ids) - { - bgl_guard.insert(*bgl_id, Fallible::Valid(bgl.clone())); - } - for bgl_id in group_ids { - bgl_guard.insert(*bgl_id, Fallible::Invalid(Arc::new(String::new()))); - } - } - let id = fid.assign(Fallible::Valid(pipeline)); api_log!("Device::create_compute_pipeline -> {id:?}"); @@ -1587,17 +1486,6 @@ impl Global { 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. - if let Some(ids) = implicit_context { - let mut pipeline_layout_guard = hub.pipeline_layouts.write(); - let mut bgl_guard = hub.bind_group_layouts.write(); - pipeline_layout_guard.insert(ids.root_id, Fallible::Invalid(Arc::new(String::new()))); - for bgl_id in ids.group_ids { - bgl_guard.insert(bgl_id, Fallible::Invalid(Arc::new(String::new()))); - } - } - (id, Some(error)) } diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 2a1c7febd..ad60e106d 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -3,8 +3,6 @@ use core::{fmt, num::NonZeroU32}; use crate::{ binding_model, - hub::Hub, - id::{BindGroupLayoutId, PipelineLayoutId}, ray_tracing::BlasCompactReadyPendingClosure, resource::{ Buffer, BufferAccessError, BufferAccessResult, BufferMapOperation, Labeled, @@ -385,31 +383,6 @@ impl WebGpuError for MissingDownlevelFlags { } } -#[derive(Clone, Debug)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub struct ImplicitPipelineContext { - pub root_id: PipelineLayoutId, - pub group_ids: ArrayVec, -} - -pub struct ImplicitPipelineIds<'a> { - pub root_id: PipelineLayoutId, - pub group_ids: &'a [BindGroupLayoutId], -} - -impl ImplicitPipelineIds<'_> { - fn prepare(self, hub: &Hub) -> ImplicitPipelineContext { - ImplicitPipelineContext { - root_id: hub.pipeline_layouts.prepare(Some(self.root_id)).id(), - group_ids: self - .group_ids - .iter() - .map(|id_in| hub.bind_group_layouts.prepare(Some(*id_in)).id()) - .collect(), - } - } -} - /// Create a validator with the given validation flags. pub fn create_validator( features: wgt::Features, diff --git a/wgpu-core/src/device/trace.rs b/wgpu-core/src/device/trace.rs index 33025818f..220a2406d 100644 --- a/wgpu-core/src/device/trace.rs +++ b/wgpu-core/src/device/trace.rs @@ -90,15 +90,11 @@ pub enum Action<'a> { CreateComputePipeline { id: id::ComputePipelineId, desc: crate::pipeline::ComputePipelineDescriptor<'a>, - #[cfg_attr(feature = "replay", serde(default))] - implicit_context: Option, }, DestroyComputePipeline(id::ComputePipelineId), CreateRenderPipeline { id: id::RenderPipelineId, desc: crate::pipeline::RenderPipelineDescriptor<'a>, - #[cfg_attr(feature = "replay", serde(default))] - implicit_context: Option, }, DestroyRenderPipeline(id::RenderPipelineId), CreatePipelineCache { diff --git a/wgpu-core/src/pipeline.rs b/wgpu-core/src/pipeline.rs index cdc88f9f3..7d055b705 100644 --- a/wgpu-core/src/pipeline.rs +++ b/wgpu-core/src/pipeline.rs @@ -190,10 +190,6 @@ pub type ImplicitBindGroupCount = u8; #[derive(Clone, Debug, Error)] #[non_exhaustive] pub enum ImplicitLayoutError { - #[error("The implicit_pipeline_ids arg is required")] - MissingImplicitPipelineIds, - #[error("Missing IDs for deriving {0} bind groups")] - MissingIds(ImplicitBindGroupCount), #[error("Unable to reflect the shader {0:?} interface")] ReflectionError(wgt::ShaderStages), #[error(transparent)] @@ -205,9 +201,7 @@ pub enum ImplicitLayoutError { impl WebGpuError for ImplicitLayoutError { fn webgpu_error_type(&self) -> ErrorType { let e: &dyn WebGpuError = match self { - Self::MissingImplicitPipelineIds | Self::MissingIds(_) | Self::ReflectionError(_) => { - return ErrorType::Validation - } + Self::ReflectionError(_) => return ErrorType::Validation, Self::BindGroup(e) => e, Self::Pipeline(e) => e, }; diff --git a/wgpu-core/src/registry.rs b/wgpu-core/src/registry.rs index 81b0b54ab..3ff81dc73 100644 --- a/wgpu-core/src/registry.rs +++ b/wgpu-core/src/registry.rs @@ -3,7 +3,7 @@ use alloc::sync::Arc; use crate::{ id::Id, identity::IdentityManager, - lock::{rank, RwLock, RwLockReadGuard, RwLockWriteGuard}, + lock::{rank, RwLock, RwLockReadGuard}, storage::{Element, Storage, StorageItem}, }; @@ -55,6 +55,7 @@ pub(crate) struct FutureId<'a, T: StorageItem> { } impl FutureId<'_, T> { + #[cfg(feature = "trace")] pub fn id(&self) -> Id { self.id } @@ -87,10 +88,6 @@ impl Registry { pub(crate) fn read<'a>(&'a self) -> RwLockReadGuard<'a, Storage> { self.storage.read() } - #[track_caller] - pub(crate) fn write<'a>(&'a self) -> RwLockWriteGuard<'a, Storage> { - self.storage.write() - } pub(crate) fn remove(&self, id: Id) -> T { let value = self.storage.write().remove(id); // This needs to happen *after* removing it from the storage, to maintain the diff --git a/wgpu/src/backend/wgpu_core.rs b/wgpu/src/backend/wgpu_core.rs index 15fb57a45..85c904af1 100644 --- a/wgpu/src/backend/wgpu_core.rs +++ b/wgpu/src/backend/wgpu_core.rs @@ -1321,10 +1321,10 @@ impl dispatch::DeviceInterface for CoreDevice { cache: desc.cache.map(|cache| cache.inner.as_core().id), }; - let (id, error) = - self.context - .0 - .device_create_render_pipeline(self.id, &descriptor, None, None); + let (id, error) = self + .context + .0 + .device_create_render_pipeline(self.id, &descriptor, None); if let Some(cause) = error { if let wgc::pipeline::CreateRenderPipelineError::Internal { stage, ref error } = cause { log::error!("Shader translation error for stage {stage:?}: {error}"); @@ -1372,10 +1372,10 @@ impl dispatch::DeviceInterface for CoreDevice { cache: desc.cache.map(|cache| cache.inner.as_core().id), }; - let (id, error) = - self.context - .0 - .device_create_compute_pipeline(self.id, &descriptor, None, None); + let (id, error) = self + .context + .0 + .device_create_compute_pipeline(self.id, &descriptor, None); if let Some(cause) = error { if let wgc::pipeline::CreateComputePipelineError::Internal(ref error) = cause { log::error!(