-
Notifications
You must be signed in to change notification settings - Fork 335
Added validation for both setBindGroup() variants #998
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, good stuff!
- |bindGroup|.{{GPUObjectBase/[[device]]}} is |this|.{{GPUObjectBase/[[device]]}}. | ||
- |index| < {{GPULimits/maxBindGroups|GPULimits.maxBindGroups}}. | ||
- dynamicOffsets.length is | ||
|bindGroup|.{{GPUBindGroup/[[layout]]}}.{{GPUBindGroupLayout/[[dynamicOffsetCount]]}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need to check that the binding offset + dynamic offset + minimumBufferSize is <= buffer size
, for each binding with dynamic offset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, forgot that we can validate this here rather than during the draw call.
I took a stab at it but... wow. There's just no clean way to document this validation! Feedback on how to help it read better is very welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a newly written rule, added it to the test plan: https://hackmd.io/@webgpu/H1MwoqqAU#encodingcmdsprogrammable_passspects
|index|: The index to set the bind group at. | ||
|bindGroup|: Bind group to use for subsequent render or compute commands. | ||
|dynamicOffsetsData|: Array containing buffer offsets in bytes for each entry in | ||
|bindGroup| with marked as {{GPUBindGroupLayoutEntry/hasDynamicOffset}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, here comes the fun part: what is the order?
In Vulkan, dynamic offsets need to be provided in the order of binding
, which can be different from the order of either BindGroupLayoutEntry
or BindGroupEntry
. I suggest to follow this route and specify that the offsets are taken in the order of increased binding number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, I have no idea what's going to be best here. Gonna let the editors work this one out. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely think it should be the binding number order. BindGroup(Layout)Descriptor.entries should be treated as an unordered map from binding => entry.
Oops! Forgot to push when I made my previous changes. Code is updated now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
CI is sad |
Weird. I had fixed that, wonder what sort of git-goof I did to lose it. 🤷 Fixed (again) now. |
Well crumb, my ability to The change was applying a suggestion from @kainino0x in a previous PR to move the repeated checks for I apologize for the mistake, as this was certainly not something I intended to slip in unnoticed. Depending on what the editors would prefer I'm happy to:
|
I think we should leave it. The spec is still heavily a draft, let's fix it as we go. |
- |bindGroup|.{{GPUObjectBase/[[device]]}} is |this|.{{GPUObjectBase/[[device]]}}. | ||
- |index| < {{GPULimits/maxBindGroups|GPULimits.maxBindGroups}}. | ||
- dynamicOffsets.length is | ||
|bindGroup|.{{GPUBindGroup/[[layout]]}}.{{GPUBindGroupLayout/[[dynamicOffsetCount]]}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a newly written rule, added it to the test plan: https://hackmd.io/@webgpu/H1MwoqqAU#encodingcmdsprogrammable_passspects
|index|: The index to set the bind group at. | ||
|bindGroup|: Bind group to use for subsequent render or compute commands. | ||
|dynamicOffsetsData|: Array containing buffer offsets in bytes for each entry in | ||
|bindGroup| with marked as {{GPUBindGroupLayoutEntry/hasDynamicOffset}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely think it should be the binding number order. BindGroup(Layout)Descriptor.entries should be treated as an unordered map from binding => entry.
|dynamicOffsetsData|[|dynamicOffsetIndex| + |dynamicOffsetsDataStart|]. | ||
- |bufferBinding|.{{GPUBufferBinding/offset}} + |bufferDynamicOffset| + | ||
|minBufferBindingSize| ≤ | ||
|bufferBinding|.{{GPUBufferBinding/buffer}}.{{GPUBuffer/[[size]]}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minBufferBindingSize is optional, and this rule should only apply if it's provided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the definition of the GPUBindGroupLayoutEntry
it says that minBufferBindingSize
defaults to 0
for buffer types. If that's the case then this works out regardless of if it's provided or not, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
</div> | ||
</dl> | ||
|
||
<div algorithm> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should pre-bake the list of dynamically-offset buffer bindings in createBindGroupLayout. I think it would just be a sorted list of binding numbers like [1, 3, 4]
and you could use those to index back into the bind group (layout) entries
- If the [=device=] that owns an object is lost, the object becomes invalid. | ||
</div> | ||
|
||
<div algorithm> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactor looks excellent.
Also fixes an error I made with a previous PR where I mistakenly compared GPUDevices against GPURenderPassEncoders instead of the GPUDevice the render pass encoder was created with.
Preview | Diff