Unreviewed, rolling out r243419.
authortsavell@apple.com <tsavell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 21:12:25 +0000 (21:12 +0000)
committertsavell@apple.com <tsavell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Mar 2019 21:12:25 +0000 (21:12 +0000)
Caused Mac WK2 testers to crash and become unresponsive.

Reverted changeset:

"[Web GPU] Prototype compute pipeline with MSL"
https://bugs.webkit.org/show_bug.cgi?id=196107
https://trac.webkit.org/changeset/243419

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243457 268f45cc-cd09-0410-ab3c-d52691b4dbfc

55 files changed:
LayoutTests/ChangeLog
LayoutTests/webgpu/compute-squares-expected.txt [deleted file]
LayoutTests/webgpu/compute-squares.html [deleted file]
LayoutTests/webgpu/whlsl.html
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources-input.xcfilelist
Source/WebCore/DerivedSources-output.xcfilelist
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h
Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.cpp
Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.h
Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.idl
Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.cpp [deleted file]
Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.h [deleted file]
Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.idl [deleted file]
Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp [deleted file]
Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h [deleted file]
Source/WebCore/Modules/webgpu/WebGPUComputePipeline.idl [deleted file]
Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.cpp [deleted file]
Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.h [deleted file]
Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.idl [deleted file]
Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
Source/WebCore/Modules/webgpu/WebGPUDevice.h
Source/WebCore/Modules/webgpu/WebGPUDevice.idl
Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.cpp [deleted file]
Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.cpp
Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.h
Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp
Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h
Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp
Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h
Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.cpp
Source/WebCore/Sources.txt
Source/WebCore/SourcesCocoa.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/WebCoreBuiltinNames.h
Source/WebCore/platform/cocoa/VideoFullscreenModel.h
Source/WebCore/platform/graphics/gpu/GPUBindGroup.h
Source/WebCore/platform/graphics/gpu/GPUComputePassEncoder.h [deleted file]
Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h [deleted file]
Source/WebCore/platform/graphics/gpu/GPUComputePipelineDescriptor.h [deleted file]
Source/WebCore/platform/graphics/gpu/GPUDevice.cpp
Source/WebCore/platform/graphics/gpu/GPUDevice.h
Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h
Source/WebCore/platform/graphics/gpu/GPUProgrammablePassEncoder.h
Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h
Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h
Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm
Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm [deleted file]
Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm [deleted file]
Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm
Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm
Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm
Source/WebCore/platform/text/mac/TextEncodingRegistryMac.mm

index fb8c9bd..e318cd7 100644 (file)
@@ -1,5 +1,17 @@
 2019-03-25  Truitt Savell  <tsavell@apple.com>
 
+        Unreviewed, rolling out r243419.
+
+        Caused Mac WK2 testers to crash and become unresponsive.
+
+        Reverted changeset:
+
+        "[Web GPU] Prototype compute pipeline with MSL"
+        https://bugs.webkit.org/show_bug.cgi?id=196107
+        https://trac.webkit.org/changeset/243419
+
+2019-03-25  Truitt Savell  <tsavell@apple.com>
+
         Unreviewed, rolling out r243438.
 
         243319 Caused Mac WK2 testers to crash and become
