<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[238208] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/238208">238208</a></dd>
<dt>Author</dt> <dd>justin_fan@apple.com</dd>
<dt>Date</dt> <dd>2018-11-14 16:33:53 -0800 (Wed, 14 Nov 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>[WebGPU] Code quality concerns raised for 191291: [WebGPU] Experimental prototype for WebGPURenderPipeline and WebGPUSwapChain
https://bugs.webkit.org/show_bug.cgi?id=191383

Reviewed by Dean Jackson.

Covered by existing WebGPU tests introduced in original patch.

* Modules/webgpu/GPUDevice.h:
* Modules/webgpu/GPUPipelineStageDescriptor.h:
* Modules/webgpu/GPURenderPipelineDescriptor.h: Now a base struct with a guaranteed vertex stage member.
(): Refactored into enum class.
(WebCore::GPURenderPipelineDescriptor::GPURenderPipelineDescriptor): Removed in favor of init-list construction.
(WebCore::GPURenderPipelineDescriptor::primitiveTopology): Now a proper enum class member.
* Modules/webgpu/GPUShaderModule.h:
* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::WebGPUDevice::createRenderPipeline const):
* Modules/webgpu/WebGPUShaderModule.h:
(WebCore::WebGPUShaderModule::module const):
* Modules/webgpu/WebGPUShaderStage.h: Replaced enum with constants to better reflect IDL.
* Modules/webgpu/cocoa/GPURenderPipeline.h:
* Modules/webgpu/cocoa/GPURenderPipelineMetal.mm:
(WebCore::setFunctionsForPipelineDescriptor):
(WebCore::GPURenderPipeline::create):
* Modules/webgpu/cocoa/GPUSwapChain.h:
* WebCore.xcodeproj/project.pbxproj: Removed GPUPipelineDescriptorBase.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuGPUDeviceh">trunk/Source/WebCore/Modules/webgpu/GPUDevice.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuGPUPipelineStageDescriptorh">trunk/Source/WebCore/Modules/webgpu/GPUPipelineStageDescriptor.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuGPURenderPipelineDescriptorh">trunk/Source/WebCore/Modules/webgpu/GPURenderPipelineDescriptor.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuGPUShaderModuleh">trunk/Source/WebCore/Modules/webgpu/GPUShaderModule.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUDevicecpp">trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUShaderModuleh">trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUShaderStageh">trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpucocoaGPURenderPipelineh">trunk/Source/WebCore/Modules/webgpu/cocoa/GPURenderPipeline.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpucocoaGPURenderPipelineMetalmm">trunk/Source/WebCore/Modules/webgpu/cocoa/GPURenderPipelineMetal.mm</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpucocoaGPUSwapChainh">trunk/Source/WebCore/Modules/webgpu/cocoa/GPUSwapChain.h</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/ChangeLog      2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2018-11-14  Justin Fan  <justin_fan@apple.com>
+
+        [WebGPU] Code quality concerns raised for 191291: [WebGPU] Experimental prototype for WebGPURenderPipeline and WebGPUSwapChain
+        https://bugs.webkit.org/show_bug.cgi?id=191383
+
+        Reviewed by Dean Jackson.
+
+        Covered by existing WebGPU tests introduced in original patch.
+
+        * Modules/webgpu/GPUDevice.h:
+        * Modules/webgpu/GPUPipelineStageDescriptor.h:
+        * Modules/webgpu/GPURenderPipelineDescriptor.h: Now a base struct with a guaranteed vertex stage member.
+        (): Refactored into enum class.
+        (WebCore::GPURenderPipelineDescriptor::GPURenderPipelineDescriptor): Removed in favor of init-list construction.
+        (WebCore::GPURenderPipelineDescriptor::primitiveTopology): Now a proper enum class member.
+        * Modules/webgpu/GPUShaderModule.h:
+        * Modules/webgpu/WebGPUDevice.cpp:
+        (WebCore::WebGPUDevice::createRenderPipeline const):
+        * Modules/webgpu/WebGPUShaderModule.h:
+        (WebCore::WebGPUShaderModule::module const):
+        * Modules/webgpu/WebGPUShaderStage.h: Replaced enum with constants to better reflect IDL.
+        * Modules/webgpu/cocoa/GPURenderPipeline.h:
+        * Modules/webgpu/cocoa/GPURenderPipelineMetal.mm:
+        (WebCore::setFunctionsForPipelineDescriptor):
+        (WebCore::GPURenderPipeline::create):
+        * Modules/webgpu/cocoa/GPUSwapChain.h:
+        * WebCore.xcodeproj/project.pbxproj: Removed GPUPipelineDescriptorBase.
+
</ins><span class="cx"> 2018-11-14  Joseph Pecoraro  <pecoraro@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Pass Inspector::FrontendChannel as a reference connect/disconnect methods
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuGPUDeviceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/GPUDevice.h (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/GPUDevice.h  2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/GPUDevice.h     2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -31,19 +31,12 @@
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><del>-#if USE(METAL)
</del><span class="cx"> OBJC_PROTOCOL(MTLDevice);
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-#if USE(METAL)
</del><span class="cx"> using PlatformDevice = MTLDevice;
</span><span class="cx"> using PlatformDeviceSmartPtr = RetainPtr<MTLDevice>;
</span><del>-#else
-using PlatformDevice = void;
-using PlatformDeviceSmartPtr = RefPtr<void>;
-#endif
</del><span class="cx"> 
</span><span class="cx"> class GPUShaderModule;
</span><span class="cx"> class GPURenderPipeline;
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuGPUPipelineStageDescriptorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/GPUPipelineStageDescriptor.h (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/GPUPipelineStageDescriptor.h 2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/GPUPipelineStageDescriptor.h    2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -34,8 +34,7 @@
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> struct GPUPipelineStageDescriptor {
</span><del>-    const GPUShaderModule& module;
-    unsigned long stage;
</del><ins>+    const GPUShaderModule* module = nullptr;
</ins><span class="cx">     String entryPoint;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuGPURenderPipelineDescriptorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/GPURenderPipelineDescriptor.h (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/GPURenderPipelineDescriptor.h        2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/GPURenderPipelineDescriptor.h   2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -34,8 +34,8 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-struct GPURenderPipelineDescriptor : GPUPipelineDescriptorBase {
-    enum {
</del><ins>+struct GPURenderPipelineDescriptor {
+    enum class PrimitiveTopology {
</ins><span class="cx">         PointList,
</span><span class="cx">         LineList,
</span><span class="cx">         LineStrip,
</span><span class="lines">@@ -43,13 +43,9 @@
</span><span class="cx">         TriangleStrip
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    GPURenderPipelineDescriptor(Vector<GPUPipelineStageDescriptor>&& stages, int topology)
-        : GPUPipelineDescriptorBase { WTFMove(stages) }
-        , primitiveTopology(topology)
-    {
-    }
-
-    int primitiveTopology;
</del><ins>+    GPUPipelineStageDescriptor vertexStage;
+    GPUPipelineStageDescriptor fragmentStage;
+    PrimitiveTopology primitiveTopology;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuGPUShaderModuleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/GPUShaderModule.h (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/GPUShaderModule.h    2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/GPUShaderModule.h       2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -31,9 +31,7 @@
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><del>-#if USE(METAL)
</del><span class="cx"> OBJC_PROTOCOL(MTLLibrary);
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -41,13 +39,8 @@
</span><span class="cx"> 
</span><span class="cx"> struct GPUShaderModuleDescriptor;
</span><span class="cx"> 
</span><del>-#if USE(METAL)
</del><span class="cx"> using PlatformShaderModule = MTLLibrary;
</span><span class="cx"> using PlatformShaderModuleSmartPtr = RetainPtr<MTLLibrary>;
</span><del>-#else
-using PlatformShaderModule = void;
-using PlatformShaderModuleSmartPtr = RefPtr<void>;
-#endif
</del><span class="cx"> 
</span><span class="cx"> class GPUShaderModule : public RefCounted<GPUShaderModule> {
</span><span class="cx"> public:
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUDevicecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp     2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp        2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #include "WebGPURenderPipelineDescriptor.h"
</span><span class="cx"> #include "WebGPUShaderModule.h"
</span><span class="cx"> #include "WebGPUShaderModuleDescriptor.h"
</span><ins>+#include "WebGPUShaderStage.h"
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -63,19 +64,59 @@
</span><span class="cx"> 
</span><span class="cx"> RefPtr<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(WebGPURenderPipelineDescriptor&& descriptor) const
</span><span class="cx"> {
</span><del>-    Vector<GPUPipelineStageDescriptor> stages;
</del><ins>+    const char* const functionName = "WebGPUDevice::createRenderPipeline()";
+#if LOG_DISABLED
+    UNUSED_PARAM(functionName);
+#endif
+
+    if (descriptor.stages.isEmpty()) {
+        LOG(WebGPU, "%s: No stages in WebGPURenderPipelineDescriptor!", functionName);
+        return nullptr;
+    }
+
+    GPUPipelineStageDescriptor vertexStage;
+    GPUPipelineStageDescriptor fragmentStage;
+
</ins><span class="cx">     for (const auto& stageDescriptor : descriptor.stages) {
</span><del>-        if (!stageDescriptor.module) {
-            LOG(WebGPU, "WebGPUDevice::createRenderPipeline(): WebGPUShaderModule not found!");
</del><ins>+        if (!stageDescriptor.module || !stageDescriptor.module->module() || stageDescriptor.entryPoint.isEmpty()) {
+            LOG(WebGPU, "%s: Invalid WebGPUPipelineStageDescriptor!", functionName);
</ins><span class="cx">             return nullptr;
</span><span class="cx">         }
</span><del>-        stages.append({ stageDescriptor.module->module(), stageDescriptor.stage, stageDescriptor.entryPoint });
</del><ins>+
+        switch (stageDescriptor.stage) {
+        case WebGPUShaderStage::VERTEX:
+            if (vertexStage.module) {
+                LOG(WebGPU, "%s: Multiple vertex stages in WebGPURenderPipelineDescriptor!", functionName);
+                return nullptr;
+            }
+
+            vertexStage.module = stageDescriptor.module->module();
+            vertexStage.entryPoint = stageDescriptor.entryPoint;
+            break;
+        case WebGPUShaderStage::FRAGMENT:
+            if (fragmentStage.module) {
+                LOG(WebGPU, "%s: Multiple fragment stages in WebGPURenderPipelineDescriptor!", functionName);
+                return nullptr;
+            }
+
+            fragmentStage.module = stageDescriptor.module->module();
+            fragmentStage.entryPoint = stageDescriptor.entryPoint;
+            break;
+        default:
+            LOG(WebGPU, "%s: Invalid shader stage in WebGPURenderPipelineDescriptor!", functionName);
+            return nullptr;
+        }
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return WebGPURenderPipeline::create(m_device->createRenderPipeline(GPURenderPipelineDescriptor { WTFMove(stages), static_cast<int>(descriptor.primitiveTopology) }));
</del><ins>+    // Metal (if not other APIs) requires at least the vertex shader.
+    if (!vertexStage.module || vertexStage.entryPoint.isEmpty()) {
+        LOG(WebGPU, "%s: Invalid vertex stage in WebGPURenderPipelineDescriptor!", functionName);
+        return nullptr;
+    }
+
+    return WebGPURenderPipeline::create(m_device->createRenderPipeline(GPURenderPipelineDescriptor { WTFMove(vertexStage), WTFMove(fragmentStage), static_cast<GPURenderPipelineDescriptor::PrimitiveTopology>(descriptor.primitiveTopology) }));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEBGPU)
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUShaderModuleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.h (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.h 2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.h    2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> public:
</span><span class="cx">     static RefPtr<WebGPUShaderModule> create(RefPtr<GPUShaderModule>&&);
</span><span class="cx"> 
</span><del>-    const GPUShaderModule& module() const { return *m_module; }
</del><ins>+    const GPUShaderModule* module() const { return m_module.get(); }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebGPUShaderModule(RefPtr<GPUShaderModule>&&);
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUShaderStageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h  2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUShaderStage.h     2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -33,11 +33,9 @@
</span><span class="cx"> 
</span><span class="cx"> class WebGPUShaderStage : public RefCounted<WebGPUShaderStage> {
</span><span class="cx"> public:
</span><del>-    enum {
-        VERTEX = 0,
-        FRAGMENT = 1,
-        COMPUTE = 2
-    };
</del><ins>+    static const unsigned long VERTEX = 0;
+    static const unsigned long FRAGMENT = 1;
+    static const unsigned long COMPUTE = 2;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpucocoaGPURenderPipelineh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/cocoa/GPURenderPipeline.h (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/cocoa/GPURenderPipeline.h    2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/cocoa/GPURenderPipeline.h       2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -31,9 +31,7 @@
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><del>-#if USE(METAL)
</del><span class="cx"> OBJC_PROTOCOL(MTLRenderPipelineState);
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="lines">@@ -41,13 +39,8 @@
</span><span class="cx"> 
</span><span class="cx"> struct GPURenderPipelineDescriptor;
</span><span class="cx"> 
</span><del>-#if USE(METAL)
</del><span class="cx"> using PlatformRenderPipeline = MTLRenderPipelineState;
</span><span class="cx"> using PlatformRenderPipelineSmartPtr = RetainPtr<MTLRenderPipelineState>;
</span><del>-#else
-using PlatformRenderPipeline = void;
-using PlatformRenderPipelineSmartPtr = RefPtr<void>;
-#endif
</del><span class="cx"> 
</span><span class="cx"> class GPURenderPipeline : public RefCounted<GPURenderPipeline> {
</span><span class="cx"> public:
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpucocoaGPURenderPipelineMetalmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/cocoa/GPURenderPipelineMetal.mm (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/cocoa/GPURenderPipelineMetal.mm      2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/cocoa/GPURenderPipelineMetal.mm 2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -30,7 +30,6 @@
</span><span class="cx"> 
</span><span class="cx"> #import "GPURenderPipelineDescriptor.h"
</span><span class="cx"> #import "Logging.h"
</span><del>-#import "WebGPUShaderStage.h"
</del><span class="cx"> 
</span><span class="cx"> #import <Metal/Metal.h>
</span><span class="cx"> #import <wtf/BlockObjCExceptions.h>
</span><span class="lines">@@ -42,35 +41,45 @@
</span><span class="cx"> #if LOG_DISABLED
</span><span class="cx">     UNUSED_PARAM(functionName);
</span><span class="cx"> #endif
</span><del>-    for (const auto& stageDescriptor : descriptor.stages) {
-        auto mtlLibrary = retainPtr(stageDescriptor.module.platformShaderModule());
</del><ins>+    // Metal requires a vertex shader in all render pipelines.
+    const auto& vertexStage = descriptor.vertexStage;
+    auto mtlLibrary = vertexStage.module->platformShaderModule();
</ins><span class="cx"> 
</span><del>-        if (!mtlLibrary) {
-            LOG(WebGPU, "%s: MTLLibrary does not exist!", functionName);
-            return false;
-        }
</del><ins>+    if (!mtlLibrary) {
+        LOG(WebGPU, "%s: MTLLibrary for vertex stage does not exist!", functionName);
+        return false;
+    }
</ins><span class="cx"> 
</span><del>-        auto function = adoptNS([mtlLibrary newFunctionWithName:stageDescriptor.entryPoint]);
</del><ins>+    auto function = adoptNS([mtlLibrary newFunctionWithName:vertexStage.entryPoint]);
</ins><span class="cx"> 
</span><del>-        if (!function) {
-            LOG(WebGPU, "%s: MTLFunction %s not found!", functionName, stageDescriptor.entryPoint.utf8().data());
-            return false;
-        }
</del><ins>+    if (!function) {
+        LOG(WebGPU, "%s: Vertex MTLFunction \"%s\" not found!", functionName, vertexStage.entryPoint.utf8().data());
+        return false;
+    }
</ins><span class="cx"> 
</span><del>-        switch (stageDescriptor.stage) {
-        case WebGPUShaderStage::VERTEX:
-            [mtlDescriptor setVertexFunction:function.get()];
-            break;
-        case WebGPUShaderStage::FRAGMENT:
-            [mtlDescriptor setFragmentFunction:function.get()];
-            break;
-        default:
-            LOG(WebGPU, "%s: Invalid shader stage specified!", functionName);
-            return false;
-            break;
-        }
</del><ins>+    [mtlDescriptor setVertexFunction:function.get()];
+
+    // However, fragment shaders are optional.
+    const auto fragmentStage = descriptor.fragmentStage;
+    if (!fragmentStage.module || !fragmentStage.entryPoint)
+        return true;
+
+    mtlLibrary = fragmentStage.module->platformShaderModule();
+
+    if (!mtlLibrary) {
+        LOG(WebGPU, "%s: MTLLibrary for fragment stage does not exist!", functionName);
+        return false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    function = adoptNS([mtlLibrary newFunctionWithName:fragmentStage.entryPoint]);
+
+    if (!function) {
+        LOG(WebGPU, "%s: Fragment MTLFunction \"%s\" not found!", functionName, fragmentStage.entryPoint.utf8().data());
+        return false;
+    }
+
+    [mtlDescriptor setFragmentFunction:function.get()];
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -106,10 +115,7 @@
</span><span class="cx"> 
</span><span class="cx">     BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> 
</span><del>-    if ([mtlDescriptor vertexFunction])
-        pipeline = adoptNS([device.platformDevice() newRenderPipelineStateWithDescriptor:mtlDescriptor.get() error:nil]);
-    else
-        LOG(WebGPU, "%s: No vertex function assigned for MTLRenderPipelineDescriptor!", functionName);
</del><ins>+    pipeline = adoptNS([device.platformDevice() newRenderPipelineStateWithDescriptor:mtlDescriptor.get() error:nil]);
</ins><span class="cx"> 
</span><span class="cx">     END_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpucocoaGPUSwapChainh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/cocoa/GPUSwapChain.h (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/cocoa/GPUSwapChain.h 2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/Modules/webgpu/cocoa/GPUSwapChain.h    2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -30,21 +30,14 @@
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><del>-#if USE(METAL)
</del><span class="cx"> OBJC_CLASS CAMetalLayer;
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class GPUDevice;
</span><span class="cx"> 
</span><del>-#if USE(METAL)
</del><span class="cx"> using PlatformSwapLayer = CAMetalLayer;
</span><span class="cx"> using PlatformSwapLayerSmartPtr = RetainPtr<CAMetalLayer>;
</span><del>-#else
-using PlatformSwapLayer = void;
-using PlatformSwapLayerSmartPtr = RefPtr<void>;
-#endif
</del><span class="cx"> 
</span><span class="cx"> class GPUSwapChain : public RefCounted<GPUSwapChain> {
</span><span class="cx"> public:
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (238207 => 238208)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2018-11-15 00:32:57 UTC (rev 238207)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2018-11-15 00:33:53 UTC (rev 238208)
</span><span class="lines">@@ -1244,7 +1244,6 @@
</span><span class="cx">          46B9519A207D635400A7D2DD /* RemoteFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 46B95192207D632E00A7D2DD /* RemoteFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          46BCBBC22085008F00710638 /* JSRemoteDOMWindowBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 46BCBBC02085007F00710638 /* JSRemoteDOMWindowBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          46C376622085177D00C73829 /* JSRemoteDOMWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C376612085176D00C73829 /* JSRemoteDOMWindow.h */; };
</span><del>-               CD5F3EDD9D333C40A9A38A54 /* AbortableTaskQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = DFDB912CF8E88A6DA1AD264F /* AbortableTaskQueue.h */; settings = {ATTRIBUTES = (Private, ); }; };
</del><span class="cx">           46C696CB1E7205F700597937 /* CPUMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C696C91E7205E400597937 /* CPUMonitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">          46C696CC1E7205FC00597937 /* CPUMonitor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46C696CA1E7205E400597937 /* CPUMonitor.cpp */; };
</span><span class="cx">          46C83EFE1A9BBE2900A79A41 /* GeoNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46C83EFC1A9BBE2900A79A41 /* GeoNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -7711,7 +7710,6 @@
</span><span class="cx">          46BCBBC3208500A700710638 /* RemoteDOMWindow.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RemoteDOMWindow.idl; sourceTree = "<group>"; };
</span><span class="cx">          46C3765F2085176C00C73829 /* JSRemoteDOMWindow.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRemoteDOMWindow.cpp; sourceTree = "<group>"; };
</span><span class="cx">          46C376612085176D00C73829 /* JSRemoteDOMWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRemoteDOMWindow.h; sourceTree = "<group>"; };
</span><del>-               DFDB912CF8E88A6DA1AD264F /* AbortableTaskQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbortableTaskQueue.h; sourceTree = "<group>"; };
</del><span class="cx">           46C696C91E7205E400597937 /* CPUMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPUMonitor.h; sourceTree = "<group>"; };
</span><span class="cx">          46C696CA1E7205E400597937 /* CPUMonitor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CPUMonitor.cpp; sourceTree = "<group>"; };
</span><span class="cx">          46C83EFB1A9BBE2900A79A41 /* GeoNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GeoNotifier.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -13821,7 +13819,6 @@
</span><span class="cx">          D045AD2321682475000A6E9B /* WebMetalCommandQueue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebMetalCommandQueue.cpp; sourceTree = "<group>"; };
</span><span class="cx">          D046FB65218D073C00CB8F62 /* GPURenderPipelineDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPURenderPipelineDescriptor.h; sourceTree = "<group>"; };
</span><span class="cx">          D046FB67218D180300CB8F62 /* GPUPipelineStageDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUPipelineStageDescriptor.h; sourceTree = "<group>"; };
</span><del>-               D046FB68218D18CD00CB8F62 /* GPUPipelineDescriptorBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUPipelineDescriptorBase.h; sourceTree = "<group>"; };
</del><span class="cx">           D0573D42217EB81E00D1BE91 /* GPULegacyTextureMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPULegacyTextureMetal.mm; sourceTree = "<group>"; };
</span><span class="cx">          D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FormatBlockCommand.cpp; sourceTree = "<group>"; };
</span><span class="cx">          D05CED280A40BB2C00C5AF38 /* FormatBlockCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FormatBlockCommand.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -14401,6 +14398,7 @@
</span><span class="cx">          DF7E9A294C7AACE0AD89B3DD /* MathMLOperatorDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLOperatorDictionary.h; sourceTree = "<group>"; };
</span><span class="cx">          DF9AFD7013FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlayerPrivateAVFoundationObjC.h; sourceTree = "<group>"; };
</span><span class="cx">          DF9AFD7113FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlayerPrivateAVFoundationObjC.mm; sourceTree = "<group>"; };
</span><ins>+               DFDB912CF8E88A6DA1AD264F /* AbortableTaskQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbortableTaskQueue.h; sourceTree = "<group>"; };
</ins><span class="cx">           E0FEF371B07C53EAC1C1FBEE /* EventSource.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventSource.idl; sourceTree = "<group>"; };
</span><span class="cx">          E0FEF371B17C53EAC1C1FBEE /* EventSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSource.h; sourceTree = "<group>"; };
</span><span class="cx">          E0FEF371B27C53EAC1C1FBEE /* EventSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventSource.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -25543,7 +25541,6 @@
</span><span class="cx">                          D00F5942216ECC7A000D71DB /* DOMWindowWebGPU.idl */,
</span><span class="cx">                          D09727CA218BD7A500942F3A /* GPUDevice.cpp */,
</span><span class="cx">                          D0615FCF217FF185008A48A8 /* GPUDevice.h */,
</span><del>-                               D046FB68218D18CD00CB8F62 /* GPUPipelineDescriptorBase.h */,
</del><span class="cx">                           D046FB67218D180300CB8F62 /* GPUPipelineStageDescriptor.h */,
</span><span class="cx">                          D0C419FA21840F6C009EC1DE /* GPURenderPipeline.h */,
</span><span class="cx">                          D046FB65218D073C00CB8F62 /* GPURenderPipelineDescriptor.h */,
</span></span></pre>
</div>
</div>

</body>
</html>