Repository navigation
Make minBufferBindingSize optional - #874
Conversation
When the author opt-in to using minBufferBindingSize, this enables two checks: 1. The appropriate buffer in any bind groups created with this bind group layout is larger than minBufferBindingSize 2. minBufferBindingSize is larger than is necessary given the shader If the author opts in to these requirements, we can do bounds checking at bind group creation / shader compilation time. However, if the author does not opt in to these requirements, we must do bounds checking at draw call time. Rather than using a sentinel 0 for the second check, we should have the author explicit enable them via out-of-band messaging. This doesn't matter for the first check (since any buffer length is greater-than-or-equal-to 0), but it does matter for the second check. This patch doesn't change any defaults; it just makes makes the opt-in to earlier bounds checking more explicit.
|
I have slight concerns about using |
|
@Kangz I share the concern about WASM :) Also:
Note that with |
I argued against this already somewhere. It's one thing to use 0 as a sentinel value. But in this case we really do literally mean "the minimum buffer binding size is 0". So in terms of the local semantics, it matches the name and I think we should keep that, despite the fact that no-minimum-buffer-binding-size does become special later. |
Co-authored-by: Kai Ninomiya <[email protected]>
|
Right now, the spec has two situations:
This patch moves the "passing 0" into the first situation. The reason for this change is that it's totally reasonable for a shader to have no resources bound other than a big array. In this situation, you don't want draw-call bounds checking, but the value to check against is 0. The switch between "do ahead-of-time bounds checking" and "do draw-call bounds checking" should be an explicit switch, not implied by a sentinel 0. |
On the call we clarified that this is impossible today, as we agreed to require the buffer binding to include at least one element of an unsized array. So there is never a case where you'd want to specify 0 there while not wanting draw-call bounds checks. I assumed that you were going to revise this proposal with that aspect clarified, but it appears to be unchanged. |
|
What needs clarification? That 0 is not a valid value? |
|
Nothing needs clarification, it was provided on the call and that's what I wrote in the comment. |
|
Right, I see now that Myles hasn't come back to this issue since the meeting. Doesn't change that I'm still fine with this if Myles wants to push it forward though. 0 would never be a valid minBufferBindingSize because it would fail to validate against any shader during pipeline creation. So if we accept this, we might want to add validation in BGL creation saying minBufferBindingSize cannot be 0. |
Co-authored-by: Kai Ninomiya <[email protected]>
Co-authored-by: Kai Ninomiya <[email protected]>
|
Presumably the set of resources attached to the shader (via bindgroups) is allowed to be a superset of the resources that the shader actually uses. For the resources which are bound but not used, 0 seems like a reasonable value. |
When the author opt-in to using minBufferBindingSize, this enables two checks:
If the author opts in to these requirements, we can do bounds checking at bind group creation / shader compilation time. However, if the author does not opt in to these requirements, we must do bounds checking at draw call time.
Rather than using a sentinel 0 for the second check, we should have the author explicit enable them via out-of-band messaging. This doesn't matter for the first check (since any buffer length is greater-than-or-equal-to 0), but it does matter for the second check.
This patch doesn't change any defaults; it just makes makes the opt-in to earlier bounds checking more explicit.
Preview | Diff