<!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>[242759] 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/242759">242759</a></dd>
<dt>Author</dt> <dd>justin_fan@apple.com</dd>
<dt>Date</dt> <dd>2019-03-11 17:46:41 -0700 (Mon, 11 Mar 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Web GPU] Update GPUSwapChainDescriptor, GPUSwapChain and implement GPUCanvasContext
https://bugs.webkit.org/show_bug.cgi?id=194406
<rdar://problem/47892466>

Reviewed by Myles C. Maxfield.

Source/JavaScriptCore:

Added WebGPU to inspector context types.

* inspector/protocol/Canvas.json:
* inspector/scripts/codegen/generator.py:

Source/WebCore:

GPUSwapChain no longer inherits from GPUBasedRenderingContext, and is now created from a GPUDevice.
WebGPURenderingContext is now GPUCanvasContext and delegates functionality to the GPUSwapChain, if it exists.
GPUQueue now implicitly presents the GPUSwapChain's current drawable at the task boundary, if one exists.
Creating a new GPUSwapChain with the same GPUCanvasContext invalidates the previous one and its drawable and pipeline attachments.
Calling GPUSwapChain::getCurrentTexture returns the same drawable within one task cycle.
Some mentions of "WebGPU" have been renamed to "Web GPU" and "gpu".

All Web GPU tests updated to match.

Add new files and symbols.
* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/WebCoreBuiltinNames.h:

Rename some mentions of "webgpu" to "gpu".
* Modules/webgpu/DOMWindowWebGPU.cpp:
(WebCore::DOMWindowWebGPU::gpu):
(WebCore::DOMWindowWebGPU::gpu const):
* Modules/webgpu/DOMWindowWebGPU.h:
* Modules/webgpu/DOMWindowWebGPU.idl:

Replace WebGPURenderingContext with GPUCanvasContext.
* Modules/webgpu/GPUCanvasContext.cpp: Renamed from Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp.
(WebCore::GPUCanvasContext::create):
(WebCore::GPUCanvasContext::GPUCanvasContext):
(WebCore::GPUCanvasContext::replaceSwapChain):
(WebCore::GPUCanvasContext::platformLayer const):
(WebCore::GPUCanvasContext::reshape):
(WebCore::GPUCanvasContext::markLayerComposited):
* Modules/webgpu/GPUCanvasContext.h: Renamed from Source/WebCore/Modules/webgpu/WebGPURenderingContext.h.
* Modules/webgpu/GPUCanvasContext.idl: Renamed from Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl.
* dom/Document.cpp:
(WebCore::Document::getCSSCanvasContext):
* dom/Document.h:
* dom/Document.idl:
* html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::getContext):
(WebCore::HTMLCanvasElement::isWebGPUType):
(WebCore::HTMLCanvasElement::createContextWebGPU):
(WebCore::HTMLCanvasElement::getContextWebGPU):
* html/HTMLCanvasElement.h:
* html/HTMLCanvasElement.idl:
* inspector/InspectorCanvas.cpp:
(WebCore::InspectorCanvas::buildObjectForCanvas):
* inspector/agents/InspectorCanvasAgent.cpp:
(WebCore::contextAsScriptValue):

Update WebGPUSwapChain.
* Modules/webgpu/GPUTextureDescriptor.idl:
* Modules/webgpu/GPUTextureFormat.idl: Add the other two texture formats supported by CAMetalLayer.
* Modules/webgpu/WebGPUDevice.cpp: Implement createSwapChain.
(WebCore::WebGPUDevice::createSwapChain const):
(WebCore::WebGPUDevice::getQueue const):
(WebCore::WebGPUDevice::getQueue): Deleted.
* Modules/webgpu/WebGPUDevice.h:
* Modules/webgpu/WebGPUDevice.idl:
* Modules/webgpu/WebGPUSwapChain.cpp:
(WebCore::WebGPUSwapChain::create):
(WebCore::WebGPUSwapChain::WebGPUSwapChain):
(WebCore::WebGPUSwapChain::getCurrentTexture): Renamed from getNextTexture. Only returns the next drawable if the last was presented.
(WebCore::WebGPUSwapChain::destroy): Invalidate this GPUSwapChain and its textures and views.
(WebCore::WebGPUSwapChain::configure): Deleted.
(WebCore::WebGPUSwapChain::getNextTexture): Deleted.
(WebCore::WebGPUSwapChain::present): Deleted.
(WebCore::WebGPUSwapChain::reshape): Deleted.
(WebCore::WebGPUSwapChain::markLayerComposited): Deleted.
* Modules/webgpu/WebGPUSwapChain.h: Now a device-based object rather than a rendering context.
(WebCore::WebGPUSwapChain::swapChain const):
(WebCore::WebGPUSwapChain::WebGPUSwapChain): Deleted.
* Modules/webgpu/WebGPUSwapChain.idl:
* Modules/webgpu/WebGPUSwapChainDescriptor.h: Added.
* platform/graphics/gpu/GPUDevice.cpp: Implement tryCreateSwapChain.
(WebCore::GPUDevice::tryCreateSwapChain const):
(WebCore::GPUDevice::getQueue const):
(WebCore::GPUDevice::getQueue): Deleted.
* platform/graphics/gpu/GPUDevice.h: Retain a reference to the current GPUSwapChain, if one exists.
(WebCore::GPUDevice::swapChain const):
* platform/graphics/gpu/GPUQueue.h:
* platform/graphics/gpu/GPUSwapChain.h:
(WebCore::GPUSwapChain::destroy):
* platform/graphics/gpu/GPUSwapChainDescriptor.h: Added.
* platform/graphics/gpu/GPUTextureFormat.h: Add the other two texture formats supported by CAMetalLayer.
* platform/graphics/gpu/cocoa/GPUBufferMetal.mm:
(WebCore::GPUBuffer::commandBufferCommitted):
* platform/graphics/gpu/cocoa/GPUQueueMetal.mm:
(WebCore::GPUQueue::tryCreate): Renamed from create to better fit functionality. Now retain a reference to the GPUDevice.
(WebCore::GPUQueue::GPUQueue):
(WebCore::GPUQueue::submit): Now checks state of all resources before marking them as committed or committing any resource.
        In addition, schedules the current drawable to be presented after all commands have been submitted during this task cycle.
* platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
(WebCore::useAttachments): Ensure that the command buffer is aware of any texture resources used as attachments.
(WebCore::GPURenderPassEncoder::tryCreate):
* platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm:
(WebCore::tryGetSupportedPixelFormat): Supported texture formats are the intersection of Web GPU's texture formats and CAMetalLayer's.
(WebCore::setLayerShape):
(WebCore::tryCreateSwapLayer): Create and configure the CAMetalLayer backing the swap chain.
(WebCore::GPUSwapChain::tryCreate):
(WebCore::GPUSwapChain::GPUSwapChain):
(WebCore::GPUSwapChain::tryGetCurrentTexture): Renamed from getNextTexture. Only returns a texture if the last one was presented.
(WebCore::GPUSwapChain::present):
(WebCore::GPUSwapChain::reshape):
(WebCore::GPUSwapChain::takeDrawable): Swaps out the current drawable so that it can be presented. The GPUSwapChain thus releases its reference to it.
(WebCore::GPUSwapChain::create): Deleted.
(WebCore::GPUSwapChain::setDevice): Deleted.
(WebCore::GPUSwapChain::setFormat): Deleted.
(WebCore::GPUSwapChain::getNextTexture): Deleted.
* platform/graphics/gpu/cocoa/GPUUtilsMetal.mm:
(WebCore::platformTextureFormatForGPUTextureFormat):

Misc:
* Modules/webgpu/WebGPUProgrammablePassEncoder.cpp: Missing include.

Source/WebInspectorUI:

Name updates for Web GPU renaming in inspector.

* UserInterface/Models/Canvas.js:
(WI.Canvas.displayNameForContextType):

LayoutTests:

Update all tests for new WebGPUSwapChain and GPUCanvasContext, and window object name change from 'webgpu' to 'gpu'.
In addition, all tests have been updated to WPT style.

