From 444da40484278b89ed07cd6f9e017def36fb216e Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Tue, 2 Oct 2018 21:41:03 -0400 Subject: [PATCH] rust: compute resource binding --- wgpu-rs/src/lib.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/wgpu-rs/src/lib.rs b/wgpu-rs/src/lib.rs index f288d1e726..3daa299070 100644 --- a/wgpu-rs/src/lib.rs +++ b/wgpu-rs/src/lib.rs @@ -35,6 +35,10 @@ pub struct BindGroupLayout { id: wgn::BindGroupLayoutId, } +pub struct BindGroup { + id: wgn::BindGroupId, +} + pub struct ShaderModule { id: wgn::ShaderModuleId, } @@ -59,6 +63,10 @@ pub struct RenderPipeline { id: wgn::RenderPipelineId, } +pub struct ComputePipeline { + id: wgn::ComputePipelineId, +} + pub struct CommandBuffer { id: wgn::CommandBufferId, } @@ -273,7 +281,16 @@ impl<'a> ComputePass<'a> { wgn::wgpu_compute_pass_end_pass(self.id); self.parent } - pub fn dispatch(&self, x: u32, y: u32, z: u32) { + + pub fn set_bind_group(&mut self, index: u32, bind_group: &BindGroup) { + wgn::wgpu_compute_pass_set_bind_group(self.id, index, bind_group.id); + } + + pub fn set_pipeline(&mut self, pipeline: &ComputePipeline) { + wgn::wgpu_compute_pass_set_pipeline(self.id, pipeline.id); + } + + pub fn dispatch(&mut self, x: u32, y: u32, z: u32) { wgn::wgpu_compute_pass_dispatch(self.id, x, y, z); } }