diff --git a/wgpu/src/backend/direct.rs b/wgpu/src/backend/direct.rs index 07f6d01880..2cdb91d878 100644 --- a/wgpu/src/backend/direct.rs +++ b/wgpu/src/backend/direct.rs @@ -1042,6 +1042,23 @@ impl crate::Context for Context { wgc::gfx_select!(*pipeline => global.render_pipeline_drop(*pipeline)) } + fn compute_pipeline_get_bind_group_layout( + &self, + pipeline: &Self::ComputePipelineId, + index: u32, + ) -> Self::BindGroupLayoutId { + let global = &self.0; + wgc::gfx_select!(*pipeline => global.compute_pipeline_get_bind_group_layout(*pipeline, index)).unwrap() + } + fn render_pipeline_get_bind_group_layout( + &self, + pipeline: &Self::RenderPipelineId, + index: u32, + ) -> Self::BindGroupLayoutId { + let global = &self.0; + wgc::gfx_select!(*pipeline => global.render_pipeline_get_bind_group_layout(*pipeline, index)).unwrap() + } + fn command_encoder_copy_buffer_to_buffer( &self, encoder: &Self::CommandEncoderId, diff --git a/wgpu/src/backend/web.rs b/wgpu/src/backend/web.rs index 02186b8fb8..aae3142b8e 100644 --- a/wgpu/src/backend/web.rs +++ b/wgpu/src/backend/web.rs @@ -1254,6 +1254,21 @@ impl crate::Context for Context { // Dropped automatically } + fn compute_pipeline_get_bind_group_layout( + &self, + _pipeline: &Self::ComputePipelineId, + _index: u32, + ) -> Self::BindGroupLayoutId { + unimplemented!() + } + fn render_pipeline_get_bind_group_layout( + &self, + _pipeline: &Self::RenderPipelineId, + _index: u32, + ) -> Self::BindGroupLayoutId { + unimplemented!() + } + fn command_encoder_copy_buffer_to_buffer( &self, encoder: &Self::CommandEncoderId, diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 5439eda683..802ae39485 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -306,6 +306,17 @@ trait Context: Debug + Send + Sized + Sync { fn compute_pipeline_drop(&self, pipeline: &Self::ComputePipelineId); fn render_pipeline_drop(&self, pipeline: &Self::RenderPipelineId); + fn compute_pipeline_get_bind_group_layout( + &self, + pipeline: &Self::ComputePipelineId, + index: u32, + ) -> Self::BindGroupLayoutId; + fn render_pipeline_get_bind_group_layout( + &self, + pipeline: &Self::RenderPipelineId, + index: u32, + ) -> Self::BindGroupLayoutId; + fn command_encoder_copy_buffer_to_buffer( &self, encoder: &Self::CommandEncoderId, @@ -682,6 +693,19 @@ impl Drop for RenderPipeline { } } +impl RenderPipeline { + /// Get an object representing the bind group layout at a given index. + pub fn get_bind_group_layout(&self, index: u32) -> BindGroupLayout { + let context = Arc::clone(&self.context); + BindGroupLayout { + context, + id: self + .context + .render_pipeline_get_bind_group_layout(&self.id, index), + } + } +} + /// Handle to a compute pipeline. /// /// A `ComputePipeline` object represents a compute pipeline and its single shader stage. @@ -700,6 +724,19 @@ impl Drop for ComputePipeline { } } +impl ComputePipeline { + /// Get an object representing the bind group layout at a given index. + pub fn get_bind_group_layout(&self, index: u32) -> BindGroupLayout { + let context = Arc::clone(&self.context); + BindGroupLayout { + context, + id: self + .context + .compute_pipeline_get_bind_group_layout(&self.id, index), + } + } +} + /// Handle to a command buffer on the GPU. /// /// A `CommandBuffer` represents a complete sequence of commands that may be submitted to a command