wgpu
wgpu copied to clipboard
Ensure safety of indirect draw/dispatch
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.
- [x] #5714
- [ ] Ensure safety of indirect draw
- [ ] Enforce a no-op if the device does not have
INDIRECT_FIRST_INSTANCEfeature enabled.
Here is a rough plan:
- wgpu-hal expects platform-dependent draw/dispatch buffer.
- the only thing exposed to the outside is the size of that buffer (for each kind of draw/draw indexed/dispatch)
- 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. - 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.
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.
I've updated the OP with the scope of remaining changes I'm aware need to happen.
Downstream Firefox tracking for indirect dispatch: bug 1921342
Downstream Firefox tracking for indirect draws: bug 1930972