* webgpu/adapter-options.html:
* webgpu/buffer-command-buffer-races.html:
* webgpu/buffer-resource-triangles.html:
* webgpu/command-buffers-expected.txt:
* webgpu/command-buffers.html:
* webgpu/depth-enabled-triangle-strip.html:
* webgpu/js/basic-webgpu-functions.js: Removed. No longer needed.
* webgpu/js/webgpu-functions.js:
(async.getBasicDevice):
(createBasicSwapChain): Renamed from createBasicContext.
(beginBasicRenderPass):
(createBasicContext): Deleted.
(createBasicDepthStateDescriptor): Deleted.
* webgpu/queue-creation.html:
* webgpu/render-command-encoding-expected.txt:
* webgpu/render-command-encoding.html:
* webgpu/render-passes-expected.txt: Removed.
* webgpu/render-passes.html: Removed for redundancy with other tests.
* webgpu/shader-modules-expected.txt:
* webgpu/shader-modules.html:
* webgpu/simple-triangle-strip.html:
* webgpu/texture-triangle-strip.html:
* webgpu/textures-textureviews.html:
* webgpu/vertex-buffer-triangle-strip.html:
* webgpu/webgpu-basics-expected.txt: Removed.
* webgpu/webgpu-basics.html: Removed for redundancy with other tests.
* webgpu/webgpu-enabled-expected.txt:
* webgpu/webgpu-enabled.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestswebgpuadapteroptionshtml">trunk/LayoutTests/webgpu/adapter-options.html</a></li>
<li><a href="#trunkLayoutTestswebgpubuffercommandbufferraceshtml">trunk/LayoutTests/webgpu/buffer-command-buffer-races.html</a></li>
<li><a href="#trunkLayoutTestswebgpubufferresourcetriangleshtml">trunk/LayoutTests/webgpu/buffer-resource-triangles.html</a></li>
<li><a href="#trunkLayoutTestswebgpucommandbuffersexpectedtxt">trunk/LayoutTests/webgpu/command-buffers-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebgpucommandbuffershtml">trunk/LayoutTests/webgpu/command-buffers.html</a></li>
<li><a href="#trunkLayoutTestswebgpudepthenabledtrianglestriphtml">trunk/LayoutTests/webgpu/depth-enabled-triangle-strip.html</a></li>
<li><a href="#trunkLayoutTestswebgpujswebgpufunctionsjs">trunk/LayoutTests/webgpu/js/webgpu-functions.js</a></li>
<li><a href="#trunkLayoutTestswebgpuqueuecreationhtml">trunk/LayoutTests/webgpu/queue-creation.html</a></li>
<li><a href="#trunkLayoutTestswebgpurendercommandencodingexpectedtxt">trunk/LayoutTests/webgpu/render-command-encoding-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebgpurendercommandencodinghtml">trunk/LayoutTests/webgpu/render-command-encoding.html</a></li>
<li><a href="#trunkLayoutTestswebgpushadermodulesexpectedtxt">trunk/LayoutTests/webgpu/shader-modules-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebgpushadermoduleshtml">trunk/LayoutTests/webgpu/shader-modules.html</a></li>
<li><a href="#trunkLayoutTestswebgpusimpletrianglestriphtml">trunk/LayoutTests/webgpu/simple-triangle-strip.html</a></li>
<li><a href="#trunkLayoutTestswebgputexturetrianglestriphtml">trunk/LayoutTests/webgpu/texture-triangle-strip.html</a></li>
<li><a href="#trunkLayoutTestswebgputexturestextureviewshtml">trunk/LayoutTests/webgpu/textures-textureviews.html</a></li>
<li><a href="#trunkLayoutTestswebgpuvertexbuffertrianglestriphtml">trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip.html</a></li>
<li><a href="#trunkLayoutTestswebgpuwebgpuenabledexpectedtxt">trunk/LayoutTests/webgpu/webgpu-enabled-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebgpuwebgpuenabledhtml">trunk/LayoutTests/webgpu/webgpu-enabled.html</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorprotocolCanvasjson">trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorscriptscodegengeneratorpy">trunk/Source/JavaScriptCore/inspector/scripts/codegen/generator.py</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesinputxcfilelist">trunk/Source/WebCore/DerivedSources-input.xcfilelist</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesoutputxcfilelist">trunk/Source/WebCore/DerivedSources-output.xcfilelist</a></li>
<li><a href="#trunkSourceWebCoreDerivedSourcesmake">trunk/Source/WebCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuDOMWindowWebGPUcpp">trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuDOMWindowWebGPUh">trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuDOMWindowWebGPUidl">trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.idl</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuGPUTextureDescriptoridl">trunk/Source/WebCore/Modules/webgpu/GPUTextureDescriptor.idl</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuGPUTextureFormatidl">trunk/Source/WebCore/Modules/webgpu/GPUTextureFormat.idl</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUDevicecpp">trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUDeviceh">trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUDeviceidl">trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUProgrammablePassEncodercpp">trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUSwapChaincpp">trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUSwapChainh">trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUSwapChainidl">trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.idl</a></li>
<li><a href="#trunkSourceWebCoreSourcestxt">trunk/Source/WebCore/Sources.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh">trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentcpp">trunk/Source/WebCore/dom/Document.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDocumenth">trunk/Source/WebCore/dom/Document.h</a></li>
<li><a href="#trunkSourceWebCoredomDocumentidl">trunk/Source/WebCore/dom/Document.idl</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCanvasElementcpp">trunk/Source/WebCore/html/HTMLCanvasElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCanvasElementh">trunk/Source/WebCore/html/HTMLCanvasElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLCanvasElementidl">trunk/Source/WebCore/html/HTMLCanvasElement.idl</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorCanvascpp">trunk/Source/WebCore/inspector/InspectorCanvas.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectoragentsInspectorCanvasAgentcpp">trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp</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="#trunkSourceWebCoreplatformgraphicsgpuGPUQueueh">trunk/Source/WebCore/platform/graphics/gpu/GPUQueue.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpuGPUSwapChainh">trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChain.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpuGPUTextureFormath">trunk/Source/WebCore/platform/graphics/gpu/GPUTextureFormat.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpucocoaGPUBufferMetalmm">trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpucocoaGPUQueueMetalmm">trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUQueueMetal.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpucocoaGPURenderPassEncoderMetalmm">trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpucocoaGPUSwapChainMetalmm">trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpucocoaGPUUtilsMetalmm">trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUUtilsMetal.mm</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsCanvasjs">trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreModuleswebgpuGPUCanvasContextcpp">trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuGPUCanvasContexth">trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuGPUCanvasContextidl">trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.idl</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPUSwapChainDescriptorh">trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgpuGPUSwapChainDescriptorh">trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChainDescriptor.h</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswebgpujsbasicwebgpufunctionsjs">trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js</a></li>
<li><a href="#trunkLayoutTestswebgpurenderpassesexpectedtxt">trunk/LayoutTests/webgpu/render-passes-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebgpurenderpasseshtml">trunk/LayoutTests/webgpu/render-passes.html</a></li>
<li><a href="#trunkLayoutTestswebgpuwebgpubasicsexpectedtxt">trunk/LayoutTests/webgpu/webgpu-basics-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebgpuwebgpubasicshtml">trunk/LayoutTests/webgpu/webgpu-basics.html</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPURenderingContextcpp">trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPURenderingContexth">trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.h</a></li>
<li><a href="#trunkSourceWebCoreModuleswebgpuWebGPURenderingContextidl">trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/ChangeLog 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2019-03-11  Justin Fan  <justin_fan@apple.com>
+
+        [Web GPU] Update GPUSwapChainDescriptor, GPUSwapChain and implement GPUCanvasContext
+        https://bugs.webkit.org/show_bug.cgi?id=194406
+        <rdar://problem/47892466>
+
+        Reviewed by Myles C. Maxfield.
+
+        Update all tests for new WebGPUSwapChain and GPUCanvasContext, and window object name change from 'webgpu' to 'gpu'.
+        In addition, all tests have been updated to WPT style. 
+
+        * webgpu/adapter-options.html:
+        * webgpu/buffer-command-buffer-races.html:
+        * webgpu/buffer-resource-triangles.html:
+        * webgpu/command-buffers-expected.txt:
+        * webgpu/command-buffers.html:
+        * webgpu/depth-enabled-triangle-strip.html:
+        * webgpu/js/basic-webgpu-functions.js: Removed. No longer needed.
+        * webgpu/js/webgpu-functions.js:
+        (async.getBasicDevice):
+        (createBasicSwapChain): Renamed from createBasicContext.
+        (beginBasicRenderPass):
+        (createBasicContext): Deleted.
+        (createBasicDepthStateDescriptor): Deleted.
+        * webgpu/queue-creation.html:
+        * webgpu/render-command-encoding-expected.txt:
+        * webgpu/render-command-encoding.html:
+        * webgpu/render-passes-expected.txt: Removed.
+        * webgpu/render-passes.html: Removed for redundancy with other tests.
+        * webgpu/shader-modules-expected.txt:
+        * webgpu/shader-modules.html:
+        * webgpu/simple-triangle-strip.html:
+        * webgpu/texture-triangle-strip.html:
+        * webgpu/textures-textureviews.html:
+        * webgpu/vertex-buffer-triangle-strip.html:
+        * webgpu/webgpu-basics-expected.txt: Removed.
+        * webgpu/webgpu-basics.html: Removed for redundancy with other tests.
+        * webgpu/webgpu-enabled-expected.txt:
+        * webgpu/webgpu-enabled.html:
+
</ins><span class="cx"> 2019-03-11  Simon Fraser  <simon.fraser@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS WK2] REGRESSION (r242687): Programmatic scroll of overflow scroll results in bad rendering
</span></span></pre></div>
<a id="trunkLayoutTestswebgpuadapteroptionshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/adapter-options.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/adapter-options.html    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/adapter-options.html       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -6,7 +6,7 @@
</span><span class="cx"> <script src="../resources/testharnessreport.js"></script>
</span><span class="cx"> <script>
</span><span class="cx"> promise_test(async () => {
</span><del>-    const defaultAdapter = await webgpu.requestAdapter();
</del><ins>+    const defaultAdapter = await gpu.requestAdapter();
</ins><span class="cx">     const device = defaultAdapter.createDevice();
</span><span class="cx"> 
</span><span class="cx">     assert_true(device instanceof WebGPUDevice, "Default device successfully created.");
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx"> }, "Create the default device.");
</span><span class="cx"> 
</span><span class="cx"> promise_test(async () => {
</span><del>-    const lowPowerAdapter = await webgpu.requestAdapter({ powerPreference: "low-power" });
</del><ins>+    const lowPowerAdapter = await gpu.requestAdapter({ powerPreference: "low-power" });
</ins><span class="cx">     const device = lowPowerAdapter.createDevice();
</span><span class="cx"> 
</span><span class="cx">     assert_true(device instanceof WebGPUDevice, "Device successfully created using low-power option.");
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> }, "Create a device with a low-power option.");
</span><span class="cx"> 
</span><span class="cx"> promise_test(async () => {
</span><del>-    const highPerfAdapter = await webgpu.requestAdapter({ powerPreference: "high-performance" });
</del><ins>+    const highPerfAdapter = await gpu.requestAdapter({ powerPreference: "high-performance" });
</ins><span class="cx">     const device = highPerfAdapter.createDevice();
</span><span class="cx"> 
</span><span class="cx">     assert_true(device instanceof WebGPUDevice, "Device successfully created using high-performance option.");
</span></span></pre></div>
<a id="trunkLayoutTestswebgpubuffercommandbufferraceshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/buffer-command-buffer-races.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/buffer-command-buffer-races.html        2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/buffer-command-buffer-races.html   2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx"> async function test() {
</span><span class="cx">     const device = await getBasicDevice();
</span><span class="cx">     const canvas = document.querySelector("canvas");
</span><del>-    const context = createBasicContext(canvas, device);
</del><ins>+    const swapChain = createBasicSwapChain(canvas, device);
</ins><span class="cx">     // FIXME: Replace with non-MSL shaders.
</span><span class="cx">     const shaderModule = device.createShaderModule({ code: shaderCode });
</span><span class="cx">     const inputStateDescriptor = createInputStateDescriptor();
</span><span class="lines">@@ -107,7 +107,7 @@
</span><span class="cx">     colorBuffer.setSubData(0, greenArray.buffer);
</span><span class="cx"> 
</span><span class="cx">     const attachment = {
</span><del>-        attachment: context.getNextTexture().createDefaultTextureView(),
</del><ins>+        attachment: swapChain.getCurrentTexture().createDefaultTextureView(),
</ins><span class="cx">         loadOp: "load",
</span><span class="cx">         storeOp: "store",
</span><span class="cx">         clearColor: { r: 1, g: 0, b: 0, a: 1 }
</span><span class="lines">@@ -148,8 +148,6 @@
</span><span class="cx">     upperLeftBuffer.destroy();
</span><span class="cx">     middleBuffer.destroy();
</span><span class="cx">     upperRightBuffer.destroy();
</span><del>-    
-    context.present();
</del><span class="cx"> 
</span><span class="cx">     if (window.testRunner)
</span><span class="cx">         testRunner.notifyDone();
</span></span></pre></div>
<a id="trunkLayoutTestswebgpubufferresourcetriangleshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/buffer-resource-triangles.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/buffer-resource-triangles.html  2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/buffer-resource-triangles.html     2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -118,7 +118,7 @@
</span><span class="cx"> async function test() {
</span><span class="cx">     const device = await getBasicDevice();
</span><span class="cx">     const canvas = document.querySelector("canvas");
</span><del>-    const context = createBasicContext(canvas, device);
</del><ins>+    const swapChain = createBasicSwapChain(canvas, device);
</ins><span class="cx">     // FIXME: Replace with non-MSL shaders.
</span><span class="cx">     const shaderModule = device.createShaderModule({ code: shaderCode });
</span><span class="cx"> 
</span><span class="lines">@@ -195,7 +195,7 @@
</span><span class="cx"> 
</span><span class="cx">     Promise.all(bufferPromises).then(() => {
</span><span class="cx">         const commandBuffer = device.createCommandBuffer();
</span><del>-        const passEncoder = beginBasicRenderPass(context, commandBuffer);
</del><ins>+        const passEncoder = beginBasicRenderPass(swapChain, commandBuffer);
</ins><span class="cx">         passEncoder.setPipeline(pipeline);
</span><span class="cx"> 
</span><span class="cx">         // Vertex data for upper triangles.
</span><span class="lines">@@ -208,7 +208,6 @@
</span><span class="cx">         const endCommandBuffer = passEncoder.endPass();
</span><span class="cx">         const queue = device.getQueue();
</span><span class="cx">         queue.submit([endCommandBuffer]);
</span><del>-        context.present();
</del><span class="cx"> 
</span><span class="cx">         if (window.testRunner)
</span><span class="cx">             testRunner.notifyDone();
</span></span></pre></div>
<a id="trunkLayoutTestswebgpucommandbuffersexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/command-buffers-expected.txt (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/command-buffers-expected.txt    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/command-buffers-expected.txt       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,7 +1,3 @@
</span><del>-PASS [object WebGPU] is defined.
-PASS Successfully created WebGPUCommandBuffer.
-All tests complete.
-PASS successfullyParsed is true
</del><span class="cx"> 
</span><del>-TEST COMPLETE
</del><ins>+PASS Create a default GPUCommandBuffer. 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebgpucommandbuffershtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/command-buffers.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/command-buffers.html    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/command-buffers.html       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,30 +1,15 @@
</span><span class="cx"> <!DOCTYPE html>
</span><span class="cx"> <html>
</span><del>-<script src="../resources/js-test-pre.js"></script>
-<script src="js/basic-webgpu-functions.js"></script>
</del><ins>+<script src="js/webgpu-functions.js"></script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
</ins><span class="cx"> <script>
</span><del>-if (window.testRunner)
-    window.testRunner.dumpAsText();
</del><ins>+promise_test(async () => {
+    const device = await getBasicDevice();
+    const commandBuffer = device.createCommandBuffer();
+    assert_true(commandBuffer instanceof WebGPUCommandBuffer, "Successfully created GPUCommandBuffer.");
+}, "Create a default GPUCommandBuffer.");
</ins><span class="cx"> 
</span><del>-function setUpCommandBuffer() {
-    // FIXME: createCommandBuffer should take a WebGPUCommandBufferDescriptor, which is currently an empty dictionary.
-    let commandBuffer = defaultDevice.createCommandBuffer();
-    if (commandBuffer)
-        testPassed("Successfully created WebGPUCommandBuffer.");
-    else
-        testFailed("Could not create WebGPUCommandBuffer!");
-}
-
-function badCommandBuffer0() {
-    // FIXME: Stress command buffer creation when WebGPUCommandBufferDescriptor is specified.
-}
-
-runWebGPUTests([
-        setUpCommandBuffer, 
-        badCommandBuffer0
-    ]);
-
-successfullyParsed = true;
</del><ins>+// FIXME: createCommandBuffer should take a GPUCommandBufferDescriptor, which is currently an empty dictionary.
</ins><span class="cx"> </script>
</span><del>-<script src="../resources/js-test-post.js"></script>
</del><span class="cx"> </html>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestswebgpudepthenabledtrianglestriphtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/depth-enabled-triangle-strip.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/depth-enabled-triangle-strip.html       2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/depth-enabled-triangle-strip.html  2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -82,7 +82,7 @@
</span><span class="cx"> async function test() {
</span><span class="cx">     const device = await getBasicDevice();
</span><span class="cx">     const canvas = document.querySelector("canvas");
</span><del>-    const context = createBasicContext(canvas, device);
</del><ins>+    const swapChain = createBasicSwapChain(canvas, device);
</ins><span class="cx">     // FIXME: Replace with non-MSL shaders.
</span><span class="cx">     const shaderModule = device.createShaderModule({ code: shaderCode });
</span><span class="cx">     const vertexBuffer = createVertexBuffer(device);
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx">     const commandBuffer = device.createCommandBuffer();
</span><span class="cx"> 
</span><span class="cx">     const basicAttachment = {
</span><del>-        attachment: context.getNextTexture().createDefaultTextureView(),
</del><ins>+        attachment: swapChain.getCurrentTexture().createDefaultTextureView(),
</ins><span class="cx">         loadOp: "clear",
</span><span class="cx">         storeOp: "store",
</span><span class="cx">         clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 }
</span><span class="lines">@@ -116,7 +116,6 @@
</span><span class="cx">     encoder.endPass();
</span><span class="cx"> 
</span><span class="cx">     device.getQueue().submit([commandBuffer]);
</span><del>-    context.present();
</del><span class="cx"> 
</span><span class="cx">     if (window.testRunner)
</span><span class="cx">         testRunner.notifyDone();
</span></span></pre></div>
<a id="trunkLayoutTestswebgpujsbasicwebgpufunctionsjs"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/js/basic-webgpu-functions.js       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,173 +0,0 @@
</span><del>-let shaderCode = `
-#include <metal_stdlib>
-    
-using namespace metal;
-
-struct Vertex
-{
-    float4 position [[position]];
-};
-
-vertex Vertex vertex_main(uint vid [[vertex_id]])
-{
-    Vertex v;
-    switch (vid) {
-    case 0:
-        v.position = float4(-.75, -.75, 0, 1);
-        break;
-    case 1:
-        v.position = float4(.75, -.75, 0, 1);
-        break;
-    case 2:
-        v.position = float4(0, .75, 0, 1);
-        break;
-    default:
-        v.position = float4(0, 0, 0, 1);
-    }
-    return v;
-}
-
-fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
-{
-    return float4(1.0, 0.0, 0.0, 1.0);
-}
-`
-
-let context, adapter, defaultDevice;
-
-function runWebGPUTests(tests) {
-    runWebGPUTestsOnCanvas(document.createElement("canvas"), tests);
-}
-
-async function runWebGPUTestsOnCanvas(canvas, tests) {
-    try {
-        await setUpContexts(canvas);
-
-        for (let test of tests)
-            test();
-
-        debug("All tests complete.");
-    } catch (error) {
-        console.error(error);
-        testFailed(`[${error}]: See console!`);
-    }
-}
-
-async function setUpContexts(canvas) {
-    context = canvas.getContext("webgpu");
-    if (!context)
-        testFailed("Could not create WebGPU context!");
-
-    shouldBeDefined(window.webgpu);
-    
-    adapter = await window.webgpu.requestAdapter();
-    if (!adapter) {
-        testFailed("Could not create default WebGPUAdapter!")
-        return;
-    }
-
-    // FIXME: requestDevice should take a WebGPUDeviceDescriptor.
-    defaultDevice = adapter.createDevice();
-    if (!defaultDevice) {
-        testFailed("Could not create WebGPUDevice!");
-        return;
-    }
-
-    // FIXME: Implement WebGPUTextureUsageEnum.
-    context.configure({ device: defaultDevice, format:"b8g8r8a8-unorm", width: canvas.width, height: canvas.height });
-}
-
-let shaderModule, vertexStageDescriptor, fragmentStageDescriptor, pipelineDescriptor, renderPipeline;
-
-function setUpModule() {
-    shaderModule = defaultDevice.createShaderModule({ code: shaderCode });
-    if (!shaderModule) {
-        testFailed("Could not create WebGPUShaderModule!");
-        return;
-    }
-}
-
-function setUpPipelineDescriptor() {
-    vertexStageDescriptor = { 
-        module: shaderModule,
-        entryPoint: "vertex_main" 
-    };
-
-    fragmentStageDescriptor = {
-        module: shaderModule,
-        entryPoint: "fragment_main"
-    };
-
-    pipelineDescriptor = {
-        vertexStage: vertexStageDescriptor, 
-        fragmentStage: fragmentStageDescriptor,
-        primitiveTopology: "triangleList"
-    };
-}
-
-function setUpPipeline() {
-    setUpModule();
-    setUpPipelineDescriptor();
-
-    renderPipeline = defaultDevice.createRenderPipeline(pipelineDescriptor);
-    if (!renderPipeline) {
-        testFailed("Could not create WebGPURenderPipeline!");
-        return;
-    }
-}
-
-function render() {
-    let commandBuffer = defaultDevice.createCommandBuffer();
-    if (!commandBuffer) {
-        testFailed("Could not create WebGPUCommandBuffer!");
-        return;
-    }
-
-    let texture = context.getNextTexture();
-    if (!texture) {
-        testFailed("Could not get next WebGPUTexture!");
-        return;
-    }
-
-    let textureView = texture.createDefaultTextureView();
-    if (!textureView) {
-        testFailed("Could not create WebGPUTextureView!");
-        return;
-    }
-
-    const colorAttachmentDescriptor = {
-        attachment : textureView,
-        loadOp: "clear",
-        storeOp: "store",
-        clearColor : { r: 0.35, g: 0.65, b: 0.85, a: 1.0 }
-    }
-
-    let renderPassDescriptor = {
-        colorAttachments : [colorAttachmentDescriptor]
-    }
-
-    let renderPassEncoder = commandBuffer.beginRenderPass(renderPassDescriptor);
-    if (!renderPassEncoder) {
-        testFailed("Could not create WebGPURenderPassEncoder!");
-        return;
-    }
-
-    renderPassEncoder.setPipeline(renderPipeline);
-
-    // Note that we didn't attach any buffers - the shader is generating the vertices for us.
-    renderPassEncoder.draw(3, 1, 0, 0);
-    let commandBufferEnd = renderPassEncoder.endPass();
-    if (!commandBufferEnd) {
-        testFailed("Unable to create WebGPUCommandBuffer from WeGPURenderPassEncoder::endPass!");
-        return;
-    }
-
-    const queue = defaultDevice.getQueue();
-    if (!queue) {
-        testFailed("Unable to create default WebGPUQueue!");
-        return;
-    }
-    queue.submit([commandBufferEnd]);
-
-    context.present();
-}
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestswebgpujswebgpufunctionsjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/js/webgpu-functions.js (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/js/webgpu-functions.js  2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/js/webgpu-functions.js     2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,14 +1,12 @@
</span><span class="cx"> async function getBasicDevice() {
</span><del>-    const adapter = await window.webgpu.requestAdapter({ powerPreference: "low-power" });
</del><ins>+    const adapter = await gpu.requestAdapter({ powerPreference: "low-power" });
</ins><span class="cx">     const device = adapter.createDevice();
</span><span class="cx">     return device;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function createBasicContext(canvas, device) {
-    const context = canvas.getContext("webgpu");
-    // FIXME: Implement and specify a WebGPUTextureUsageEnum.
-    context.configure({ device: device, format:"b8g8r8a8-unorm", width: canvas.width, height: canvas.height });
-    return context;
</del><ins>+function createBasicSwapChain(canvas, device) {
+    const context = canvas.getContext("gpu");
+    return device.createSwapChain({ context: context, format: "b8g8r8a8-unorm" });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function createBasicDepthStateDescriptor() {
</span><span class="lines">@@ -65,9 +63,9 @@
</span><span class="cx">     return device.createRenderPipeline(pipelineDescriptor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function beginBasicRenderPass(context, commandBuffer) {
</del><ins>+function beginBasicRenderPass(swapChain, commandBuffer) {
</ins><span class="cx">     const basicAttachment = {
</span><del>-        attachment: context.getNextTexture().createDefaultTextureView(),
</del><ins>+        attachment: swapChain.getCurrentTexture().createDefaultTextureView(),
</ins><span class="cx">         loadOp: "clear",
</span><span class="cx">         storeOp: "store",
</span><span class="cx">         clearColor: { r: 1.0, g: 0, b: 0, a: 1.0 }
</span></span></pre></div>
<a id="trunkLayoutTestswebgpuqueuecreationhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/queue-creation.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/queue-creation.html     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/queue-creation.html        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -9,12 +9,12 @@
</span><span class="cx"> 'use strict';
</span><span class="cx"> 
</span><span class="cx"> promise_test(async t => {
</span><del>-    assert_not_equals(window.webgpu, undefined, "window.webgpu exists");
</del><ins>+    assert_not_equals(window.gpu, undefined, "window.gpu exists");
</ins><span class="cx"> 
</span><del>-    const swapChain = document.createElement("canvas").getContext("webgpu");
-    assert_true(swapChain instanceof WebGPUSwapChain, "getContext returned a WebGPUSwapChain.");
</del><ins>+    const context = document.createElement("canvas").getContext("gpu");
+    assert_true(context instanceof GPUCanvasContext, "getContext returned a GPUCanvasContext.");
</ins><span class="cx"> 
</span><del>-    const adapter = await window.webgpu.requestAdapter({});
</del><ins>+    const adapter = await window.gpu.requestAdapter({});
</ins><span class="cx">     assert_true(adapter instanceof WebGPUAdapter, "requestAdapter returned a WebGPUAdapter.");
</span><span class="cx"> 
</span><span class="cx">     const device = adapter.createDevice();
</span></span></pre></div>
<a id="trunkLayoutTestswebgpurendercommandencodingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/render-command-encoding-expected.txt (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/render-command-encoding-expected.txt    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/render-command-encoding-expected.txt       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,4 +1,3 @@
</span><del>-PASS [object WebGPU] is defined.
</del><span class="cx"> 
</span><span class="cx"> PASS WebGPURenderPassEncoder created and successfully ended 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebgpurendercommandencodinghtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/render-command-encoding.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/render-command-encoding.html    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/render-command-encoding.html       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -4,50 +4,45 @@
</span><span class="cx"> <body>
</span><span class="cx"> <script src="../resources/testharness.js"></script>
</span><span class="cx"> <script src="../resources/testharnessreport.js"></script>
</span><del>-<script src="../resources/js-test-pre.js"></script>
-<script src="js/basic-webgpu-functions.js"></script>
</del><ins>+<script src="js/webgpu-functions.js"></script>
</ins><span class="cx"> <script>
</span><del>-'use strict';
</del><ins>+const shaders = `
+#include <metal_stdlib>
+    
+using namespace metal;
</ins><span class="cx"> 
</span><del>-let commandBuffer, renderPassEncoder;
</del><ins>+struct Vertex
+{
+    float4 position [[position]];
+};
</ins><span class="cx"> 
</span><del>-function beginPass() {
-    const colorAttachmentDescriptor = {
-        attachment: context.getNextTexture().createDefaultTextureView(),
-        loadOp: "clear",
-        storeOp: "store",
-        clearColor: { r: 0.35, g: 0.65, b: 0.85, a: 1.0 }
-    }
</del><ins>+vertex Vertex vertex_main()
+{
+    return Vertex { float4(0, 0, 0, 1) };
+}
</ins><span class="cx"> 
</span><del>-    let renderPassDescriptor = {
-        colorAttachments : [colorAttachmentDescriptor]
-    }
-
-    renderPassEncoder = commandBuffer.beginRenderPass(renderPassDescriptor);
-    assert_true(renderPassEncoder instanceof WebGPURenderPassEncoder, "beginRenderPass returned a WebGPURenderPassEncoder");
</del><ins>+fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
+{
+    return vertexIn.position;
</ins><span class="cx"> }
</span><ins>+`
+promise_test(async () => {
+    const device = await getBasicDevice();
</ins><span class="cx"> 
</span><del>-function setUpCommandBuffer() {
-    commandBuffer = defaultDevice.createCommandBuffer();
</del><ins>+    const canvas = document.createElement("canvas");
+    const swapChain = createBasicSwapChain(canvas, device);
+    const shaderModule = device.createShaderModule({ code: shaders });
+    const pipeline = createBasicPipeline(shaderModule, device);
+
+    const commandBuffer = device.createCommandBuffer();
</ins><span class="cx">     assert_true(commandBuffer instanceof WebGPUCommandBuffer, "createCommandBuffer returned a WebGPUCommandBuffer");
</span><del>-}
</del><span class="cx"> 
</span><del>-function endRenderPass() {
-    renderPassEncoder.setPipeline(renderPipeline);
</del><ins>+    const encoder = beginBasicRenderPass(swapChain, commandBuffer);
+    assert_true(encoder instanceof WebGPURenderPassEncoder, "beginRenderPass() returned a WebGPURenderPassEncoder");
</ins><span class="cx"> 
</span><del>-    const commandBufferEnd = renderPassEncoder.endPass();
</del><ins>+    encoder.setPipeline(pipeline);
+    const commandBufferEnd = encoder.endPass();
</ins><span class="cx">     assert_true(commandBufferEnd instanceof WebGPUCommandBuffer, "endPass() returned a WebGPUCommandBuffer");
</span><del>-
-    // FIXME: Should commandBufferEnd === commandBuffer?
-}
-
-promise_test(async () => {
-    const canvas = document.createElement("canvas");
-    await setUpContexts(canvas);
-    setUpPipeline();
-    setUpCommandBuffer();
-    beginPass();
-    endRenderPass();
</del><span class="cx"> }, "WebGPURenderPassEncoder created and successfully ended");
</span><span class="cx"> 
</span><span class="cx"> </script>
</span></span></pre></div>
<a id="trunkLayoutTestswebgpurenderpassesexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/webgpu/render-passes-expected.txt (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/render-passes-expected.txt      2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/render-passes-expected.txt 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,9 +0,0 @@
</span><del>-PASS [object WebGPU] is defined.
-PASS Successfully created basic WebGPURenderPassEncoder.
-PASS WebGPURenderPassEncoder with invalid WebGPURenderPassDescriptor was not created.
-PASS WebGPURenderPassEncoder with invalid WebGPURenderPassDescriptor was not created.
-All tests complete.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestswebgpurenderpasseshtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/webgpu/render-passes.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/render-passes.html      2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/render-passes.html 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,51 +0,0 @@
</span><del>-<!DOCTYPE html>
-<html>
-<script src="../resources/js-test-pre.js"></script>
-<script src="js/basic-webgpu-functions.js"></script>
-<script>
-if (window.testRunner)
-    window.testRunner.dumpAsText();
-
-let commandBuffer, renderPassEncoder;
-
-function setUpBasicRenderPassEncoder() {
-    commandBuffer = defaultDevice.createCommandBuffer();
-
-    const colorAttachmentDescriptor = {
-        attachment: context.getNextTexture().createDefaultTextureView(),
-        loadOp: "clear",
-        storeOp: "store",
-        clearColor: { r: 0.35, g: 0.65, b: 0.85, a: 1.0 }
-    }
-
-    let renderPassDescriptor = {
-        colorAttachments: [colorAttachmentDescriptor]
-    }
-
-    renderPassEncoder = commandBuffer.beginRenderPass(renderPassDescriptor);
-    if (renderPassEncoder)
-        testPassed("Successfully created basic WebGPURenderPassEncoder.");
-    else
-        testFailed("Could not create WebGPURenderPassEncoder!");
-}
-
-function checkBadRenderPassDescriptor(descriptor, testSubjectName) {
-    renderPassEncoder = commandBuffer.beginRenderPass(descriptor);
-
-    if (renderPassEncoder)
-        testFailed(`WebGPURenderPassEncoder was created with an invalid ${testSubjectName}!`);
-    else 
-        testPassed(`WebGPURenderPassEncoder with invalid ${testSubjectName} was not created.`);
-}
-
-function noAttachmentDescriptors() {
-    checkBadRenderPassDescriptor(null, "WebGPURenderPassDescriptor");
-    checkBadRenderPassDescriptor({}, "WebGPURenderPassDescriptor");
-}
-
-runWebGPUTests([setUpBasicRenderPassEncoder, noAttachmentDescriptors]);
-
-successfullyParsed = true;
-</script>
-<script src="../resources/js-test-post.js"></script>
-</html>
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestswebgpushadermodulesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/shader-modules-expected.txt (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/shader-modules-expected.txt     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/shader-modules-expected.txt        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,9 +1,3 @@
</span><del>-PASS [object WebGPU] is defined.
-PASS Bad shader code should not create a module.
-PASS Incomplete shader code should not create a module.
-PASS Shader module created successfully.
-All tests complete.
-PASS successfullyParsed is true
</del><span class="cx"> 
</span><del>-TEST COMPLETE
</del><ins>+PASS Test shader code validation when creating modules. 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebgpushadermoduleshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/shader-modules.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/shader-modules.html     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/shader-modules.html        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,74 +1,62 @@
</span><del>-<!DOCTYPE html>
</del><ins>+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
</ins><span class="cx"> <html>
</span><del>-<script src="../resources/js-test-pre.js"></script>
-<script src="js/basic-webgpu-functions.js"></script>
-<script id="library_incomplete" type="x-shader/x-metal">
-    #include <metal_stdlib>
</del><ins>+<meta charset=utf-8>
+<title>Test shader validation.</title>
+<script src="js/webgpu-functions.js"></script>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script>
+const shaders = `
+#include <metal_stdlib>
</ins><span class="cx">     
</span><del>-    using namespace metal;
-    
-    vertex Vertex vertex_main(uint vid [[vertex_id]])
-    {
-        Vertex v;
-        switch (vid) {
-        case 0:
-            v.position = float4(-.75, -.75, 0, 1);
-            break;
-        case 1:
-            v.position = float4(.75, -.75, 0, 1);
-            break;
-        case 2:
-            v.position = float4(0, .75, 0, 1);
-            break;
-        default:
-            v.position = float4(0, 0, 0, 1);
-        }
-        return v;
-    }
-    
-    fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
-    {
-        return float4(1.0, 0.0, 0.0, 1.0);
-    }
-</script>
-<script>
-if (window.testRunner)
-    window.testRunner.dumpAsText();
</del><ins>+using namespace metal;
</ins><span class="cx"> 
</span><del>-function setUpShaders() {
-    let shaderDescriptor0 = {
-        code : "Hello World"
-    };
-    let shaderModule = defaultDevice.createShaderModule(shaderDescriptor0);
-    if (!shaderModule)
-        testPassed("Bad shader code should not create a module.");
-    else
-        testFailed("Bad shader code created a valid module!");
</del><ins>+struct Vertex
+{
+    float4 position [[position]];
+};
</ins><span class="cx"> 
</span><del>-    let shaderDescriptor1 = {
-        code : document.getElementById("library_incomplete").text
-    };
</del><ins>+vertex Vertex vertex_main()
+{
+    return Vertex { float4(0, 0, 0, 1) };
+}
</ins><span class="cx"> 
</span><del>-    shaderModule = defaultDevice.createShaderModule(shaderDescriptor1);
-    if (!shaderModule)
-        testPassed("Incomplete shader code should not create a module.");
-    else
-        testFailed("Incomplete shader code created a valid module!");
</del><ins>+fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
+{
+    return vertexIn.position;
+}
+`
+
+const incompleteShaders = `
+#include <metal_stdlib>
</ins><span class="cx">     
</span><del>-    let shaderDescriptor2 = {
-        code : shaderCode
-    };
</del><ins>+using namespace metal;
</ins><span class="cx"> 
</span><del>-    shaderModule = defaultDevice.createShaderModule(shaderDescriptor2);
-    if (shaderModule)
-        testPassed("Shader module created successfully.");
-    else 
-        testFailed("Shader module not created successfully!");
</del><ins>+vertex Vertex vertex_main(uint vid [[vertex_id]])
+{
+    return Vertex { float4(0, 0, 0, 1) };
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-runWebGPUTests([setUpShaders]);
</del><ins>+fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
+{
+    rreturn vertexIn.position;
+}
+`
</ins><span class="cx"> 
</span><del>-successfullyParsed = true;
</del><ins>+promise_test(async () => {
+    const device = await getBasicDevice();
+
+    const shaderDescriptor0 = {
+        code : "Hello World"
+    };
+    let shaderModule = device.createShaderModule(shaderDescriptor0);
+    assert_equals(shaderModule, null, "Bad shader code did not create a module.");
+
+    shaderModule = device.createShaderModule({ code: incompleteShaders });
+    assert_equals(shaderModule, null, "Incomplete shader code did not create a module.");
+
+    shaderModule = device.createShaderModule({ code: shaders });
+    assert_true(shaderModule instanceof WebGPUShaderModule, "Shader module created successfully.");
+}, "Test shader code validation when creating modules.");
</ins><span class="cx"> </script>
</span><del>-<script src="../resources/js-test-post.js"></script>
</del><span class="cx"> </html>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestswebgpusimpletrianglestriphtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/simple-triangle-strip.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/simple-triangle-strip.html      2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/simple-triangle-strip.html 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -7,6 +7,9 @@
</span><span class="cx"> <canvas width="400" height="400"></canvas>
</span><span class="cx"> <script src="js/webgpu-functions.js"></script>
</span><span class="cx"> <script>
</span><ins>+if (window.testRunner)
+    testRunner.waitUntilDone();
+
</ins><span class="cx"> const shaderCode = `
</span><span class="cx"> #include <metal_stdlib>
</span><span class="cx">     
</span><span class="lines">@@ -45,17 +48,21 @@
</span><span class="cx"> async function test() {
</span><span class="cx">     const device = await getBasicDevice();
</span><span class="cx">     const canvas = document.querySelector("canvas");
</span><del>-    const context = createBasicContext(canvas, device);
</del><ins>+    const swapChain = createBasicSwapChain(canvas, device);
</ins><span class="cx">     // FIXME: Replace with non-MSL shaders.
</span><span class="cx">     const shaderModule = device.createShaderModule({ code: shaderCode });
</span><span class="cx">     const pipeline = createBasicPipeline(shaderModule, device);
</span><span class="cx">     const commandBuffer = device.createCommandBuffer();
</span><del>-    const passEncoder = beginBasicRenderPass(context, commandBuffer);
</del><ins>+    const passEncoder = beginBasicRenderPass(swapChain, commandBuffer);
</ins><span class="cx">     const endCommandBuffer = encodeBasicCommands(passEncoder, pipeline);
</span><span class="cx">     const queue = device.getQueue();
</span><span class="cx"> 
</span><span class="cx">     queue.submit([endCommandBuffer]);
</span><del>-    context.present();
</del><ins>+
+    requestAnimationFrame(() => { 
+        if (window.testRunner)
+            testRunner.notifyDone();
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> test();
</span></span></pre></div>
<a id="trunkLayoutTestswebgputexturetrianglestriphtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/texture-triangle-strip.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/texture-triangle-strip.html     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/texture-triangle-strip.html        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -84,7 +84,7 @@
</span><span class="cx"> async function test() {
</span><span class="cx">     const device = await getBasicDevice();
</span><span class="cx">     const canvas = document.querySelector("canvas");
</span><del>-    const context = createBasicContext(canvas, device);
</del><ins>+    const swapChain = createBasicSwapChain(canvas, device);
</ins><span class="cx">     // FIXME: Replace with non-MSL shaders.
</span><span class="cx">     const shaderModule = device.createShaderModule({ code: shaderCode });
</span><span class="cx"> 
</span><span class="lines">@@ -201,7 +201,7 @@
</span><span class="cx">         origin: { x: 0, y: 0, z: 0 }
</span><span class="cx">     };
</span><span class="cx">     commandBuffer.copyBufferToTexture(bufferCopyView, textureCopyView, textureSize);
</span><del>-    const passEncoder = beginBasicRenderPass(context, commandBuffer);
</del><ins>+    const passEncoder = beginBasicRenderPass(swapChain, commandBuffer);
</ins><span class="cx">     passEncoder.setPipeline(pipeline);
</span><span class="cx">     passEncoder.setBindGroup(bindGroupIndex, bindGroup);
</span><span class="cx">     passEncoder.setVertexBuffers(positionBufferIndex, [positionBuffer, textureCoordBuffer], [0, 0]);
</span><span class="lines">@@ -213,7 +213,6 @@
</span><span class="cx">     positionBuffer.destroy();
</span><span class="cx">     textureCoordBuffer.destroy();
</span><span class="cx">     texture.destroy();
</span><del>-    context.present();
</del><span class="cx"> 
</span><span class="cx">     if (window.testRunner)
</span><span class="cx">         testRunner.notifyDone();
</span></span></pre></div>
<a id="trunkLayoutTestswebgputexturestextureviewshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/textures-textureviews.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/textures-textureviews.html      2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/textures-textureviews.html 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -28,9 +28,9 @@
</span><span class="cx"> 
</span><span class="cx"> promise_test(async () => {
</span><span class="cx">     device = await getBasicDevice();
</span><del>-    context = createBasicContext(canvas, device);
</del><ins>+    swapChain = createBasicSwapChain(canvas, device);
</ins><span class="cx"> 
</span><del>-    const texture = context.getNextTexture();
</del><ins>+    const texture = swapChain.getCurrentTexture();
</ins><span class="cx">     assert_true(texture instanceof WebGPUTexture, "Successfully acquired next texture.");
</span><span class="cx"> 
</span><span class="cx">     const textureView = texture.createDefaultTextureView();
</span></span></pre></div>
<a id="trunkLayoutTestswebgpuvertexbuffertrianglestriphtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip.html       2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip.html  2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx"> async function test() {
</span><span class="cx">     const device = await getBasicDevice();
</span><span class="cx">     const canvas = document.querySelector("canvas");
</span><del>-    const context = createBasicContext(canvas, device);
</del><ins>+    const swapChain = createBasicSwapChain(canvas, device);
</ins><span class="cx">     // FIXME: Replace with non-MSL shaders.
</span><span class="cx">     const shaderModule = device.createShaderModule({ code: shaderCode });
</span><span class="cx">     const vertexBuffer = createVertexBuffer(device);
</span><span class="lines">@@ -92,12 +92,11 @@
</span><span class="cx">     const inputStateDescriptor = createInputStateDescriptor();
</span><span class="cx">     const pipeline = createBasicPipeline(shaderModule, device, null, inputStateDescriptor);
</span><span class="cx">     const commandBuffer = device.createCommandBuffer();
</span><del>-    const passEncoder = beginBasicRenderPass(context, commandBuffer);
</del><ins>+    const passEncoder = beginBasicRenderPass(swapChain, commandBuffer);
</ins><span class="cx">     const endCommandBuffer = encodeBasicCommands(passEncoder, pipeline, vertexBuffer);
</span><span class="cx">     const queue = device.getQueue();
</span><span class="cx">     queue.submit([endCommandBuffer]);
</span><span class="cx">     vertexBuffer.destroy();
</span><del>-    context.present();
</del><span class="cx"> 
</span><span class="cx">     if (window.testRunner)
</span><span class="cx">         testRunner.notifyDone();
</span></span></pre></div>
<a id="trunkLayoutTestswebgpuwebgpubasicsexpectedtxt"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/webgpu/webgpu-basics-expected.txt (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/webgpu-basics-expected.txt      2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/webgpu-basics-expected.txt 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,6 +0,0 @@
</span><del>-PASS [object WebGPU] is defined.
-All tests complete.
-PASS successfullyParsed is true
-
-TEST COMPLETE
-
</del></span></pre></div>
<a id="trunkLayoutTestswebgpuwebgpubasicshtml"></a>
<div class="delfile"><h4>Deleted: trunk/LayoutTests/webgpu/webgpu-basics.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/webgpu-basics.html      2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/webgpu-basics.html 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,18 +0,0 @@
</span><del>-<!DOCTYPE html>
-<html>
-<head>
-<script src="../resources/js-test-pre.js"></script>
-<script src="js/basic-webgpu-functions.js"></script>
-<body>
-<canvas width="420" height="420"></canvas>
-<script>
-if (window.testRunner)
-    window.testRunner.dumpAsText();
-
-runWebGPUTestsOnCanvas(document.querySelector("canvas"), [setUpPipeline, render]);
-
-successfullyParsed = true;
-</script>
-<script src="../resources/js-test-post.js"></script>
-</body>
-</html>
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestswebgpuwebgpuenabledexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/webgpu-enabled-expected.txt (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/webgpu-enabled-expected.txt     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/webgpu-enabled-expected.txt        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,5 +1,3 @@
</span><del>-PASS [object WebGPU] is defined.
-PASS successfullyParsed is true
</del><span class="cx"> 
</span><del>-TEST COMPLETE
</del><ins>+PASS Web GPU is enabled. 
</ins><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestswebgpuwebgpuenabledhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/webgpu/webgpu-enabled.html (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webgpu/webgpu-enabled.html     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/LayoutTests/webgpu/webgpu-enabled.html        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,37 +1,22 @@
</span><del>-<!DOCTYPE html>
</del><ins>+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
</ins><span class="cx"> <html>
</span><del>-<script src="../resources/js-test-pre.js"></script>
-
</del><ins>+<meta charset=utf-8>
+<title>Test if WebGPU is enabled.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
</ins><span class="cx"> <script>
</span><del>-if (window.testRunner)
-    window.testRunner.dumpAsText();
</del><ins>+promise_test(async () => {
+    const canvas = document.createElement("canvas");
+    const context = canvas.getContext("gpu");
+    assert_true(context instanceof GPUCanvasContext, "Created GPUCanvasContext.");
</ins><span class="cx"> 
</span><del>-function runTest() {
-    let canvas = document.createElement("canvas");
-    let context = canvas.getContext("webgpu");
-    if (!context)
-        testFailed("Could not create WebGPU context!");
</del><ins>+    assert_not_equals(window.gpu, undefined, "window.gpu is defined.");
</ins><span class="cx"> 
</span><del>-    shouldBeDefined(window.webgpu);
-    window.webgpu.requestAdapter({ powerPreference: "default" }).then(adapter => {
-        if (!adapter) {
-            testFailed("Could not create default WebGPUAdapter!")
-            return;
-        }
-        let defaultDevice = adapter.createDevice();
-        if (!defaultDevice) {
-            testFailed("Could not create WebGPUDevice!");
-            return;
-        }
-    }).catch(error => {
-        testFailed(error);
-    });
-}
-
-runTest();
-
-var successfullyParsed = true;
</del><ins>+    const adapter = await window.gpu.requestAdapter();
+    assert_true(adapter instanceof WebGPUAdapter, "Created default GPUAdapter.");
+    
+    const device = adapter.createDevice();
+    assert_true(device instanceof WebGPUDevice, "Created GPUDevice.");
+}, "Web GPU is enabled.");
</ins><span class="cx"> </script>
</span><del>-
-<script src="../resources/js-test-post.js"></script>
</del><span class="cx"> </html>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/JavaScriptCore/ChangeLog       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2019-03-11  Justin Fan  <justin_fan@apple.com>
+
+        [Web GPU] Update GPUSwapChainDescriptor, GPUSwapChain and implement GPUCanvasContext
+        https://bugs.webkit.org/show_bug.cgi?id=194406
+        <rdar://problem/47892466>
+
+        Reviewed by Myles C. Maxfield.
+
+        Added WebGPU to inspector context types.
+
+        * inspector/protocol/Canvas.json:
+        * inspector/scripts/codegen/generator.py:
+
</ins><span class="cx"> 2019-03-11  Yusuke Suzuki  <ysuzuki@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [JSC] Reduce # of structures in JSGlobalObject initialization
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorprotocolCanvasjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json       2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json  2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -16,7 +16,7 @@
</span><span class="cx">         {
</span><span class="cx">             "id": "ContextType",
</span><span class="cx">             "type": "string",
</span><del>-            "enum": ["canvas-2d", "bitmaprenderer", "webgl", "webgl2", "webmetal"],
</del><ins>+            "enum": ["canvas-2d", "bitmaprenderer", "webgl", "webgl2", "webgpu", "webmetal"],
</ins><span class="cx">             "description": "The type of rendering context backing the canvas element."
</span><span class="cx">         },
</span><span class="cx">         {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorscriptscodegengeneratorpy"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/scripts/codegen/generator.py (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/scripts/codegen/generator.py       2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/JavaScriptCore/inspector/scripts/codegen/generator.py  2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx">     'canvas-webgl': 'CanvasWebGL',  # Recording.Type.canvas-webgl
</span><span class="cx">     'webgl': 'WebGL',  # Canvas.ContextType.webgl
</span><span class="cx">     'webgl2': 'WebGL2',  # Canvas.ContextType.webgl2
</span><ins>+    'webgpu': 'WebGPU',  # Canvas.ContextType.gpu
</ins><span class="cx">     'webmetal': 'WebMetal',  # Canvas.ContextType.webmetal
</span><span class="cx">     'bitmaprenderer': 'BitmapRenderer',  # Canvas.ContextType.bitmaprenderer
</span><span class="cx">     'webrtc': 'WebRTC',  # Console.ChannelSource.webrtc
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt      2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/CMakeLists.txt 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -466,6 +466,7 @@
</span><span class="cx">     Modules/webgpu/GPUBindGroupLayoutDescriptor.idl
</span><span class="cx">     Modules/webgpu/GPUBufferDescriptor.idl
</span><span class="cx">     Modules/webgpu/GPUBufferUsage.idl
</span><ins>+    Modules/webgpu/GPUCanvasContext.idl
</ins><span class="cx">     Modules/webgpu/GPUColor.idl
</span><span class="cx">     Modules/webgpu/GPUCompareFunction.idl
</span><span class="cx">     Modules/webgpu/GPUDepthStencilStateDescriptor.idl
</span><span class="lines">@@ -503,7 +504,6 @@
</span><span class="cx">     Modules/webgpu/WebGPURenderPassEncoder.idl
</span><span class="cx">     Modules/webgpu/WebGPURenderPipeline.idl
</span><span class="cx">     Modules/webgpu/WebGPURenderPipelineDescriptor.idl
</span><del>-    Modules/webgpu/WebGPURenderingContext.idl
</del><span class="cx">     Modules/webgpu/WebGPUSampler.idl
</span><span class="cx">     Modules/webgpu/WebGPUShaderModule.idl
</span><span class="cx">     Modules/webgpu/WebGPUShaderModuleDescriptor.idl
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/ChangeLog      2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,3 +1,127 @@
</span><ins>+2019-03-11  Justin Fan  <justin_fan@apple.com>
+
+        [Web GPU] Update GPUSwapChainDescriptor, GPUSwapChain and implement GPUCanvasContext
+        https://bugs.webkit.org/show_bug.cgi?id=194406
+        <rdar://problem/47892466>
+
+        Reviewed by Myles C. Maxfield.
+
+        GPUSwapChain no longer inherits from GPUBasedRenderingContext, and is now created from a GPUDevice. 
+        WebGPURenderingContext is now GPUCanvasContext and delegates functionality to the GPUSwapChain, if it exists. 
+        GPUQueue now implicitly presents the GPUSwapChain's current drawable at the task boundary, if one exists.
+        Creating a new GPUSwapChain with the same GPUCanvasContext invalidates the previous one and its drawable and pipeline attachments.
+        Calling GPUSwapChain::getCurrentTexture returns the same drawable within one task cycle. 
+        Some mentions of "WebGPU" have been renamed to "Web GPU" and "gpu".
+
+        All Web GPU tests updated to match.
+
+        Add new files and symbols.
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/WebCoreBuiltinNames.h:
+
+        Rename some mentions of "webgpu" to "gpu".
+        * Modules/webgpu/DOMWindowWebGPU.cpp:
+        (WebCore::DOMWindowWebGPU::gpu):
+        (WebCore::DOMWindowWebGPU::gpu const):
+        * Modules/webgpu/DOMWindowWebGPU.h:
+        * Modules/webgpu/DOMWindowWebGPU.idl:
+
+        Replace WebGPURenderingContext with GPUCanvasContext.
+        * Modules/webgpu/GPUCanvasContext.cpp: Renamed from Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp.
+        (WebCore::GPUCanvasContext::create):
+        (WebCore::GPUCanvasContext::GPUCanvasContext):
+        (WebCore::GPUCanvasContext::replaceSwapChain):
+        (WebCore::GPUCanvasContext::platformLayer const):
+        (WebCore::GPUCanvasContext::reshape):
+        (WebCore::GPUCanvasContext::markLayerComposited):
+        * Modules/webgpu/GPUCanvasContext.h: Renamed from Source/WebCore/Modules/webgpu/WebGPURenderingContext.h.
+        * Modules/webgpu/GPUCanvasContext.idl: Renamed from Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl.
+        * dom/Document.cpp:
+        (WebCore::Document::getCSSCanvasContext):
+        * dom/Document.h:
+        * dom/Document.idl:
+        * html/HTMLCanvasElement.cpp:
+        (WebCore::HTMLCanvasElement::getContext):
+        (WebCore::HTMLCanvasElement::isWebGPUType):
+        (WebCore::HTMLCanvasElement::createContextWebGPU):
+        (WebCore::HTMLCanvasElement::getContextWebGPU):
+        * html/HTMLCanvasElement.h:
+        * html/HTMLCanvasElement.idl:
+        * inspector/InspectorCanvas.cpp:
+        (WebCore::InspectorCanvas::buildObjectForCanvas):
+        * inspector/agents/InspectorCanvasAgent.cpp:
+        (WebCore::contextAsScriptValue):
+
+        Update WebGPUSwapChain.
+        * Modules/webgpu/GPUTextureDescriptor.idl:
+        * Modules/webgpu/GPUTextureFormat.idl: Add the other two texture formats supported by CAMetalLayer.
+        * Modules/webgpu/WebGPUDevice.cpp: Implement createSwapChain.
+        (WebCore::WebGPUDevice::createSwapChain const):
+        (WebCore::WebGPUDevice::getQueue const):
+        (WebCore::WebGPUDevice::getQueue): Deleted.
+        * Modules/webgpu/WebGPUDevice.h:
+        * Modules/webgpu/WebGPUDevice.idl:
+        * Modules/webgpu/WebGPUSwapChain.cpp:
+        (WebCore::WebGPUSwapChain::create):
+        (WebCore::WebGPUSwapChain::WebGPUSwapChain):
+        (WebCore::WebGPUSwapChain::getCurrentTexture): Renamed from getNextTexture. Only returns the next drawable if the last was presented.
+        (WebCore::WebGPUSwapChain::destroy): Invalidate this GPUSwapChain and its textures and views.
+        (WebCore::WebGPUSwapChain::configure): Deleted.
+        (WebCore::WebGPUSwapChain::getNextTexture): Deleted.
+        (WebCore::WebGPUSwapChain::present): Deleted.
+        (WebCore::WebGPUSwapChain::reshape): Deleted.
+        (WebCore::WebGPUSwapChain::markLayerComposited): Deleted.
+        * Modules/webgpu/WebGPUSwapChain.h: Now a device-based object rather than a rendering context.
+        (WebCore::WebGPUSwapChain::swapChain const):
+        (WebCore::WebGPUSwapChain::WebGPUSwapChain): Deleted.
+        * Modules/webgpu/WebGPUSwapChain.idl:
+        * Modules/webgpu/WebGPUSwapChainDescriptor.h: Added.
+        * platform/graphics/gpu/GPUDevice.cpp: Implement tryCreateSwapChain.
+        (WebCore::GPUDevice::tryCreateSwapChain const):
+        (WebCore::GPUDevice::getQueue const):
+        (WebCore::GPUDevice::getQueue): Deleted.
+        * platform/graphics/gpu/GPUDevice.h: Retain a reference to the current GPUSwapChain, if one exists.
+        (WebCore::GPUDevice::swapChain const):
+        * platform/graphics/gpu/GPUQueue.h:
+        * platform/graphics/gpu/GPUSwapChain.h:
+        (WebCore::GPUSwapChain::destroy):
+        * platform/graphics/gpu/GPUSwapChainDescriptor.h: Added.
+        * platform/graphics/gpu/GPUTextureFormat.h: Add the other two texture formats supported by CAMetalLayer.
+        * platform/graphics/gpu/cocoa/GPUBufferMetal.mm:
+        (WebCore::GPUBuffer::commandBufferCommitted):
+        * platform/graphics/gpu/cocoa/GPUQueueMetal.mm:
+        (WebCore::GPUQueue::tryCreate): Renamed from create to better fit functionality. Now retain a reference to the GPUDevice.
+        (WebCore::GPUQueue::GPUQueue):
+        (WebCore::GPUQueue::submit): Now checks state of all resources before marking them as committed or committing any resource.
+                In addition, schedules the current drawable to be presented after all commands have been submitted during this task cycle.
+        * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
+        (WebCore::useAttachments): Ensure that the command buffer is aware of any texture resources used as attachments.
+        (WebCore::GPURenderPassEncoder::tryCreate):
+        * platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm:
+        (WebCore::tryGetSupportedPixelFormat): Supported texture formats are the intersection of Web GPU's texture formats and CAMetalLayer's.
+        (WebCore::setLayerShape):
+        (WebCore::tryCreateSwapLayer): Create and configure the CAMetalLayer backing the swap chain.
+        (WebCore::GPUSwapChain::tryCreate):
+        (WebCore::GPUSwapChain::GPUSwapChain):
+        (WebCore::GPUSwapChain::tryGetCurrentTexture): Renamed from getNextTexture. Only returns a texture if the last one was presented.
+        (WebCore::GPUSwapChain::present):
+        (WebCore::GPUSwapChain::reshape):
+        (WebCore::GPUSwapChain::takeDrawable): Swaps out the current drawable so that it can be presented. The GPUSwapChain thus releases its reference to it.
+        (WebCore::GPUSwapChain::create): Deleted.
+        (WebCore::GPUSwapChain::setDevice): Deleted.
+        (WebCore::GPUSwapChain::setFormat): Deleted.
+        (WebCore::GPUSwapChain::getNextTexture): Deleted.
+        * platform/graphics/gpu/cocoa/GPUUtilsMetal.mm:
+        (WebCore::platformTextureFormatForGPUTextureFormat):
+
+        Misc:
+        * Modules/webgpu/WebGPUProgrammablePassEncoder.cpp: Missing include.
+
</ins><span class="cx"> 2019-03-11  Chris Dumez  <cdumez@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Update device orientation & motion permission native SPI as per latest proposal
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesinputxcfilelist"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources-input.xcfilelist     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -325,6 +325,7 @@
</span><span class="cx"> $(PROJECT_DIR)/Modules/webgpu/GPUBindGroupLayoutDescriptor.idl
</span><span class="cx"> $(PROJECT_DIR)/Modules/webgpu/GPUBufferDescriptor.idl
</span><span class="cx"> $(PROJECT_DIR)/Modules/webgpu/GPUBufferUsage.idl
</span><ins>+$(PROJECT_DIR)/Modules/webgpu/GPUCanvasContext.idl
</ins><span class="cx"> $(PROJECT_DIR)/Modules/webgpu/GPUColor.idl
</span><span class="cx"> $(PROJECT_DIR)/Modules/webgpu/GPUCompareFunction.idl
</span><span class="cx"> $(PROJECT_DIR)/Modules/webgpu/GPUDepthStencilStateDescriptor.idl
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesoutputxcfilelist"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources-output.xcfilelist    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -589,6 +589,8 @@
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUBufferDescriptor.h
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUBufferUsage.cpp
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUBufferUsage.h
</span><ins>+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUCanvasContext.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUCanvasContext.h
</ins><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColor.cpp
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColor.h
</span><span class="cx"> $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUCompareFunction.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/DerivedSources.make (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/DerivedSources.make 2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/DerivedSources.make    2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -372,6 +372,7 @@
</span><span class="cx">     $(WebCore)/Modules/webdatabase/SQLTransactionErrorCallback.idl \
</span><span class="cx">     $(WebCore)/Modules/webdriver/NavigatorWebDriver.idl \
</span><span class="cx">     $(WebCore)/Modules/webgpu/DOMWindowWebGPU.idl \
</span><ins>+    $(WebCore)/Modules/webgpu/GPUCanvasContext.idl \
</ins><span class="cx">     $(WebCore)/Modules/webgpu/GPUColor.idl \
</span><span class="cx">     $(WebCore)/Modules/webgpu/GPUBindGroupLayoutBinding.idl \
</span><span class="cx">     $(WebCore)/Modules/webgpu/GPUBindGroupLayoutDescriptor.idl \
</span><span class="lines">@@ -413,7 +414,6 @@
</span><span class="cx">     $(WebCore)/Modules/webgpu/WebGPURenderPassEncoder.idl \
</span><span class="cx">     $(WebCore)/Modules/webgpu/WebGPURenderPipeline.idl \
</span><span class="cx">     $(WebCore)/Modules/webgpu/WebGPURenderPipelineDescriptor.idl \
</span><del>-    $(WebCore)/Modules/webgpu/WebGPURenderingContext.idl \
</del><span class="cx">     $(WebCore)/Modules/webgpu/WebGPUSampler.idl \
</span><span class="cx">     $(WebCore)/Modules/webgpu/WebGPUShaderModule.idl \
</span><span class="cx">     $(WebCore)/Modules/webgpu/WebGPUShaderModuleDescriptor.idl \
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuDOMWindowWebGPUcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.cpp  2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.cpp     2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -55,18 +55,18 @@
</span><span class="cx">     return supplement;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebGPU* DOMWindowWebGPU::webgpu(DOMWindow& window)
</del><ins>+WebGPU* DOMWindowWebGPU::gpu(DOMWindow& window)
</ins><span class="cx"> {
</span><del>-    return DOMWindowWebGPU::from(&window)->webgpu();
</del><ins>+    return DOMWindowWebGPU::from(&window)->gpu();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebGPU* DOMWindowWebGPU::webgpu() const
</del><ins>+WebGPU* DOMWindowWebGPU::gpu() const
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(RuntimeEnabledFeatures::sharedFeatures().webGPUEnabled());
</span><span class="cx"> 
</span><del>-    if (!m_webgpu && frame())
-        m_webgpu = WebGPU::create();
-    return m_webgpu.get();
</del><ins>+    if (!m_gpu && frame())
+        m_gpu = WebGPU::create();
+    return m_gpu.get();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuDOMWindowWebGPUh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.h    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.h       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -41,13 +41,13 @@
</span><span class="cx">     explicit DOMWindowWebGPU(DOMWindow*);
</span><span class="cx">     virtual ~DOMWindowWebGPU() = default;
</span><span class="cx">     static DOMWindowWebGPU* from(DOMWindow*);
</span><del>-    static WebGPU* webgpu(DOMWindow&);
-    WebGPU* webgpu() const;
</del><ins>+    static WebGPU* gpu(DOMWindow&);
+    WebGPU* gpu() const;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     static const char* supplementName();
</span><span class="cx"> 
</span><del>-    mutable RefPtr<WebGPU> m_webgpu;
</del><ins>+    mutable RefPtr<WebGPU> m_gpu;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuDOMWindowWebGPUidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.idl (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.idl  2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/DOMWindowWebGPU.idl     2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -28,5 +28,5 @@
</span><span class="cx">     Conditional=WEBGPU,
</span><span class="cx">     EnabledAtRuntime=WebGPU
</span><span class="cx"> ] partial interface DOMWindow {
</span><del>-    [Replaceable, SameObject] readonly attribute WebGPU webgpu;
</del><ins>+    [Replaceable, SameObject] readonly attribute WebGPU gpu;
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuGPUCanvasContextcppfromrev242758trunkSourceWebCoreModuleswebgpuWebGPURenderingContextcpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp (from rev 242758, trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp) (0 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp                         (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.cpp    2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -0,0 +1,76 @@
</span><ins>+/*
+ * Copyright (C) 2018 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.
+ */
+
+#include "config.h"
+#include "GPUCanvasContext.h"
+
+#if ENABLE(WEBGPU)
+
+namespace WebCore {
+
+std::unique_ptr<GPUCanvasContext> GPUCanvasContext::create(CanvasBase& canvas)
+{
+    auto context = std::unique_ptr<GPUCanvasContext>(new GPUCanvasContext(canvas));
+    context->suspendIfNeeded();
+    return context;
+}
+
+GPUCanvasContext::GPUCanvasContext(CanvasBase& canvas)
+    : GPUBasedCanvasRenderingContext(canvas)
+{
+}
+
+void GPUCanvasContext::replaceSwapChain(Ref<WebGPUSwapChain>&& newSwapChain)
+{
+    ASSERT(newSwapChain->swapChain());
+
+    if (m_swapChain)
+        m_swapChain->destroy();
+
+    m_swapChain = WTFMove(newSwapChain);
+}
+
+CALayer* GPUCanvasContext::platformLayer() const
+{
+    if (m_swapChain && m_swapChain->swapChain())
+        return m_swapChain->swapChain()->platformLayer();
+    return nullptr;
+}
+
+void GPUCanvasContext::reshape(int width, int height)
+{
+    if (m_swapChain && m_swapChain->swapChain())
+        m_swapChain->swapChain()->reshape(width, height);
+}
+
+void GPUCanvasContext::markLayerComposited()
+{
+    if (m_swapChain && m_swapChain->swapChain())
+        m_swapChain->swapChain()->present();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)
</ins></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuGPUCanvasContexthfromrev242758trunkSourceWebCoreModuleswebgpuWebGPURenderingContexth"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h (from rev 242758, trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.h) (0 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h                           (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.h      2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+/*
+ * Copyright (C) 2018 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
+
+#if ENABLE(WEBGPU)
+
+#include "GPUBasedCanvasRenderingContext.h"
+#include "WebGPUSwapChain.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class GPUCanvasContext final : public GPUBasedCanvasRenderingContext {
+public:
+    static std::unique_ptr<GPUCanvasContext> create(CanvasBase&);
+
+    void replaceSwapChain(Ref<WebGPUSwapChain>&&);
+
+private:
+    GPUCanvasContext(CanvasBase&);
+
+    // GPUBasedCanvasRenderingContext
+    bool isWebGPU() const final { return true; }
+    PlatformLayer* platformLayer() const final;
+    void reshape(int width, int height) final;
+    void markLayerComposited() final;
+    const char* activeDOMObjectName() const final { return "GPUCanvasContext"; }
+    // FIXME: Stubs.
+    bool hasPendingActivity() const final { return false; }
+    void stop() final { }
+    bool canSuspendForDocumentSuspension() const final { return false; }
+
+    RefPtr<WebGPUSwapChain> m_swapChain;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::GPUCanvasContext, isWebGPU())
+
+#endif // ENABLE(WEBGPU)
</ins></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuGPUCanvasContextidlfromrev242758trunkSourceWebCoreModuleswebgpuWebGPURenderingContextidl"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.idl (from rev 242758, trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl) (0 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.idl                         (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/GPUCanvasContext.idl    2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+/*
+ * Copyright (C) 2018 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.
+ */
+// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
+
+[
+    Conditional=WEBGPU,
+    EnabledAtRuntime=WebGPU
+] interface GPUCanvasContext {
+};
</ins></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuGPUTextureDescriptoridl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/GPUTextureDescriptor.idl (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/GPUTextureDescriptor.idl     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/GPUTextureDescriptor.idl        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> // https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
</span><span class="cx"> 
</span><span class="cx"> typedef unsigned long u32;
</span><del>-typedef u32 GPUTextureUsageFlags;
</del><ins>+typedef unsigned long GPUTextureUsageFlags;
</ins><span class="cx"> 
</span><span class="cx"> [
</span><span class="cx">     Conditional=WEBGPU,
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuGPUTextureFormatidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/GPUTextureFormat.idl (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/GPUTextureFormat.idl 2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/GPUTextureFormat.idl    2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -30,5 +30,7 @@
</span><span class="cx">     "r8g8b8a8-unorm",
</span><span class="cx">     "r8g8b8a8-uint",
</span><span class="cx">     "b8g8r8a8-unorm",
</span><del>-    "d32-float-s8-uint"
</del><ins>+    "d32-float-s8-uint",
+    "bgra8unorm-srgb",
+    "rgba16float"
</ins><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUDevicecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> #include "WebGPUSampler.h"
</span><span class="cx"> #include "WebGPUShaderModule.h"
</span><span class="cx"> #include "WebGPUShaderModuleDescriptor.h"
</span><ins>+#include "WebGPUSwapChain.h"
</ins><span class="cx"> #include "WebGPUTexture.h"
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -159,8 +160,22 @@
</span><span class="cx">     return nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr<WebGPUQueue> WebGPUDevice::getQueue()
</del><ins>+Ref<WebGPUSwapChain> WebGPUDevice::createSwapChain(const WebGPUSwapChainDescriptor& descriptor) const
</ins><span class="cx"> {
</span><ins>+    if (!descriptor.context) {
+        LOG(WebGPU, "GPUSwapChain::create(): Invalid GPUCanvasContext!");
+        return WebGPUSwapChain::create(nullptr);
+    }
+
+    auto gpuSwapChain = m_device->tryCreateSwapChain(descriptor, descriptor.context->canvasBase().width(), descriptor.context->canvasBase().height());
+    auto newSwapChain = WebGPUSwapChain::create(gpuSwapChain.copyRef());
+    if (gpuSwapChain)
+        descriptor.context->replaceSwapChain(newSwapChain.copyRef());
+    return newSwapChain;
+}
+
+RefPtr<WebGPUQueue> WebGPUDevice::getQueue() const
+{
</ins><span class="cx">     if (!m_queue)
</span><span class="cx">         m_queue = WebGPUQueue::create(m_device->getQueue());
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUDeviceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h       2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h  2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> #include "GPUDevice.h"
</span><span class="cx"> #include "WebGPUAdapter.h"
</span><span class="cx"> #include "WebGPUQueue.h"
</span><del>-
</del><ins>+#include "WebGPUSwapChainDescriptor.h"
</ins><span class="cx"> #include <wtf/Ref.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> class WebGPURenderPipeline;
</span><span class="cx"> class WebGPUSampler;
</span><span class="cx"> class WebGPUShaderModule;
</span><ins>+class WebGPUSwapChain;
</ins><span class="cx"> class WebGPUTexture;
</span><span class="cx"> 
</span><span class="cx"> struct GPUBindGroupLayoutDescriptor;
</span><span class="lines">@@ -76,14 +77,17 @@
</span><span class="cx">     RefPtr<WebGPURenderPipeline> createRenderPipeline(WebGPURenderPipelineDescriptor&&) const;
</span><span class="cx"> 
</span><span class="cx">     RefPtr<WebGPUCommandBuffer> createCommandBuffer() const;
</span><del>-    RefPtr<WebGPUQueue> getQueue();
</del><span class="cx"> 
</span><ins>+    Ref<WebGPUSwapChain> createSwapChain(const WebGPUSwapChainDescriptor&) const;
+
+    RefPtr<WebGPUQueue> getQueue() const;
+
</ins><span class="cx"> private:
</span><span class="cx">     WebGPUDevice(Ref<WebGPUAdapter>&&, Ref<GPUDevice>&&);
</span><span class="cx"> 
</span><span class="cx">     Ref<WebGPUAdapter> m_adapter;
</span><span class="cx">     Ref<GPUDevice> m_device;
</span><del>-    RefPtr<WebGPUQueue> m_queue;
</del><ins>+    mutable RefPtr<WebGPUQueue> m_queue;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUDeviceidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -24,9 +24,21 @@
</span><span class="cx">  */
</span><span class="cx"> // https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
</span><span class="cx"> 
</span><ins>+typedef unsigned long GPUTextureUsageFlags;
+
</ins><span class="cx"> [
</span><span class="cx">     Conditional=WEBGPU,
</span><span class="cx">     EnabledAtRuntime=WebGPU,
</span><ins>+    ImplementedAs=WebGPUSwapChainDescriptor
+] dictionary WebGPUSwapChainDescriptor {
+    required GPUCanvasContext context;
+    required GPUTextureFormat format;
+    GPUTextureUsageFlags usage = 16; // FIXME: How to set this to GPUTextureUsage.OUTPUT_ATTACHMENT in IDL?
+};
+
+[
+    Conditional=WEBGPU,
+    EnabledAtRuntime=WebGPU,
</ins><span class="cx">     ImplementationLacksVTable
</span><span class="cx"> ] interface WebGPUDevice {
</span><span class="cx">     readonly attribute WebGPUAdapter adapter;
</span><span class="lines">@@ -45,6 +57,8 @@
</span><span class="cx">     // FIXME: Currently, WebGPUCommandBufferDescriptor is an empty dictionary.
</span><span class="cx">     WebGPUCommandBuffer createCommandBuffer(/*WebGPUCommandBufferDescriptor descriptor*/);
</span><span class="cx"> 
</span><ins>+    WebGPUSwapChain createSwapChain(WebGPUSwapChainDescriptor descriptor);
+
</ins><span class="cx">     WebGPUQueue getQueue();
</span><span class="cx"> 
</span><span class="cx">     // FIXME: Unimplemented.
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUProgrammablePassEncodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.cpp    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.cpp       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><span class="cx"> 
</span><span class="cx"> #include "GPUProgrammablePassEncoder.h"
</span><ins>+#include "Logging.h"
</ins><span class="cx"> #include "WebGPUBindGroup.h"
</span><span class="cx"> #include "WebGPURenderPipeline.h"
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPURenderingContextcpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp   2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.cpp      2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,52 +0,0 @@
</span><del>-/*
- * Copyright (C) 2018 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.
- */
-
-#include "config.h"
-#include "WebGPURenderingContext.h"
-
-#if ENABLE(WEBGPU)
-
-namespace WebCore {
-
-std::unique_ptr<WebGPURenderingContext> WebGPURenderingContext::create(CanvasBase& canvas)
-{
-    auto swapChain = GPUSwapChain::create();
-
-    if (!swapChain)
-        return nullptr;
-
-    auto context = std::unique_ptr<WebGPURenderingContext>(new WebGPURenderingContext(canvas, WTFMove(swapChain)));
-    context->suspendIfNeeded();
-    return context;
-}
-
-WebGPURenderingContext::WebGPURenderingContext(CanvasBase& canvas, RefPtr<GPUSwapChain>&& swapChain)
-    : WebGPUSwapChain(canvas, WTFMove(swapChain))
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
</del></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPURenderingContexth"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.h     2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.h        2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,50 +0,0 @@
</span><del>-/*
- * Copyright (C) 2018 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
-
-#if ENABLE(WEBGPU)
-
-#include "WebGPUSwapChain.h"
-
-namespace WebCore {
-
-class WebGPURenderingContext final : public WebGPUSwapChain {
-public:
-    static std::unique_ptr<WebGPURenderingContext> create(CanvasBase&);
-
-private:
-    WebGPURenderingContext(CanvasBase&, RefPtr<GPUSwapChain>&&);
-    // CanvasRenderingContext
-    bool isWebGPU() const final { return true; }
-    // ActiveDOMObject
-    const char* activeDOMObjectName() const final { return "WebGPURenderingContext"; }
-};
-
-} // namespace WebCore
-
-SPECIALIZE_TYPE_TRAITS_CANVASRENDERINGCONTEXT(WebCore::WebGPURenderingContext, isWebGPU())
-
-#endif // ENABLE(WEBGPU)
</del></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPURenderingContextidl"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl   2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderingContext.idl      2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,31 +0,0 @@
</span><del>-/*
- * Copyright (C) 2018 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.
- */
-// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
-
-[
-    Conditional=WEBGPU,
-    EnabledAtRuntime=WebGPU
-] interface WebGPURenderingContext : WebGPUSwapChain {
-};
</del></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUSwapChaincpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.cpp  2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.cpp     2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -28,38 +28,41 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><span class="cx"> 
</span><ins>+#include "Logging.h"
+#include "WebGPUSwapChainDescriptor.h"
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-WebGPUSwapChain::~WebGPUSwapChain() = default;
-
-void WebGPUSwapChain::configure(Descriptor&& descriptor)
</del><ins>+Ref<WebGPUSwapChain> WebGPUSwapChain::create(RefPtr<GPUSwapChain>&& swapChain)
</ins><span class="cx"> {
</span><del>-    if (descriptor.device)
-        m_swapChain->setDevice(descriptor.device->device());
-
-    m_swapChain->setFormat(descriptor.format);
-
-    reshape(descriptor.width, descriptor.height);
</del><ins>+    return adoptRef(*new WebGPUSwapChain(WTFMove(swapChain)));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr<WebGPUTexture> WebGPUSwapChain::getNextTexture()
</del><ins>+WebGPUSwapChain::WebGPUSwapChain(RefPtr<GPUSwapChain>&& swapChain)
+    : m_swapChain(WTFMove(swapChain))
</ins><span class="cx"> {
</span><del>-    return WebGPUTexture::create(m_swapChain->getNextTexture());
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebGPUSwapChain::present()
</del><ins>+Ref<WebGPUTexture> WebGPUSwapChain::getCurrentTexture()
</ins><span class="cx"> {
</span><del>-    markLayerComposited();
</del><ins>+    if (!m_swapChain) {
+        LOG(WebGPU, "GPUSwapChain::getCurrentTexture(): Invalid operation!");
+        return WebGPUTexture::create(nullptr);
+    }
+    m_currentTexture = WebGPUTexture::create(m_swapChain->tryGetCurrentTexture());
+    return m_currentTexture.releaseNonNull();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebGPUSwapChain::reshape(int width, int height)
</del><ins>+void WebGPUSwapChain::destroy()
</ins><span class="cx"> {
</span><del>-    m_swapChain->reshape(width, height);
-}
</del><ins>+    if (!m_swapChain)
+        return;
</ins><span class="cx"> 
</span><del>-void WebGPUSwapChain::markLayerComposited()
-{
-    m_swapChain->present();
</del><ins>+    m_swapChain->destroy();
+    m_swapChain = nullptr;
+
+    if (m_currentTexture && m_currentTexture->texture())
+        m_currentTexture->destroy();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUSwapChainh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -27,54 +27,30 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><span class="cx"> 
</span><del>-#include "GPUBasedCanvasRenderingContext.h"
</del><span class="cx"> #include "GPUSwapChain.h"
</span><del>-#include "GPUTextureFormat.h"
-#include "WebGPUDevice.h"
</del><span class="cx"> #include "WebGPUTexture.h"
</span><del>-
</del><ins>+#include <wtf/RefCounted.h>
</ins><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class WebGPUSwapChain : public GPUBasedCanvasRenderingContext {
</del><ins>+struct WebGPUSwapChainDescriptor;
+
+class WebGPUSwapChain : public RefCounted<WebGPUSwapChain> {
</ins><span class="cx"> public:
</span><del>-    struct Descriptor {
-        const WebGPUDevice* device = nullptr;
-        // FIXME: More texture properties.
-        GPUTextureFormat format;
-        unsigned long width;
-        unsigned long height;
-    };
</del><ins>+    static Ref<WebGPUSwapChain> create(RefPtr<GPUSwapChain>&&);
</ins><span class="cx"> 
</span><del>-    virtual ~WebGPUSwapChain() = 0;
</del><ins>+    GPUSwapChain* swapChain() const { return m_swapChain.get(); }
</ins><span class="cx"> 
</span><del>-    void configure(Descriptor&&);
-    RefPtr<WebGPUTexture> getNextTexture();
-    void present();
</del><ins>+    Ref<WebGPUTexture> getCurrentTexture();
</ins><span class="cx"> 
</span><del>-protected:
-    WebGPUSwapChain(CanvasBase& canvas, RefPtr<GPUSwapChain>&& swapChain)
-        : GPUBasedCanvasRenderingContext(canvas)
-        , m_swapChain(WTFMove(swapChain))
-    {
-    }
</del><ins>+    void destroy();
</ins><span class="cx"> 
</span><del>-    const char* activeDOMObjectName() const override { return "WebGPUSwapChain"; }
-    PlatformLayer* platformLayer() const final { return m_swapChain->platformLayer(); };
-
</del><span class="cx"> private:
</span><del>-    // GPUBasedRenderingContext
-    void reshape(int width, int height) final;
-    void markLayerComposited() final;
</del><ins>+    WebGPUSwapChain(RefPtr<GPUSwapChain>&&);
</ins><span class="cx"> 
</span><del>-    // ActiveDOMObject
-    // FIXME: Stubs.
-    bool hasPendingActivity() const override { return false; }
-    void stop() override { }
-    bool canSuspendForDocumentSuspension() const override { return false; }
-
</del><span class="cx">     RefPtr<GPUSwapChain> m_swapChain;
</span><ins>+    RefPtr<WebGPUTexture> m_currentTexture;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUSwapChainidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.idl (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.idl  2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.idl     2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -27,23 +27,8 @@
</span><span class="cx"> [
</span><span class="cx">     Conditional=WEBGPU,
</span><span class="cx">     EnabledAtRuntime=WebGPU,
</span><ins>+    InterfaceName=GPUSwapChain,
</ins><span class="cx">     SkipVTableValidation
</span><span class="cx"> ] interface WebGPUSwapChain {
</span><del>-    void configure(WebGPUSwapChainDescriptor descriptor);
-    WebGPUTexture getNextTexture();
-    void present();
</del><ins>+    WebGPUTexture getCurrentTexture();
</ins><span class="cx"> };
</span><del>-
-typedef unsigned long u32;
-
-[
-    Conditional=WEBGPU,
-    EnabledAtRuntime=WebGPU
-] dictionary WebGPUSwapChainDescriptor {
-    WebGPUDevice? device;
-    // WebGPUTextureUsageFlags usage;
-    GPUTextureFormat format;
-    u32 width;
-    u32 height;
-};
-
</del></span></pre></div>
<a id="trunkSourceWebCoreModuleswebgpuWebGPUSwapChainDescriptorhfromrev242758trunkSourceWebCoreplatformgraphicsgpuGPUTextureFormath"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.h (from rev 242758, trunk/Source/WebCore/platform/graphics/gpu/GPUTextureFormat.h) (0 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.h                          (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChainDescriptor.h     2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+/*
+ * Copyright (C) 2019 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
+
+#if ENABLE(WEBGPU)
+
+#include "GPUCanvasContext.h"
+#include "GPUSwapChainDescriptor.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+struct WebGPUSwapChainDescriptor : GPUSwapChainDescriptor {
+    RefPtr<GPUCanvasContext> context;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)
</ins></span></pre></div>
<a id="trunkSourceWebCoreSourcestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Sources.txt (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Sources.txt 2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/Sources.txt    2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -306,6 +306,7 @@
</span><span class="cx"> Modules/websockets/WorkerThreadableWebSocketChannel.cpp
</span><span class="cx"> 
</span><span class="cx"> Modules/webgpu/DOMWindowWebGPU.cpp
</span><ins>+Modules/webgpu/GPUCanvasContext.cpp
</ins><span class="cx"> Modules/webgpu/WHLSL/WHLSLInferTypes.cpp
</span><span class="cx"> Modules/webgpu/WHLSL/WHLSLLexer.cpp
</span><span class="cx"> Modules/webgpu/WHLSL/WHLSLParser.cpp
</span><span class="lines">@@ -359,7 +360,6 @@
</span><span class="cx"> Modules/webgpu/WebGPUQueue.cpp
</span><span class="cx"> Modules/webgpu/WebGPUPipelineLayout.cpp
</span><span class="cx"> Modules/webgpu/WebGPUProgrammablePassEncoder.cpp
</span><del>-Modules/webgpu/WebGPURenderingContext.cpp
</del><span class="cx"> Modules/webgpu/WebGPURenderPassDescriptor.cpp
</span><span class="cx"> Modules/webgpu/WebGPURenderPassEncoder.cpp
</span><span class="cx"> Modules/webgpu/WebGPURenderPipeline.cpp
</span><span class="lines">@@ -2776,6 +2776,7 @@
</span><span class="cx"> JSFocusEvent.cpp
</span><span class="cx"> JSFontFace.cpp
</span><span class="cx"> JSFontFaceSet.cpp
</span><ins>+JSGPUCanvasContext.cpp
</ins><span class="cx"> JSGPUColor.cpp
</span><span class="cx"> JSGPUBindGroupLayoutBinding.cpp
</span><span class="cx"> JSGPUBindGroupLayoutDescriptor.cpp
</span><span class="lines">@@ -3341,7 +3342,6 @@
</span><span class="cx"> JSWebGPUPipelineLayoutDescriptor.cpp
</span><span class="cx"> JSWebGPUPipelineStageDescriptor.cpp
</span><span class="cx"> JSWebGPUProgrammablePassEncoder.cpp
</span><del>-JSWebGPURenderingContext.cpp
</del><span class="cx"> JSWebGPURenderPassDescriptor.cpp
</span><span class="cx"> JSWebGPURenderPassEncoder.cpp
</span><span class="cx"> JSWebGPURenderPipeline.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -14111,9 +14111,9 @@
</span><span class="cx">          D08AA032220D0D0B0058C502 /* GPUStoreOp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUStoreOp.h; sourceTree = "<group>"; };
</span><span class="cx">          D08AA036220D19DA0058C502 /* WebGPURenderPassDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPURenderPassDescriptor.idl; sourceTree = "<group>"; };
</span><span class="cx">          D08AA037220D1D050058C502 /* WebGPURenderPassDescriptor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPURenderPassDescriptor.cpp; sourceTree = "<group>"; };
</span><del>-               D093D225217951D400329217 /* WebGPURenderingContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPURenderingContext.h; sourceTree = "<group>"; };
-               D093D227217951D400329217 /* WebGPURenderingContext.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPURenderingContext.idl; sourceTree = "<group>"; };
-               D093D2292179541600329217 /* WebGPURenderingContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPURenderingContext.cpp; sourceTree = "<group>"; };
</del><ins>+                D093D225217951D400329217 /* GPUCanvasContext.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUCanvasContext.h; sourceTree = "<group>"; };
+               D093D227217951D400329217 /* GPUCanvasContext.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUCanvasContext.idl; sourceTree = "<group>"; };
+               D093D2292179541600329217 /* GPUCanvasContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUCanvasContext.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           D0A20D542092A0A600E0C259 /* WebGLCompressedTextureASTC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLCompressedTextureASTC.h; sourceTree = "<group>"; };
</span><span class="cx">          D0A20D562092A0A600E0C259 /* WebGLCompressedTextureASTC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLCompressedTextureASTC.cpp; sourceTree = "<group>"; };
</span><span class="cx">          D0A3A7301405A39800FB8ED3 /* ResourceLoaderOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoaderOptions.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -14124,6 +14124,8 @@
</span><span class="cx">          D0ADB26C2230BB8E00A22935 /* WebGPUSampler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUSampler.h; sourceTree = "<group>"; };
</span><span class="cx">          D0ADB26D2230BB8E00A22935 /* WebGPUSampler.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUSampler.cpp; sourceTree = "<group>"; };
</span><span class="cx">          D0ADB26F2230C1F100A22935 /* WebGPUSampler.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUSampler.idl; sourceTree = "<group>"; };
</span><ins>+               D0ADB27E2232F0C000A22935 /* WebGPUSwapChainDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUSwapChainDescriptor.h; sourceTree = "<group>"; };
+               D0ADB27F2232F17300A22935 /* GPUSwapChainDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = GPUSwapChainDescriptor.h; path = platform/graphics/gpu/GPUSwapChainDescriptor.h; sourceTree = SOURCE_ROOT; };
</ins><span class="cx">           D0B0556609C6700100307E43 /* CreateLinkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CreateLinkCommand.h; sourceTree = "<group>"; };
</span><span class="cx">          D0B0556709C6700100307E43 /* CreateLinkCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreateLinkCommand.cpp; sourceTree = "<group>"; };
</span><span class="cx">          D0B8BB0121C46E78000C7681 /* GPUBindGroupLayoutBinding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBindGroupLayoutBinding.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -26111,6 +26113,9 @@
</span><span class="cx">                          D0D69C9D222E00C20032927E /* GPUBindGroupLayoutDescriptor.idl */,
</span><span class="cx">                          D01B811922135EB900627B6C /* GPUBufferDescriptor.idl */,
</span><span class="cx">                          D01B811C2213627300627B6C /* GPUBufferUsage.idl */,
</span><ins>+                               D093D2292179541600329217 /* GPUCanvasContext.cpp */,
+                               D093D225217951D400329217 /* GPUCanvasContext.h */,
+                               D093D227217951D400329217 /* GPUCanvasContext.idl */,
</ins><span class="cx">                           D01B811222125AFC00627B6C /* GPUColor.idl */,
</span><span class="cx">                          D03C849E21FFCF000002227F /* GPUCompareFunction.idl */,
</span><span class="cx">                          D03C84A221FFD7230002227F /* GPUDepthStencilStateDescriptor.idl */,
</span><span class="lines">@@ -26123,6 +26128,7 @@
</span><span class="cx">                          D0DE8FB8222E09E200882550 /* GPUShaderStageBit.h */,
</span><span class="cx">                          D0DE8FB9222E09E200882550 /* GPUShaderStageBit.idl */,
</span><span class="cx">                          D08AA031220D0CE60058C502 /* GPUStoreOp.idl */,
</span><ins>+                               D0ADB27F2232F17300A22935 /* GPUSwapChainDescriptor.h */,
</ins><span class="cx">                           D026F48B220A5B0B00AC5F49 /* GPUTextureDescriptor.idl */,
</span><span class="cx">                          D026F489220A539800AC5F49 /* GPUTextureDimension.idl */,
</span><span class="cx">                          D0EACFAE219E30FD000FA75C /* GPUTextureFormat.idl */,
</span><span class="lines">@@ -26176,9 +26182,6 @@
</span><span class="cx">                          312FF93C21A61CA100EB199D /* WebGPUQueue.cpp */,
</span><span class="cx">                          312FF93921A61C9F00EB199D /* WebGPUQueue.h */,
</span><span class="cx">                          312FF93B21A61CA000EB199D /* WebGPUQueue.idl */,
</span><del>-                               D093D2292179541600329217 /* WebGPURenderingContext.cpp */,
-                               D093D225217951D400329217 /* WebGPURenderingContext.h */,
-                               D093D227217951D400329217 /* WebGPURenderingContext.idl */,
</del><span class="cx">                           D08AA037220D1D050058C502 /* WebGPURenderPassDescriptor.cpp */,
</span><span class="cx">                          D0EACF8C219403C9000FA75C /* WebGPURenderPassDescriptor.h */,
</span><span class="cx">                          D08AA036220D19DA0058C502 /* WebGPURenderPassDescriptor.idl */,
</span><span class="lines">@@ -26201,6 +26204,7 @@
</span><span class="cx">                          D0DA0BE5217930E2007FE2AC /* WebGPUSwapChain.cpp */,
</span><span class="cx">                          D0DA0BE4217930E2007FE2AC /* WebGPUSwapChain.h */,
</span><span class="cx">                          D0DA0BE6217930E2007FE2AC /* WebGPUSwapChain.idl */,
</span><ins>+                               D0ADB27E2232F0C000A22935 /* WebGPUSwapChainDescriptor.h */,
</ins><span class="cx">                           D0EACF852193B02E000FA75C /* WebGPUTexture.cpp */,
</span><span class="cx">                          D0EACF842193B02E000FA75C /* WebGPUTexture.h */,
</span><span class="cx">                          D0EACF862193B02E000FA75C /* WebGPUTexture.idl */,
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsWebCoreBuiltinNamesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h   2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h      2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -82,7 +82,9 @@
</span><span class="cx">     macro(GamepadButton) \
</span><span class="cx">     macro(GamepadEvent) \
</span><span class="cx">     macro(GPUBufferUsage) \
</span><ins>+    macro(GPUCanvasContext) \
</ins><span class="cx">     macro(GPUShaderStageBit) \
</span><ins>+    macro(GPUSwapChain) \
</ins><span class="cx">     macro(GPUTextureUsage) \
</span><span class="cx">     macro(HTMLAttachmentElement) \
</span><span class="cx">     macro(HTMLAudioElement) \
</span><span class="lines">@@ -205,12 +207,10 @@
</span><span class="cx">     macro(WebGPUQueue) \
</span><span class="cx">     macro(WebGPUPipelineLayout) \
</span><span class="cx">     macro(WebGPUProgrammablePassEncoder) \
</span><del>-    macro(WebGPURenderingContext) \
</del><span class="cx">     macro(WebGPURenderPassEncoder) \
</span><span class="cx">     macro(WebGPURenderPipeline) \
</span><span class="cx">     macro(WebGPUSampler) \
</span><span class="cx">     macro(WebGPUShaderModule) \
</span><del>-    macro(WebGPUSwapChain) \
</del><span class="cx">     macro(WebGPUTexture) \
</span><span class="cx">     macro(WebGPUTextureView) \
</span><span class="cx">     macro(WebGPUVertexFormat) \
</span><span class="lines">@@ -280,6 +280,7 @@
</span><span class="cx">     macro(frames) \
</span><span class="cx">     macro(getTracks) \
</span><span class="cx">     macro(getUserMedia) \
</span><ins>+    macro(gpu) \
</ins><span class="cx">     macro(header) \
</span><span class="cx">     macro(href) \
</span><span class="cx">     macro(indexedDB) \
</span><span class="lines">@@ -363,7 +364,6 @@
</span><span class="cx">     macro(webkitIDBRequest) \
</span><span class="cx">     macro(webkitIDBTransaction) \
</span><span class="cx">     macro(webkitIndexedDB) \
</span><del>-    macro(webgpu) \
</del><span class="cx">     macro(window) \
</span><span class="cx">     macro(writing) \
</span><span class="cx">     WEBCORE_ADDITIONAL_PRIVATE_IDENTIFIERS(macro) \
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.cpp    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/dom/Document.cpp       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -316,7 +316,7 @@
</span><span class="cx"> #include "WebGL2RenderingContext.h"
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><del>-#include "WebGPURenderingContext.h"
</del><ins>+#include "GPUCanvasContext.h"
</ins><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(WEBMETAL)
</span><span class="cx"> #include "WebMetalRenderingContext.h"
</span><span class="lines">@@ -6074,8 +6074,8 @@
</span><span class="cx">         return RenderingContext { RefPtr<WebGL2RenderingContext> { &downcast<WebGL2RenderingContext>(*context) } };
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><del>-    if (is<WebGPURenderingContext>(*context))
-        return RenderingContext { RefPtr<WebGPURenderingContext> { &downcast<WebGPURenderingContext>(*context) } };
</del><ins>+    if (is<GPUCanvasContext>(*context))
+        return RenderingContext { RefPtr<GPUCanvasContext> { &downcast<GPUCanvasContext>(*context) } };
</ins><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(WEBMETAL)
</span><span class="cx">     if (is<WebMetalRenderingContext>(*context))
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.h      2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/dom/Document.h 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -195,7 +195,7 @@
</span><span class="cx"> class WebAnimation;
</span><span class="cx"> class WebGL2RenderingContext;
</span><span class="cx"> class WebGLRenderingContext;
</span><del>-class WebGPURenderingContext;
</del><ins>+class GPUCanvasContext;
</ins><span class="cx"> class WebMetalRenderingContext;
</span><span class="cx"> class WindowProxy;
</span><span class="cx"> class Worklet;
</span><span class="lines">@@ -321,7 +321,7 @@
</span><span class="cx">     RefPtr<WebGL2RenderingContext>,
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><del>-    RefPtr<WebGPURenderingContext>,
</del><ins>+    RefPtr<GPUCanvasContext>,
</ins><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(WEBMETAL)
</span><span class="cx">     RefPtr<WebMetalRenderingContext>,
</span></span></pre></div>
<a id="trunkSourceWebCoredomDocumentidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Document.idl (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Document.idl    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/dom/Document.idl       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx">     WebGL2RenderingContext or
</span><span class="cx"> #endif
</span><span class="cx"> #if defined(ENABLE_WEBGPU) && ENABLE_WEBGPU
</span><del>-    WebGPURenderingContext or
</del><ins>+    GPUCanvasContext or
</ins><span class="cx"> #endif
</span><span class="cx"> #if defined(ENABLE_WEBMETAL) && ENABLE_WEBMETAL
</span><span class="cx">     WebMetalRenderingContext or
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCanvasElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCanvasElement.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCanvasElement.cpp  2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.cpp     2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><del>-#include "WebGPURenderingContext.h"
</del><ins>+#include "GPUCanvasContext.h"
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBMETAL)
</span><span class="lines">@@ -246,7 +246,7 @@
</span><span class="cx">         if (m_context->isWebGPU()) {
</span><span class="cx">             if (!isWebGPUType(contextId))
</span><span class="cx">                 return Optional<RenderingContext> { WTF::nullopt };
</span><del>-            return Optional<RenderingContext> { RefPtr<WebGPURenderingContext> { &downcast<WebGPURenderingContext>(*m_context) } };
</del><ins>+            return Optional<RenderingContext> { RefPtr<GPUCanvasContext> { &downcast<GPUCanvasContext>(*m_context) } };
</ins><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -304,7 +304,7 @@
</span><span class="cx">         auto context = createContextWebGPU(contextId);
</span><span class="cx">         if (!context)
</span><span class="cx">             return Optional<RenderingContext> { WTF::nullopt };
</span><del>-        return Optional<RenderingContext> { RefPtr<WebGPURenderingContext> { context } };
</del><ins>+        return Optional<RenderingContext> { RefPtr<GPUCanvasContext> { context } };
</ins><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -467,10 +467,10 @@
</span><span class="cx"> 
</span><span class="cx"> bool HTMLCanvasElement::isWebGPUType(const String& type)
</span><span class="cx"> {
</span><del>-    return type == "webgpu";
</del><ins>+    return type == "gpu";
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebGPURenderingContext* HTMLCanvasElement::createContextWebGPU(const String& type)
</del><ins>+GPUCanvasContext* HTMLCanvasElement::createContextWebGPU(const String& type)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT_UNUSED(type, HTMLCanvasElement::isWebGPUType(type));
</span><span class="cx">     ASSERT(!m_context);
</span><span class="lines">@@ -478,16 +478,16 @@
</span><span class="cx">     if (!RuntimeEnabledFeatures::sharedFeatures().webGPUEnabled())
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><del>-    m_context = WebGPURenderingContext::create(*this);
</del><ins>+    m_context = GPUCanvasContext::create(*this);
</ins><span class="cx">     if (m_context) {
</span><span class="cx">         // Need to make sure a RenderLayer and compositing layer get created for the Canvas.
</span><span class="cx">         invalidateStyleAndLayerComposition();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return static_cast<WebGPURenderingContext*>(m_context.get());
</del><ins>+    return static_cast<GPUCanvasContext*>(m_context.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-WebGPURenderingContext* HTMLCanvasElement::getContextWebGPU(const String& type)
</del><ins>+GPUCanvasContext* HTMLCanvasElement::getContextWebGPU(const String& type)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT_UNUSED(type, HTMLCanvasElement::isWebGPUType(type));
</span><span class="cx"> 
</span><span class="lines">@@ -499,7 +499,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (!m_context)
</span><span class="cx">         return createContextWebGPU(type);
</span><del>-    return static_cast<WebGPURenderingContext*>(m_context.get());
</del><ins>+    return static_cast<GPUCanvasContext*>(m_context.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEBGPU)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCanvasElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCanvasElement.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCanvasElement.h    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.h       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> class MediaSample;
</span><span class="cx"> class MediaStream;
</span><span class="cx"> class WebGLRenderingContextBase;
</span><del>-class WebGPURenderingContext;
</del><ins>+class GPUCanvasContext;
</ins><span class="cx"> class WebMetalRenderingContext;
</span><span class="cx"> struct UncachedString;
</span><span class="cx"> 
</span><span class="lines">@@ -100,8 +100,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><span class="cx">     static bool isWebGPUType(const String&);
</span><del>-    WebGPURenderingContext* createContextWebGPU(const String&);
-    WebGPURenderingContext* getContextWebGPU(const String&);
</del><ins>+    GPUCanvasContext* createContextWebGPU(const String&);
+    GPUCanvasContext* getContextWebGPU(const String&);
</ins><span class="cx"> #endif
</span><span class="cx"> #if ENABLE(WEBMETAL)
</span><span class="cx">     static bool isWebMetalType(const String&);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLCanvasElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLCanvasElement.idl (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLCanvasElement.idl  2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/html/HTMLCanvasElement.idl     2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx">     WebGL2RenderingContext or
</span><span class="cx"> #endif
</span><span class="cx"> #if defined(ENABLE_WEBGPU) && ENABLE_WEBGPU
</span><del>-    WebGPURenderingContext or
</del><ins>+    GPUCanvasContext or
</ins><span class="cx"> #endif
</span><span class="cx"> #if defined(ENABLE_WEBMETAL) && ENABLE_WEBMETAL
</span><span class="cx">     WebMetalRenderingContext or
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorCanvascpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorCanvas.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorCanvas.cpp       2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/inspector/InspectorCanvas.cpp  2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -63,6 +63,9 @@
</span><span class="cx"> #if ENABLE(WEBGL2)
</span><span class="cx"> #include "WebGL2RenderingContext.h"
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(WEBGPU)
+#include "GPUCanvasContext.h"
+#endif
</ins><span class="cx"> #if ENABLE(WEBMETAL)
</span><span class="cx"> #include "WebMetalRenderingContext.h"
</span><span class="cx"> #endif
</span><span class="lines">@@ -244,6 +247,10 @@
</span><span class="cx">     else if (is<WebGL2RenderingContext>(m_context))
</span><span class="cx">         contextType = Inspector::Protocol::Canvas::ContextType::WebGL2;
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(WEBGPU)
+    else if (is<GPUCanvasContext>(m_context))
+        contextType = Inspector::Protocol::Canvas::ContextType::WebGPU;
+#endif
</ins><span class="cx"> #if ENABLE(WEBMETAL)
</span><span class="cx">     else if (is<WebMetalRenderingContext>(m_context))
</span><span class="cx">         contextType = Inspector::Protocol::Canvas::ContextType::WebMetal;
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectoragentsInspectorCanvasAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp   2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp      2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -58,6 +58,10 @@
</span><span class="cx"> #include "JSWebGL2RenderingContext.h"
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if ENABLE(WEBGPU)
+#include "JSGPUCanvasContext.h"
+#endif
+
</ins><span class="cx"> #if ENABLE(WEBMETAL)
</span><span class="cx"> #include "JSWebMetalRenderingContext.h"
</span><span class="cx"> #endif
</span><span class="lines">@@ -244,6 +248,10 @@
</span><span class="cx">     if (is<WebGL2RenderingContext>(context))
</span><span class="cx">         return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<WebGL2RenderingContext>(context));
</span><span class="cx"> #endif
</span><ins>+#if ENABLE(WEBGPU)
+    if (is<GPUCanvasContext>(context))
+        return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<GPUCanvasContext>(context));
+#endif
</ins><span class="cx"> #if ENABLE(WEBMETAL)
</span><span class="cx">     if (is<WebMetalRenderingContext>(context))
</span><span class="cx">         return toJS(&state, deprecatedGlobalObjectForPrototype(&state), downcast<WebMetalRenderingContext>(context));
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUDevicecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp 2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp    2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include "GPUSamplerDescriptor.h"
</span><span class="cx"> #include "GPUShaderModule.h"
</span><span class="cx"> #include "GPUShaderModuleDescriptor.h"
</span><ins>+#include "GPUSwapChain.h"
</ins><span class="cx"> #include "GPUTexture.h"
</span><span class="cx"> #include "GPUTextureDescriptor.h"
</span><span class="cx"> 
</span><span class="lines">@@ -86,10 +87,16 @@
</span><span class="cx">     return GPUCommandBuffer::create(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr<GPUQueue> GPUDevice::getQueue()
</del><ins>+RefPtr<GPUSwapChain> GPUDevice::tryCreateSwapChain(const GPUSwapChainDescriptor& descriptor, int width, int height) const
</ins><span class="cx"> {
</span><ins>+    m_swapChain = GPUSwapChain::tryCreate(*this, descriptor, width, height);
+    return m_swapChain;
+}
+
+RefPtr<GPUQueue> GPUDevice::getQueue() const
+{
</ins><span class="cx">     if (!m_queue)
</span><del>-        m_queue = GPUQueue::create(*this);
</del><ins>+        m_queue = GPUQueue::tryCreate(*this);
</ins><span class="cx"> 
</span><span class="cx">     return m_queue;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUDeviceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h   2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h      2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -28,10 +28,12 @@
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><span class="cx"> 
</span><span class="cx"> #include "GPUQueue.h"
</span><ins>+#include "GPUSwapChainDescriptor.h"
</ins><span class="cx"> #include <wtf/Optional.h>
</span><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><ins>+#include <wtf/WeakPtr.h>
</ins><span class="cx"> 
</span><span class="cx"> OBJC_PROTOCOL(MTLDevice);
</span><span class="cx"> 
</span><span class="lines">@@ -47,6 +49,7 @@
</span><span class="cx"> class GPURenderPipeline;
</span><span class="cx"> class GPUSampler;
</span><span class="cx"> class GPUShaderModule;
</span><ins>+class GPUSwapChain;
</ins><span class="cx"> class GPUTexture;
</span><span class="cx"> 
</span><span class="cx"> struct GPUBindGroupLayoutDescriptor;
</span><span class="lines">@@ -58,7 +61,7 @@
</span><span class="cx"> struct GPUShaderModuleDescriptor;
</span><span class="cx"> struct GPUTextureDescriptor;
</span><span class="cx"> 
</span><del>-class GPUDevice : public RefCounted<GPUDevice> {
</del><ins>+class GPUDevice : public RefCounted<GPUDevice>, public CanMakeWeakPtr<GPUDevice> {
</ins><span class="cx"> public:
</span><span class="cx">     static RefPtr<GPUDevice> create(Optional<GPURequestAdapterOptions>&&);
</span><span class="cx"> 
</span><span class="lines">@@ -74,14 +77,18 @@
</span><span class="cx"> 
</span><span class="cx">     RefPtr<GPUCommandBuffer> createCommandBuffer();
</span><span class="cx"> 
</span><del>-    RefPtr<GPUQueue> getQueue();
</del><ins>+    RefPtr<GPUSwapChain> tryCreateSwapChain(const GPUSwapChainDescriptor&, int width, int height) const;
+
+    RefPtr<GPUQueue> getQueue() const;
</ins><span class="cx">     PlatformDevice* platformDevice() const { return m_platformDevice.get(); }
</span><ins>+    GPUSwapChain* swapChain() const { return m_swapChain.get(); }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     GPUDevice(PlatformDeviceSmartPtr&&);
</span><span class="cx"> 
</span><span class="cx">     PlatformDeviceSmartPtr m_platformDevice;
</span><del>-    RefPtr<GPUQueue> m_queue;
</del><ins>+    mutable RefPtr<GPUQueue> m_queue;
+    mutable RefPtr<GPUSwapChain> m_swapChain;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUQueueh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUQueue.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUQueue.h    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUQueue.h       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -27,10 +27,12 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><span class="cx"> 
</span><ins>+#include "DeferrableTask.h"
</ins><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><ins>+#include <wtf/WeakPtr.h>
</ins><span class="cx"> 
</span><span class="cx"> OBJC_PROTOCOL(MTLCommandQueue);
</span><span class="cx"> 
</span><span class="lines">@@ -44,7 +46,7 @@
</span><span class="cx"> 
</span><span class="cx"> class GPUQueue : public RefCounted<GPUQueue> {
</span><span class="cx"> public:
</span><del>-    static RefPtr<GPUQueue> create(const GPUDevice&);
</del><ins>+    static RefPtr<GPUQueue> tryCreate(const GPUDevice&);
</ins><span class="cx"> 
</span><span class="cx">     PlatformQueue* platformQueue() const { return m_platformQueue.get(); }
</span><span class="cx"> 
</span><span class="lines">@@ -54,9 +56,11 @@
</span><span class="cx">     void setLabel(const String&) const;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    GPUQueue(PlatformQueueSmartPtr&&);
</del><ins>+    GPUQueue(PlatformQueueSmartPtr&&, const GPUDevice&);
</ins><span class="cx"> 
</span><span class="cx">     PlatformQueueSmartPtr m_platformQueue;
</span><ins>+    WeakPtr<const GPUDevice> m_device;
+    DeferrableTask<Timer> m_presentTask;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUSwapChainh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChain.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChain.h        2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChain.h   2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><span class="cx"> 
</span><span class="cx"> #include "GPUTexture.h"
</span><ins>+#include <wtf/OptionSet.h>
</ins><span class="cx"> #include <wtf/RefPtr.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx"> 
</span><span class="lines">@@ -39,6 +40,8 @@
</span><span class="cx"> 
</span><span class="cx"> class GPUDevice;
</span><span class="cx"> 
</span><ins>+struct GPUSwapChainDescriptor;
+
</ins><span class="cx"> enum class GPUTextureFormat;
</span><span class="cx"> 
</span><span class="cx"> using PlatformDrawableSmartPtr = RetainPtr<CAMetalDrawable>;
</span><span class="lines">@@ -47,21 +50,27 @@
</span><span class="cx"> 
</span><span class="cx"> class GPUSwapChain : public RefCounted<GPUSwapChain> {
</span><span class="cx"> public:
</span><del>-    static RefPtr<GPUSwapChain> create();
</del><ins>+    static RefPtr<GPUSwapChain> tryCreate(const GPUDevice&, const GPUSwapChainDescriptor&, int width, int height);
</ins><span class="cx"> 
</span><del>-    void setDevice(const GPUDevice&);
-    void setFormat(GPUTextureFormat);
-    void reshape(int width, int height);
-    RefPtr<GPUTexture> getNextTexture();
-    void present();
</del><ins>+    RefPtr<GPUTexture> tryGetCurrentTexture();
</ins><span class="cx"> 
</span><ins>+#if USE(METAL)
+    RetainPtr<CAMetalDrawable> takeDrawable();
+#endif
+
+    // For GPUCanvasContext.
</ins><span class="cx">     PlatformLayer* platformLayer() const;
</span><span class="cx"> 
</span><ins>+    void present();
+    void reshape(int width, int height);
+    void destroy() { m_currentDrawable = nullptr; }
+
</ins><span class="cx"> private:
</span><del>-    GPUSwapChain(PlatformSwapLayerSmartPtr&&);
</del><ins>+    GPUSwapChain(PlatformSwapLayerSmartPtr&&, OptionSet<GPUTextureUsage::Flags>);
</ins><span class="cx"> 
</span><span class="cx">     PlatformSwapLayerSmartPtr m_platformSwapLayer;
</span><span class="cx">     PlatformDrawableSmartPtr m_currentDrawable;
</span><ins>+    OptionSet<GPUTextureUsage::Flags> m_usage;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUSwapChainDescriptorhfromrev242758trunkSourceWebCoreplatformgraphicsgpuGPUTextureFormath"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChainDescriptor.h (from rev 242758, trunk/Source/WebCore/platform/graphics/gpu/GPUTextureFormat.h) (0 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChainDescriptor.h                              (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUSwapChainDescriptor.h 2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+/*
+ * Copyright (C) 2019 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
+
+#if ENABLE(WEBGPU)
+
+#include "GPUTextureFormat.h"
+#include "GPUTextureUsage.h"
+
+namespace WebCore {
+
+struct GPUSwapChainDescriptor {
+    GPUTextureFormat format;
+    GPUTextureUsageFlags usage { static_cast<GPUTextureUsageFlags>(GPUTextureUsage::Flags::OutputAttachment) };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpuGPUTextureFormath"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUTextureFormat.h (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/GPUTextureFormat.h    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUTextureFormat.h       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -33,7 +33,9 @@
</span><span class="cx">     R8g8b8a8Unorm,
</span><span class="cx">     R8g8b8a8Uint,
</span><span class="cx">     B8g8r8a8Unorm,
</span><del>-    D32FloatS8Uint
</del><ins>+    D32FloatS8Uint,
+    Bgra8unormSRGB,
+    Rgba16float
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> using PlatformTextureFormat = unsigned long;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpucocoaGPUBufferMetalmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm       2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm  2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -180,9 +180,11 @@
</span><span class="cx">     ++m_numScheduledCommandBuffers;
</span><span class="cx"> 
</span><span class="cx">     auto protectedThis = makeRefPtr(this);
</span><ins>+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
</ins><span class="cx">     [commandBuffer addCompletedHandler:^(id<MTLCommandBuffer>) {
</span><span class="cx">         protectedThis->commandBufferCompleted();
</span><span class="cx">     }];
</span><ins>+    END_BLOCK_OBJC_EXCEPTIONS;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GPUBuffer::commandBufferCompleted()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpucocoaGPUQueueMetalmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUQueueMetal.mm (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUQueueMetal.mm        2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUQueueMetal.mm   2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -30,8 +30,8 @@
</span><span class="cx"> 
</span><span class="cx"> #import "GPUCommandBuffer.h"
</span><span class="cx"> #import "GPUDevice.h"
</span><ins>+#import "GPUSwapChain.h"
</ins><span class="cx"> #import "Logging.h"
</span><del>-
</del><span class="cx"> #import <Metal/Metal.h>
</span><span class="cx"> #import <wtf/BlockObjCExceptions.h>
</span><span class="cx"> #import <wtf/text/WTFString.h>
</span><span class="lines">@@ -41,14 +41,14 @@
</span><span class="cx"> static NSString * const commandQueueDefaultLabel = @"com.apple.WebKit";
</span><span class="cx"> static NSString * const commandQueueLabelPrefix = @"com.apple.WebKit.";
</span><span class="cx"> 
</span><del>-RefPtr<GPUQueue> GPUQueue::create(const GPUDevice& device)
</del><ins>+RefPtr<GPUQueue> GPUQueue::tryCreate(const GPUDevice& device)
</ins><span class="cx"> {
</span><span class="cx">     if (!device.platformDevice()) {
</span><del>-        LOG(WebGPU, "GPUQueue::create(): Invalid GPUDevice!");
</del><ins>+        LOG(WebGPU, "GPUQueue::tryCreate(): Invalid GPUDevice!");
</ins><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    PlatformQueueSmartPtr queue;
</del><ins>+    RetainPtr<MTLCommandQueue> queue;
</ins><span class="cx"> 
</span><span class="cx">     BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> 
</span><span class="lines">@@ -58,33 +58,29 @@
</span><span class="cx">     END_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> 
</span><span class="cx">     if (!queue) {
</span><del>-        LOG(WebGPU, "GPUQueue::create(): Unable to create MTLCommandQueue!");
</del><ins>+        LOG(WebGPU, "GPUQueue::tryCreate(): Unable to create MTLCommandQueue!");
</ins><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return adoptRef(new GPUQueue(WTFMove(queue)));
</del><ins>+    return adoptRef(new GPUQueue(WTFMove(queue), device));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-GPUQueue::GPUQueue(PlatformQueueSmartPtr&& queue)
</del><ins>+GPUQueue::GPUQueue(RetainPtr<MTLCommandQueue>&& queue, const GPUDevice& device)
</ins><span class="cx">     : m_platformQueue(WTFMove(queue))
</span><ins>+    , m_device(makeWeakPtr(device))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GPUQueue::submit(Vector<Ref<GPUCommandBuffer>>&& commandBuffers)
</span><span class="cx"> {
</span><del>-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
</del><span class="cx">     for (auto& commandBuffer : commandBuffers) {
</span><del>-        commandBuffer->endBlitEncoding();
-        // Prevent any buffer mapping callbacks from executing until command buffer is complete.
</del><ins>+        // Validate resource integrity.
</ins><span class="cx">         for (auto& buffer : commandBuffer->usedBuffers()) {
</span><span class="cx">             if (buffer->state() != GPUBuffer::State::Unmapped) {
</span><span class="cx">                 LOG(WebGPU, "GPUQueue::submit(): Invalid GPUBuffer set on a GPUCommandBuffer!");
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><del>-            buffer->commandBufferCommitted(commandBuffer->platformCommandBuffer());
</del><span class="cx">         }
</span><del>-        // Also ensure textures are still valid.
</del><span class="cx">         for (auto& texture : commandBuffer->usedTextures()) {
</span><span class="cx">             if (!texture->platformTexture()) {
</span><span class="cx">                 LOG(WebGPU, "GPUQueue::submit(): Invalid GPUTexture set on a GPUCommandBuffer!");
</span><span class="lines">@@ -91,11 +87,29 @@
</span><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-
</del><ins>+        commandBuffer->endBlitEncoding();
+        // Okay to commit; prevent any buffer mapping callbacks from executing until command buffer is complete.
+        for (auto& buffer : commandBuffer->usedBuffers())
+            buffer->commandBufferCommitted(commandBuffer->platformCommandBuffer());
+        BEGIN_BLOCK_OBJC_EXCEPTIONS;
</ins><span class="cx">         [commandBuffer->platformCommandBuffer() commit];
</span><ins>+        END_BLOCK_OBJC_EXCEPTIONS;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    END_BLOCK_OBJC_EXCEPTIONS;
</del><ins>+    if (m_presentTask.hasPendingTask() || !m_device->swapChain())
+        return;
+
+    // If a GPUSwapChain exists, ensure that a present is scheduled after all command buffers.
+    m_presentTask.scheduleTask([this, protectedThis = makeRef(*this), swapChain = makeRef(*m_device->swapChain())] () {
+        auto currentDrawable = swapChain->takeDrawable();
+        // If the GPUSwapChain has no drawable, it was invalidated between command submission and this task.
+        if (!currentDrawable)
+            return;
+
+        auto presentCommandBuffer = [m_platformQueue commandBuffer];
+        [presentCommandBuffer presentDrawable:static_cast<id<MTLDrawable>>(currentDrawable.get())];
+        [presentCommandBuffer commit];
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String GPUQueue::label() const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpucocoaGPURenderPassEncoderMetalmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -113,6 +113,14 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void useAttachments(GPUCommandBuffer& buffer, GPURenderPassDescriptor&& descriptor)
+{
+    for (auto& colorAttachment : descriptor.colorAttachments)
+        buffer.useTexture(WTFMove(colorAttachment.attachment));
+    if (descriptor.depthStencilAttachment)
+        buffer.useTexture(WTFMove((*descriptor.depthStencilAttachment).attachment));
+}
+
</ins><span class="cx"> RefPtr<GPURenderPassEncoder> GPURenderPassEncoder::tryCreate(Ref<GPUCommandBuffer>&& buffer, GPURenderPassDescriptor&& descriptor)
</span><span class="cx"> {
</span><span class="cx">     const char* const functionName = "GPURenderPassEncoder::tryCreate()";
</span><span class="lines">@@ -157,6 +165,9 @@
</span><span class="cx">         LOG(WebGPU, "%s: Unable to create MTLRenderCommandEncoder!", functionName);
</span><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><ins>+
+    // All is well; ensure GPUCommandBuffer is aware of new attachments.
+    useAttachments(buffer, WTFMove(descriptor));
</ins><span class="cx">     
</span><span class="cx">     return adoptRef(new GPURenderPassEncoder(WTFMove(buffer), WTFMove(mtlEncoder)));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpucocoaGPUSwapChainMetalmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #if ENABLE(WEBGPU)
</span><span class="cx"> 
</span><span class="cx"> #import "GPUDevice.h"
</span><del>-#import "GPUTexture.h"
</del><ins>+#import "GPUSwapChainDescriptor.h"
</ins><span class="cx"> #import "GPUTextureFormat.h"
</span><span class="cx"> #import "GPUUtils.h"
</span><span class="cx"> #import "Logging.h"
</span><span class="lines">@@ -37,100 +37,134 @@
</span><span class="cx"> #import <Metal/Metal.h>
</span><span class="cx"> #import <QuartzCore/QuartzCore.h>
</span><span class="cx"> #import <wtf/BlockObjCExceptions.h>
</span><ins>+#import <wtf/Optional.h>
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-RefPtr<GPUSwapChain> GPUSwapChain::create()
</del><ins>+static Optional<MTLPixelFormat> tryGetSupportedPixelFormat(GPUTextureFormat format)
</ins><span class="cx"> {
</span><del>-    PlatformSwapLayerSmartPtr platformLayer;
</del><ins>+    auto mtlFormat = static_cast<MTLPixelFormat>(platformTextureFormatForGPUTextureFormat(format));
</ins><span class="cx"> 
</span><del>-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
</del><ins>+    switch (mtlFormat) {
+    case MTLPixelFormatBGRA8Unorm:
+    case MTLPixelFormatBGRA8Unorm_sRGB:
+    case MTLPixelFormatRGBA16Float:
+        return mtlFormat;
+    default: {
+        LOG(WebGPU, "GPUSwapChain::tryCreate(): Unsupported MTLPixelFormat!");
+        return WTF::nullopt;
+    }
+    }
+}
</ins><span class="cx"> 
</span><del>-    platformLayer = adoptNS([[WebGPULayer alloc] init]);
</del><ins>+static void setLayerShape(WebGPULayer *layer, int width, int height)
+{
+    [layer setBounds:CGRectMake(0, 0, width, height)];
+    [layer setDrawableSize:CGSizeMake(width, height)];
+}
</ins><span class="cx"> 
</span><del>-    [platformLayer setOpaque:0];
-    [platformLayer setName:@"WebGPU Layer"];
</del><ins>+static RetainPtr<WebGPULayer> tryCreateWebGPULayer(MTLDevice *device, MTLPixelFormat format, OptionSet<GPUTextureUsage::Flags> usage)
+{
</ins><span class="cx"> 
</span><del>-    // FIXME: For now, default to this usage flag.
-    [platformLayer setFramebufferOnly:YES];
</del><ins>+    RetainPtr<WebGPULayer> layer;
</ins><span class="cx"> 
</span><ins>+    BEGIN_BLOCK_OBJC_EXCEPTIONS;
+    layer = adoptNS([WebGPULayer new]);
+
+    [layer setName:@"Web GPU Layer"];
+    [layer setOpaque:0];
+
+    [layer setDevice:device];
+    [layer setFramebufferOnly:(usage == GPUTextureUsage::Flags::OutputAttachment)];
+    [layer setPixelFormat:format];
</ins><span class="cx">     END_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> 
</span><del>-    if (!platformLayer) {
-        LOG(WebGPU, "GPUSwapChain::create(): Unable to create CAMetalLayer!");
-        return nullptr;
-    }
</del><ins>+    if (!layer)
+        LOG(WebGPU, "GPUSwapChain::tryCreate(): Unable to create CAMetalLayer!");
</ins><span class="cx"> 
</span><del>-    return adoptRef(new GPUSwapChain(WTFMove(platformLayer)));
</del><ins>+    return layer;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-GPUSwapChain::GPUSwapChain(PlatformSwapLayerSmartPtr&& platformLayer)
-    : m_platformSwapLayer(WTFMove(platformLayer))
</del><ins>+RefPtr<GPUSwapChain> GPUSwapChain::tryCreate(const GPUDevice& device, const GPUSwapChainDescriptor& descriptor, int width, int height)
</ins><span class="cx"> {
</span><del>-    platformLayer.get().swapChain = this;
-}
-
-void GPUSwapChain::setDevice(const GPUDevice& device)
-{
</del><span class="cx">     if (!device.platformDevice()) {
</span><span class="cx">         LOG(WebGPU, "GPUSwapChain::setDevice(): Invalid GPUDevice!");
</span><del>-        return;
</del><ins>+        return nullptr;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    [m_platformSwapLayer setDevice:device.platformDevice()];
-}
</del><ins>+    auto pixelFormat = tryGetSupportedPixelFormat(descriptor.format);
+    if (!pixelFormat)
+        return nullptr;
</ins><span class="cx"> 
</span><del>-void GPUSwapChain::setFormat(GPUTextureFormat format)
-{
-    auto mtlFormat = static_cast<MTLPixelFormat>(platformTextureFormatForGPUTextureFormat(format));
</del><ins>+    auto usageOptions = OptionSet<GPUTextureUsage::Flags>::fromRaw(descriptor.usage);
+    if (!usageOptions.contains(GPUTextureUsage::Flags::OutputAttachment)) {
+        LOG(WebGPU, "GPUSwapChain::tryCreate(): Swap chain usage must include OUTPUT_ATTACHMENT!");
+        return nullptr;
+    }
</ins><span class="cx"> 
</span><del>-    switch (mtlFormat) {
-    case MTLPixelFormatBGRA8Unorm:
-    // FIXME: Add the other supported swap layer formats as they are added to GPU spec.
-    //  MTLPixelFormatBGRA8Unorm_sRGB, MTLPixelFormatRGBA16Float, MTLPixelFormatBGRA10_XR, and MTLPixelFormatBGRA10_XR_sRGB.
-        [m_platformSwapLayer setPixelFormat:mtlFormat];
-        return;
-    default:
-        LOG(WebGPU, "GPUSwapChain::setFormat(): Unsupported MTLPixelFormat!");
-    }
</del><ins>+    auto layer = tryCreateWebGPULayer(device.platformDevice(), *pixelFormat, usageOptions);
+    if (!layer)
+        return nullptr;
+
+    setLayerShape(layer.get(), width, height);
+
+    return adoptRef(new GPUSwapChain(WTFMove(layer), usageOptions));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void GPUSwapChain::reshape(int width, int height)
</del><ins>+GPUSwapChain::GPUSwapChain(RetainPtr<WebGPULayer>&& platformLayer, OptionSet<GPUTextureUsage::Flags> usageOptions)
+    : m_platformSwapLayer(WTFMove(platformLayer))
+    , m_usage(usageOptions)
</ins><span class="cx"> {
</span><del>-    [m_platformSwapLayer setBounds:CGRectMake(0, 0, width, height)];
-    [m_platformSwapLayer setDrawableSize:CGSizeMake(width, height)];
</del><ins>+    [m_platformSwapLayer setSwapChain:this];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr<GPUTexture> GPUSwapChain::getNextTexture()
</del><ins>+RefPtr<GPUTexture> GPUSwapChain::tryGetCurrentTexture()
</ins><span class="cx"> {
</span><span class="cx">     RetainPtr<MTLTexture> mtlTexture;
</span><span class="cx"> 
</span><span class="cx">     BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span><del>-
-    m_currentDrawable = retainPtr([m_platformSwapLayer nextDrawable]);
</del><ins>+    if (!m_currentDrawable)
+        m_currentDrawable = retainPtr([m_platformSwapLayer nextDrawable]);
</ins><span class="cx">     mtlTexture = [m_currentDrawable texture];
</span><span class="cx"> 
</span><span class="cx">     END_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> 
</span><span class="cx">     if (!mtlTexture) {
</span><del>-        LOG(WebGPU, "GPUSwapChain::getNextTexture(): Unable to get next MTLTexture!");
</del><ins>+        LOG(WebGPU, "GPUSwapChain::getCurrentTexture(): Unable to get current MTLTexture!");
</ins><span class="cx">         return nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return GPUTexture::create(WTFMove(mtlTexture), GPUTextureUsage::Flags::OutputAttachment);
</del><ins>+    return GPUTexture::create(WTFMove(mtlTexture), m_usage);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void GPUSwapChain::present()
</span><span class="cx"> {
</span><ins>+    if (!m_currentDrawable)
+        return;
+
</ins><span class="cx">     [m_currentDrawable present];
</span><span class="cx">     m_currentDrawable = nullptr;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void GPUSwapChain::reshape(int width, int height)
+{
+    setLayerShape(m_platformSwapLayer.get(), width, height);
+}
+
</ins><span class="cx"> PlatformLayer* GPUSwapChain::platformLayer() const
</span><span class="cx"> {
</span><span class="cx">     return m_platformSwapLayer.get();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if USE(METAL)
+RetainPtr<CAMetalDrawable> GPUSwapChain::takeDrawable()
+{
+    RetainPtr<CAMetalDrawable> ptr;
+    ptr.swap(m_currentDrawable);
+    return ptr;
+}
+#endif
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEBGPU)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgpucocoaGPUUtilsMetalmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUUtilsMetal.mm (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUUtilsMetal.mm        2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUUtilsMetal.mm   2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -43,6 +43,10 @@
</span><span class="cx">         return MTLPixelFormatBGRA8Unorm;
</span><span class="cx">     case GPUTextureFormat::D32FloatS8Uint:
</span><span class="cx">         return MTLPixelFormatDepth32Float_Stencil8;
</span><ins>+    case GPUTextureFormat::Bgra8unormSRGB:
+        return MTLPixelFormatBGRA8Unorm_sRGB;
+    case GPUTextureFormat::Rgba16float:
+        return MTLPixelFormatRGBA16Float;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT_NOT_REACHED();
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog    2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebInspectorUI/ChangeLog       2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2019-03-11  Justin Fan  <justin_fan@apple.com>
+
+        [Web GPU] Update GPUSwapChainDescriptor, GPUSwapChain and implement GPUCanvasContext
+        https://bugs.webkit.org/show_bug.cgi?id=194406
+        <rdar://problem/47892466>
+
+        Reviewed by Myles C. Maxfield.
+
+        Name updates for Web GPU renaming in inspector.
+
+        * UserInterface/Models/Canvas.js:
+        (WI.Canvas.displayNameForContextType):
+
</ins><span class="cx"> 2019-03-11  Joseph Pecoraro  <pecoraro@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Editing Timelines shows two CPU Timelines
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsCanvasjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js (242758 => 242759)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js       2019-03-12 00:11:23 UTC (rev 242758)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js  2019-03-12 00:46:41 UTC (rev 242759)
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">         case WI.Canvas.ContextType.WebGL2:
</span><span class="cx">             return WI.unlocalizedString("WebGL2");
</span><span class="cx">         case WI.Canvas.ContextType.WebGPU:
</span><del>-            return WI.unlocalizedString("WebGPU");
</del><ins>+            return WI.unlocalizedString("Web GPU");
</ins><span class="cx">         case WI.Canvas.ContextType.WebMetal:
</span><span class="cx">             return WI.unlocalizedString("WebMetal");
</span><span class="cx">         default:
</span><span class="lines">@@ -412,7 +412,7 @@
</span><span class="cx">     BitmapRenderer: "bitmaprenderer",
</span><span class="cx">     WebGL: "webgl",
</span><span class="cx">     WebGL2: "webgl2",
</span><del>-    WebGPU: "webgpu",
</del><ins>+    WebGPU: "gpu",
</ins><span class="cx">     WebMetal: "webmetal",
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>