Title: [249881] trunk/Source/WebCore
Revision
249881
Author
[email protected]
Date
2019-09-14 15:31:02 -0700 (Sat, 14 Sep 2019)

Log Message

[WebGPU] Make WebGPURenderPipeline and WebGPUComputePipeline inherit from GPUObjectBase
https://bugs.webkit.org/show_bug.cgi?id=201207

Reviewed by Dean Jackson.

Make remaining WebGPU "client" classes manage their error scopes, instead of the internal classes.
Matches Web/GPUBuffer, and allows "invalid" WebGPU objects to create errors.

Covered by existing tests.

* Modules/webgpu/WebGPUComputePipeline.cpp:
(WebCore::WebGPUComputePipeline::create):
(WebCore::WebGPUComputePipeline::WebGPUComputePipeline):
* Modules/webgpu/WebGPUComputePipeline.h:
* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::WebGPUDevice::createRenderPipeline const):
(WebCore::WebGPUDevice::createComputePipeline const):
* Modules/webgpu/WebGPURenderPipeline.cpp:
(WebCore::WebGPURenderPipeline::create):
(WebCore::WebGPURenderPipeline::WebGPURenderPipeline):
* Modules/webgpu/WebGPURenderPipeline.h:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/gpu/GPUComputePipeline.h:
* platform/graphics/gpu/GPURenderPipeline.h:
* platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm:
(WebCore::GPUComputePipeline::tryCreate):
(WebCore::GPUComputePipeline::GPUComputePipeline):
* platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
(WebCore::GPURenderPipeline::tryCreate):
(WebCore::GPURenderPipeline::GPURenderPipeline):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (249880 => 249881)


