[meta] Draw-time validation
Draw calls are the hottest operation in the API tight loops. It's highly desirable for WebGPU to minimize the overhead associated with them. Here are the things we either have to validate, or may need to validate, per draw:
- ensure that there is an active pipeline
- ensure the active bind groups have compatible layouts with the pipeline layout of the active pipeline
- check that index range is within the bound index buffer slice - #1834
- check that vertex/instance range is within all of the relevant vertex buffer slices (some are per-vertex, some are per-instance).
- check the minimum binding sizes for buffer bindings, which weren't specified in bind group layout - #874. For each such binding, we need to consider the size passed to bind group creation (for the active bind groups) and compare it with the shader requirements, reflected by the active pipeline.
- (not needed right now) check texture sample type and storage texture format - #851
- (rejected by the group) check all the intersections of writable buffer bindings (as well as writable storage textures) for fragment stage - #1842
This list is kind of concerning. 4) 5) 6) and 7) are all variable-length checks too and much more expensive than 1-3 (dirty bits can help for 1) and 2)). 5) can be mitigated by the application, but 4) is always a variable-length computation with overflow checks etc and makes me sad. That's also part of why 6) and 7) look unattractive.
I’d really love to see measured costs here.
Meeting: Moving this meta bug to post-V1, but if there are particular validations that we want to discuss moving for V1 we should file them separately.
WGSL meeting minutes 2022-01-19
- #1907 draw time validation
- KG: when do we want this implemented by?
- MM: what are the exit criteria?
- KN: it's essentially - can we move any of these out of draw time validation?
- Which are expensive enough that we want to?
- Probably could come up with a way to do this post-V1. Come up with new API for specifying things ahead of time.
- KG: think we should mark this as post-V1, and if someone feels strongly, we can revisit it.
- KN: agree we've probably talked about these enough that we're happy with them
- MM: if anyone wants to move specific items, think they can do that - but for this specific one, nothing actionable in this timeframe.