Skip to content

multi_draw_indirect dispatches one draw call even when count is set to 0  #6854

@davidhi7

Description

@davidhi7

Description
When calling RenderPass::multi_draw_indirect (or the indexed equivalent) with the count parameter set to 0, wgpu internally changes the draw count to 1.

Repro steps
See this sample gist: https://gist.github.com/davidhi7/47b35e393d83c0062f280737f765befb
This is effectively just the "hello-triangle" example changed to use indirect draw calls.

Expected vs observed behavior
If the count parameter is set to 0, then zero, and not one, draw calls should be dispatched.

Extra materials
I think the bug emerges here:

base.commands.push(ArcRenderCommand::MultiDrawIndirect {
buffer: self.resolve_render_pass_buffer_id(scope, buffer_id)?,
offset,
count: NonZeroU32::new(count),
indexed: false,
});

If count is 0, the command count field is set to None. Later, count: None is interpreted as a single indirect draw call:
MultiDrawIndirect {
buffer_id: id::BufferId,
offset: BufferAddress,
/// Count of `None` represents a non-multi call.
count: Option<NonZeroU32>,
indexed: bool,
},

Platform
wgpu v23.0.1
Intel UHD Graphics 620
On Arch Linux running Vulkan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions