Skip to content

Commit 3cc422a

Browse files
committed
Move command encoding to a queue
1 parent b5c36e3 commit 3cc422a

2 files changed

Lines changed: 84 additions & 23 deletions

File tree

samples/hello-cube.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@
278278
updateTransformArray(new Float32Array(mappedGroup.arrayBuffer));
279279
mappedGroup.buffer.unmap();
280280

281-
const commandEncoder = device.createCommandEncoder();
281+
const commandEncoder = device.defaultQueue.createCommandEncoder();
282282
renderPassDescriptor.colorAttachments[0].attachment = swapChain.getCurrentTexture().createDefaultView();
283283
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
284284

spec/index.bs

Lines changed: 83 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,9 +1410,6 @@ interface GPUDevice : EventTarget {
14101410
Promise<GPUComputePipeline> createReadyComputePipeline(GPUComputePipelineDescriptor descriptor);
14111411
Promise<GPURenderPipeline> createReadyRenderPipeline(GPURenderPipelineDescriptor descriptor);
14121412

1413-
GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
1414-
GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
1415-
14161413
GPUQuerySet createQuerySet(GPUQuerySetDescriptor descriptor);
14171414
};
14181415
GPUDevice includes GPUObjectBase;
@@ -2024,11 +2021,15 @@ GPUTextureView includes GPUObjectBase;
20242021
::
20252022
The {{GPUTexture}} into which this is a view.
20262023

2027-
: <dfn>\[[descriptor]]</dfn>
2024+
: <dfn>\[[descriptor]]</dfn>, of type {{GPUTextureViewDescriptor}}, read-only
20282025
::
2029-
The {{GPUTextureViewDescriptor}} describing this texture view.
2026+
The descriptor used to create this texture view.
20302027

20312028
All optional fields of {{GPUTextureViewDescriptor}} are defined.
2029+
2030+
: <dfn>\[[extent]]</dfn>, of type {{GPUExtent3DDict}}, read-only
2031+
::
2032+
The extent of this texture view.
20322033
</dl>
20332034

20342035
### Texture View Creation ### {#texture-view-creation}
@@ -4271,6 +4272,10 @@ GPUCommandBuffer includes GPUObjectBase;
42714272
{{GPUCommandBuffer}} has the following internal slots:
42724273

42734274
<dl dfn-type=attribute dfn-for="GPUCommandBuffer">
4275+
: <dfn>\[[queue]]</dfn> of type {{GPUQueue}}.
4276+
::
4277+
The parent queue, which will be executing the commands.
4278+
42744279
: <dfn>\[[command_list]]</dfn> of type [=list=]&lt;[=GPU command=]&gt;.
42754280
::
42764281
A [=list=] of [=GPU commands=] to be executed on the [=Queue timeline=] when this command
@@ -4337,6 +4342,10 @@ GPUCommandEncoder includes GPUObjectBase;
43374342
{{GPUCommandEncoder}} has the following internal slots:
43384343

43394344
<dl dfn-type=attribute dfn-for="GPUCommandEncoder">
4345+
: <dfn>\[[queue]]</dfn> of type {{GPUQueue}}.
4346+
::
4347+
The parent queue, which will be executing the commands.
4348+
43404349
: <dfn>\[[command_list]]</dfn> of type [=list=]&lt;[=GPU command=]&gt;.
43414350
::
43424351
A [=list=] of [=GPU command=] to be executed on the [=Queue timeline=] when the
@@ -4400,22 +4409,30 @@ dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
44004409
Enable measurement of the GPU execution time of the entire command buffer.
44014410
</dl>
44024411

4403-
<dl dfn-type=method dfn-for=GPUDevice>
4412+
<dl dfn-type=method dfn-for=GPUQueue>
44044413
: <dfn>createCommandEncoder(descriptor)</dfn>
44054414
::
44064415
Creates a {{GPUCommandEncoder}}.
44074416

4408-
<div algorithm=GPUDevice.createCommandEncoder>
4409-
**Called on:** {{GPUDevice}} this.
4417+
<div algorithm=GPUQueue.createCommandEncoder>
4418+
**Called on:** {{GPUQueue}} this.
44104419

44114420
**Arguments:**
4412-
<pre class=argumentdef for="GPUDevice/createCommandEncoder(descriptor)">
4421+
<pre class=argumentdef for="GPUQueue/createCommandEncoder(descriptor)">
44134422
descriptor: Description of the {{GPUCommandEncoder}} to create.
44144423
</pre>
44154424

44164425
**Returns:** {{GPUCommandEncoder}}
44174426

