Skip to content

Commit

Permalink
Improve render bundle steps (gpuweb#4702)
Browse files Browse the repository at this point in the history
* Improve render bundle steps

* Address Kai's feedback

* One more bit of feedback to address
  • Loading branch information
toji authored Jun 11, 2024
1 parent a99e48e commit 0e9ee00
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -10686,16 +10686,16 @@ dictionary GPUComputePassDescriptor
|this|.device.limits.{{supported limits/maxComputeWorkgroupsPerDimension}}.
</div>

1. Let |passState| be a snapshot of |this|'s current state.
1. Let |bindingState| be a snapshot of |this|'s current state.
1. [$Enqueue a command$] on |this| which issues the subsequent steps on the
[=Queue timeline=].
</div>
<div data-timeline=queue>
[=Queue timeline=] steps:

1. Execute a grid of workgroups with dimensions [|workgroupCountX|, |workgroupCountY|,
|workgroupCountZ|] with |passState|.{{GPUComputePassEncoder/[[pipeline]]}} using
|passState|.{{GPUBindingCommandsMixin/[[bind_groups]]}}.
|workgroupCountZ|] with |bindingState|.{{GPUComputePassEncoder/[[pipeline]]}} using
|bindingState|.{{GPUBindingCommandsMixin/[[bind_groups]]}}.
</div>
</div>

Expand Down Expand Up @@ -10752,7 +10752,7 @@ dictionary GPUComputePassDescriptor
</div>
1. Add |indirectBuffer| to the [=usage scope=] as [=internal usage/input=].

1. Let |passState| be a snapshot of |this|'s current state.
1. Let |bindingState| be a snapshot of |this|'s current state.
1. [$Enqueue a command$] on |this| which issues the subsequent steps on the
[=Queue timeline=].
</div>
Expand All @@ -10769,8 +10769,8 @@ dictionary GPUComputePassDescriptor
|this|.device.limits.{{supported limits/maxComputeWorkgroupsPerDimension}},
stop.
1. Execute a grid of workgroups with dimensions [|workgroupCountX|, |workgroupCountY|,
|workgroupCountZ|] with |passState|.{{GPUComputePassEncoder/[[pipeline]]}} using
|passState|.{{GPUBindingCommandsMixin/[[bind_groups]]}}.
|workgroupCountZ|] with |bindingState|.{{GPUComputePassEncoder/[[pipeline]]}} using
|bindingState|.{{GPUBindingCommandsMixin/[[bind_groups]]}}.
</div>
</div>
</dl>
Expand Down Expand Up @@ -11777,7 +11777,7 @@ It must only be included by interfaces which also include those mixins.
</div>
1. Increment |this|.{{GPURenderCommandsMixin/[[drawCount]]}} by 1.

1. Let |passState| be a snapshot of |this|'s current state.
1. Let |bindingState| be a snapshot of |this|'s current state.
1. [$Enqueue a render command$] on |this| which issues the subsequent steps on the
[=Queue timeline=] with |renderState| when executed.
</div>
Expand All @@ -11786,7 +11786,7 @@ It must only be included by interfaces which also include those mixins.

1. Draw |instanceCount| instances, starting with instance |firstInstance|, of
primitives consisting of |vertexCount| verticies, starting with vertex |firstVertex|,
with the states from |passState| and |renderState|.
with the states from |bindingState| and |renderState|.
</div>
</div>

Expand Down Expand Up @@ -11838,7 +11838,7 @@ It must only be included by interfaces which also include those mixins.
</div>
1. Increment |this|.{{GPURenderCommandsMixin/[[drawCount]]}} by 1.

1. Let |passState| be a snapshot of |this|'s current state.
1. Let |bindingState| be a snapshot of |this|'s current state.
1. [$Enqueue a render command$] on |this| which issues the subsequent steps on the
[=Queue timeline=] with |renderState| when executed.
</div>
Expand All @@ -11848,7 +11848,7 @@ It must only be included by interfaces which also include those mixins.
1. Draw |instanceCount| instances, starting with instance |firstInstance|, of
primitives consisting of |indexCount| indexed verticies, starting with index
|firstIndex| from vertex |baseVertex|,
with the states from |passState| and |renderState|.
with the states from |bindingState| and |renderState|.
</div>

Note: a valid program should also never use vertex indices with
Expand Down Expand Up @@ -11914,7 +11914,7 @@ It must only be included by interfaces which also include those mixins.
1. Add |indirectBuffer| to the [=usage scope=] as [=internal usage/input=].
1. Increment |this|.{{GPURenderCommandsMixin/[[drawCount]]}} by 1.

