Skip to content

Commit 18a80e7

Browse files
[rs] Merge gfx-rs#254
254: Specify expected structure for draw_indirect and draw_indexed_indirect r=kvark a=lachlansneff ~~Based on https://www.khronos.org/opengl/wiki/Vertex_Rendering#Indirect_rendering.~~ Turns out the opengl docs are wrong. Based on https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkDrawIndirectCommand.html. Co-authored-by: Lachlan Sneff <[email protected]>
2 parents c3ebf3b + 3d7bc8c commit 18a80e7

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

wgpu/src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,6 +1447,18 @@ impl<'a> RenderPass<'a> {
14471447
/// Draws primitives from the active vertex buffer(s) based on the contents of the `indirect_buffer`.
14481448
///
14491449
/// The active vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
1450+
///
1451+
/// The structure expected in `indirect_buffer` is the following:
1452+
///
1453+
/// ```rust
1454+
/// #[repr(C)]
1455+
/// struct DrawIndirect {
1456+
/// vertex_count: u32, // The number of vertices to draw.
1457+
/// instance_count: u32, // The number of instances to draw.
1458+
/// base_vertex: u32, // The Index of the first vertex to draw.
1459+
/// base_instance: u32, // The instance ID of the first instance to draw.
1460+
/// }
1461+
/// ```
14501462
pub fn draw_indirect(&mut self, indirect_buffer: &'a Buffer, indirect_offset: BufferAddress) {
14511463
unsafe {
14521464
wgn::wgpu_render_pass_draw_indirect(
@@ -1462,6 +1474,19 @@ impl<'a> RenderPass<'a> {
14621474
///
14631475
/// The active index buffer can be set with [`RenderPass::set_index_buffer`], while the active
14641476
/// vertex buffers can be set with [`RenderPass::set_vertex_buffer`].
1477+
///
1478+
/// The structure expected in `indirect_buffer` is the following:
1479+
///
1480+
/// ```rust
1481+
/// #[repr(C)]
1482+
/// struct DrawIndexedIndirect {
1483+
/// vertex_count: u32, // The number of vertices to draw.
1484+
/// instance_count: u32, // The number of instances to draw.
1485+
/// base_index: u32, // The base index within the index buffer.
1486+
/// vertex_offset: i32, // The value added to the vertex index before indexing into the vertex buffer.
1487+
/// base_instance: u32, // The instance ID of the first instance to draw.
1488+
/// }
1489+
/// ```
14651490
pub fn draw_indexed_indirect(
14661491
&mut self,
14671492
indirect_buffer: &'a Buffer,

0 commit comments

Comments
 (0)