4418-
Issue: Describe {{GPUDevice/createCommandEncoder()}} algorithm steps.
4427+
Issue the following steps on the [=Device timeline=] of |this|.{{GPUQueue/[[device]]}}:
4428+
<div class=device-timeline>
4429+
1. Let |e| be a new {{GPUCommandEncoder}} object.
4430+
1. Set |e|.{{GPUCommandEncoder/[[command_list]]}} to an empty list.
4431+
1. Set |e|.{{GPUCommandEncoder/[[state]]}} to {{encoder state/open}}.
4432+
1. Set |e|.{{GPUCommandEncoder/[[debug_group_stack]]}} to an empty list.
4433+
1. Set |e|.{{GPUCommandEncoder/[[queue]]}} to |this|.
4434+
1. Return |e|.
4435+
</div>
44194436
</div>
44204437
</dl>
44214438

@@ -4458,6 +4475,12 @@ dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
44584475
are considered to be used as [=internal usage/attachment-read=] for the duration of the render pass.
44594476
1. Else, the [=texture subresource=] seen by |depthStencilAttachment|.{{GPURenderPassDepthStencilAttachmentDescriptor/attachment}}
44604477
is considered to be used as [=internal usage/attachment=] for the duration of the render pass.
4478+
1. Let |p| be a new {{GPURenderPassEncoder}} object.
4479+
1. Set |p|.{{GPURenderPassEncoder/[[attachment_size]]}} to {{GPUTextureView/[[extent]]}}
4480+
of any non-`null` attachment.
4481+
1. Set |p|.{{GPURenderPassEncoder/[[queue]]}} to |this|.{{GPUCommandEncoder/[[queue]]}}.
4482+
1. Return |p|.
4483+
44614484
</div>
44624485

44634486
Issue: specify the behavior of read-only depth/stencil
@@ -5095,6 +5118,7 @@ command encoder can no longer be used.
50955118
</div>
50965119

50975120
1. Set |this|.{{GPUCommandEncoder/[[state]]}} to {{encoder state/closed}}.
5121+
1. Let |commandBuffer|.{{GPUCommandBuffer/[[queue]]}} be |this|.{{GPUCommandEncoder/[[queue]]}}.
50985122
1. Let |commandBuffer|.{{GPUCommandBuffer/[[command_list]]}} be a [=list/clone=]
50995123
of |this|.{{GPUCommandEncoder/[[command_list]]}}.
51005124
</div>
@@ -5641,6 +5665,10 @@ GPURenderPassEncoder includes GPURenderEncoderBase;
56415665
{{GPURenderPassEncoder}} has the following internal slots:
56425666