1. Let |passState| be a snapshot of |this|'s current state.
1. Let |bindingState| be a snapshot of |this|'s current state.
1. [$Enqueue a render command$] on |this| which issues the subsequent steps on the
[=Queue timeline=] with |renderState| when executed.
</div>
Expand All @@ -11931,7 +11931,7 @@ It must only be included by interfaces which also include those mixins.
(|indirectOffset| + 12) bytes.
1. Draw |instanceCount| instances, starting with instance |firstInstance|, of
primitives consisting of |vertexCount| verticies, starting with vertex |firstVertex|,
with the states from |passState| and |renderState|.
with the states from |bindingState| and |renderState|.
</div>
</div>

Expand Down Expand Up @@ -11995,7 +11995,7 @@ It must only be included by interfaces which also include those mixins.
1. Add |indirectBuffer| to the [=usage scope=] as [=internal usage/input=].
1. Increment |this|.{{GPURenderCommandsMixin/[[drawCount]]}} by 1.

1. Let |passState| be a snapshot of |this|'s current state.
1. Let |bindingState| be a snapshot of |this|'s current state.
1. [$Enqueue a render command$] on |this| which issues the subsequent steps on the
[=Queue timeline=] with |renderState| when executed.
</div>
Expand All @@ -12015,7 +12015,7 @@ It must only be included by interfaces which also include those mixins.
1. Draw |instanceCount| instances, starting with instance |firstInstance|, of
primitives consisting of |indexCount| indexed verticies, starting with index
|firstIndex| from vertex |baseVertex|,
with the states from |passState| and |renderState|.
with the states from |bindingState| and |renderState|.
</div>
</div>
</dl>
Expand Down Expand Up @@ -12384,30 +12384,34 @@ attachments used by this encoder.

1. For each |bundle| in |bundles|:
1. Increment |this|.{{GPURenderCommandsMixin/[[drawCount]]}} by |bundle|.{{GPURenderBundle/[[drawCount]]}}.
1. [$Enqueue a render command$] on |this| which issues the following steps on the
[=Queue timeline=] with |renderState| when executed:

1. [=map/Clear=] |this|.{{GPUBindingCommandsMixin/[[bind_groups]]}}.
1. Set |this|.{{GPURenderCommandsMixin/[[pipeline]]}} to `null`.
1. Set |this|.{{GPURenderCommandsMixin/[[index_buffer]]}} to `null`.
1. [=map/Clear=] |this|.{{GPURenderCommandsMixin/[[vertex_buffers]]}}.
<div data-timeline=queue>
[=Queue timeline=] steps:

1. Let |passState| be a snapshot of |this|'s current state.
1. [$Enqueue a render command$] on |this| which issues the subsequent steps on the
[=Queue timeline=] with |renderState| when executed.
</div>
<div data-timeline=queue>
[=Queue timeline=] steps:
1. Execute each command in |bundle|.{{GPURenderBundle/[[command_list]]}}
with |renderState|.

1. For each |bundle| in |bundles|:
1. Execute each command in |bundle|.{{GPURenderBundle/[[command_list]]}}
with |passState| and |renderState|.
Note: |renderState| cannot be changed by executing render bundles. Binding state was
already captured at bundle encoding time, and so isn't used when executing bundles.
</div>

Note: |renderState| cannot be changed by executing render bundles.
Also note, no mutable |passState| state is visible to render bundles.
1. [$Reset the render pass binding state$] of |this|.
</div>

</div>
</dl>

<div algorithm data-timeline=device>
To <dfn abstract-op>Reset the render pass binding state</dfn> of {{GPURenderPassEncoder}} |encoder| run
the following [=device timeline=] steps:

1. [=map/Clear=] |encoder|.{{GPUBindingCommandsMixin/[[bind_groups]]}}.
1. Set |encoder|.{{GPURenderCommandsMixin/[[pipeline]]}} to `null`.
1. Set |encoder|.{{GPURenderCommandsMixin/[[index_buffer]]}} to `null`.
1. [=map/Clear=] |encoder|.{{GPURenderCommandsMixin/[[vertex_buffers]]}}.
</div>

# Bundles # {#bundles}

A bundle is a partial, limited pass that is encoded once and can then be executed multiple times as
Expand Down Expand Up @@ -12523,8 +12527,6 @@ GPURenderBundleEncoder includes GPURenderCommandsMixin;
1. Set |e|.{{GPURenderCommandsMixin/[[stencilReadOnly]]}} to |descriptor|.{{GPURenderBundleEncoderDescriptor/stencilReadOnly}}.
1. Set |e|.{{GPUCommandsMixin/[[state]]}} to "[=encoder state/open=]".
1. Set |e|.{{GPURenderCommandsMixin/[[drawCount]]}} to 0.

Issue: Describe the reset of the steps for {{GPUDevice/createRenderBundleEncoder()}}.
</div>
</div>
</dl>
Expand Down

0 comments on commit 0e9ee00

Please sign in to comment.