Skip to content

Commit 0f05d2d

Browse files
committed
Move command encoder creation back to GPUDevice
1 parent 3cc422a commit 0f05d2d

2 files changed

Lines changed: 21 additions & 14 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.defaultQueue.createCommandEncoder();
281+
const commandEncoder = device.createCommandEncoder();
282282
renderPassDescriptor.colorAttachments[0].attachment = swapChain.getCurrentTexture().createDefaultView();
283283
const passEncoder = commandEncoder.beginRenderPass(renderPassDescriptor);
284284

spec/index.bs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,9 @@ interface GPUDevice : EventTarget {
13961396

13971397
[SameObject] readonly attribute GPUQueue defaultQueue;
13981398

1399+
GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
1400+
GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
1401+
13991402
GPUBuffer createBuffer(GPUBufferDescriptor descriptor);
14001403
GPUTexture createTexture(GPUTextureDescriptor descriptor);
14011404
GPUSampler createSampler(optional GPUSamplerDescriptor descriptor = {});
@@ -4398,6 +4401,7 @@ which may be one of the following:
43984401
<script type=idl>
43994402
dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
44004403
boolean measureExecutionTime = false;
4404+
GPUQueue queue;
44014405

44024406
// TODO: reusability flag?
44034407
};
@@ -4407,30 +4411,35 @@ dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
44074411
: <dfn>measureExecutionTime</dfn>
44084412
::
44094413
Enable measurement of the GPU execution time of the entire command buffer.
4414+
4415+
: <dfn>queue</dfn>
4416+
::
4417+
The target queue which will be executing the commands.
44104418
</dl>
44114419

4412-
<dl dfn-type=method dfn-for=GPUQueue>
4420+
<dl dfn-type=method dfn-for=GPUDevice>
44134421
: <dfn>createCommandEncoder(descriptor)</dfn>
44144422
::
44154423
Creates a {{GPUCommandEncoder}}.
44164424

4417-
<div algorithm=GPUQueue.createCommandEncoder>
4418-
**Called on:** {{GPUQueue}} this.
4425+
<div algorithm=GPUDevice.createCommandEncoder>
4426+
**Called on:** {{GPUDevice}} this.
44194427

44204428
**Arguments:**
4421-
<pre class=argumentdef for="GPUQueue/createCommandEncoder(descriptor)">
4422-
descriptor: Description of the {{GPUCommandEncoder}} to create.
4429+
<pre class=argumentdef for="GPUDevice/createCommandEncoder(descriptor)">
4430+
|descriptor|: Description of the {{GPUCommandEncoder}} to create.
44234431
</pre>
44244432

44254433
**Returns:** {{GPUCommandEncoder}}
44264434

4427-
Issue the following steps on the [=Device timeline=] of |this|.{{GPUQueue/[[device]]}}:
4435+
Issue the following steps on the [=Device timeline=] of |this|:
44284436
<div class=device-timeline>
44294437
1. Let |e| be a new {{GPUCommandEncoder}} object.
44304438
1. Set |e|.{{GPUCommandEncoder/[[command_list]]}} to an empty list.
44314439
1. Set |e|.{{GPUCommandEncoder/[[state]]}} to {{encoder state/open}}.
44324440
1. Set |e|.{{GPUCommandEncoder/[[debug_group_stack]]}} to an empty list.
4433-
1. Set |e|.{{GPUCommandEncoder/[[queue]]}} to |this|.
4441+
1. Set |e|.{{GPUCommandEncoder/[[queue]]}} to |descriptor|.{{GPUCommandEncoderDescriptor/queue}},
4442+
if it's not `null`, or otherwise to |this|.{{GPUDevice/defaultQueue}}.
44344443
1. Return |e|.
44354444
</div>
44364445
</div>
@@ -6462,7 +6471,7 @@ GPURenderBundleEncoder includes GPUProgrammablePassEncoder;
64626471
GPURenderBundleEncoder includes GPURenderEncoderBase;
64636472
</script>
64646473

6465-
<dl dfn-type=method dfn-for=GPUQueue>
6474+
<dl dfn-type=method dfn-for=GPUDevice>
64666475
: <dfn>createRenderBundleEncoder(descriptor)</dfn>
64676476
::
64686477
Creates a {{GPURenderBundleEncoder}}.
@@ -6471,13 +6480,13 @@ GPURenderBundleEncoder includes GPURenderEncoderBase;
64716480
**Called on:** {{GPUQueue}} this.
64726481

64736482
**Arguments:**
6474-
<pre class=argumentdef for="GPUQueue/createRenderBundleEncoder(descriptor)">
6483+
<pre class=argumentdef for="GPUDevice/createRenderBundleEncoder(descriptor)">
64756484
descriptor: Description of the {{GPURenderBundleEncoder}} to create.
64766485
</pre>
64776486

64786487
**Returns:** {{GPURenderBundleEncoder}}
64796488

6480-
Issue: Describe {{GPUQueue/createRenderBundleEncoder()}} algorithm steps.
6489+
Issue: Describe {{GPUDevice/createRenderBundleEncoder()}} algorithm steps.
64816490
</div>
64826491
</dl>
64836492

@@ -6496,6 +6505,7 @@ dictionary GPURenderBundleEncoderDescriptor : GPUObjectDescriptorBase {
64966505
required sequence<GPUTextureFormat> colorFormats;
64976506
GPUTextureFormat depthStencilFormat;
64986507
GPUSize32 sampleCount = 1;
6508+
GPUQueue queue;
64996509
};
65006510
</script>
65016511

@@ -6528,9 +6538,6 @@ interface GPUQueue {
65286538

65296539
Promise<undefined> onSubmittedWorkDone();
65306540

6531-
GPUCommandEncoder createCommandEncoder(optional GPUCommandEncoderDescriptor descriptor = {});
6532-
GPURenderBundleEncoder createRenderBundleEncoder(GPURenderBundleEncoderDescriptor descriptor);
6533-
65346541
undefined writeBuffer(
65356542
GPUBuffer buffer,
65366543
GPUSize64 bufferOffset,

0 commit comments

Comments
 (0)