diff --git a/LayoutTests/webgpu/compute-squares-expected.txt b/LayoutTests/webgpu/compute-squares-expected.txt
deleted file mode 100644 (file)
index 8b13789..0000000
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/LayoutTests/webgpu/compute-squares.html b/LayoutTests/webgpu/compute-squares.html
deleted file mode 100644 (file)
index cb7210b..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGPUEnabled=true ] -->
-<meta charset=utf-8>
-<title>Execute a simple compute shader with Web GPU.</title>
-<body>
-<script src="../resources/testharness.js"></script>
-<script src="../resources/testharnessreport.js"></script>
-<script src="js/webgpu-functions.js"></script>
-<script>
-if (window.testRunner)
-    testRunner.waitUntilDone();
-
-const data = new Uint32Array([2, 3, 4, 5, 6, 7, 8, 9, 10]);
-
-const dataBinding = 0;
-const bindGroupIndex = 0;
-
-const shaderCode = `
-#include <metal_stdlib>
-
-struct Data {
-    device unsigned* numbers [[id(${dataBinding})]];
-};
-
-kernel void compute(device Data& data [[buffer(${bindGroupIndex})]], unsigned gid [[thread_position_in_grid]])
-{
-    if (gid >= ${data.length})
-        return;
-
-    unsigned original = data.numbers[gid];
-    data.numbers[gid] = original * original;
-}
-`
-
-promise_test(async () => {
-    
-    const device = await getBasicDevice();
-    
-    const shaderModule = device.createShaderModule({ code: shaderCode, isWHLSL: false });
-    const computeStageDescriptor = { module: shaderModule, entryPoint: "compute" };
-    const pipeline = device.createComputePipeline({ computeStage: computeStageDescriptor });
-    
-    const dataBuffer = device.createBuffer({ size: data.byteLength, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.TRANSFER_DST | GPUBufferUsage.MAP_READ });
-    dataBuffer.setSubData(0, data.buffer);
-    
-    const bgLayoutBinding = { binding: dataBinding, visibility: GPUShaderStageBit.COMPUTE, type: "storage-buffer" };
-    const bgLayout = device.createBindGroupLayout({ bindings: [bgLayoutBinding] });
-    
-    const bufferBinding = { buffer: dataBuffer, offset: 0, size: data.byteLength };
-    const bgBinding = { binding: dataBinding, resource: bufferBinding };
-    
-    const bindGroupDescriptor = { layout: bgLayout, bindings: [bgBinding] };
-    const bindGroup = device.createBindGroup(bindGroupDescriptor);
-    
-    const commandEncoder = device.createCommandEncoder();
-    const passEncoder = commandEncoder.beginComputePass();
-    
-    passEncoder.setBindGroup(bindGroupIndex, bindGroup);
-    
-    passEncoder.setPipeline(pipeline);
-    
-    passEncoder.dispatch(data.length, 1, 1);
-    passEncoder.endPass();
-    
-    device.getQueue().submit([commandEncoder.finish()]);
-    
-    const readDataArrayBuffer = await dataBuffer.mapReadAsync();
-    assert_not_equals(readDataArrayBuffer, null, "Async read promise resolved successfully");
-    
-    const readData = new Uint32Array(readDataArrayBuffer);
-
-    for (var i = 0; i < readData.length; ++i)
-        assert_equals(readData[i], data[i] * data[i], "Data was succesfully squared");
-
-    if (window.testRunner)
-        testRunner.notifyDone();
-}, "Successfully executed a basic compute pass");
-</script>
-</body>
\ No newline at end of file
index 2b468f4..7ab4776 100644 (file)
@@ -93,7 +93,7 @@ async function start() {
     const swapChainDescriptor = {context, format: "bgra8unorm"};
     const swapChain = device.createSwapChain(swapChainDescriptor);
     const outputTexture = swapChain.getCurrentTexture();
-    const outputTextureView = outputTexture.createDefaultView();
+    const outputTextureView = outputTexture.createDefaultView(); // createDefaultView()
 
     const commandEncoder = device.createCommandEncoder(); // {}
     const red = {r: 0, g: 0, b: 1, a: 1};
index f66d2ae..9be26e3 100644 (file)
@@ -495,9 +495,6 @@ set(WebCore_NON_SVG_IDL_FILES
     Modules/webgpu/WebGPUBufferBinding.idl
     Modules/webgpu/WebGPUCommandBuffer.idl
     Modules/webgpu/WebGPUCommandEncoder.idl
-    Modules/webgpu/WebGPUComputePassEncoder.idl
-    Modules/webgpu/WebGPUComputePipeline.idl
-    Modules/webgpu/WebGPUComputePipelineDescriptor.idl
     Modules/webgpu/WebGPUDevice.idl
     Modules/webgpu/WebGPUPipelineDescriptorBase.idl
     Modules/webgpu/WebGPUPipelineLayout.idl
index 57520f5..a9574f5 100644 (file)
@@ -1,5 +1,17 @@
 2019-03-25  Truitt Savell  <tsavell@apple.com>
 
+        Unreviewed, rolling out r243419.
+
+        Caused Mac WK2 testers to crash and become unresponsive.
+
+        Reverted changeset:
+
+        "[Web GPU] Prototype compute pipeline with MSL"
+        https://bugs.webkit.org/show_bug.cgi?id=196107
+        https://trac.webkit.org/changeset/243419
+
+2019-03-25  Truitt Savell  <tsavell@apple.com>
+
         Unreviewed, rolling out r243438.
 
         243319 Caused Mac WK2 testers to crash and become
index aa25323..6628e46 100644 (file)
@@ -367,9 +367,6 @@ $(PROJECT_DIR)/Modules/webgpu/WebGPUBufferUsage.idl
 $(PROJECT_DIR)/Modules/webgpu/WebGPUColor.idl
 $(PROJECT_DIR)/Modules/webgpu/WebGPUCommandBuffer.idl
 $(PROJECT_DIR)/Modules/webgpu/WebGPUCommandEncoder.idl
-$(PROJECT_DIR)/Modules/webgpu/WebGPUComputePassEncoder.idl
-$(PROJECT_DIR)/Modules/webgpu/WebGPUComputePipeline.idl
-$(PROJECT_DIR)/Modules/webgpu/WebGPUComputePipelineDescriptor.idl
 $(PROJECT_DIR)/Modules/webgpu/WebGPUDevice.idl
 $(PROJECT_DIR)/Modules/webgpu/WebGPUIndexFormat.idl
 $(PROJECT_DIR)/Modules/webgpu/WebGPUInputStateDescriptor.idl
index 1093341..cf758f9 100644 (file)
@@ -1931,12 +1931,6 @@ $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUCommandBuffer.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUCommandBuffer.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUCommandEncoder.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUCommandEncoder.h
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePassEncoder.cpp
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePassEncoder.h
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePipeline.cpp
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePipeline.h
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePipelineDescriptor.cpp
-$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePipelineDescriptor.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUDevice.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUDevice.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUIndexFormat.cpp
index e31aaec..a89ab71 100644 (file)
@@ -407,9 +407,6 @@ JS_BINDING_IDLS = \
        $(WebCore)/Modules/webgpu/WebGPUBufferBinding.idl \
     $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \
     $(WebCore)/Modules/webgpu/WebGPUCommandEncoder.idl \
-    $(WebCore)/Modules/webgpu/WebGPUComputePassEncoder.idl \
-    $(WebCore)/Modules/webgpu/WebGPUComputePipeline.idl \
-    $(WebCore)/Modules/webgpu/WebGPUComputePipelineDescriptor.idl \
     $(WebCore)/Modules/webgpu/WebGPUDevice.idl \
     $(WebCore)/Modules/webgpu/WebGPUQueue.idl \
     $(WebCore)/Modules/webgpu/WebGPUPipelineDescriptorBase.idl \
index 8fb4a34..08f0f65 100644 (file)
@@ -29,7 +29,6 @@
 
 #include "WHLSLNameContext.h"
 #include "WHLSLVisitor.h"
-#include <wtf/HashSet.h>
 
 namespace WebCore {
 
index 4b6ca92..0c165a3 100644 (file)
 
 #if ENABLE(WEBGPU)
 
-#include "GPUComputePassEncoder.h"
 #include "GPURenderPassDescriptor.h"
 #include "GPURenderPassEncoder.h"
 #include "WebGPUBuffer.h"
-#include "WebGPUComputePassEncoder.h"
 #include "WebGPURenderPassDescriptor.h"
 #include "WebGPURenderPassEncoder.h"
 #include "WebGPUTexture.h"
@@ -78,24 +76,14 @@ Ref<WebGPURenderPassEncoder> WebGPUCommandEncoder::beginRenderPass(WebGPURenderP
 {
     if (!m_commandBuffer) {
         LOG(WebGPU, "WebGPUCommandEncoder::beginRenderPass(): Invalid operation!");
-        return WebGPURenderPassEncoder::create(nullptr);
+        return WebGPURenderPassEncoder::create(*this, nullptr);
     }
     auto gpuDescriptor = descriptor.tryCreateGPURenderPassDescriptor();
     if (!gpuDescriptor)
-        return WebGPURenderPassEncoder::create(nullptr);
+        return WebGPURenderPassEncoder::create(*this, nullptr);
 
     auto encoder = GPURenderPassEncoder::tryCreate(makeRef(*m_commandBuffer), WTFMove(*gpuDescriptor));
-    return WebGPURenderPassEncoder::create(WTFMove(encoder));
-}
-
-Ref<WebGPUComputePassEncoder> WebGPUCommandEncoder::beginComputePass()
-{
-    if (!m_commandBuffer) {
-        LOG(WebGPU, "WebGPUCommandEncoder::beginComputePass(): Invalid operation!");
-        return WebGPUComputePassEncoder::create(nullptr);
-    }
-    auto encoder = GPUComputePassEncoder::tryCreate(makeRef(*m_commandBuffer));
-    return WebGPUComputePassEncoder::create(WTFMove(encoder));
+    return WebGPURenderPassEncoder::create(*this, WTFMove(encoder));
 }
 
 void WebGPUCommandEncoder::copyBufferToBuffer(const WebGPUBuffer& src, unsigned long srcOffset, const WebGPUBuffer& dst, unsigned long dstOffset, unsigned long size)
index a3a0286..24d71ba 100644 (file)
@@ -35,7 +35,6 @@
 namespace WebCore {
 
 class WebGPUBuffer;
-class WebGPUComputePassEncoder;
 class WebGPURenderPassEncoder;
 class WebGPUTexture;
 
@@ -59,7 +58,6 @@ public:
     static Ref<WebGPUCommandEncoder> create(RefPtr<GPUCommandBuffer>&&);
 
     Ref<WebGPURenderPassEncoder> beginRenderPass(WebGPURenderPassDescriptor&&);
-    Ref<WebGPUComputePassEncoder> beginComputePass();
     void copyBufferToBuffer(const WebGPUBuffer&, unsigned long srcOffset, const WebGPUBuffer&, unsigned long dstOffset, unsigned long size);
     void copyBufferToTexture(const WebGPUBufferCopyView&, const WebGPUTextureCopyView&, const GPUExtent3D&);
     void copyTextureToBuffer(const WebGPUTextureCopyView&, const WebGPUBufferCopyView&, const GPUExtent3D&);
index bac43f6..bb96b4a 100644 (file)
@@ -56,7 +56,6 @@ typedef unsigned long long u64;
     InterfaceName=GPUCommandEncoder
 ] interface WebGPUCommandEncoder {
     WebGPURenderPassEncoder beginRenderPass(WebGPURenderPassDescriptor descriptor);
-    WebGPUComputePassEncoder beginComputePass();
 
     void copyBufferToBuffer(
         WebGPUBuffer src,
@@ -81,4 +80,7 @@ typedef unsigned long long u64;
         GPUExtent3D copySize);
 
     WebGPUCommandBuffer finish();
+
+    // Not Yet Implemented
+    // WebGPUComputePassEncoder beginComputePass();
 };
diff --git a/Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.cpp b/Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.cpp
deleted file mode 100644 (file)
index 770d1a1..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.
- */
-
-#include "config.h"
-#include "WebGPUComputePassEncoder.h"
-
-#if ENABLE(WEBGPU)
-
-#include "GPUComputePassEncoder.h"
-#include "GPUProgrammablePassEncoder.h"
-#include "WebGPUComputePipeline.h"
-
-namespace WebCore {
-
-Ref<WebGPUComputePassEncoder> WebGPUComputePassEncoder::create(RefPtr<GPUComputePassEncoder>&& encoder)
-{
-    return adoptRef(*new WebGPUComputePassEncoder(WTFMove(encoder)));
-}
-
-WebGPUComputePassEncoder::WebGPUComputePassEncoder(RefPtr<GPUComputePassEncoder>&& encoder)
-    : m_passEncoder { WTFMove(encoder) }
-{
-}
-
-void WebGPUComputePassEncoder::setPipeline(const WebGPUComputePipeline& pipeline)
-{
-    if (!m_passEncoder) {
-        LOG(WebGPU, "GPUComputePassEncoder::setPipeline(): Invalid operation!");
-        return;
-    }
-    if (!pipeline.computePipeline()) {
-        LOG(WebGPU, "GPUComputePassEncoder::setPipeline(): Invalid pipeline!");
-        return;
-    }
-    m_passEncoder->setPipeline(makeRef(*pipeline.computePipeline()));
-}
-
-void WebGPUComputePassEncoder::dispatch(unsigned x, unsigned y, unsigned z)
-{
-    if (!m_passEncoder) {
-        LOG(WebGPU, "GPUComputePassEncoder::dispatch(): Invalid operation!");
-        return;
-    }
-
-    // FIXME: Add Web GPU validation.
-    m_passEncoder->dispatch(x, y, z);
-}
-
-GPUProgrammablePassEncoder* WebGPUComputePassEncoder::passEncoder()
-{
-    return m_passEncoder.get();
-}
-
-const GPUProgrammablePassEncoder* WebGPUComputePassEncoder::passEncoder() const
-{
-    return m_passEncoder.get();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.h b/Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.h
deleted file mode 100644 (file)
index 0aedc12..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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 "WebGPUProgrammablePassEncoder.h"
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class GPUComputePassEncoder;
-class GPUProgrammablePassEncoder;
-class WebGPUComputePipeline;
-
-class WebGPUComputePassEncoder : public WebGPUProgrammablePassEncoder {
-public:
-    static Ref<WebGPUComputePassEncoder> create(RefPtr<GPUComputePassEncoder>&&);
-
-    void setPipeline(const WebGPUComputePipeline&);
-    void dispatch(unsigned x, unsigned y, unsigned z);
-
-private:
-    WebGPUComputePassEncoder(RefPtr<GPUComputePassEncoder>&&);
-
-    GPUProgrammablePassEncoder* passEncoder() final;
-    const GPUProgrammablePassEncoder* passEncoder() const final;
-
-    RefPtr<GPUComputePassEncoder> m_passEncoder;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.idl b/Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.idl
deleted file mode 100644 (file)
index 8376341..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.
- */
-// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
-
-typedef unsigned long u32;
-
-[
-    Conditional=WEBGPU,
-    EnabledAtRuntime=WebGPU,
-    InterfaceName=GPUComputePassEncoder,
-    JSGenerateToJSObject
-] interface WebGPUComputePassEncoder : WebGPUProgrammablePassEncoder {
-    void setPipeline(WebGPUComputePipeline pipeline);
-    void dispatch(u32 x, u32 y, u32 z);
-
-    // TODO add missing commands
-};
diff --git a/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp b/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp
deleted file mode 100644 (file)
index 13c2448..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.
- */
-
-#include "config.h"
-#include "WebGPUComputePipeline.h"
-
-#if ENABLE(WEBGPU)
-
-namespace WebCore {
-
-Ref<WebGPUComputePipeline> WebGPUComputePipeline::create(RefPtr<GPUComputePipeline>&& pipeline)
-{
-    return adoptRef(*new WebGPUComputePipeline(WTFMove(pipeline)));
-}
-
-WebGPUComputePipeline::WebGPUComputePipeline(RefPtr<GPUComputePipeline>&& pipeline)
-    : m_computePipeline { WTFMove(pipeline) }
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h b/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h
deleted file mode 100644 (file)
index 9a758c0..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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 "GPUComputePipeline.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-
-class WebGPUComputePipeline : public RefCounted<WebGPUComputePipeline> {
-public:
-    static Ref<WebGPUComputePipeline> create(RefPtr<GPUComputePipeline>&&);
-
-    const GPUComputePipeline* computePipeline() const { return m_computePipeline.get(); }
-
-private:
-    WebGPUComputePipeline(RefPtr<GPUComputePipeline>&&);
-
-    RefPtr<GPUComputePipeline> m_computePipeline;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.idl b/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.idl
deleted file mode 100644 (file)
index 1d12b48..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.
- */
-// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
-
-[
-    Conditional=WEBGPU,
-    EnabledAtRuntime=WebGPU,
-    ImplementationLacksVTable,
-    InterfaceName=GPUComputePipeline
-] interface WebGPUComputePipeline {
-};
diff --git a/Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.cpp b/Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.cpp
deleted file mode 100644 (file)
index de204bb..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.
- */
-
-#include "config.h"
-#include "WebGPUComputePipelineDescriptor.h"
-
-#if ENABLE(WEBGPU)
-
-#include "GPUComputePipelineDescriptor.h"
-#include "Logging.h"
-
-namespace WebCore {
-
-Optional<GPUComputePipelineDescriptor> WebGPUComputePipelineDescriptor::tryCreateGPUComputePipelineDescriptor() const
-{
-    auto pipelineLayout = layout ? makeRefPtr(layout->pipelineLayout()) : nullptr;
-
-    auto compute = computeStage.tryCreateGPUPipelineStageDescriptor();
-    if (!compute) {
-        LOG(WebGPU, "GPUDevice::createComputePipeline(): Invalid GPUPipelineStageDescriptor!");
-        return WTF::nullopt;
-    }
-
-    return GPUComputePipelineDescriptor { WTFMove(pipelineLayout), WTFMove(*compute) };
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.h b/Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.h
deleted file mode 100644 (file)
index a453902..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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 "WebGPUPipelineDescriptorBase.h"
-#include "WebGPUPipelineStageDescriptor.h"
-#include <wtf/Optional.h>
-
-namespace WebCore {
-
-struct GPUComputePipelineDescriptor;
-
-struct WebGPUComputePipelineDescriptor : WebGPUPipelineDescriptorBase {
-    Optional<GPUComputePipelineDescriptor> tryCreateGPUComputePipelineDescriptor() const;
-
-    WebGPUPipelineStageDescriptor computeStage;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.idl b/Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.idl
deleted file mode 100644 (file)
index d5d2083..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-// https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl
-
-[
-    Conditional=WEBGPU,
-    EnabledAtRuntime=WebGPU
-] dictionary WebGPUComputePipelineDescriptor : WebGPUPipelineDescriptorBase {
-    required WebGPUPipelineStageDescriptor computeStage;
-};
index b2b72e1..b9b5665 100644 (file)
@@ -49,8 +49,6 @@
 #include "WebGPUBuffer.h"
 #include "WebGPUBufferBinding.h"
 #include "WebGPUCommandEncoder.h"
-#include "WebGPUComputePipeline.h"
-#include "WebGPUComputePipelineDescriptor.h"
 #include "WebGPUPipelineLayout.h"
 #include "WebGPUPipelineLayoutDescriptor.h"
 #include "WebGPUPipelineStageDescriptor.h"
@@ -139,16 +137,6 @@ Ref<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(const WebGPURenderP
     return WebGPURenderPipeline::create(WTFMove(pipeline));
 }
 
-Ref<WebGPUComputePipeline> WebGPUDevice::createComputePipeline(const WebGPUComputePipelineDescriptor& descriptor) const
-{
-    auto gpuDescriptor = descriptor.tryCreateGPUComputePipelineDescriptor();
-    if (!gpuDescriptor)
-        return WebGPUComputePipeline::create(nullptr);
-
-    auto pipeline = m_device->tryCreateComputePipeline(*gpuDescriptor);
-    return WebGPUComputePipeline::create(WTFMove(pipeline));
-}
-
 Ref<WebGPUCommandEncoder> WebGPUDevice::createCommandEncoder() const
 {
     auto commandBuffer = m_device->tryCreateCommandBuffer();
index 1441f38..7e2689d 100644 (file)
@@ -42,7 +42,6 @@ class WebGPUBindGroup;
 class WebGPUBindGroupLayout;
 class WebGPUBuffer;
 class WebGPUCommandEncoder;
-class WebGPUComputePipeline;
 class WebGPUPipelineLayout;
 class WebGPURenderPipeline;
 class WebGPUSampler;
@@ -55,7 +54,6 @@ struct GPUBufferDescriptor;
 struct GPUSamplerDescriptor;
 struct GPUTextureDescriptor;
 struct WebGPUBindGroupDescriptor;
-struct WebGPUComputePipelineDescriptor;
 struct WebGPUPipelineLayoutDescriptor;
 struct WebGPURenderPipelineDescriptor;
 struct WebGPUShaderModuleDescriptor;
@@ -77,7 +75,6 @@ public:
 
     RefPtr<WebGPUShaderModule> createShaderModule(WebGPUShaderModuleDescriptor&&) const;
     Ref<WebGPURenderPipeline> createRenderPipeline(const WebGPURenderPipelineDescriptor&) const;
-    Ref<WebGPUComputePipeline> createComputePipeline(const WebGPUComputePipelineDescriptor&) const;
 
     Ref<WebGPUCommandEncoder> createCommandEncoder() const;
 
index 8f681af..4abaa18 100644 (file)
@@ -53,7 +53,6 @@ typedef unsigned long GPUTextureUsageFlags;
 
     WebGPUShaderModule createShaderModule(WebGPUShaderModuleDescriptor descriptor);
     WebGPURenderPipeline createRenderPipeline(WebGPURenderPipelineDescriptor descriptor);
-    WebGPUComputePipeline createComputePipeline(WebGPUComputePipelineDescriptor descriptor);
 
     // FIXME: Currently, GPUCommandEncoderDescriptor is an empty dictionary.
     WebGPUCommandEncoder createCommandEncoder(/*GPUCommandEncoderDescriptor descriptor*/);
@@ -66,6 +65,7 @@ typedef unsigned long GPUTextureUsageFlags;
     // readonly attribute WebGPUExtensions extensions;
     // readonly attribute WebGPULimits limits;
 
+    // WebGPUComputePipeline createComputePipeline(WebGPUComputePipelineDescriptor descriptor);
     // WebGPUFence createFence(WebGPUFenceDescriptor descriptor);
 
     // attribute WebGPULogCallback onLog;
diff --git a/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.cpp b/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.cpp
deleted file mode 100644 (file)
index 2d62dea..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.
- */
-
-#include "config.h"
-#include "WebGPUPipelineStageDescriptor.h"
-
-#if ENABLE(WEBGPU)
-
-namespace WebCore {
-
-Optional<GPUPipelineStageDescriptor> WebGPUPipelineStageDescriptor::tryCreateGPUPipelineStageDescriptor() const
-{
-    if (!module || !module->module() || entryPoint.isEmpty())
-        return WTF::nullopt;
-
-    return GPUPipelineStageDescriptor { makeRef(*module->module()), *this };
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
index d343ca7..53f0d64 100644 (file)
 #include "GPUProgrammablePassEncoder.h"
 #include "Logging.h"
 #include "WebGPUBindGroup.h"
+#include "WebGPURenderPipeline.h"
 
 namespace WebCore {
 
+WebGPUProgrammablePassEncoder::WebGPUProgrammablePassEncoder(Ref<WebGPUCommandEncoder>&& creator)
+    : m_commandBuffer(WTFMove(creator))
+{
+}
+
 void WebGPUProgrammablePassEncoder::endPass()
 {
     if (!passEncoder()) {
@@ -43,7 +49,7 @@ void WebGPUProgrammablePassEncoder::endPass()
     passEncoder()->endPass();
 }
 
-void WebGPUProgrammablePassEncoder::setBindGroup(unsigned index, WebGPUBindGroup& bindGroup)
+void WebGPUProgrammablePassEncoder::setBindGroup(unsigned index, WebGPUBindGroup& bindGroup) const
 {
     if (!passEncoder()) {
         LOG(WebGPU, "GPUProgrammablePassEncoder::setBindGroup(): Invalid operation!");
index 965f50a..7beb804 100644 (file)
 
 #if ENABLE(WEBGPU)
 
+#include "WebGPUCommandEncoder.h"
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
 
 class GPUProgrammablePassEncoder;
 class WebGPUBindGroup;
+class WebGPURenderPipeline;
 
 class WebGPUProgrammablePassEncoder : public RefCounted<WebGPUProgrammablePassEncoder> {
 public:
     virtual ~WebGPUProgrammablePassEncoder() = default;
 
     void endPass();
-    void setBindGroup(unsigned, WebGPUBindGroup&);
+    void setBindGroup(unsigned, WebGPUBindGroup&) const;
 
 protected:
-    WebGPUProgrammablePassEncoder() = default;
+    WebGPUProgrammablePassEncoder(Ref<WebGPUCommandEncoder>&&);
 
-    virtual GPUProgrammablePassEncoder* passEncoder() = 0;
-    virtual const GPUProgrammablePassEncoder* passEncoder() const = 0;
+    virtual GPUProgrammablePassEncoder* passEncoder() const = 0;
+
+private:
+    Ref<WebGPUCommandEncoder> m_commandBuffer;
 };
 
 } // namespace WebCore
index 43a16d2..b001480 100644 (file)
 #include "GPURenderPassEncoder.h"
 #include "Logging.h"
 #include "WebGPUBuffer.h"
-#include "WebGPURenderPipeline.h"
 
 namespace WebCore {
 
-Ref<WebGPURenderPassEncoder> WebGPURenderPassEncoder::create(RefPtr<GPURenderPassEncoder>&& encoder)
+Ref<WebGPURenderPassEncoder> WebGPURenderPassEncoder::create(Ref<WebGPUCommandEncoder>&& commandBuffer, RefPtr<GPURenderPassEncoder>&& encoder)
 {
-    return adoptRef(*new WebGPURenderPassEncoder(WTFMove(encoder)));
+    return adoptRef(*new WebGPURenderPassEncoder(WTFMove(commandBuffer), WTFMove(encoder)));
 }
 
-WebGPURenderPassEncoder::WebGPURenderPassEncoder(RefPtr<GPURenderPassEncoder>&& encoder)
-    : m_passEncoder { WTFMove(encoder) }
+WebGPURenderPassEncoder::WebGPURenderPassEncoder(Ref<WebGPUCommandEncoder>&& creator, RefPtr<GPURenderPassEncoder>&& encoder)
+    : WebGPUProgrammablePassEncoder(WTFMove(creator))
+    , m_passEncoder(WTFMove(encoder))
 {
 }
 
 void WebGPURenderPassEncoder::setPipeline(const WebGPURenderPipeline& pipeline)
 {
     if (!m_passEncoder) {
-        LOG(WebGPU, "GPURenderPassEncoder::setPipeline(): Invalid operation!");
+        LOG(WebGPU, "GPUProgrammablePassEncoder::setPipeline(): Invalid operation!");
         return;
     }
     if (!pipeline.renderPipeline()) {
-        LOG(WebGPU, "GPURenderPassEncoder::setPipeline(): Invalid pipeline!");
+        LOG(WebGPU, "GPUProgrammablePassEncoder::setPipeline(): Invalid pipeline!");
         return;
     }
     m_passEncoder->setPipeline(makeRef(*pipeline.renderPipeline()));
@@ -108,12 +108,7 @@ void WebGPURenderPassEncoder::draw(unsigned long vertexCount, unsigned long inst
     m_passEncoder->draw(vertexCount, instanceCount, firstVertex, firstInstance);
 }
 
-GPUProgrammablePassEncoder* WebGPURenderPassEncoder::passEncoder()
-{
-    return m_passEncoder.get();
-}
-
-const GPUProgrammablePassEncoder* WebGPURenderPassEncoder::passEncoder() const
+GPUProgrammablePassEncoder* WebGPURenderPassEncoder::passEncoder() const
 {
     return m_passEncoder.get();
 }
index 1fcfe49..568b2f3 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(WEBGPU)
 
 #include "WebGPUProgrammablePassEncoder.h"
+
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
@@ -36,21 +37,19 @@ namespace WebCore {
 class GPUProgrammablePassEncoder;
 class GPURenderPassEncoder;
 class WebGPUBuffer;
-class WebGPURenderPipeline;
 
 class WebGPURenderPassEncoder final : public WebGPUProgrammablePassEncoder {
 public:
-    static Ref<WebGPURenderPassEncoder> create(RefPtr<GPURenderPassEncoder>&&);
+    static Ref<WebGPURenderPassEncoder> create(Ref<WebGPUCommandEncoder>&&, RefPtr<GPURenderPassEncoder>&&);
 
     void setPipeline(const WebGPURenderPipeline&);
     void setVertexBuffers(unsigned long, Vector<RefPtr<WebGPUBuffer>>&&, Vector<unsigned long long>&&);
     void draw(unsigned long vertexCount, unsigned long instanceCount, unsigned long firstVertex, unsigned long firstInstance);
 
 private:
-    WebGPURenderPassEncoder(RefPtr<GPURenderPassEncoder>&&);
+    WebGPURenderPassEncoder(Ref<WebGPUCommandEncoder>&&, RefPtr<GPURenderPassEncoder>&&);
 
-    GPUProgrammablePassEncoder* passEncoder() final;
-    const GPUProgrammablePassEncoder* passEncoder() const final;
+    GPUProgrammablePassEncoder* passEncoder() const final;
 
     RefPtr<GPURenderPassEncoder> m_passEncoder;
 };
index 1dc4ddf..6069035 100644 (file)
@@ -28,6 +28,8 @@
 
 #if ENABLE(WEBGPU)
 
+#include "GPURenderPipeline.h"
+
 namespace WebCore {
 
 Ref<WebGPURenderPipeline> WebGPURenderPipeline::create(RefPtr<GPURenderPipeline>&& pipeline)
index f39cfed..7e87504 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(WEBGPU)
 
 #include "GPURenderPipeline.h"
+
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
index ee41fbb..9e0068c 100644 (file)
 
 #if ENABLE(WEBGPU)
 
-#include "Logging.h"
-
 namespace WebCore {
 
+Optional<GPUPipelineStageDescriptor> WebGPUPipelineStageDescriptor::tryCreateGPUPipelineStageDescriptor() const
+{
+    if (!module || !module->module() || entryPoint.isEmpty())
+        return WTF::nullopt;
+
+    return GPUPipelineStageDescriptor { makeRef(*module->module()), *this };
+}
+
 Optional<GPURenderPipelineDescriptor> WebGPURenderPipelineDescriptor::tryCreateGPURenderPipelineDescriptor() const
 {
     auto pipelineLayout = layout ? makeRefPtr(layout->pipelineLayout()) : nullptr;
index 5cde78b..f0c31ac 100644 (file)
@@ -348,20 +348,16 @@ Modules/webgpu/WHLSL/AST/WHLSLIntegerLiteral.cpp
 Modules/webgpu/WHLSL/AST/WHLSLUnsignedIntegerLiteral.cpp
 Modules/webgpu/WHLSL/WHLSLPrepare.cpp
 Modules/webgpu/WebGPU.cpp
-Modules/webgpu/WebGPUAdapter.cpp
 Modules/webgpu/WebGPUBindGroup.cpp
 Modules/webgpu/WebGPUBindGroupDescriptor.cpp
-Modules/webgpu/WebGPUBindGroupLayout.cpp
-Modules/webgpu/WebGPUBuffer.cpp
 Modules/webgpu/WebGPUCommandBuffer.cpp
 Modules/webgpu/WebGPUCommandEncoder.cpp
-Modules/webgpu/WebGPUComputePassEncoder.cpp
-Modules/webgpu/WebGPUComputePipeline.cpp
-Modules/webgpu/WebGPUComputePipelineDescriptor.cpp
+Modules/webgpu/WebGPUAdapter.cpp
+Modules/webgpu/WebGPUBindGroupLayout.cpp
+Modules/webgpu/WebGPUBuffer.cpp
 Modules/webgpu/WebGPUDevice.cpp
 Modules/webgpu/WebGPUQueue.cpp
 Modules/webgpu/WebGPUPipelineLayout.cpp
-Modules/webgpu/WebGPUPipelineStageDescriptor.cpp
 Modules/webgpu/WebGPUProgrammablePassEncoder.cpp
 Modules/webgpu/WebGPURenderPassDescriptor.cpp
 Modules/webgpu/WebGPURenderPassEncoder.cpp
@@ -3336,9 +3332,6 @@ JSWebGPUBuffer.cpp
 JSWebGPUBufferBinding.cpp
 JSWebGPUCommandBuffer.cpp
 JSWebGPUCommandEncoder.cpp
-JSWebGPUComputePassEncoder.cpp
-JSWebGPUComputePipeline.cpp
-JSWebGPUComputePipelineDescriptor.cpp
 JSWebGPUDevice.cpp
 JSWebGPUQueue.cpp
 JSWebGPUPipelineDescriptorBase.cpp
index de74edc..d8aa822 100644 (file)
@@ -322,8 +322,6 @@ platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm
 platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm
 platform/graphics/gpu/cocoa/GPUBufferMetal.mm
 platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm
-platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm
-platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm
 platform/graphics/gpu/cocoa/GPUDeviceMetal.mm
 platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm
 platform/graphics/gpu/cocoa/GPUQueueMetal.mm
index 4c26c72..3d44885 100644 (file)
                D003288621C9A4E500622AA6 /* GPUPipelineLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUPipelineLayout.h; sourceTree = "<group>"; };
                D003288721C9A4E500622AA6 /* GPUPipelineLayout.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUPipelineLayout.cpp; sourceTree = "<group>"; };
                D003914122248D400098998C /* GPUProgrammablePassEncoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUProgrammablePassEncoder.cpp; sourceTree = "<group>"; };
-               D00D77FD2242ED450043F12C /* WebGPUComputePassEncoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUComputePassEncoder.h; sourceTree = "<group>"; };
-               D00D77FE2242ED450043F12C /* WebGPUComputePassEncoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUComputePassEncoder.cpp; sourceTree = "<group>"; };
-               D00D77FF2242ED450043F12C /* WebGPUComputePassEncoder.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUComputePassEncoder.idl; sourceTree = "<group>"; };
                D00F5940216ECC7A000D71DB /* DOMWindowWebGPU.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMWindowWebGPU.h; sourceTree = "<group>"; };
                D00F5941216ECC7A000D71DB /* DOMWindowWebGPU.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowWebGPU.cpp; sourceTree = "<group>"; };
                D00F5942216ECC7A000D71DB /* DOMWindowWebGPU.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMWindowWebGPU.idl; sourceTree = "<group>"; };
                D087CE3E21ACA94200BDE174 /* GPUSwapChainMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUSwapChainMetal.mm; sourceTree = "<group>"; };
                D087CE3F21ACA94200BDE174 /* GPUTextureMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUTextureMetal.mm; sourceTree = "<group>"; };
                D087CE4021ACA94200BDE174 /* GPUShaderModuleMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUShaderModuleMetal.mm; sourceTree = "<group>"; };
-               D08903342240601D00F3F440 /* WebGPUComputePipelineDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUComputePipelineDescriptor.h; sourceTree = "<group>"; };
-               D08903352240601D00F3F440 /* WebGPUComputePipelineDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUComputePipelineDescriptor.idl; sourceTree = "<group>"; };
-               D0890337224061AC00F3F440 /* WebGPUPipelineStageDescriptor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUPipelineStageDescriptor.cpp; sourceTree = "<group>"; };
-               D08903382240628900F3F440 /* WebGPUComputePipelineDescriptor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUComputePipelineDescriptor.cpp; sourceTree = "<group>"; };
-               D08903392240642D00F3F440 /* GPUComputePipelineDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUComputePipelineDescriptor.h; sourceTree = "<group>"; };
-               D089033A224179B500F3F440 /* GPUComputePipeline.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUComputePipeline.h; sourceTree = "<group>"; };
-               D089033B224179B500F3F440 /* GPUComputePipelineMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUComputePipelineMetal.mm; sourceTree = "<group>"; };
-               D089033C2241A99F00F3F440 /* WebGPUComputePipeline.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUComputePipeline.h; sourceTree = "<group>"; };
-               D089033D2241A99F00F3F440 /* WebGPUComputePipeline.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUComputePipeline.cpp; sourceTree = "<group>"; };
-               D089033E2241A99F00F3F440 /* WebGPUComputePipeline.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUComputePipeline.idl; sourceTree = "<group>"; };
-               D089033F2241CE4600F3F440 /* GPUComputePassEncoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUComputePassEncoder.h; sourceTree = "<group>"; };
-               D08903402241CE4600F3F440 /* GPUComputePassEncoderMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUComputePassEncoderMetal.mm; sourceTree = "<group>"; };
                D08AA02D220D0B9C0058C502 /* GPULoadOp.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPULoadOp.idl; sourceTree = "<group>"; };
                D08AA02F220D0BD50058C502 /* GPULoadOp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPULoadOp.h; sourceTree = "<group>"; };
                D08AA031220D0CE60058C502 /* GPUStoreOp.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUStoreOp.idl; sourceTree = "<group>"; };
                                D0ADB28B2237842E00A22935 /* GPUColorStateDescriptor.h */,
                                312FF8BD21A4C2F100EB199D /* GPUCommandBuffer.h */,
                                D03C849C21FFC7FC0002227F /* GPUCompareFunction.h */,
-                               D089033F2241CE4600F3F440 /* GPUComputePassEncoder.h */,
-                               D089033A224179B500F3F440 /* GPUComputePipeline.h */,
-                               D08903392240642D00F3F440 /* GPUComputePipelineDescriptor.h */,
                                D03C849A21FFC6670002227F /* GPUDepthStencilStateDescriptor.h */,
                                312FF8BF21A4C2F100EB199D /* GPUDevice.cpp */,
                                312FF8BE21A4C2F100EB199D /* GPUDevice.h */,
                                D0EACF7721937228000FA75C /* WebGPUCommandEncoder.cpp */,
                                D0EACF7621937228000FA75C /* WebGPUCommandEncoder.h */,
                                D0EACF7821937228000FA75C /* WebGPUCommandEncoder.idl */,
-                               D00D77FE2242ED450043F12C /* WebGPUComputePassEncoder.cpp */,
-                               D00D77FD2242ED450043F12C /* WebGPUComputePassEncoder.h */,
-                               D00D77FF2242ED450043F12C /* WebGPUComputePassEncoder.idl */,
-                               D089033D2241A99F00F3F440 /* WebGPUComputePipeline.cpp */,
-                               D089033C2241A99F00F3F440 /* WebGPUComputePipeline.h */,
-                               D089033E2241A99F00F3F440 /* WebGPUComputePipeline.idl */,
-                               D08903382240628900F3F440 /* WebGPUComputePipelineDescriptor.cpp */,
-                               D08903342240601D00F3F440 /* WebGPUComputePipelineDescriptor.h */,
-                               D08903352240601D00F3F440 /* WebGPUComputePipelineDescriptor.idl */,
                                D00F595321701D8C000D71DB /* WebGPUDevice.cpp */,
                                D00F595221701D8C000D71DB /* WebGPUDevice.h */,
                                D00F595421701D8C000D71DB /* WebGPUDevice.idl */,
                                D05A99E621C9BF2C00032B75 /* WebGPUPipelineLayout.idl */,
                                D05A99E121C9B50F00032B75 /* WebGPUPipelineLayoutDescriptor.h */,
                                D05A99E221C9B50F00032B75 /* WebGPUPipelineLayoutDescriptor.idl */,
-                               D0890337224061AC00F3F440 /* WebGPUPipelineStageDescriptor.cpp */,
                                D0C419EB2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.h */,
                                D0C419EC2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.idl */,
                                D0EACF9221940A5B000FA75C /* WebGPUProgrammablePassEncoder.cpp */,
                                D085E64A2236DEAE00C3E1E2 /* GPUBindGroupMetal.mm */,
                                D0D8649121B760C4003C983C /* GPUBufferMetal.mm */,
                                D087CE3821ACA94200BDE174 /* GPUCommandBufferMetal.mm */,
-                               D08903402241CE4600F3F440 /* GPUComputePassEncoderMetal.mm */,
-                               D089033B224179B500F3F440 /* GPUComputePipelineMetal.mm */,
                                D087CE3C21ACA94200BDE174 /* GPUDeviceMetal.mm */,
                                D087CE3B21ACA94200BDE174 /* GPUProgrammablePassEncoderMetal.mm */,
                                D087CE3921ACA94200BDE174 /* GPUQueueMetal.mm */,
index 35d5784..c349593 100644 (file)
@@ -86,8 +86,6 @@ namespace WebCore {
     macro(GPUShaderModule) \
     macro(GPUCommandBuffer) \
     macro(GPUCommandEncoder) \
-    macro(GPUComputePassEncoder) \
-    macro(GPUComputePipeline) \
     macro(GPUShaderStageBit) \
     macro(GPUSwapChain) \
     macro(GPUTextureUsage) \
index 7b2bfa6..f5829c2 100644 (file)
@@ -34,7 +34,6 @@
 #include "MediaPlayerEnums.h"
 #include "PlaybackSessionModel.h"
 #include <wtf/CompletionHandler.h>
-#include <wtf/WeakPtr.h>
 
 #if PLATFORM(IOS_FAMILY)
 OBJC_CLASS AVPlayerViewController;
index f29f00e..4600cc7 100644 (file)
 
 #if ENABLE(WEBGPU)
 
-#include "GPUBuffer.h"
-#include "GPUTexture.h"
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
+#include "GPUBuffer.h"
+#include "GPUTexture.h"
 
 OBJC_PROTOCOL(MTLBuffer);
 
@@ -45,20 +45,18 @@ public:
     static RefPtr<GPUBindGroup> tryCreate(const GPUBindGroupDescriptor&);
     
 #if USE(METAL)
-    const MTLBuffer *vertexArgsBuffer() const { return m_vertexArgsBuffer.get(); }
-    const MTLBuffer *fragmentArgsBuffer() const { return m_fragmentArgsBuffer.get(); }
-    const MTLBuffer *computeArgsBuffer() const { return m_computeArgsBuffer.get(); }
+    MTLBuffer *vertexArgsBuffer() { return m_vertexArgsBuffer.get(); }
+    MTLBuffer *fragmentArgsBuffer() { return m_fragmentArgsBuffer.get(); }
 #endif
     const Vector<Ref<GPUBuffer>>& boundBuffers() const { return m_boundBuffers; }
     const Vector<Ref<GPUTexture>>& boundTextures() const { return m_boundTextures; }
 
 private:
 #if USE(METAL)
-    GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, RetainPtr<MTLBuffer>&& computeArgsBuffer, Vector<Ref<GPUBuffer>>&&, Vector<Ref<GPUTexture>>&&);
+    GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, Vector<Ref<GPUBuffer>>&&, Vector<Ref<GPUTexture>>&&);
     
     RetainPtr<MTLBuffer> m_vertexArgsBuffer;
     RetainPtr<MTLBuffer> m_fragmentArgsBuffer;
-    RetainPtr<MTLBuffer> m_computeArgsBuffer;
 #endif
     Vector<Ref<GPUBuffer>> m_boundBuffers;
     Vector<Ref<GPUTexture>> m_boundTextures;
diff --git a/Source/WebCore/platform/graphics/gpu/GPUComputePassEncoder.h b/Source/WebCore/platform/graphics/gpu/GPUComputePassEncoder.h
deleted file mode 100644 (file)
index cd9f9df..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 "GPUComputePipeline.h"
-#include "GPUProgrammablePassEncoder.h"
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/RetainPtr.h>
-
-OBJC_PROTOCOL(MTLComputeCommandEncoder);
-
-namespace WebCore {
-
-using PlatformComputePassEncoder = MTLComputeCommandEncoder;
-using PlatformComputePassEncoderSmartPtr = RetainPtr<MTLComputeCommandEncoder>;
-
-class GPUComputePassEncoder : public GPUProgrammablePassEncoder {
-public:
-    static RefPtr<GPUComputePassEncoder> tryCreate(Ref<GPUCommandBuffer>&&);
-
-    void setPipeline(Ref<const GPUComputePipeline>&&);
-    void dispatch(unsigned x, unsigned y, unsigned z);
-
-private:
-    GPUComputePassEncoder(Ref<GPUCommandBuffer>&&, PlatformComputePassEncoderSmartPtr&&);
-    ~GPUComputePassEncoder() { endPass(); }
-
-    // GPUProgrammablePassEncoder
-    const PlatformProgrammablePassEncoder* platformPassEncoder() const final;
-    void invalidateEncoder() final { m_platformComputePassEncoder = nullptr; }
-#if USE(METAL)
-    void useResource(const MTLResource *, unsigned usage) final;
-    void setComputeBuffer(const MTLBuffer *, unsigned offset, unsigned index) final;
-#endif
-
-    PlatformComputePassEncoderSmartPtr m_platformComputePassEncoder;
-    RefPtr<const GPUComputePipeline> m_pipeline;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h b/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h
deleted file mode 100644 (file)
index 0359f29..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
-#include <wtf/RetainPtr.h>
-
-OBJC_PROTOCOL(MTLComputePipelineState);
-
-namespace WebCore {
-
-class GPUDevice;
-
-struct GPUComputePipelineDescriptor;
-
-using PlatformComputePipeline = MTLComputePipelineState;
-using PlatformComputePipelineSmartPtr = RetainPtr<MTLComputePipelineState>;
-
-class GPUComputePipeline : public RefCounted<GPUComputePipeline> {
-public:
-    static RefPtr<GPUComputePipeline> tryCreate(const GPUDevice&, const GPUComputePipelineDescriptor&);
-
-    const PlatformComputePipeline* platformComputePipeline() const { return m_platformComputePipeline.get(); }
-
-private:
-    GPUComputePipeline(PlatformComputePipelineSmartPtr&&);
-
-    PlatformComputePipelineSmartPtr m_platformComputePipeline;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/platform/graphics/gpu/GPUComputePipelineDescriptor.h b/Source/WebCore/platform/graphics/gpu/GPUComputePipelineDescriptor.h
deleted file mode 100644 (file)
index 3d74c11..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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 "GPUPipelineDescriptorBase.h"
-#include "GPUPipelineStageDescriptor.h"
-
-namespace WebCore {
-
-struct GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
-    GPUComputePipelineDescriptor(RefPtr<GPUPipelineLayout>&& layout, GPUPipelineStageDescriptor&& compute)
-        : GPUPipelineDescriptorBase { WTFMove(layout) }
-        , computeStage { WTFMove(compute) }
-    {
-    }
-
-    GPUPipelineStageDescriptor computeStage;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
index 1cc78b5..9bdf666 100644 (file)
@@ -33,8 +33,6 @@
 #include "GPUBuffer.h"
 #include "GPUBufferDescriptor.h"
 #include "GPUCommandBuffer.h"
-#include "GPUComputePipeline.h"
-#include "GPUComputePipelineDescriptor.h"
 #include "GPUPipelineLayout.h"
 #include "GPUPipelineLayoutDescriptor.h"
 #include "GPURenderPipeline.h"
@@ -44,7 +42,6 @@
 #include "GPUShaderModule.h"
 #include "GPUShaderModuleDescriptor.h"
 #include "GPUSwapChain.h"
-#include "GPUSwapChainDescriptor.h"
 #include "GPUTexture.h"
 #include "GPUTextureDescriptor.h"
 #include <wtf/Optional.h>
@@ -86,11 +83,6 @@ RefPtr<GPURenderPipeline> GPUDevice::createRenderPipeline(GPURenderPipelineDescr
     return GPURenderPipeline::create(*this, WTFMove(descriptor));
 }
 
-RefPtr<GPUComputePipeline> GPUDevice::tryCreateComputePipeline(const GPUComputePipelineDescriptor& descriptor) const
-{
-    return GPUComputePipeline::tryCreate(*this, descriptor);
-}
-
 RefPtr<GPUCommandBuffer> GPUDevice::tryCreateCommandBuffer() const
 {
     return GPUCommandBuffer::tryCreate(*this);
index 97fc889..aba954c 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(WEBGPU)
 
 #include "GPUQueue.h"
+#include "GPUSwapChainDescriptor.h"
 #include <wtf/RefCounted.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/WeakPtr.h>
@@ -39,7 +40,6 @@ namespace WebCore {
 class GPUBindGroupLayout;
 class GPUBuffer;
 class GPUCommandBuffer;
-class GPUComputePipeline;
 class GPUPipelineLayout;
 class GPURenderPipeline;
 class GPUSampler;
@@ -49,13 +49,11 @@ class GPUTexture;
 
 struct GPUBindGroupLayoutDescriptor;
 struct GPUBufferDescriptor;
-struct GPUComputePipelineDescriptor;
 struct GPUPipelineLayoutDescriptor;
 struct GPURenderPipelineDescriptor;
 struct GPURequestAdapterOptions;
 struct GPUSamplerDescriptor;
 struct GPUShaderModuleDescriptor;
-struct GPUSwapChainDescriptor;
 struct GPUTextureDescriptor;
     
 using PlatformDevice = MTLDevice;
@@ -74,7 +72,6 @@ public:
 
     RefPtr<GPUShaderModule> createShaderModule(GPUShaderModuleDescriptor&&) const;
     RefPtr<GPURenderPipeline> createRenderPipeline(GPURenderPipelineDescriptor&&) const;
-    RefPtr<GPUComputePipeline> tryCreateComputePipeline(const GPUComputePipelineDescriptor&) const;
 
     RefPtr<GPUCommandBuffer> tryCreateCommandBuffer() const;
 
index e32404e..bdc3e7d 100644 (file)
@@ -29,7 +29,7 @@
 
 #include "GPUPipelineLayout.h"
 #include "GPUPipelineStageDescriptor.h"
-#include <wtf/RefPtr.h>
+
 #include <wtf/Vector.h>
 
 namespace WebCore {
index cb36032..143d554 100644 (file)
@@ -28,7 +28,6 @@
 #if ENABLE(WEBGPU)
 
 #include "GPUBindGroupBinding.h"
-#include "GPUCommandBuffer.h"
 #include <wtf/RefCounted.h>
 
 #if USE(METAL)
@@ -40,6 +39,7 @@ OBJC_PROTOCOL(MTLResource);
 namespace WebCore {
 
 class GPUBindGroup;
+class GPUCommandBuffer;
 class GPURenderPipeline;
 
 using PlatformProgrammablePassEncoder = MTLCommandEncoder;
@@ -48,25 +48,22 @@ class GPUProgrammablePassEncoder : public RefCounted<GPUProgrammablePassEncoder>
 public:
     virtual ~GPUProgrammablePassEncoder() = default;
 
-    void endPass();
+    virtual void endPass();
     void setBindGroup(unsigned, GPUBindGroup&);
 
 protected:
     GPUProgrammablePassEncoder(Ref<GPUCommandBuffer>&&);
 
     GPUCommandBuffer& commandBuffer() const { return m_commandBuffer.get(); }
-    virtual const PlatformProgrammablePassEncoder* platformPassEncoder() const = 0;
+    virtual PlatformProgrammablePassEncoder* platformPassEncoder() const = 0;
 
 private:
-    virtual void invalidateEncoder() = 0;
 #if USE(METAL)
-    virtual void useResource(const MTLResource *, unsigned) = 0;
+    virtual void useResource(MTLResource *, unsigned) = 0;
 
     // Render command encoder methods.
-    virtual void setVertexBuffer(const MTLBuffer *, unsigned, unsigned) { }
-    virtual void setFragmentBuffer(const MTLBuffer *, unsigned, unsigned) { }
-    // Compute.
-    virtual void setComputeBuffer(const MTLBuffer *, unsigned, unsigned) { }
+    virtual void setVertexBuffer(MTLBuffer *, unsigned, unsigned) { }
+    virtual void setFragmentBuffer(MTLBuffer *, unsigned, unsigned) { }
 #endif // USE(METAL)
 
     Ref<GPUCommandBuffer> m_commandBuffer;
index 752c996..e053ce0 100644 (file)
@@ -51,21 +51,23 @@ class GPURenderPassEncoder : public GPUProgrammablePassEncoder {
 public:
     static RefPtr<GPURenderPassEncoder> tryCreate(Ref<GPUCommandBuffer>&&, GPURenderPassDescriptor&&);
 
+    void endPass() final;
     void setPipeline(Ref<const GPURenderPipeline>&&);
+
     void setVertexBuffers(unsigned long, Vector<Ref<GPUBuffer>>&&, Vector<unsigned long long>&&);
     void draw(unsigned long vertexCount, unsigned long instanceCount, unsigned long firstVertex, unsigned long firstInstance);
 
 private:
     GPURenderPassEncoder(Ref<GPUCommandBuffer>&&, PlatformRenderPassEncoderSmartPtr&&);
-    ~GPURenderPassEncoder() { endPass(); }
+    ~GPURenderPassEncoder() { endPass(); } // Ensure that encoding has ended before release.
+
+    PlatformProgrammablePassEncoder* platformPassEncoder() const final;
 
-    // GPUProgrammablePassEncoder
-    const PlatformProgrammablePassEncoder* platformPassEncoder() const final;
-    void invalidateEncoder() final { m_platformRenderPassEncoder = nullptr; }
 #if USE(METAL)
-    void useResource(const MTLResource *, unsigned usage) final;
-    void setVertexBuffer(const MTLBuffer *, unsigned offset, unsigned index) final;
-    void setFragmentBuffer(const MTLBuffer *, unsigned offset, unsigned index) final;
+    // GPUProgrammablePassEncoder
+    void useResource(MTLResource *, unsigned usage) final;
+    void setVertexBuffer(MTLBuffer *, unsigned offset, unsigned index) final;
+    void setFragmentBuffer(MTLBuffer *, unsigned offset, unsigned index) final;
 #endif // USE(METAL)
 
     PlatformRenderPassEncoderSmartPtr m_platformRenderPassEncoder;
index 41fb106..7eff754 100644 (file)
@@ -61,6 +61,7 @@ private:
     RetainPtr<MTLDepthStencilState> m_depthStencilState;
 #endif // USE(METAL)
     PlatformRenderPipelineSmartPtr m_platformRenderPipeline;
+    RefPtr<GPUPipelineLayout> m_layout;
     GPUPrimitiveTopology m_primitiveTopology;
 };
 
index aacb4f4..31505d5 100644 (file)
@@ -31,7 +31,9 @@
 #import "GPUBindGroupBinding.h"
 #import "GPUBindGroupDescriptor.h"
 #import "GPUBindGroupLayout.h"
+#import "GPUBuffer.h"
 #import "GPUSampler.h"
+#import "GPUTexture.h"
 #import "Logging.h"
 #import <Metal/Metal.h>
 #import <wtf/BlockObjCExceptions.h>
@@ -75,7 +77,7 @@ static void setBufferOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBuf
     END_BLOCK_OBJC_EXCEPTIONS;
 }
     
-static MTLSamplerState *tryGetResourceAsMTLSamplerState(const GPUBindingResource& resource, const char* const functionName)
+static RefPtr<GPUSampler> tryGetResourceAsSampler(const GPUBindingResource& resource, const char* const functionName)
 {
 #if LOG_DISABLED
     UNUSED_PARAM(functionName);
@@ -84,11 +86,12 @@ static MTLSamplerState *tryGetResourceAsMTLSamplerState(const GPUBindingResource
         LOG(WebGPU, "%s: Resource is not a GPUSampler!", functionName);
         return nullptr;
     }
-    auto samplerState = WTF::get<Ref<GPUSampler>>(resource)->platformSampler();
-    if (!samplerState)
+    auto& samplerRef = WTF::get<Ref<GPUSampler>>(resource);
+    if (!samplerRef->platformSampler()) {
         LOG(WebGPU, "%s: Invalid MTLSamplerState in GPUSampler binding!", functionName);
-
-    return samplerState;
+        return nullptr;
+    }
+    return samplerRef.copyRef();
 }
 
 static void setSamplerOnEncoder(MTLArgumentEncoder *argumentEncoder, MTLSamplerState *sampler, unsigned index)
@@ -132,7 +135,7 @@ RefPtr<GPUBindGroup> GPUBindGroup::tryCreate(const GPUBindGroupDescriptor& descr
     
     MTLArgumentEncoder *vertexEncoder = descriptor.layout->vertexEncoder();
     MTLArgumentEncoder *fragmentEncoder = descriptor.layout->fragmentEncoder();
-    MTLArgumentEncoder *computeEncoder = descriptor.layout->computeEncoder();
+    // FIXME: Finish support for compute.
     
     RetainPtr<MTLBuffer> vertexArgsBuffer;
     if (vertexEncoder && !(vertexArgsBuffer = tryCreateArgumentBuffer(vertexEncoder))) {
@@ -144,11 +147,6 @@ RefPtr<GPUBindGroup> GPUBindGroup::tryCreate(const GPUBindGroupDescriptor& descr
         LOG(WebGPU, "%s: Unable to create MTLBuffer for fragment argument buffer!", functionName);
         return nullptr;
     }
-    RetainPtr<MTLBuffer> computeArgsBuffer;
-    if (computeEncoder && !(computeArgsBuffer = tryCreateArgumentBuffer(computeEncoder))) {
-        LOG(WebGPU, "%s: Unable to create MTLBuffer for compute argument buffer!", functionName);
-        return nullptr;
-    }
     
     Vector<Ref<GPUBuffer>> boundBuffers;
     Vector<Ref<GPUTexture>> boundTextures;
@@ -156,72 +154,55 @@ RefPtr<GPUBindGroup> GPUBindGroup::tryCreate(const GPUBindGroupDescriptor& descr
     // Set each resource on each MTLArgumentEncoder it should be visible on.
     const auto& layoutBindingsMap = descriptor.layout->bindingsMap();
     for (const auto& resourceBinding : descriptor.bindings) {
-        auto index = resourceBinding.binding;
-        auto layoutIterator = layoutBindingsMap.find(index);
+        auto layoutIterator = layoutBindingsMap.find(resourceBinding.binding);
         if (layoutIterator == layoutBindingsMap.end()) {
-            LOG(WebGPU, "%s: GPUBindGroupBinding %lu not found in GPUBindGroupLayout!", functionName, index);
+            LOG(WebGPU, "%s: GPUBindGroupBinding %lu not found in GPUBindGroupLayout!", functionName, resourceBinding.binding);
             return nullptr;
         }
         auto layoutBinding = layoutIterator->value;
         if (layoutBinding.visibility == GPUShaderStageBit::Flags::None)
             continue;
-
-        bool isForVertex = layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex;
-        bool isForFragment = layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment;
-        bool isForCompute = layoutBinding.visibility & GPUShaderStageBit::Flags::Compute;
-
-        if (isForVertex && !vertexEncoder) {
-            LOG(WebGPU, "%s: No vertex argument encoder found for binding %lu!", functionName, index);
+        if ((layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex) && !vertexEncoder) {
+            LOG(WebGPU, "%s: No vertex encoder found for binding %lu!", functionName, resourceBinding.binding);
             return nullptr;
         }
-        if (isForFragment && !fragmentEncoder) {
-            LOG(WebGPU, "%s: No fragment argument encoder found for binding %lu!", functionName, index);
+        if ((layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment) && !fragmentEncoder) {
+            LOG(WebGPU, "%s: No fragment encoder found for binding %lu!", functionName, resourceBinding.binding);
             return nullptr;
         }
-        if (isForCompute && !computeEncoder) {
-            LOG(WebGPU, "%s: No compute argument encoder found for binding %lu!", functionName, index);
-            return nullptr;
-        }
-
+        
         switch (layoutBinding.type) {
         // FIXME: Support more resource types.
-        // FIXME: We could avoid this ugly switch-on-type using virtual functions if GPUBindingResource is refactored as a base class rather than a Variant.
         case GPUBindingType::UniformBuffer:
         case GPUBindingType::StorageBuffer: {
             auto bufferResource = tryGetResourceAsBufferBinding(resourceBinding.resource, functionName);
             if (!bufferResource)
                 return nullptr;
-            if (isForVertex)
-                setBufferOnEncoder(vertexEncoder, *bufferResource, index);
-            if (isForFragment)
-                setBufferOnEncoder(fragmentEncoder, *bufferResource, index);
-            if (isForCompute)
-                setBufferOnEncoder(computeEncoder, *bufferResource, index);
+            if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
+                setBufferOnEncoder(vertexEncoder, *bufferResource, resourceBinding.binding);
+            if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
+                setBufferOnEncoder(fragmentEncoder, *bufferResource, resourceBinding.binding);
             boundBuffers.append(bufferResource->buffer.copyRef());
             break;
         }
         case GPUBindingType::Sampler: {
-            auto samplerState = tryGetResourceAsMTLSamplerState(resourceBinding.resource, functionName);
-            if (!samplerState)
+            auto samplerResource = tryGetResourceAsSampler(resourceBinding.resource, functionName);
+            if (!samplerResource)
                 return nullptr;
-            if (isForVertex)
-                setSamplerOnEncoder(vertexEncoder, samplerState, index);
-            if (isForFragment)
-                setSamplerOnEncoder(fragmentEncoder, samplerState, index);
-            if (isForCompute)
-                setSamplerOnEncoder(computeEncoder, samplerState, index);
+            if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
+                setSamplerOnEncoder(vertexEncoder, samplerResource->platformSampler(), resourceBinding.binding);
+            if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
+                setSamplerOnEncoder(fragmentEncoder, samplerResource->platformSampler(), resourceBinding.binding);
             break;
         }
         case GPUBindingType::SampledTexture: {
             auto textureResource = tryGetResourceAsTexture(resourceBinding.resource, functionName);
             if (!textureResource)
                 return nullptr;
-            if (isForVertex)
-                setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), index);
-            if (isForFragment)
-                setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), index);
-            if (isForCompute)
-                setTextureOnEncoder(computeEncoder, textureResource->platformTexture(), index);
+            if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
+                setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), resourceBinding.binding);
+            if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
+                setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), resourceBinding.binding);
             boundTextures.append(textureResource.releaseNonNull());
             break;
         }
@@ -231,13 +212,12 @@ RefPtr<GPUBindGroup> GPUBindGroup::tryCreate(const GPUBindGroupDescriptor& descr
         }
     }
     
-    return adoptRef(new GPUBindGroup(WTFMove(vertexArgsBuffer), WTFMove(fragmentArgsBuffer), WTFMove(computeArgsBuffer), WTFMove(boundBuffers), WTFMove(boundTextures)));
+    return adoptRef(new GPUBindGroup(WTFMove(vertexArgsBuffer), WTFMove(fragmentArgsBuffer), WTFMove(boundBuffers), WTFMove(boundTextures)));
 }
     
-GPUBindGroup::GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, RetainPtr<MTLBuffer>&& computeBuffer, Vector<Ref<GPUBuffer>>&& buffers, Vector<Ref<GPUTexture>>&& textures)
+GPUBindGroup::GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, Vector<Ref<GPUBuffer>>&& buffers, Vector<Ref<GPUTexture>>&& textures)
     : m_vertexArgsBuffer(WTFMove(vertexBuffer))
     , m_fragmentArgsBuffer(WTFMove(fragmentBuffer))
-    , m_computeArgsBuffer(WTFMove(computeBuffer))
     , m_boundBuffers(WTFMove(buffers))
     , m_boundTextures(WTFMove(textures))
 {
diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm
deleted file mode 100644 (file)
index 3208dcf..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.
- */
-
-#include "config.h"
-#include "GPUComputePassEncoder.h"
-
-#if ENABLE(WEBGPU)
-
-#include "GPUComputePipeline.h"
-#include "Logging.h"
-#include <Metal/Metal.h>
-#include <wtf/BlockObjCExceptions.h>
-
-namespace WebCore {
-
-RefPtr<GPUComputePassEncoder> GPUComputePassEncoder::tryCreate(Ref<GPUCommandBuffer>&& buffer)
-{
-    if (buffer->isEncodingPass()) {
-        LOG(WebGPU, "GPUComputePassEncoder::tryCreate(): Existing pass encoder must be ended first!");
-        return nullptr;
-    }
-
-    buffer->endBlitEncoding();
-
-    RetainPtr<MTLComputeCommandEncoder> mtlEncoder;
-
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    mtlEncoder = [buffer->platformCommandBuffer() computeCommandEncoder];
-    END_BLOCK_OBJC_EXCEPTIONS;
-
-    if (!mtlEncoder) {
-        LOG(WebGPU, "GPUComputePassEncoder::tryCreate(): Unable to create MTLComputeCommandEncoder!");
-        return nullptr;
-    }
-
-    return adoptRef(new GPUComputePassEncoder(WTFMove(buffer), WTFMove(mtlEncoder)));
-}
-
-GPUComputePassEncoder::GPUComputePassEncoder(Ref<GPUCommandBuffer>&& buffer, RetainPtr<MTLComputeCommandEncoder>&& encoder)
-    : GPUProgrammablePassEncoder(WTFMove(buffer))
-    , m_platformComputePassEncoder(WTFMove(encoder))
-{
-}
-
-void GPUComputePassEncoder::setPipeline(Ref<const GPUComputePipeline>&& pipeline)
-{
-    if (!m_platformComputePassEncoder) {
-        LOG(WebGPU, "GPUComputePassEncoder::setPipeline(): Invalid operation!");
-        return;
-    }
-
-    ASSERT(pipeline->platformComputePipeline());
-
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [m_platformComputePassEncoder setComputePipelineState:pipeline->platformComputePipeline()];
-    END_BLOCK_OBJC_EXCEPTIONS;
-
-    m_pipeline = WTFMove(pipeline);
-}
-
-void GPUComputePassEncoder::dispatch(unsigned x, unsigned y, unsigned z)
-{
-    if (!m_platformComputePassEncoder) {
-        LOG(WebGPU, "GPUComputePassEncoder::dispatch(): Invalid operation!");
-        return;
-    }
-
-    if (!m_pipeline) {
-        LOG(WebGPU, "GPUComputePassEncoder::dispatch(): No valid GPUComputePipeline found!");
-        return;
-    }
-
-    auto pipelineState = m_pipeline->platformComputePipeline();
-    ASSERT(pipelineState);
-
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    // FIXME: This should be gleaned from the shader if not using MSL. For now, use the docs' example calculation.
-    auto w = pipelineState.threadExecutionWidth;
-    auto h = pipelineState.maxTotalThreadsPerThreadgroup / w;
-    auto threadsPerThreadgroup = MTLSizeMake(w, h, 1);
-
-    [m_platformComputePassEncoder dispatchThreads:MTLSizeMake(x, y, z) threadsPerThreadgroup:threadsPerThreadgroup];
-    END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-const MTLCommandEncoder *GPUComputePassEncoder::platformPassEncoder() const
-{
-    return m_platformComputePassEncoder.get();
-}
-
-#if USE(METAL)
-
-void GPUComputePassEncoder::useResource(const MTLResource *resource, unsigned usage)
-{
-    ASSERT(m_platformComputePassEncoder);
-
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [m_platformComputePassEncoder useResource:resource usage:usage];
-    END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void GPUComputePassEncoder::setComputeBuffer(const MTLBuffer * buffer, unsigned offset, unsigned index)
-{
-    ASSERT(m_platformComputePassEncoder);
-
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    [m_platformComputePassEncoder setBuffer:buffer offset:offset atIndex:index];
-    END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-#endif
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
diff --git a/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm b/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm
deleted file mode 100644 (file)
index fbe43f4..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.
- */
-
-#import "config.h"
-#import "GPUComputePipeline.h"
-
-#if ENABLE(WEBGPU)
-
-#import "GPUComputePipelineDescriptor.h"
-#import "GPUDevice.h"
-#import "Logging.h"
-#import <Metal/Metal.h>
-#import <wtf/BlockObjCExceptions.h>
-
-OBJC_PROTOCOL(MTLFunction);
-
-namespace WebCore {
-
-static RetainPtr<MTLFunction> tryCreateMtlComputeFunction(const GPUPipelineStageDescriptor& stage)
-{
-    if (!stage.module->platformShaderModule() || stage.entryPoint.isNull()) {
-        LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUShaderModule!");
-        return nullptr;
-    }
-
-    RetainPtr<MTLFunction> function;
-
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    function = adoptNS([stage.module->platformShaderModule() newFunctionWithName:stage.entryPoint]);
-    END_BLOCK_OBJC_EXCEPTIONS;
-
-    if (!function)
-        LOG(WebGPU, "GPUComputePipeline::tryCreate(): Cannot create compute MTLFunction \"%s\"!", stage.entryPoint.utf8().data());
-
-    return function;
-}
-
-static RetainPtr<MTLComputePipelineState> tryCreateMTLComputePipelineState(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor)
-{
-    if (!device.platformDevice()) {
-        LOG(WebGPU, "GPUComputePipeline::tryCreate(): Invalid GPUDevice!");
-        return nullptr;
-    }
-
-    auto computeFunction = tryCreateMtlComputeFunction(descriptor.computeStage);
-    if (!computeFunction)
-        return nullptr;
-
-    RetainPtr<MTLComputePipelineState> pipelineState;
-    NSError *error = nil;
-
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
-    pipelineState = adoptNS([device.platformDevice() newComputePipelineStateWithFunction:computeFunction.get() error:&error]);
-    END_BLOCK_OBJC_EXCEPTIONS;
-
-    if (!pipelineState)
-        LOG(WebGPU, "GPUComputePipeline::tryCreate(): %s!", error ? error.localizedDescription.UTF8String : "Unable to create MTLComputePipelineState!");
-
-    return pipelineState;
-}
-
-RefPtr<GPUComputePipeline> GPUComputePipeline::tryCreate(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor)
-{
-    auto mtlPipeline = tryCreateMTLComputePipelineState(device, descriptor);
-    if (!mtlPipeline)
-        return nullptr;
-
-    return adoptRef(new GPUComputePipeline(WTFMove(mtlPipeline)));
-}
-
-GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline)
-    : m_platformComputePipeline(WTFMove(pipeline))
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
index 2e98718..6cadcfb 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(WEBGPU)
 
 #import "GPUBindGroup.h"
+#import "GPUCommandBuffer.h"
 #import "Logging.h"
 #import <Metal/Metal.h>
 #import <wtf/BlockObjCExceptions.h>
@@ -37,14 +38,12 @@ namespace WebCore {
 
 void GPUProgrammablePassEncoder::endPass()
 {
-    if (!platformPassEncoder())
-        return;
+    ASSERT(platformPassEncoder());
 
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     [platformPassEncoder() endEncoding];
     END_BLOCK_OBJC_EXCEPTIONS;
 
-    invalidateEncoder();
     m_commandBuffer->setIsEncodingPass(false);
 }
 
@@ -59,8 +58,6 @@ void GPUProgrammablePassEncoder::setBindGroup(unsigned index, GPUBindGroup& bind
         setVertexBuffer(bindGroup.vertexArgsBuffer(), 0, index);
     if (bindGroup.fragmentArgsBuffer())
         setFragmentBuffer(bindGroup.fragmentArgsBuffer(), 0, index);
-    if (bindGroup.computeArgsBuffer())
-        setComputeBuffer(bindGroup.computeArgsBuffer(), 0, index);
 
     for (auto& bufferRef : bindGroup.boundBuffers()) {
         useResource(bufferRef->platformBuffer(), bufferRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite);
index fea9c99..3423f10 100644 (file)
@@ -178,11 +178,19 @@ GPURenderPassEncoder::GPURenderPassEncoder(Ref<GPUCommandBuffer>&& commandBuffer
 {
 }
 
-const MTLCommandEncoder *GPURenderPassEncoder::platformPassEncoder() const
+MTLCommandEncoder *GPURenderPassEncoder::platformPassEncoder() const
 {
     return m_platformRenderPassEncoder.get();
 }
 
+void GPURenderPassEncoder::endPass()
+{
+    if (!m_platformRenderPassEncoder)
+        return;
+    GPUProgrammablePassEncoder::endPass();
+    m_platformRenderPassEncoder = nullptr;
+}
+
 void GPURenderPassEncoder::setPipeline(Ref<const GPURenderPipeline>&& pipeline)
 {
     if (!m_platformRenderPassEncoder) {
@@ -190,7 +198,7 @@ void GPURenderPassEncoder::setPipeline(Ref<const GPURenderPipeline>&& pipeline)
         return;
     }
 
-    // FIXME: Metal throws an error if the MTLPipelineState's attachment formats do not match the MTLCommandEncoder's attachment formats.
+    // FIXME: Metal throws an error if the MTLPipelineState's attachment formats do not match the MTLCommandEncoder's attachment formats. Does this have to be validated at the Web GPU level?
 
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
@@ -257,40 +265,44 @@ void GPURenderPassEncoder::draw(unsigned long vertexCount, unsigned long instanc
         return;
     }
 
-    BEGIN_BLOCK_OBJC_EXCEPTIONS;
     [m_platformRenderPassEncoder 
         drawPrimitives:primitiveTypeForGPUPrimitiveTopology(m_pipeline->primitiveTopology())
         vertexStart:firstVertex
         vertexCount:vertexCount
         instanceCount:instanceCount
         baseInstance:firstInstance];
-    END_BLOCK_OBJC_EXCEPTIONS;
 }
 
 #if USE(METAL)
 
-void GPURenderPassEncoder::useResource(const MTLResource *resource, unsigned usage)
+void GPURenderPassEncoder::useResource(MTLResource *resource, unsigned usage)
 {
-    ASSERT(m_platformRenderPassEncoder);
-
+    if (!m_platformRenderPassEncoder) {
+        LOG(WebGPU, "GPURenderPassEncoder: Invalid operation: Encoding is ended!");
+        return;
+    }
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     [m_platformRenderPassEncoder useResource:resource usage:usage];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void GPURenderPassEncoder::setVertexBuffer(const MTLBuffer *buffer, unsigned offset, unsigned index)
+void GPURenderPassEncoder::setVertexBuffer(MTLBuffer *buffer, unsigned offset, unsigned index)
 {
-    ASSERT(m_platformRenderPassEncoder);
-
+    if (!m_platformRenderPassEncoder) {
+        LOG(WebGPU, "GPURenderPassEncoder: Invalid operation: Encoding is ended!");
+        return;
+    }
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     [m_platformRenderPassEncoder setVertexBuffer:buffer offset:offset atIndex:index];
     END_BLOCK_OBJC_EXCEPTIONS;
 }
 
-void GPURenderPassEncoder::setFragmentBuffer(const MTLBuffer *buffer, unsigned offset, unsigned index)
+void GPURenderPassEncoder::setFragmentBuffer(MTLBuffer *buffer, unsigned offset, unsigned index)
 {
-    ASSERT(m_platformRenderPassEncoder);
-
+    if (!m_platformRenderPassEncoder) {
+        LOG(WebGPU, "GPURenderPassEncoder: Invalid operation: Encoding is ended!");
+        return;
+    }
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
     [m_platformRenderPassEncoder setFragmentBuffer:buffer offset:offset atIndex:index];
     END_BLOCK_OBJC_EXCEPTIONS;
index a9f2d4f..21d8f57 100644 (file)
@@ -28,7 +28,6 @@
 
 #if ENABLE(WEBGPU)
 
-#import "GPUDevice.h"
 #import "GPULimits.h"
 #import "GPUUtils.h"
 #import "Logging.h"
@@ -442,6 +441,7 @@ RefPtr<GPURenderPipeline> GPURenderPipeline::create(const GPUDevice& device, GPU
 GPURenderPipeline::GPURenderPipeline(RetainPtr<MTLDepthStencilState>&& depthStencil, RetainPtr<MTLRenderPipelineState>&& pipeline, GPURenderPipelineDescriptor&& descriptor)
     : m_depthStencilState(WTFMove(depthStencil))
     , m_platformRenderPipeline(WTFMove(pipeline))
+    , m_layout(WTFMove(descriptor.layout))
     , m_primitiveTopology(descriptor.primitiveTopology)
 {
 }
index 16f9f6f..6324b50 100644 (file)
@@ -28,6 +28,7 @@
 
 #if PLATFORM(MAC)
 
+#import <Carbon/Carbon.h>
 #import <wtf/spi/cf/CFStringSPI.h>
 
 namespace WebCore {