pebble/wgpu/
compute_pass.rs1use crate::wgpu::{buffers::BindGroup, compute::ComputePipeline};
2
3pub struct ComputePass<'a> {
8 raw: wgpu::ComputePass<'a>,
9}
10
11impl<'a> ComputePass<'a> {
12 pub(crate) fn new(raw: wgpu::ComputePass<'a>) -> Self {
13 Self { raw }
14 }
15
16 pub fn set_pipeline(&mut self, pipeline: &ComputePipeline) {
17 self.raw.set_pipeline(pipeline.raw());
18 }
19
20 pub fn set_bind_group(&mut self, index: u32, bind_group: &BindGroup, offsets: &[u32]) {
24 self.raw.set_bind_group(index, Some(bind_group.raw()), offsets);
25 }
26
27 pub fn dispatch_workgroups(&mut self, x: u32, y: u32, z: u32) {
28 self.raw.dispatch_workgroups(x, y, z);
29 }
30}
31
32pub struct CommandEncoder {
39 raw: wgpu::CommandEncoder,
40}
41
42impl CommandEncoder {
43 pub(crate) fn new(raw: wgpu::CommandEncoder) -> Self {
44 Self { raw }
45 }
46
47 pub fn compute_pass(&mut self, label: Option<&str>) -> ComputePass<'_> {
48 let raw = self.raw.begin_compute_pass(&wgpu::ComputePassDescriptor {
49 label,
50 timestamp_writes: None,
51 });
52 ComputePass::new(raw)
53 }
54
55 pub(crate) fn into_raw(self) -> wgpu::CommandEncoder {
56 self.raw
57 }
58}