Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure safety of indirect draw/dispatch #2431

Open
1 of 3 tasks
kvark opened this issue Jan 28, 2022 · 5 comments
Open
1 of 3 tasks

Ensure safety of indirect draw/dispatch #2431

kvark opened this issue Jan 28, 2022 · 5 comments
Assignees
Labels
area: correctness We're behaving incorrectly help required We need community help to make this happen. type: enhancement New feature or request

Comments

@kvark
Copy link
Member

kvark commented Jan 28, 2022

When doing an indirect draw, the range of vertices/indices to draw needs to be within the bounds of the active vertex and index buffers. Similarly, indirect dispatches must be within the limits of the workgroup count.

@kvark kvark added type: enhancement New feature or request help required We need community help to make this happen. area: correctness We're behaving incorrectly labels Jan 28, 2022
@kvark
Copy link
Member Author

kvark commented Feb 10, 2022

Here is a rough plan:

  1. wgpu-hal expects platform-dependent draw/dispatch buffer.
  2. the only thing exposed to the outside is the size of that buffer (for each kind of draw/draw indexed/dispatch)
  3. wgpu-hal command encoder gets a new fn prepare_indirect(src_buffer, src_offset, dst_buffer, dst_offset, kind, count). Under the hood it will be a compute operation that does clamping as well as copies of first instance/vertex.
  4. wgpu-core spawns a separate encoder to prepare indirect calls whenever it sees one, and orders it accordingly. It also manages the destination buffer as a temporary thing.

@teoxoy
Copy link
Member

teoxoy commented Jan 24, 2024

When we get to this, we should also validate usage of the indirect-first-instance feature.

The value corresponding to firstInstance must be 0, unless the "indirect-first-instance" feature is enabled. If the "indirect-first-instance" feature is not enabled and firstInstance is not zero the drawIndirect() call will be treated as a no-op.

@ErichDonGubler
Copy link
Member

I've updated the OP with the scope of remaining changes I'm aware need to happen.

@ErichDonGubler
Copy link
Member

ErichDonGubler commented Sep 27, 2024

Downstream Firefox tracking for indirect dispatch: bug 1921342

@ErichDonGubler
Copy link
Member

Downstream Firefox tracking for indirect draws: bug 1930972

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: correctness We're behaving incorrectly help required We need community help to make this happen. type: enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

3 participants