Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[WebGPU] Move 'gpu' API entry point from DOMWindow to Navigator
https://bugs.webkit.org/show_bug.cgi?id=197348 Reviewed by Myles C. Maxfield. Source/WebCore: Latest API provides 'gpu' through Navigator instead of DOMWindow. Replace DOMWindowWebGPU with NavigatorGPU. Existing tests updated to match. Add test: webgpu-enabled-in-worker.html to ensure workers can access WebGPU. * CMakeLists.txt: * DerivedSources.make: * Modules/webgpu/NavigatorGPU.cpp: (WebCore::NavigatorGPU::from): (WebCore::NavigatorGPU::supplementName): (WebCore::NavigatorGPU::gpu): (WebCore::NavigatorGPU::gpu const): * Modules/webgpu/NavigatorGPU.h: * Modules/webgpu/NavigatorGPU.idl: * Modules/webgpu/WorkerNavigatorGPU.cpp: (WebCore::WorkerNavigatorGPU::from): (WebCore::WorkerNavigatorGPU::supplementName): (WebCore::WorkerNavigatorGPU::gpu): (WebCore::WorkerNavigatorGPU::gpu const): * Modules/webgpu/WorkerNavigatorGPU.h: * Modules/webgpu/WorkerNavigatorGPU.idl: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: LayoutTests: WebGPU is now accessed through navigator.gpu instead of window.gpu. Add webgpu-enabled-in-worker to ensure workers can access WebGPU. * webgpu/adapter-options.html: * webgpu/js/create-worker-device.js: Added. (async.tryCreateDevice): * webgpu/js/webgpu-functions.js: (async.getBasicDevice): * webgpu/queue-creation.html: * webgpu/webgpu-enabled-in-worker-expected.txt: Added. * webgpu/webgpu-enabled-in-worker.html: Added. * webgpu/webgpu-enabled.html: * webgpu/whlsl.html: Add navigator.gpu to expectations for navigator-detached-no-crash. * fast/dom/navigator-detached-no-crash-expected.txt: * platform/mac-highsierra/fast/dom/navigator-detached-no-crash-expected.txt: * platform/mac-wk2/fast/dom/navigator-detached-no-crash-expected.txt: Canonical link: https://commits.webkit.org/211602@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244777 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Justin Fan
committed
Apr 30, 2019
1 parent
4cd3193
commit 5ef00cf
Showing
23 changed files
with
306 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
async function tryCreateDevice() { | ||
if (!navigator.gpu) | ||
postMessage(false); | ||
|
||
const adapter = await navigator.gpu.requestAdapter(); | ||
await adapter.requestDevice(); | ||
|
||
postMessage(true); | ||
} | ||
|
||
tryCreateDevice(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Test if WebGPU is enabled for workers. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] --> | ||
<html> | ||
<meta charset=utf-8> | ||
<title>Test if WebGPU is enabled for workers.</title> | ||
<script src="../resources/testharness.js"></script> | ||
<script src="../resources/testharnessreport.js"></script> | ||
<script> | ||
if (window.testRunner) | ||
testRunner.waitUntilDone(); | ||
|
||
const worker = new Worker('js/create-worker-device.js'); | ||
|
||
worker.onmessage = event => { | ||
test(() => { assert_true(event.data, "Create GPUDevice with a worker."); }); | ||
|
||
if (window.testRunner) | ||
testRunner.notifyDone(); | ||
}; | ||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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/spec/index.bs | ||
|
||
[ | ||
Conditional=WEBGPU, | ||
EnabledAtRuntime=WebGPU, | ||
Exposed=Window | ||
] partial interface Navigator { | ||
[SameObject] readonly attribute WebGPU gpu; | ||
}; |
Oops, something went wrong.