56435667
<dl dfn-type=attribute dfn-for="GPURenderPassEncoder">
5668+
: <dfn>\[[queue]]</dfn> of type {{GPUQueue}}.
5669+
::
5670+
The queue owning {{GPUCommandEncoder}}, which contains the pass.
5671+
56445672
: <dfn>\[[attachment_size]]</dfn>
56455673
::
56465674
Set to the following extents:
@@ -5700,12 +5728,10 @@ dictionary GPURenderPassDescriptor : GPUObjectDescriptorBase {
57005728
1. |this|.{{GPURenderPassDescriptor/depthStencilAttachment}} must meet the [$GPURenderPassDepthStencilAttachmentDescriptor/GPURenderPassDepthStencilAttachmentDescriptor Valid Usage$] rules.
57015729

57025730
1. Each {{GPURenderPassColorAttachmentDescriptor/attachment}} in |this|.{{GPURenderPassDescriptor/colorAttachments}}
5703-
and |this|.{{GPURenderPassDescriptor/depthStencilAttachment}}.{{GPURenderPassDepthStencilAttachmentDescriptor/attachment}},
5704-
if present, must have all have the same {{GPUTexture/[[sampleCount]]}}.
5705-
5706-
1. The dimensions of the [=subresource=]s seen by each {{GPURenderPassColorAttachmentDescriptor/attachment}} in |this|.{{GPURenderPassDescriptor/colorAttachments}}
5707-
and |this|.{{GPURenderPassDescriptor/depthStencilAttachment}}.{{GPURenderPassDepthStencilAttachmentDescriptor/attachment}},
5708-
if present, must match.
5731+
and |this|.{{GPURenderPassDescriptor/depthStencilAttachment}}.{{GPURenderPassDepthStencilAttachmentDescriptor/attachment}}
5732+
if present:
5733+
- must have all the same {{GPUTextureView/[[texture]]}}.{{GPUTexture/[[sampleCount]]}}.
5734+
- must have all the same {{GPUTextureView/[[extent]]}}.
57095735

57105736
Issue: Define <dfn for=>maximum color attachments</dfn>
57115737

@@ -6352,15 +6378,21 @@ attachments used by this encoder.
63526378
{{GPURenderBundle}}s are executed, the command buffer state is unchanged.
63536379

63546380
<div algorithm="GPURenderPassEncoder.executeBundles">
6355-
**Called on:** {{GPURenderPassEncoder}} this.
6381+
**Called on:** {{GPURenderPassEncoder}} |this|.
63566382

63576383
**Arguments:**
63586384
<pre class=argumentdef for="GPURenderPassEncoder/executeBundles(bundles)">
6359-
bundles: List of render bundles to execute.
6385+
|bundles|: List of render bundles to execute.
63606386
</pre>
63616387

63626388
**Returns:** {{undefined}}
63636389

6390+
If any of the following conditions are unsatisfied, generate a validation error and stop.
6391+
<div class=validusage>
6392+
- For each |bundle| in |bundles|,
6393+
|bundle|.{{GPURenderBundle/[[queue]]}} is |this|.{{GPURenderPassEncoder/[[queue]]}}.
6394+
</div>
6395+
63646396
Issue: Describe {{GPURenderPassEncoder/executeBundles()}} algorithm steps.
63656397
</div>
63666398
</dl>
@@ -6406,6 +6438,14 @@ interface GPURenderBundle {
64066438
GPURenderBundle includes GPUObjectBase;
64076439
</script>
64086440

6441+
{{GPURenderBundle}} has the following internal slots:
6442+
6443+
<dl dfn-type=attribute dfn-for="GPURenderBundle">
6444+
: <dfn>\[[queue]]</dfn> of type {{GPUQueue}}.
6445+
::
6446+
The parent queue, which will be executing the commands.
6447+
</dl>
6448+
64096449
### Creation ### {#render-bundle-creation}
64106450

64116451
<script type=idl>
@@ -6422,25 +6462,33 @@ GPURenderBundleEncoder includes GPUProgrammablePassEncoder;
64226462
GPURenderBundleEncoder includes GPURenderEncoderBase;
64236463
</script>
64246464

6425-
<dl dfn-type=method dfn-for=GPUDevice>
6465+
<dl dfn-type=method dfn-for=GPUQueue>
64266466
: <dfn>createRenderBundleEncoder(descriptor)</dfn>
64276467
::
64286468
Creates a {{GPURenderBundleEncoder}}.
64296469

64306470
<div algorithm=GPUDevice.createRenderBundleEncoder>
6431-
**Called on:** {{GPUDevice}} this.
6471+
**Called on:** {{GPUQueue}} this.
64326472

64336473
**Arguments:**
6434-
<pre class=argumentdef for="GPUDevice/createRenderBundleEncoder(descriptor)">
6474+
<pre class=argumentdef for="GPUQueue/createRenderBundleEncoder(descriptor)">
64356475
descriptor: Description of the {{GPURenderBundleEncoder}} to create.
64366476
</pre>
64376477

64386478
**Returns:** {{GPURenderBundleEncoder}}
64396479

6440-
Issue: Describe {{GPUDevice/createRenderBundleEncoder()}} algorithm steps.
6480+
Issue: Describe {{GPUQueue/createRenderBundleEncoder()}} algorithm steps.
64416481
</div>
64426482
</dl>
64436483

6484+
{{GPURenderBundleEncoder}} has the following internal slots:
6485+
6486+
<dl dfn-type=attribute dfn-for="GPURenderBundleEncoder">
6487+
: <dfn>\[[queue]]</dfn> of type {{GPUQueue}}.
6488+
::
6489+
The parent queue, which will be executing the commands.
6490+
</dl>
6491+
64446492
### Encoding ### {#render-bundle-encoding}
64456493

64466494
<script type=idl>
@@ -6480,6 +6528,9 @@ interface GPUQueue {
64806528

64816529
Promise<undefined> onSubmittedWorkDone();
64826530

6531+
GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
6532+
GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
6533+
64836534
undefined writeBuffer(
64846535
GPUBuffer buffer,
64856536
GPUSize64 bufferOffset,
@@ -6501,6 +6552,14 @@ interface GPUQueue {
65016552
GPUQueue includes GPUObjectBase;
65026553
</script>
65036554

6555+
{{GPUQueue}} has the following internal slots:
6556+
6557+
<dl dfn-type=attribute dfn-for="GPUQueue">
6558+
: <dfn>\[[device]]</dfn>, of type {{GPUDevice}}
6559+
::
6560+
The parent device of this queue.
6561+
</dl>
6562+
65046563
{{GPUQueue}} has the following methods:
65056564

65066565
<dl dfn-type=method dfn-for=GPUQueue>
@@ -6666,6 +6725,8 @@ GPUQueue includes GPUObjectBase;
66666725
<div class=validusage>
66676726
- Every {{GPUBuffer}} referenced in any element of |commandBuffers| is in the
66686727
`"unmapped"` [=buffer state=].
6728+
- For every {{GPUCommandBuffer}} |commandBuffer| in |commandBuffers|,
6729+
|commandBuffer|.{{GPUCommandBuffer/[[queue]]}} is |this|.
66696730
</div>
66706731

66716732
1. Issue the following steps on the [=Queue timeline=] of |this|:

0 commit comments

Comments
 (0)