You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Figure out whether indirectBuffer OOB is a validation error #1834
In #955 (scenario 5), it was recorded that we decided not to generate validation errors when draw calls go out of bounds on indirect buffers.
However, in #980 we (accidentally, I think) ended up speccing that it does. Editors should revisit to resolve this.
As an analogy to index-buffer-OOB behavior, it makes sense that no validation error would be raised here:
drawIndexed could produce a validation error on index-buffer-OOB, but would be inconsistent with drawIndexedIndirect. Consistency also allows implementations to upgrade drawIndexed to drawIndexedIndirect if they want to.
drawIndirect/drawIndexedIndirect could produce a validation error on indirect-buffer-OOB, but would (probably) be inconsistent with drawIndirectCount/drawIndexedIndirectCount (which we don't have, but exist in Vulkan). Consistency also allows implementations to upgrade to the drawIndirectCount versions.
Note, looking into vkCmdDrawIndirectCount/vkCmdDrawIndexedIndirectCount, I noticed that Vulkan's maxDrawCount behavior is (somewhat peculiarly) actually safe, which would make it possible to check for indirect-buffer-OOB at validation time even for these calls. However, I don't know if this extends to Metal indirect command buffers, for example.
maxDrawCount specifies the maximum number of draws that will be executed. The actual number of executed draw calls is the minimum of the count specified in countBuffer and maxDrawCount.
Note there is no equivalent dispatchIndirectCount. (I guess you would need indirect command buffers (VK_NV_device_generated_commands?) to achieve that.)
I'm not sure I understand the discussion about implementation internally upgrading drawIndirect to drawIndirectCount: we still know at the place where drawIndirect is called which buffer is used for the indirect call, at what offset, etc so we can easily validate that we are in bounds of the indirect buffer. Likewise for drawIndexed we have all the data to validate OOB on the index buffer in the call, so we might as well validate at that point. We can't do the same for drawIndexedIndirect because the parameters of the call are on the GPU.
It is better developer experience for them to have errors specced for index buffer or indirect buffer OOB as it's more convenient to surround them with push/popErrorScope, break on error (in the devtools when that's a thing), etc. Consistency between the direct and indirect call seems fairly minor in comparison.
Always generate validation errors when we can do so on the CPU from the current state and draw args. The benefit of this is developers get validation errors instead of warnings (does it matter?), and they are protected from loosely-defined behavior (like vertex access clamping vs wrapping vs zeroing).
draw: Must be within range of all bound vertex buffers
drawIndexed: Must be within range of bound index buffer
drawIndirect: Must be within range of indirectBuffer
drawIndexedIndirect: Must be within range of indirectBuffer
Never validate (which I think was the previous agreement, in Summary of current robust buffer access opinions #955).
The benefit of this is just saving some potentially-redundant checks on the CPU, i.e. if an implementation already uses some kind of robustness for vertex access, then the CPU checks are extra overhead (but if implementations are issuing warnings in this case anyway then it doesn't save them anything). Also more consistent because validation error cases will be the same between e.g. draw and drawIndirect.
Activity
Kangz commentedon Jun 11, 2021
I'm not sure I understand the discussion about implementation internally upgrading
drawIndirecttodrawIndirectCount: we still know at the place wheredrawIndirectis called which buffer is used for the indirect call, at what offset, etc so we can easily validate that we are in bounds of the indirect buffer. Likewise fordrawIndexedwe have all the data to validate OOB on the index buffer in the call, so we might as well validate at that point. We can't do the same fordrawIndexedIndirectbecause the parameters of the call are on the GPU.It is better developer experience for them to have errors specced for index buffer or indirect buffer OOB as it's more convenient to surround them with push/popErrorScope, break on error (in the devtools when that's a thing), etc. Consistency between the direct and indirect call seems fairly minor in comparison.
kainino0x commentedon Jun 14, 2021
Editors: raise to group
Strawman options, the two ends of the spectrum:
The benefit of this is just saving some potentially-redundant checks on the CPU, i.e. if an implementation already uses some kind of robustness for vertex access, then the CPU checks are extra overhead (but if implementations are issuing warnings in this case anyway then it doesn't save them anything). Also more consistent because validation error cases will be the same between e.g. draw and drawIndirect.
Or we can pick something in between.
kainino0x commentedon Jun 21, 2021
Resolution
We can remove validation errors later on, as we consider that to be a non-breaking change.