From 3f0256bf4eef955f730cc941c3cf7146dfdd5087 Mon Sep 17 00:00:00 2001 From: Tristam MacDonald Date: Sun, 15 Sep 2019 12:57:22 -0700 Subject: [PATCH] Add indirect draw/dispatch methods --- src/lib.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 60f3be1dfd..1b31aed5f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1248,6 +1248,22 @@ impl<'a> RenderPass<'a> { instances.start, ); } + + /// Draws primitives from the active vertex buffer(s) based on the contents of the `indirect_buffer`. + /// + /// The active vertex buffers can be set with [`RenderPass::set_vertex_buffers`]. + pub fn draw_indirect(&mut self, indirect_buffer: &Buffer, indirect_offset: BufferAddress) { + wgn::wgpu_render_pass_draw_indirect(self.id, indirect_buffer.id, indirect_offset); + } + + /// Draws indexed primitives using the active index buffer and the active vertex buffers, + /// based on the contents of the `indirect_buffer`. + /// + /// The active index buffer can be set with [`RenderPass::set_index_buffer`], while the active + /// vertex buffers can be set with [`RenderPass::set_vertex_buffers`]. + pub fn draw_indexed_indirect(&mut self, indirect_buffer: &Buffer, indirect_offset: BufferAddress) { + wgn::wgpu_render_pass_draw_indexed_indirect(self.id, indirect_buffer.id, indirect_offset); + } } impl<'a> Drop for RenderPass<'a> { @@ -1286,6 +1302,11 @@ impl<'a> ComputePass<'a> { pub fn dispatch(&mut self, x: u32, y: u32, z: u32) { wgn::wgpu_compute_pass_dispatch(self.id, x, y, z); } + + /// Dispatches compute work operations, based on the contents of the `indirect_buffer`. + pub fn dispatch_indirect(&mut self, indirect_buffer: &Buffer, indirect_offset: BufferAddress) { + wgn::wgpu_compute_pass_dispatch_indirect(self.id, indirect_buffer.id, indirect_offset); + } } impl<'a> Drop for ComputePass<'a> {