--- trunk/Source/WebCore/ChangeLog	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/ChangeLog	2019-09-14 22:31:02 UTC (rev 249881)
@@ -1,3 +1,36 @@
+2019-09-14  Justin Fan  <[email protected]>
+
+        [WebGPU] Make WebGPURenderPipeline and WebGPUComputePipeline inherit from GPUObjectBase
+        https://bugs.webkit.org/show_bug.cgi?id=201207
+
+        Reviewed by Dean Jackson.
+
+        Make remaining WebGPU "client" classes manage their error scopes, instead of the internal classes.
+        Matches Web/GPUBuffer, and allows "invalid" WebGPU objects to create errors.
+
+        Covered by existing tests.
+
+        * Modules/webgpu/WebGPUComputePipeline.cpp:
+        (WebCore::WebGPUComputePipeline::create):
+        (WebCore::WebGPUComputePipeline::WebGPUComputePipeline):
+        * Modules/webgpu/WebGPUComputePipeline.h:
+        * Modules/webgpu/WebGPUDevice.cpp:
+        (WebCore::WebGPUDevice::createRenderPipeline const):
+        (WebCore::WebGPUDevice::createComputePipeline const):
+        * Modules/webgpu/WebGPURenderPipeline.cpp:
+        (WebCore::WebGPURenderPipeline::create):
+        (WebCore::WebGPURenderPipeline::WebGPURenderPipeline):
+        * Modules/webgpu/WebGPURenderPipeline.h:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/gpu/GPUComputePipeline.h:
+        * platform/graphics/gpu/GPURenderPipeline.h:
+        * platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm:
+        (WebCore::GPUComputePipeline::tryCreate):
+        (WebCore::GPUComputePipeline::GPUComputePipeline):
+        * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
+        (WebCore::GPURenderPipeline::tryCreate):
+        (WebCore::GPURenderPipeline::GPURenderPipeline):
+
 2019-09-14  Yusuke Suzuki  <[email protected]>
 
         Retire x86 32bit JIT support

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp (249880 => 249881)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp	2019-09-14 22:31:02 UTC (rev 249881)
@@ -30,13 +30,14 @@
 
 namespace WebCore {
 
-Ref<WebGPUComputePipeline> WebGPUComputePipeline::create(RefPtr<GPUComputePipeline>&& pipeline)
+Ref<WebGPUComputePipeline> WebGPUComputePipeline::create(RefPtr<GPUComputePipeline>&& pipeline, GPUErrorScopes& errorScopes)
 {
-    return adoptRef(*new WebGPUComputePipeline(WTFMove(pipeline)));
+    return adoptRef(*new WebGPUComputePipeline(WTFMove(pipeline), errorScopes));
 }
 
-WebGPUComputePipeline::WebGPUComputePipeline(RefPtr<GPUComputePipeline>&& pipeline)
-    : m_computePipeline { WTFMove(pipeline) }
+WebGPUComputePipeline::WebGPUComputePipeline(RefPtr<GPUComputePipeline>&& pipeline, GPUErrorScopes& errorScopes)
+    : GPUObjectBase(makeRef(errorScopes))
+    , m_computePipeline { WTFMove(pipeline) }
 {
 }
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h (249880 => 249881)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h	2019-09-14 22:31:02 UTC (rev 249881)
@@ -28,19 +28,19 @@
 #if ENABLE(WEBGPU)
 
 #include "GPUComputePipeline.h"
-#include <wtf/RefCounted.h>
+#include "GPUObjectBase.h"
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
 
-class WebGPUComputePipeline : public RefCounted<WebGPUComputePipeline> {
+class WebGPUComputePipeline : public GPUObjectBase {
 public:
-    static Ref<WebGPUComputePipeline> create(RefPtr<GPUComputePipeline>&&);
+    static Ref<WebGPUComputePipeline> create(RefPtr<GPUComputePipeline>&&, GPUErrorScopes&);
 
     const GPUComputePipeline* computePipeline() const { return m_computePipeline.get(); }
 
 private:
-    WebGPUComputePipeline(RefPtr<GPUComputePipeline>&&);
+    WebGPUComputePipeline(RefPtr<GPUComputePipeline>&&, GPUErrorScopes&);
 
     RefPtr<GPUComputePipeline> m_computePipeline;
 };

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (249880 => 249881)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2019-09-14 22:31:02 UTC (rev 249881)
@@ -214,10 +214,10 @@
 
     auto gpuDescriptor = descriptor.tryCreateGPURenderPipelineDescriptor(m_errorScopes);
     if (!gpuDescriptor)
-        return WebGPURenderPipeline::create(nullptr);
+        return WebGPURenderPipeline::create(nullptr, m_errorScopes);
 
     auto pipeline = m_device->tryCreateRenderPipeline(*gpuDescriptor, m_errorScopes);
-    return WebGPURenderPipeline::create(WTFMove(pipeline));
+    return WebGPURenderPipeline::create(WTFMove(pipeline), m_errorScopes);
 }
 
 Ref<WebGPUComputePipeline> WebGPUDevice::createComputePipeline(const WebGPUComputePipelineDescriptor& descriptor) const
@@ -226,10 +226,10 @@
 
     auto gpuDescriptor = descriptor.tryCreateGPUComputePipelineDescriptor(m_errorScopes);
     if (!gpuDescriptor)
-        return WebGPUComputePipeline::create(nullptr);
+        return WebGPUComputePipeline::create(nullptr, m_errorScopes);
 
     auto pipeline = m_device->tryCreateComputePipeline(*gpuDescriptor, m_errorScopes);
-    return WebGPUComputePipeline::create(WTFMove(pipeline));
+    return WebGPUComputePipeline::create(WTFMove(pipeline), m_errorScopes);
 }
 
 Ref<WebGPUCommandEncoder> WebGPUDevice::createCommandEncoder() const

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp (249880 => 249881)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp	2019-09-14 22:31:02 UTC (rev 249881)
@@ -30,13 +30,14 @@
 
 namespace WebCore {
 
-Ref<WebGPURenderPipeline> WebGPURenderPipeline::create(RefPtr<GPURenderPipeline>&& pipeline)
+Ref<WebGPURenderPipeline> WebGPURenderPipeline::create(RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes)
 {
-    return adoptRef(*new WebGPURenderPipeline(WTFMove(pipeline)));
+    return adoptRef(*new WebGPURenderPipeline(WTFMove(pipeline), errorScopes));
 }
 
-WebGPURenderPipeline::WebGPURenderPipeline(RefPtr<GPURenderPipeline>&& pipeline)
-    : m_renderPipeline(WTFMove(pipeline))
+WebGPURenderPipeline::WebGPURenderPipeline(RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes)
+    : GPUObjectBase(makeRef(errorScopes))
+    , m_renderPipeline(WTFMove(pipeline))
 {
 }
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h (249880 => 249881)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h	2019-09-14 22:31:02 UTC (rev 249881)
@@ -27,20 +27,20 @@
 
 #if ENABLE(WEBGPU)
 
+#include "GPUObjectBase.h"
 #include "GPURenderPipeline.h"
-#include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
 
-class WebGPURenderPipeline : public RefCounted<WebGPURenderPipeline> {
+class WebGPURenderPipeline : public GPUObjectBase {
 public:
-    static Ref<WebGPURenderPipeline> create(RefPtr<GPURenderPipeline>&&);
+    static Ref<WebGPURenderPipeline> create(RefPtr<GPURenderPipeline>&&, GPUErrorScopes&);
 
     const GPURenderPipeline* renderPipeline() const { return m_renderPipeline.get(); }
 
 private:
-    WebGPURenderPipeline(RefPtr<GPURenderPipeline>&&);
+    WebGPURenderPipeline(RefPtr<GPURenderPipeline>&&, GPUErrorScopes&);
 
     RefPtr<GPURenderPipeline> m_renderPipeline;
 };

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (249880 => 249881)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-09-14 22:31:02 UTC (rev 249881)
@@ -26006,6 +26006,8 @@
 				D03C849E21FFCF000002227F /* GPUCompareFunction.idl */,
 				D03C84A221FFD7230002227F /* GPUDepthStencilStateDescriptor.idl */,
 				D09AFB0622D417B300C4538C /* GPUErrorFilter.idl */,
+				D03586B222D7F2EA00DA0284 /* GPUErrorScopes.cpp */,
+				D03586B122D7F2EA00DA0284 /* GPUErrorScopes.h */,
 				D026F480220A2B7000AC5F49 /* GPUExtent3D.idl */,
 				D08AA02D220D0B9C0058C502 /* GPULoadOp.idl */,
 				D0CCA94922299F97006979B6 /* GPUOrigin3D.h */,

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h (249880 => 249881)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h	2019-09-14 22:31:02 UTC (rev 249881)
@@ -27,7 +27,6 @@
 
 #if ENABLE(WEBGPU)
 
-#include "GPUObjectBase.h"
 #include "WHLSLPrepare.h"
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -38,6 +37,7 @@
 namespace WebCore {
 
 class GPUDevice;
+class GPUErrorScopes;
 
 struct GPUComputePipelineDescriptor;
 
@@ -44,7 +44,7 @@
 using PlatformComputePipeline = MTLComputePipelineState;
 using PlatformComputePipelineSmartPtr = RetainPtr<MTLComputePipelineState>;
 
-class GPUComputePipeline : public GPUObjectBase {
+class GPUComputePipeline : public RefCounted<GPUComputePipeline> {
 public:
     static RefPtr<GPUComputePipeline> tryCreate(const GPUDevice&, const GPUComputePipelineDescriptor&, GPUErrorScopes&);
 
@@ -53,7 +53,7 @@
     WHLSL::ComputeDimensions computeDimensions() const { return m_computeDimensions; }
 
 private:
-    GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions, GPUErrorScopes&);
+    GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions);
 
     PlatformComputePipelineSmartPtr m_platformComputePipeline;
     WHLSL::ComputeDimensions m_computeDimensions { 0, 0, 0 };

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h (249880 => 249881)


--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h	2019-09-14 22:31:02 UTC (rev 249881)
@@ -27,7 +27,6 @@
 
 #if ENABLE(WEBGPU)
 
-#include "GPUObjectBase.h"
 #include "GPURenderPipelineDescriptor.h"
 #include <wtf/Optional.h>
 #include <wtf/RefCounted.h>
@@ -42,11 +41,12 @@
 namespace WebCore {
 
 class GPUDevice;
+class GPUErrorScopes;
 
 using PlatformRenderPipeline = MTLRenderPipelineState;
 using PlatformRenderPipelineSmartPtr = RetainPtr<MTLRenderPipelineState>;
 
-class GPURenderPipeline : public GPUObjectBase {
+class GPURenderPipeline : public RefCounted<GPURenderPipeline> {
 public:
     static RefPtr<GPURenderPipeline> tryCreate(const GPUDevice&, const GPURenderPipelineDescriptor&, GPUErrorScopes&);
 
@@ -59,7 +59,7 @@
 
 private:
 #if USE(METAL)
-    GPURenderPipeline(RetainPtr<MTLDepthStencilState>&&, PlatformRenderPipelineSmartPtr&&, GPUPrimitiveTopology, Optional<GPUIndexFormat>, GPUErrorScopes&);
+    GPURenderPipeline(RetainPtr<MTLDepthStencilState>&&, PlatformRenderPipelineSmartPtr&&, GPUPrimitiveTopology, Optional<GPUIndexFormat>);
 
     RetainPtr<MTLDepthStencilState> m_depthStencilState;
 #endif // USE(METAL)

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm (249880 => 249881)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm	2019-09-14 22:31:02 UTC (rev 249881)
@@ -30,6 +30,7 @@
 
 #import "GPUComputePipelineDescriptor.h"
 #import "GPUDevice.h"
+#import "GPUErrorScopes.h"
 #import "GPUPipelineMetalConvertLayout.h"
 #import "WHLSLPrepare.h"
 #import <Metal/Metal.h>
@@ -193,12 +194,11 @@
     if (!createResult)
         return nullptr;
 
-    return adoptRef(new GPUComputePipeline(WTFMove(createResult->pipelineState), createResult->computeDimensions, errorScopes));
+    return adoptRef(new GPUComputePipeline(WTFMove(createResult->pipelineState), createResult->computeDimensions));
 }
 
-GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline, WHLSL::ComputeDimensions computeDimensions, GPUErrorScopes& errorScopes)
-    : GPUObjectBase(makeRef(errorScopes))
-    , m_platformComputePipeline(WTFMove(pipeline))
+GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline, WHLSL::ComputeDimensions computeDimensions)
+    : m_platformComputePipeline(WTFMove(pipeline))
     , m_computeDimensions(computeDimensions)
 {
 }

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm (249880 => 249881)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2019-09-14 19:36:29 UTC (rev 249880)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2019-09-14 22:31:02 UTC (rev 249881)
@@ -29,6 +29,7 @@
 #if ENABLE(WEBGPU)
 
 #import "GPUDevice.h"
+#import "GPUErrorScopes.h"
 #import "GPULimits.h"
 #import "GPUPipelineMetalConvertLayout.h"
 #import "GPUUtils.h"
@@ -525,12 +526,11 @@
     if (!pipeline)
         return nullptr;
 
-    return adoptRef(new GPURenderPipeline(WTFMove(depthStencil), WTFMove(pipeline), descriptor.primitiveTopology, descriptor.vertexInput.indexFormat, errorScopes));
+    return adoptRef(new GPURenderPipeline(WTFMove(depthStencil), WTFMove(pipeline), descriptor.primitiveTopology, descriptor.vertexInput.indexFormat));
 }
 
-GPURenderPipeline::GPURenderPipeline(RetainPtr<MTLDepthStencilState>&& depthStencil, RetainPtr<MTLRenderPipelineState>&& pipeline, GPUPrimitiveTopology topology, Optional<GPUIndexFormat> format, GPUErrorScopes& errorScopes)
-    : GPUObjectBase(makeRef(errorScopes))
-    , m_depthStencilState(WTFMove(depthStencil))
+GPURenderPipeline::GPURenderPipeline(RetainPtr<MTLDepthStencilState>&& depthStencil, RetainPtr<MTLRenderPipelineState>&& pipeline, GPUPrimitiveTopology topology, Optional<GPUIndexFormat> format)
+    : m_depthStencilState(WTFMove(depthStencil))
     , m_platformRenderPipeline(WTFMove(pipeline))
     , m_primitiveTopology(topology)
     , m_indexFormat(format)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to