Title: [291685] trunk/Source/WebGPU
Revision
291685
Author
[email protected]
Date
2022-03-22 11:54:16 -0700 (Tue, 22 Mar 2022)

Log Message

[WebGPU] Lifetime of CommandEncoder's internal MTLBlitCommandEncoder is not managed correctly
https://bugs.webkit.org/show_bug.cgi?id=238167

Reviewed by Kimmo Kinnunen.

We lazily create a MTLBlitCommandEncoder inside CommandEncoder to service a few various calls
which require one. Metal has some state tracking inside it, such that when objects are destroyed,
they have to be in the right state. This patch aligns WebGPU's state tracking and Metal's state
tracking.

Test: api/validation/encoding/programmable/pipeline_bind_group_compat.spec.ts

* WebGPU/CommandEncoder.mm:
(WebGPU::CommandEncoder::~CommandEncoder):
(WebGPU::CommandEncoder::finalizeBlitCommandEncoder):

Modified Paths

Diff

Modified: trunk/Source/WebGPU/ChangeLog (291684 => 291685)


--- trunk/Source/WebGPU/ChangeLog	2022-03-22 18:49:26 UTC (rev 291684)
+++ trunk/Source/WebGPU/ChangeLog	2022-03-22 18:54:16 UTC (rev 291685)
@@ -1,3 +1,21 @@
+2022-03-22  Myles C. Maxfield  <[email protected]>
+
+        [WebGPU] Lifetime of CommandEncoder's internal MTLBlitCommandEncoder is not managed correctly
+        https://bugs.webkit.org/show_bug.cgi?id=238167
+
+        Reviewed by Kimmo Kinnunen.
+
+        We lazily create a MTLBlitCommandEncoder inside CommandEncoder to service a few various calls
+        which require one. Metal has some state tracking inside it, such that when objects are destroyed,
+        they have to be in the right state. This patch aligns WebGPU's state tracking and Metal's state
+        tracking.
+
+        Test: api/validation/encoding/programmable/pipeline_bind_group_compat.spec.ts
+
+        * WebGPU/CommandEncoder.mm:
+        (WebGPU::CommandEncoder::~CommandEncoder):
+        (WebGPU::CommandEncoder::finalizeBlitCommandEncoder):
+
 2022-03-21  Myles C. Maxfield  <[email protected]>
 
         [WebGPU] maxAnisotropy > 16 is clamped, rather than illegal

Modified: trunk/Source/WebGPU/WebGPU/CommandEncoder.mm (291684 => 291685)


--- trunk/Source/WebGPU/WebGPU/CommandEncoder.mm	2022-03-22 18:49:26 UTC (rev 291684)
+++ trunk/Source/WebGPU/WebGPU/CommandEncoder.mm	2022-03-22 18:54:16 UTC (rev 291685)
@@ -60,7 +60,10 @@
 {
 }
 
-CommandEncoder::~CommandEncoder() = default;
+CommandEncoder::~CommandEncoder()
+{
+    finalizeBlitCommandEncoder();
+}
 
 void CommandEncoder::ensureBlitCommandEncoder()
 {
@@ -70,8 +73,10 @@
 
 void CommandEncoder::finalizeBlitCommandEncoder()
 {
-    if (m_blitCommandEncoder)
+    if (m_blitCommandEncoder) {
         [m_blitCommandEncoder endEncoding];
+        m_blitCommandEncoder = nil;
+    }
 }
 
 RefPtr<ComputePassEncoder> CommandEncoder::beginComputePass(const WGPUComputePassDescriptor& descriptor)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to