<!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>[213650] trunk</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/213650">213650</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2017-03-09 11:02:11 -0800 (Thu, 09 Mar 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>WebGPU: Backend - Library and Functions
https://bugs.webkit.org/show_bug.cgi?id=169371
<rdar://problem/30928792>
Reviewed by Tim Horton.
Source/WebCore:
Implement the backends for GPULibrary and GPUFunction.
A GPULibrary is created from a GPUDevice, given some
shader source code. You can then extract the GPUFunctions
from the library.
WebKitAPITests: GPULibrary and GPUFunction.
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/cocoa/GPUFunctionMetal.mm:
(WebCore::GPUFunction::GPUFunction):
(WebCore::GPUFunction::name):
(WebCore::GPUFunction::platformFunction):
* platform/graphics/cocoa/GPULibraryMetal.mm:
(WebCore::GPULibrary::GPULibrary):
(WebCore::GPULibrary::label):
(WebCore::GPULibrary::setLabel):
(WebCore::GPULibrary::functionNames):
(WebCore::GPULibrary::platformLibrary):
* platform/graphics/gpu/GPUDevice.cpp:
(WebCore::GPUDevice::createLibrary):
* platform/graphics/gpu/GPUDevice.h:
* platform/graphics/gpu/GPUFunction.cpp:
(WebCore::GPUFunction::create):
(WebCore::GPUFunction::~GPUFunction):
(WebCore::GPUFunction::GPUFunction):
(WebCore::GPUFunction::name):
* platform/graphics/gpu/GPUFunction.h:
* platform/graphics/gpu/GPULibrary.cpp:
(WebCore::GPULibrary::create):
(WebCore::GPULibrary::~GPULibrary):
(WebCore::GPULibrary::label):
(WebCore::GPULibrary::setLabel):
(WebCore::GPULibrary::functionNames):
(WebCore::GPULibrary::functionWithName):
* platform/graphics/gpu/GPULibrary.h:
Tools:
Add tests for GPULibrary and GPUFunction.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm:
(TestWebKitAPI::TEST_F):
(TestWebKitAPI::TEST): Deleted.
* TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm: Copied from Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm.
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm: Copied from Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm.
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebCore/mac/GPUTest.h: Copied from Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm.
(TestWebKitAPI::GPU::librarySourceCode):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformMaccmake">trunk/Source/WebCore/PlatformMac.cmake</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpuGPUDevicecpp">trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpuGPUDeviceh">trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoremacGPUDevicemm">trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaGPUFunctionMetalmm">trunk/Source/WebCore/platform/graphics/cocoa/GPUFunctionMetal.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscocoaGPULibraryMetalmm">trunk/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpuGPUFunctioncpp">trunk/Source/WebCore/platform/graphics/gpu/GPUFunction.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpuGPUFunctionh">trunk/Source/WebCore/platform/graphics/gpu/GPUFunction.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpuGPULibrarycpp">trunk/Source/WebCore/platform/graphics/gpu/GPULibrary.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpuGPULibraryh">trunk/Source/WebCore/platform/graphics/gpu/GPULibrary.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoremacGPUFunctionmm">trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoremacGPULibrarymm">trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebCoremacGPUTesth">trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUTest.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (213649 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-03-09 18:54:01 UTC (rev 213649)
+++ trunk/Source/WebCore/ChangeLog        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -1,3 +1,47 @@
</span><ins>+2017-03-08 Dean Jackson <dino@apple.com>
+
+ WebGPU: Backend - Library and Functions
+ https://bugs.webkit.org/show_bug.cgi?id=169371
+ <rdar://problem/30928792>
+
+ Reviewed by Tim Horton.
+
+ Implement the backends for GPULibrary and GPUFunction.
+ A GPULibrary is created from a GPUDevice, given some
+ shader source code. You can then extract the GPUFunctions
+ from the library.
+
+ WebKitAPITests: GPULibrary and GPUFunction.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/cocoa/GPUFunctionMetal.mm:
+ (WebCore::GPUFunction::GPUFunction):
+ (WebCore::GPUFunction::name):
+ (WebCore::GPUFunction::platformFunction):
+ * platform/graphics/cocoa/GPULibraryMetal.mm:
+ (WebCore::GPULibrary::GPULibrary):
+ (WebCore::GPULibrary::label):
+ (WebCore::GPULibrary::setLabel):
+ (WebCore::GPULibrary::functionNames):
+ (WebCore::GPULibrary::platformLibrary):
+ * platform/graphics/gpu/GPUDevice.cpp:
+ (WebCore::GPUDevice::createLibrary):
+ * platform/graphics/gpu/GPUDevice.h:
+ * platform/graphics/gpu/GPUFunction.cpp:
+ (WebCore::GPUFunction::create):
+ (WebCore::GPUFunction::~GPUFunction):
+ (WebCore::GPUFunction::GPUFunction):
+ (WebCore::GPUFunction::name):
+ * platform/graphics/gpu/GPUFunction.h:
+ * platform/graphics/gpu/GPULibrary.cpp:
+ (WebCore::GPULibrary::create):
+ (WebCore::GPULibrary::~GPULibrary):
+ (WebCore::GPULibrary::label):
+ (WebCore::GPULibrary::setLabel):
+ (WebCore::GPULibrary::functionNames):
+ (WebCore::GPULibrary::functionWithName):
+ * platform/graphics/gpu/GPULibrary.h:
+
</ins><span class="cx"> 2017-03-09 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Align Document.elementFromPoint() with the CSSOM specification
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformMac.cmake (213649 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformMac.cmake        2017-03-09 18:54:01 UTC (rev 213649)
+++ trunk/Source/WebCore/PlatformMac.cmake        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -417,6 +417,8 @@
</span><span class="cx"> platform/graphics/cg/TransformationMatrixCG.cpp
</span><span class="cx">
</span><span class="cx"> platform/graphics/cocoa/GPUDeviceMetal.mm
</span><ins>+ platform/graphics/cocoa/GPUFunctionMetal.mm
+ platform/graphics/cocoa/GPULibraryMetal.mm
</ins><span class="cx"> platform/graphics/cocoa/FontCacheCoreText.cpp
</span><span class="cx"> platform/graphics/cocoa/FontCascadeCocoa.mm
</span><span class="cx"> platform/graphics/cocoa/FontCocoa.mm
</span><span class="lines">@@ -431,6 +433,8 @@
</span><span class="cx"> platform/graphics/cv/VideoTextureCopierCV.cpp
</span><span class="cx">
</span><span class="cx"> platform/graphics/gpu/GPUDevice.cpp
</span><ins>+ platform/graphics/gpu/GPUFunction.cpp
+ platform/graphics/gpu/GPULibrary.cpp
</ins><span class="cx">
</span><span class="cx"> platform/graphics/mac/ColorMac.mm
</span><span class="cx"> platform/graphics/mac/ComplexTextControllerCoreText.mm
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (213649 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-09 18:54:01 UTC (rev 213649)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -1359,6 +1359,12 @@
</span><span class="cx">                 316BDB8B1E6E153000DE0D5A /* WebGPULayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDB891E6E153000DE0D5A /* WebGPULayer.mm */; };
</span><span class="cx">                 316BDB8C1E6E153000DE0D5A /* WebGPULayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDB8A1E6E153000DE0D5A /* WebGPULayer.h */; };
</span><span class="cx">                 316BDB8D1E6E189800DE0D5A /* GPUDeviceMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDB881E6E141C00DE0D5A /* GPUDeviceMetal.mm */; };
</span><ins>+                316BDB941E70C89700DE0D5A /* GPUFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDB921E70C89700DE0D5A /* GPUFunction.cpp */; };
+                316BDB951E70C89700DE0D5A /* GPUFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDB931E70C89700DE0D5A /* GPUFunction.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                316BDB971E70CA2400DE0D5A /* GPUFunctionMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */; };
+                316BDB9A1E70CBBF00DE0D5A /* GPULibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDB981E70CBBF00DE0D5A /* GPULibrary.cpp */; };
+                316BDB9B1E70CBBF00DE0D5A /* GPULibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDB991E70CBBF00DE0D5A /* GPULibrary.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                316BDB9E1E70CD9000DE0D5A /* GPULibraryMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */; };
</ins><span class="cx">                 316FE0710E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */; };
</span><span class="cx">                 316FE0720E6CCBEE00BF6088 /* JSCSSKeyframeRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */; };
</span><span class="cx">                 316FE0730E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06F0E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp */; };
</span><span class="lines">@@ -8686,6 +8692,12 @@
</span><span class="cx">                 316BDB881E6E141C00DE0D5A /* GPUDeviceMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUDeviceMetal.mm; sourceTree = "<group>"; };
</span><span class="cx">                 316BDB891E6E153000DE0D5A /* WebGPULayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebGPULayer.mm; sourceTree = "<group>"; };
</span><span class="cx">                 316BDB8A1E6E153000DE0D5A /* WebGPULayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGPULayer.h; sourceTree = "<group>"; };
</span><ins>+                316BDB921E70C89700DE0D5A /* GPUFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUFunction.cpp; sourceTree = "<group>"; };
+                316BDB931E70C89700DE0D5A /* GPUFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUFunction.h; sourceTree = "<group>"; };
+                316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUFunctionMetal.mm; sourceTree = "<group>"; };
+                316BDB981E70CBBF00DE0D5A /* GPULibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPULibrary.cpp; sourceTree = "<group>"; };
+                316BDB991E70CBBF00DE0D5A /* GPULibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPULibrary.h; sourceTree = "<group>"; };
+                316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPULibraryMetal.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSKeyframeRule.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSKeyframeRule.h; sourceTree = "<group>"; };
</span><span class="cx">                 316FE06F0E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSKeyframesRule.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -17474,6 +17486,10 @@
</span><span class="cx">                         children = (
</span><span class="cx">                                 316BDB841E6E0A2100DE0D5A /* GPUDevice.cpp */,
</span><span class="cx">                                 316BDB851E6E0A2100DE0D5A /* GPUDevice.h */,
</span><ins>+                                316BDB921E70C89700DE0D5A /* GPUFunction.cpp */,
+                                316BDB931E70C89700DE0D5A /* GPUFunction.h */,
+                                316BDB981E70CBBF00DE0D5A /* GPULibrary.cpp */,
+                                316BDB991E70CBBF00DE0D5A /* GPULibrary.h */,
</ins><span class="cx">                                 498770D71242C535002226BA /* Texture.cpp */,
</span><span class="cx">                                 498770D81242C535002226BA /* Texture.h */,
</span><span class="cx">                                 498770D91242C535002226BA /* TilingData.cpp */,
</span><span class="lines">@@ -22566,6 +22582,8 @@
</span><span class="cx">                                 7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
</span><span class="cx">                                 B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
</span><span class="cx">                                 316BDB881E6E141C00DE0D5A /* GPUDeviceMetal.mm */,
</span><ins>+                                316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */,
+                                316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */,
</ins><span class="cx">                                 2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */,
</span><span class="cx">                                 2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
</span><span class="cx">                                 AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */,
</span><span class="lines">@@ -26204,6 +26222,7 @@
</span><span class="cx">                                 93309DE4099E64920056E581 /* EditCommand.h in Headers */,
</span><span class="cx">                                 4F1534DE11B532EC0021FD86 /* EditingBehavior.h in Headers */,
</span><span class="cx">                                 4F1534E011B533020021FD86 /* EditingBehaviorTypes.h in Headers */,
</span><ins>+                                316BDB9B1E70CBBF00DE0D5A /* GPULibrary.h in Headers */,
</ins><span class="cx">                                 3AC648B2129E146500C3EB25 /* EditingBoundary.h in Headers */,
</span><span class="cx">                                 9BAB6C6C12550631001626D4 /* EditingStyle.h in Headers */,
</span><span class="cx">                                 4B3043CD0AE0373B00A82647 /* Editor.h in Headers */,
</span><span class="lines">@@ -28005,6 +28024,7 @@
</span><span class="cx">                                 BCEA4866097D93020094C9E4 /* RenderButton.h in Headers */,
</span><span class="cx">                                 B56579B51824D12A00E79F23 /* RenderChildIterator.h in Headers */,
</span><span class="cx">                                 BCE4413412F748E2009B84B8 /* RenderCombineText.h in Headers */,
</span><ins>+                                316BDB951E70C89700DE0D5A /* GPUFunction.h in Headers */,
</ins><span class="cx">                                 9392F1420AD185F400691BD4 /* RenderCounter.h in Headers */,
</span><span class="cx">                                 BCEA486E097D93020094C9E4 /* RenderDeprecatedFlexibleBox.h in Headers */,
</span><span class="cx">                                 836DAA061CEAB80D00A2B707 /* RenderDescendantIterator.h in Headers */,
</span><span class="lines">@@ -30429,6 +30449,7 @@
</span><span class="cx">                                 977B3877122883E900B81FF8 /* HTMLTokenizer.cpp in Sources */,
</span><span class="cx">                                 0707568B142262D600414161 /* HTMLTrackElement.cpp in Sources */,
</span><span class="cx">                                 977B37251228721700B81FF8 /* HTMLTreeBuilder.cpp in Sources */,
</span><ins>+                                316BDB941E70C89700DE0D5A /* GPUFunction.cpp in Sources */,
</ins><span class="cx">                                 A8EA79F30A1916DF00A8EF5F /* HTMLUListElement.cpp in Sources */,
</span><span class="cx">                                 E44613AA0CD6331000FADA75 /* HTMLVideoElement.cpp in Sources */,
</span><span class="cx">                                 839AAFEC1A0C0C8D00605F99 /* HTMLWBRElement.cpp in Sources */,
</span><span class="lines">@@ -31948,6 +31969,7 @@
</span><span class="cx">                                 078E090917D14CEE00420AA1 /* RTCIceCandidate.cpp in Sources */,
</span><span class="cx">                                 073BE34F17D18183002BD431 /* RTCIceCandidateDescriptor.cpp in Sources */,
</span><span class="cx">                                 078E090A17D14CEE00420AA1 /* RTCIceCandidateEvent.cpp in Sources */,
</span><ins>+                                316BDB9E1E70CD9000DE0D5A /* GPULibraryMetal.mm in Sources */,
</ins><span class="cx">                                 073794FD19F5864E00E5A045 /* RTCNotifiersMock.cpp in Sources */,
</span><span class="cx">                                 078E090B17D14CEE00420AA1 /* RTCPeerConnection.cpp in Sources */,
</span><span class="cx">                                 5E2C43621BCEE32B0001E2BC /* RTCRtpReceiver.cpp in Sources */,
</span><span class="lines">@@ -32315,6 +32337,7 @@
</span><span class="cx">                                 8476C9EA11DF6A2900555B02 /* SVGPathBuilder.cpp in Sources */,
</span><span class="cx">                                 8419D2A8120D92D000141F8F /* SVGPathByteStreamBuilder.cpp in Sources */,
</span><span class="cx">                                 8419D2AC120D92FC00141F8F /* SVGPathByteStreamSource.cpp in Sources */,
</span><ins>+                                316BDB9A1E70CBBF00DE0D5A /* GPULibrary.cpp in Sources */,
</ins><span class="cx">                                 B2227A580D00BF220071B782 /* SVGPathElement.cpp in Sources */,
</span><span class="cx">                                 8476C9EF11DF6A5800555B02 /* SVGPathParser.cpp in Sources */,
</span><span class="cx">                                 7C39C3711DDBB8AE00FEFB29 /* SVGPathSegList.cpp in Sources */,
</span><span class="lines">@@ -32613,6 +32636,7 @@
</span><span class="cx">                                 6F995A151A70756200A735F4 /* WebGLSync.cpp in Sources */,
</span><span class="cx">                                 49C7B9E51042D32F0009D447 /* WebGLTexture.cpp in Sources */,
</span><span class="cx">                                 6F995A231A7078B100A735F4 /* WebGLTransformFeedback.cpp in Sources */,
</span><ins>+                                316BDB971E70CA2400DE0D5A /* GPUFunctionMetal.mm in Sources */,
</ins><span class="cx">                                 0C3F1F5A10C8871200D72CE1 /* WebGLUniformLocation.cpp in Sources */,
</span><span class="cx">                                 6F995A251A7078B100A735F4 /* WebGLVertexArrayObject.cpp in Sources */,
</span><span class="cx">                                 6F222B761AB52D8A0094651A /* WebGLVertexArrayObjectBase.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaGPUFunctionMetalmmfromrev213649trunkSourceWebCoreplatformgraphicsgpuGPUDevicecpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/cocoa/GPUFunctionMetal.mm (from rev 213649, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/GPUFunctionMetal.mm         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GPUFunctionMetal.mm        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GPUFunction.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPULibrary.h"
+#import "Logging.h"
+#import <Metal/Metal.h>
+
+namespace WebCore {
+
+GPUFunction::GPUFunction(GPULibrary* library, const String& name)
+{
+ LOG(WebGPU, "GPUFunction::GPUFunction()");
+
+ if (!library || !library->platformLibrary())
+ return;
+
+ m_function = (MTLFunction*)[library->platformLibrary() newFunctionWithName:name];
+}
+
+String GPUFunction::name() const
+{
+ if (!m_function)
+ return emptyString();
+
+ return [m_function name];
+}
+
+MTLFunction* GPUFunction::platformFunction()
+{
+ return m_function.get();
+}
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscocoaGPULibraryMetalmmfromrev213649trunkSourceWebCoreplatformgraphicsgpuGPUDevicecpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm (from rev 213649, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -0,0 +1,88 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GPULibrary.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUDevice.h"
+#import "Logging.h"
+
+#import <Metal/Metal.h>
+
+namespace WebCore {
+
+GPULibrary::GPULibrary(GPUDevice* device, const String& sourceCode)
+{
+ LOG(WebGPU, "GPULibrary::GPULibrary()");
+
+ if (!device || !device->platformDevice())
+ return;
+
+ NSError *error = [NSError errorWithDomain:@"com.apple.WebKit.GPU" code:1 userInfo:nil];
+ m_library = (MTLLibrary*)[device->platformDevice() newLibraryWithSource:sourceCode options:nil error:&error];
+ if (!m_library)
+ LOG(WebGPU, "Compilation error: %s", [[error localizedDescription] UTF8String]);
+}
+
+String GPULibrary::label() const
+{
+ if (!m_library)
+ return emptyString();
+
+ return [m_library label];
+}
+
+void GPULibrary::setLabel(const String& label)
+{
+ if (!m_library)
+ return;
+
+ [m_library setLabel:label];
+}
+
+Vector<String> GPULibrary::functionNames()
+{
+ if (!m_library)
+ return Vector<String>();
+
+ Vector<String> names;
+
+ NSArray<NSString*> *functionNames = [m_library functionNames];
+ for (NSString *string in functionNames)
+ names.append(string);
+
+ return names;
+}
+
+MTLLibrary* GPULibrary::platformLibrary()
+{
+ return m_library.get();
+}
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUDevicecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp (213649 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp        2017-03-09 18:54:01 UTC (rev 213649)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -23,12 +23,13 @@
</span><span class="cx"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#import "config.h"
-#import "GPUDevice.h"
</del><ins>+#include "config.h"
+#include "GPUDevice.h"
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><span class="cx">
</span><del>-#import "Logging.h"
</del><ins>+#include "GPULibrary.h"
+#include "Logging.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -52,6 +53,11 @@
</span><span class="cx"> LOG(WebGPU, "GPUDevice::~GPUDevice()");
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode)
+{
+ return GPULibrary::create(this, sourceCode);
+}
+
</ins><span class="cx"> #if !PLATFORM(COCOA)
</span><span class="cx">
</span><span class="cx"> GPUDevice::GPUDevice()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUDeviceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h (213649 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h        2017-03-09 18:54:01 UTC (rev 213649)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -46,9 +46,10 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class GPULibrary;
+
</ins><span class="cx"> class GPUDevice : public RefCounted<GPUDevice> {
</span><span class="cx"> public:
</span><del>-
</del><span class="cx"> WEBCORE_EXPORT static RefPtr<GPUDevice> create();
</span><span class="cx"> WEBCORE_EXPORT ~GPUDevice();
</span><span class="cx">
</span><span class="lines">@@ -61,6 +62,8 @@
</span><span class="cx">
</span><span class="cx"> WebGPULayer* layer() { return m_layer.get(); }
</span><span class="cx">
</span><ins>+ WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode);
+
</ins><span class="cx"> private:
</span><span class="cx"> GPUDevice();
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUFunctioncppfromrev213649trunkSourceWebCoreplatformgraphicsgpuGPUDevicecpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUFunction.cpp (from rev 213649, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUFunction.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUFunction.cpp        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -0,0 +1,70 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GPUFunction.h"
+
+#if ENABLE(WEBGPU)
+
+#include "GPULibrary.h"
+#include "Logging.h"
+
+namespace WebCore {
+
+RefPtr<GPUFunction> GPUFunction::create(GPULibrary* library, const String& name)
+{
+ RefPtr<GPUFunction> function = adoptRef(new GPUFunction(library, name));
+#if PLATFORM(COCOA)
+ if (!function->platformFunction())
+ return nullptr;
+#endif
+ return function;
+}
+
+GPUFunction::~GPUFunction()
+{
+ LOG(WebGPU, "GPUFunction::~GPUFunction()");
+}
+
+#if !PLATFORM(COCOA)
+GPUFunction::GPUFunction(GPULibrary* library, const String& name)
+{
+ LOG(WebGPU, "GPUFunction::GPUFunction()");
+
+ if (!library || !library->library())
+ return;
+}
+
+String GPUFunction::name() const
+{
+ return emptyString();
+}
+#endif
+
+
+} // namespace WebCore
+
+#endif
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUFunctionhfromrev213649trunkSourceWebCoreplatformgraphicsgpuGPUDevicecpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUFunction.h (from rev 213649, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUFunction.h         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUFunction.h        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGPU)
+
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+#if PLATFORM(COCOA)
+OBJC_CLASS MTLFunction;
+#endif
+
+namespace WebCore {
+
+class GPULibrary;
+
+class GPUFunction : public RefCounted<GPUFunction> {
+public:
+ static RefPtr<GPUFunction> create(GPULibrary*, const String& name);
+ WEBCORE_EXPORT ~GPUFunction();
+
+ WEBCORE_EXPORT String name() const;
+
+#if PLATFORM(COCOA)
+ WEBCORE_EXPORT MTLFunction* platformFunction();
+#endif
+
+private:
+ GPUFunction(GPULibrary*, const String& name);
+
+#if PLATFORM(COCOA)
+ RetainPtr<MTLFunction> m_function;
+#endif
+};
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPULibrarycppfromrev213649trunkSourceWebCoreplatformgraphicsgpuGPUDevicecpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/gpu/GPULibrary.cpp (from rev 213649, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPULibrary.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPULibrary.cpp        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GPULibrary.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUDevice.h"
+#import "GPUFunction.h"
+#import "Logging.h"
+
+namespace WebCore {
+
+RefPtr<GPULibrary> GPULibrary::create(GPUDevice* device, const String& sourceCode)
+{
+ RefPtr<GPULibrary> library = adoptRef(new GPULibrary(device, sourceCode));
+ return library;
+}
+
+GPULibrary::~GPULibrary()
+{
+ LOG(WebGPU, "GPULibrary::~GPULibrary()");
+}
+
+#if !PLATFORM(COCOA)
+
+String GPULibrary::label() const
+{
+ return emptyString();
+}
+
+void GPULibrary::setLabel(const String&)
+{
+}
+
+Vector<String> GPULibrary::functionNames()
+{
+ return { };
+}
+
+#endif
+
+RefPtr<GPUFunction> GPULibrary::functionWithName(const String& name)
+{
+ return GPUFunction::create(this, name);
+}
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPULibraryhfromrev213649trunkSourceWebCoreplatformgraphicsgpuGPUDeviceh"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/gpu/GPULibrary.h (from rev 213649, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h) (0 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPULibrary.h         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPULibrary.h        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -0,0 +1,69 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGPU)
+
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+#if PLATFORM(COCOA)
+OBJC_CLASS MTLLibrary;
+#endif
+
+namespace WebCore {
+
+class GPUDevice;
+class GPUFunction;
+
+class GPULibrary : public RefCounted<GPULibrary> {
+public:
+ static RefPtr<GPULibrary> create(GPUDevice*, const String& sourceCode);
+ WEBCORE_EXPORT ~GPULibrary();
+
+ WEBCORE_EXPORT String label() const;
+ WEBCORE_EXPORT void setLabel(const String&);
+
+ WEBCORE_EXPORT Vector<String> functionNames();
+
+ WEBCORE_EXPORT RefPtr<GPUFunction> functionWithName(const String&);
+
+#if PLATFORM(COCOA)
+ WEBCORE_EXPORT MTLLibrary* platformLibrary();
+#endif
+
+private:
+ GPULibrary(GPUDevice*, const String& sourceCode);
+
+#if PLATFORM(COCOA)
+ RetainPtr<MTLLibrary> m_library;
+#endif
+};
+
+} // namespace WebCore
+#endif
</ins></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (213649 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-03-09 18:54:01 UTC (rev 213649)
+++ trunk/Tools/ChangeLog        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2017-03-08 Dean Jackson <dino@apple.com>
+
+ WebGPU: Backend - Library and Functions
+ https://bugs.webkit.org/show_bug.cgi?id=169371
+ <rdar://problem/30928792>
+
+ Reviewed by Tim Horton.
+
+ Add tests for GPULibrary and GPUFunction.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm:
+ (TestWebKitAPI::TEST_F):
+ (TestWebKitAPI::TEST): Deleted.
+ * TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm: Copied from Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm.
+ (TestWebKitAPI::TEST_F):
+ * TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm: Copied from Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm.
+ (TestWebKitAPI::TEST_F):
+ * TestWebKitAPI/Tests/WebCore/mac/GPUTest.h: Copied from Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm.
+ (TestWebKitAPI::GPU::librarySourceCode):
+
</ins><span class="cx"> 2017-03-08 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> WTF should make it super easy to do ARM concurrency tricks
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (213649 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-03-09 18:54:01 UTC (rev 213649)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -94,6 +94,8 @@
</span><span class="cx">                 2EFF06D71D8AF34A0004BB30 /* WKWebViewCandidateTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */; };
</span><span class="cx">                 315118101DB1AE4000176304 /* ExtendedColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3151180F1DB1ADD500176304 /* ExtendedColor.cpp */; };
</span><span class="cx">                 3162AE9C1E6F2FF5000E4DBC /* GPUDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3162AE9B1E6F2FCE000E4DBC /* GPUDevice.mm */; };
</span><ins>+                316BDBA11E70D71B00DE0D5A /* GPULibrary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA01E70D6D800DE0D5A /* GPULibrary.mm */; };
+                316BDBA41E70EF6800DE0D5A /* GPUFunction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA31E70EF5D00DE0D5A /* GPUFunction.mm */; };
</ins><span class="cx">                 33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; };
</span><span class="cx">                 33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33DC890E1419539300747EF7 /* simple-iframe.html */; };
</span><span class="cx">                 33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; };
</span><span class="lines">@@ -948,6 +950,9 @@
</span><span class="cx">                 2EFF06D61D8AF34A0004BB30 /* WKWebViewCandidateTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewCandidateTests.mm; sourceTree = "<group>"; };
</span><span class="cx">                 3151180F1DB1ADD500176304 /* ExtendedColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtendedColor.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 3162AE9B1E6F2FCE000E4DBC /* GPUDevice.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUDevice.mm; sourceTree = "<group>"; };
</span><ins>+                316BDBA01E70D6D800DE0D5A /* GPULibrary.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPULibrary.mm; sourceTree = "<group>"; };
+                316BDBA21E70DEE500DE0D5A /* GPUTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUTest.h; sourceTree = "<group>"; };
+                316BDBA31E70EF5D00DE0D5A /* GPUFunction.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUFunction.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash_Bundle.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -1666,6 +1671,9 @@
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><span class="cx">                                 3162AE9B1E6F2FCE000E4DBC /* GPUDevice.mm */,
</span><ins>+                                316BDBA31E70EF5D00DE0D5A /* GPUFunction.mm */,
+                                316BDBA01E70D6D800DE0D5A /* GPULibrary.mm */,
+                                316BDBA21E70DEE500DE0D5A /* GPUTest.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = mac;
</span><span class="cx">                         sourceTree = "<group>";
</span><span class="lines">@@ -2750,6 +2758,7 @@
</span><span class="cx">                                 37D36ED71AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm in Sources */,
</span><span class="cx">                                 7CCE7EFE1A411AE600447C4C /* LoadAlternateHTMLStringWithNonDirectoryURL.cpp in Sources */,
</span><span class="cx">                                 5C0BF8941DD599C900B00328 /* MenuTypesForMouseEvents.mm in Sources */,
</span><ins>+                                316BDBA11E70D71B00DE0D5A /* GPULibrary.mm in Sources */,
</ins><span class="cx">                                 5C0BF8931DD599BD00B00328 /* IsNavigationActionTrusted.mm in Sources */,
</span><span class="cx">                                 7CCE7EFF1A411AE600447C4C /* LoadCanceledNoServerRedirectCallback.cpp in Sources */,
</span><span class="cx">                                 7C83E0C01D0A652700FEBCF3 /* LoadInvalidURLRequest.mm in Sources */,
</span><span class="lines">@@ -2880,6 +2889,7 @@
</span><span class="cx">                                 7CCE7ED71A411A7E00447C4C /* WillPerformClientRedirectToURLCrash.mm in Sources */,
</span><span class="cx">                                 7CCE7F1C1A411AE600447C4C /* WillSendSubmitEvent.cpp in Sources */,
</span><span class="cx">                                 7CCE7ED81A411A7E00447C4C /* WillSendSubmitEvent.mm in Sources */,
</span><ins>+                                316BDBA41E70EF6800DE0D5A /* GPUFunction.mm in Sources */,
</ins><span class="cx">                                 7CCE7ED91A411A7E00447C4C /* WindowlessWebViewWithMedia.mm in Sources */,
</span><span class="cx">                                 1F83571B1D3FFB2300E3967B /* WKBackForwardList.mm in Sources */,
</span><span class="cx">                                 A17991881E1C994E00A505ED /* SharedBuffer.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoremacGPUDevicemm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm (213649 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm        2017-03-09 18:54:01 UTC (rev 213649)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -23,10 +23,11 @@
</span><span class="cx"> * THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#ifdef ENABLE_WEBGPU
</del><ins>+#import "config.h"
</ins><span class="cx">
</span><del>-#include "config.h"
-#import "Test.h"
</del><ins>+#if ENABLE(WEBGPU)
+
+#import "GPUTest.h"
</ins><span class="cx"> #import <Metal/Metal.h>
</span><span class="cx"> #import <WebCore/GPUDevice.h>
</span><span class="cx">
</span><span class="lines">@@ -34,7 +35,7 @@
</span><span class="cx">
</span><span class="cx"> namespace TestWebKitAPI {
</span><span class="cx">
</span><del>-TEST(GPU, Basic)
</del><ins>+TEST_F(GPU, DeviceCreate)
</ins><span class="cx"> {
</span><span class="cx"> auto device = GPUDevice::create();
</span><span class="cx"> // Not all hardware supports Metal, so it is possible
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoremacGPUFunctionmmfromrev213649trunkToolsTestWebKitAPITestsWebCoremacGPUDevicemm"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm (from rev 213649, trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm) (0 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -0,0 +1,71 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#import "config.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUTest.h"
+#import <Metal/Metal.h>
+#import <WebCore/GPUDevice.h>
+#import <WebCore/GPUFunction.h>
+#import <WebCore/GPULibrary.h>
+#import <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+TEST_F(GPU, FunctionAccessByName)
+{
+ auto device = GPUDevice::create();
+ // Not all hardware supports Metal, so it is possible
+ // that we were unable to create the MTLDevice object.
+ // In that case, the device should be null.
+ if (!device)
+ return;
+
+ id<MTLDevice> mtlDevice = (id<MTLDevice>)device->platformDevice();
+ EXPECT_NOT_NULL(mtlDevice);
+
+ auto library = device->createLibrary(librarySourceCode());
+ EXPECT_NOT_NULL(library);
+
+ auto vertexFunction = library->functionWithName("vertex_main");
+ EXPECT_NOT_NULL(vertexFunction);
+ EXPECT_TRUE(vertexFunction->name() == "vertex_main");
+
+ auto fragmentFunction = library->functionWithName("fragment_main");
+ EXPECT_NOT_NULL(fragmentFunction);
+ EXPECT_TRUE(fragmentFunction->name() == "fragment_main");
+
+ auto nonExistentFunction = library->functionWithName("name_that_is_not_in_library");
+ EXPECT_NULL(nonExistentFunction);
+}
+
+} // namespace TestWebKitAPI
+
+#endif
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoremacGPULibrarymmfromrev213649trunkToolsTestWebKitAPITestsWebCoremacGPUDevicemm"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm (from rev 213649, trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm) (0 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUTest.h"
+#import <Metal/Metal.h>
+#import <WebCore/GPUDevice.h>
+#import <WebCore/GPULibrary.h>
+#import <wtf/MainThread.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+TEST_F(GPU, LibraryCreate)
+{
+ auto device = GPUDevice::create();
+ // Not all hardware supports Metal, so it is possible
+ // that we were unable to create the MTLDevice object.
+ // In that case, the device should be null.
+ if (!device)
+ return;
+
+ id<MTLDevice> mtlDevice = (id<MTLDevice>)device->platformDevice();
+ EXPECT_NOT_NULL(mtlDevice);
+
+ auto library = device->createLibrary(librarySourceCode());
+ EXPECT_NOT_NULL(library);
+}
+
+TEST_F(GPU, LibrarySetLabel)
+{
+ auto device = GPUDevice::create();
+ if (!device)
+ return;
+
+ auto library = device->createLibrary(librarySourceCode());
+ EXPECT_NOT_NULL(library);
+
+ library->setLabel("TestLabel");
+ EXPECT_TRUE(library->label() == "TestLabel");
+}
+
+TEST_F(GPU, LibraryFunctionNames)
+{
+ auto device = GPUDevice::create();
+ if (!device)
+ return;
+
+ auto library = device->createLibrary(librarySourceCode());
+ EXPECT_NOT_NULL(library);
+
+ auto functionNames = library->functionNames();
+ EXPECT_EQ(functionNames.size(), static_cast<unsigned long>(2));
+ EXPECT_TRUE(functionNames[0] == "vertex_main");
+ EXPECT_TRUE(functionNames[1] == "fragment_main");
+}
+
+} // namespace TestWebKitAPI
+
+#endif
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebCoremacGPUTesthfromrev213649trunkToolsTestWebKitAPITestsWebCoremacGPUDevicemm"></a>
<div class="copfile"><h4>Copied: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUTest.h (from rev 213649, trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUDevice.mm) (0 => 213650)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUTest.h         (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUTest.h        2017-03-09 19:02:11 UTC (rev 213650)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#import "Test.h"
+#import "WTFStringUtilities.h"
+#import <wtf/MainThread.h>
+
+namespace TestWebKitAPI {
+
+class GPU : public testing::Test {
+public:
+ void SetUp() final
+ {
+ WTF::initializeMainThread();
+
+ m_librarySourceCode = ASCIILiteral("using namespace metal;\n\
+ struct Vertex\n\
+ {\n\
+ float4 position [[position]];\n\
+ float4 color;\n\
+ };\n\
+ vertex Vertex vertex_main(device Vertex *vertices [[buffer(0)]],\n\
+ uint vid [[vertex_id]])\n\
+ {\n\
+ return vertices[vid];\n\
+ }\n\
+ fragment float4 fragment_main(Vertex inVertex [[stage_in]])\n\
+ {\n\
+ return inVertex.color;\n\
+ }");
+ }
+
+ const String& librarySourceCode() { return m_librarySourceCode; }
+
+private:
+ String m_librarySourceCode;
+};
+
+}
</ins></span></pre>
</div>
</div>
</body>
</html>