Diff
Modified: trunk/Source/_javascript_Core/Configurations/FeatureDefines.xcconfig (239494 => 239495)
--- trunk/Source/_javascript_Core/Configurations/FeatureDefines.xcconfig 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/_javascript_Core/Configurations/FeatureDefines.xcconfig 2018-12-21 03:04:52 UTC (rev 239495)
@@ -373,10 +373,12 @@
ENABLE_WEBGL2 = ENABLE_WEBGL2;
ENABLE_WEBGPU = $(ENABLE_WEBGPU_$(WK_PLATFORM_NAME));
-ENABLE_WEBGPU_iphoneos = ENABLE_WEBGPU;
+ENABLE_WEBGPU_iphoneos = $(ENABLE_WEBGPU$(WK_IOS_1100));
+ENABLE_WEBGPU_IOS_SINCE_1100 = ENABLE_WEBGPU;
ENABLE_WEBGPU_watchos = ENABLE_WEBGPU;
ENABLE_WEBGPU_appletvos = ENABLE_WEBGPU;
-ENABLE_WEBGPU_macosx = ENABLE_WEBGPU;
+ENABLE_WEBGPU_macosx = $(ENABLE_WEBGPU$(WK_MACOS_1013));
+ENABLE_WEBGPU_MACOS_SINCE_1013 = ENABLE_WEBGPU;
ENABLE_WEBMETAL = $(ENABLE_WEBMETAL_$(WK_PLATFORM_NAME));
ENABLE_WEBMETAL_iphoneos = ENABLE_WEBMETAL;
Modified: trunk/Source/WebCore/ChangeLog (239494 => 239495)
--- trunk/Source/WebCore/ChangeLog 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebCore/ChangeLog 2018-12-21 03:04:52 UTC (rev 239495)
@@ -1,3 +1,27 @@
+2018-12-20 Justin Fan <justin_...@apple.com>
+
+ [WebGPU] Convert WebGPUBindGroups into MTLArgumentEncoders
+ https://bugs.webkit.org/show_bug.cgi?id=192956
+
+ Reviewed by Myles Maxfield.
+
+ No testable behavior change. Existing tests cover possible crashing.
+
+ Add GPUBindGroupLayoutMetal.mm:
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+
+ Flesh out GPUBindGroupLayout::create:
+ * platform/graphics/gpu/GPUBindGroupLayout.cpp:
+ * platform/graphics/gpu/GPUBindGroupLayout.h:
+ * platform/graphics/gpu/GPUDevice.cpp:
+ (WebCore::GPUDevice::createBindGroupLayout const):
+ * platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm: Added.
+ (WebCore::appendArgumentToArrayInMap): Added.
+ (WebCore::GPUBindGroupLayout::create):
+ (WebCore::GPUBindGroupLayout::GPUBindGroupLayout):
+ (WebCore::MTLDataTypeForBindingType): Added.
+
2018-12-20 Michael Catanzaro <mcatanz...@igalia.com>
Unreviewed, remove stray #pragma once added to .cpp file
Modified: trunk/Source/WebCore/Configurations/FeatureDefines.xcconfig (239494 => 239495)
--- trunk/Source/WebCore/Configurations/FeatureDefines.xcconfig 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebCore/Configurations/FeatureDefines.xcconfig 2018-12-21 03:04:52 UTC (rev 239495)
@@ -373,10 +373,12 @@
ENABLE_WEBGL2 = ENABLE_WEBGL2;
ENABLE_WEBGPU = $(ENABLE_WEBGPU_$(WK_PLATFORM_NAME));
-ENABLE_WEBGPU_iphoneos = ENABLE_WEBGPU;
+ENABLE_WEBGPU_iphoneos = $(ENABLE_WEBGPU$(WK_IOS_1100));
+ENABLE_WEBGPU_IOS_SINCE_1100 = ENABLE_WEBGPU;
ENABLE_WEBGPU_watchos = ENABLE_WEBGPU;
ENABLE_WEBGPU_appletvos = ENABLE_WEBGPU;
-ENABLE_WEBGPU_macosx = ENABLE_WEBGPU;
+ENABLE_WEBGPU_macosx = $(ENABLE_WEBGPU$(WK_MACOS_1013));
+ENABLE_WEBGPU_MACOS_SINCE_1013 = ENABLE_WEBGPU;
ENABLE_WEBMETAL = $(ENABLE_WEBMETAL_$(WK_PLATFORM_NAME));
ENABLE_WEBMETAL_iphoneos = ENABLE_WEBMETAL;
Modified: trunk/Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig (239494 => 239495)
--- trunk/Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebCore/PAL/Configurations/FeatureDefines.xcconfig 2018-12-21 03:04:52 UTC (rev 239495)
@@ -373,10 +373,12 @@
ENABLE_WEBGL2 = ENABLE_WEBGL2;
ENABLE_WEBGPU = $(ENABLE_WEBGPU_$(WK_PLATFORM_NAME));
-ENABLE_WEBGPU_iphoneos = ENABLE_WEBGPU;
+ENABLE_WEBGPU_iphoneos = $(ENABLE_WEBGPU$(WK_IOS_1100));
+ENABLE_WEBGPU_IOS_SINCE_1100 = ENABLE_WEBGPU;
ENABLE_WEBGPU_watchos = ENABLE_WEBGPU;
ENABLE_WEBGPU_appletvos = ENABLE_WEBGPU;
-ENABLE_WEBGPU_macosx = ENABLE_WEBGPU;
+ENABLE_WEBGPU_macosx = $(ENABLE_WEBGPU$(WK_MACOS_1013));
+ENABLE_WEBGPU_MACOS_SINCE_1013 = ENABLE_WEBGPU;
ENABLE_WEBMETAL = $(ENABLE_WEBMETAL_$(WK_PLATFORM_NAME));
ENABLE_WEBMETAL_iphoneos = ENABLE_WEBMETAL;
Modified: trunk/Source/WebCore/SourcesCocoa.txt (239494 => 239495)
--- trunk/Source/WebCore/SourcesCocoa.txt 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2018-12-21 03:04:52 UTC (rev 239495)
@@ -318,6 +318,7 @@
platform/graphics/cv/TextureCacheCV.mm
platform/graphics/cv/VideoTextureCopierCV.cpp
+platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm
platform/graphics/gpu/cocoa/GPUBufferMetal.mm
platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm
platform/graphics/gpu/cocoa/GPUDeviceMetal.mm
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (239494 => 239495)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-12-21 03:04:52 UTC (rev 239495)
@@ -13736,6 +13736,7 @@
D00F595421701D8C000D71DB /* WebGPUDevice.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUDevice.idl; sourceTree = "<group>"; };
D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpaceSplitString.cpp; sourceTree = "<group>"; };
D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpaceSplitString.h; sourceTree = "<group>"; };
+ D0232B5821CB49B7009483B9 /* GPUBindGroupLayoutMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUBindGroupLayoutMetal.mm; sourceTree = "<group>"; };
D02454D021C4A41C00B73628 /* GPUBindGroupLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBindGroupLayout.h; sourceTree = "<group>"; };
D02454D121C4A41C00B73628 /* GPUBindGroupLayout.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUBindGroupLayout.cpp; sourceTree = "<group>"; };
D02B83ED21C8397A00F85473 /* WebGPUBindGroupLayoutDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBindGroupLayoutDescriptor.idl; sourceTree = "<group>"; };
@@ -25677,6 +25678,7 @@
D087CE3721ACA94200BDE174 /* cocoa */ = {
isa = PBXGroup;
children = (
+ D0232B5821CB49B7009483B9 /* GPUBindGroupLayoutMetal.mm */,
D0D8649121B760C4003C983C /* GPUBufferMetal.mm */,
D087CE3821ACA94200BDE174 /* GPUCommandBufferMetal.mm */,
D087CE3C21ACA94200BDE174 /* GPUDeviceMetal.mm */,
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.cpp (239494 => 239495)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.cpp 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.cpp 2018-12-21 03:04:52 UTC (rev 239495)
@@ -30,16 +30,6 @@
namespace WebCore {
-Ref<GPUBindGroupLayout> GPUBindGroupLayout::create(GPUBindGroupLayoutDescriptor&& descriptor)
-{
- return adoptRef(*new GPUBindGroupLayout(WTFMove(descriptor)));
-}
-
-GPUBindGroupLayout::GPUBindGroupLayout(GPUBindGroupLayoutDescriptor&&)
-{
- // FIXME: Stub implementation.
-}
-
} // namespace WebCore
#endif // ENABLE(WEBGPU)
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.h (239494 => 239495)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.h 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.h 2018-12-21 03:04:52 UTC (rev 239495)
@@ -29,17 +29,28 @@
#include "GPUBindGroupLayoutDescriptor.h"
+#include <wtf/HashMap.h>
#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/Vector.h>
+OBJC_PROTOCOL(MTLArgumentEncoder);
+
namespace WebCore {
+class GPUDevice;
+
class GPUBindGroupLayout : public RefCounted<GPUBindGroupLayout> {
public:
- static Ref<GPUBindGroupLayout> create(GPUBindGroupLayoutDescriptor&&);
+ using ArgumentsMap = HashMap<GPUShaderStageFlags, RetainPtr<MTLArgumentEncoder>>;
+ static Ref<GPUBindGroupLayout> create(const GPUDevice&, GPUBindGroupLayoutDescriptor&&);
+
private:
- GPUBindGroupLayout(GPUBindGroupLayoutDescriptor&&);
+ GPUBindGroupLayout(ArgumentsMap&&);
+
+ ArgumentsMap m_argumentsMap;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp (239494 => 239495)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp 2018-12-21 03:04:52 UTC (rev 239495)
@@ -48,7 +48,7 @@
Ref<GPUBindGroupLayout> GPUDevice::createBindGroupLayout(GPUBindGroupLayoutDescriptor&& descriptor) const
{
- return GPUBindGroupLayout::create(WTFMove(descriptor));
+ return GPUBindGroupLayout::create(*this, WTFMove(descriptor));
}
Ref<GPUPipelineLayout> GPUDevice::createPipelineLayout(GPUPipelineLayoutDescriptor&& descriptor) const
Added: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm (0 => 239495)
--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm 2018-12-21 03:04:52 UTC (rev 239495)
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "GPUBindGroupLayout.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUDevice.h"
+
+#import <Metal/Metal.h>
+#import <wtf/BlockObjCExceptions.h>
+
+namespace WebCore {
+
+static MTLDataType MTLDataTypeForBindingType(GPUBindGroupLayoutBinding::BindingType type)
+{
+ switch (type) {
+ case GPUBindGroupLayoutBinding::BindingType::Sampler:
+ return MTLDataTypeSampler;
+ case GPUBindGroupLayoutBinding::BindingType::SampledTexture:
+ return MTLDataTypeTexture;
+ case GPUBindGroupLayoutBinding::BindingType::UniformBuffer:
+ case GPUBindGroupLayoutBinding::BindingType::StorageBuffer:
+ return MTLDataTypePointer;
+ }
+}
+
+using ArgumentArraysMap = HashMap<GPUShaderStageFlags, RetainPtr<NSMutableArray<MTLArgumentDescriptor *>>>;
+static void appendArgumentToArrayInMap(ArgumentArraysMap& map, GPUShaderStageFlags stage, RetainPtr<MTLArgumentDescriptor> argument)
+{
+ auto iterator = map.find(stage);
+ if (iterator == map.end()) {
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ map.set(stage, [[NSMutableArray alloc] initWithObjects:argument.get(), nil]);
+ END_BLOCK_OBJC_EXCEPTIONS;
+ } else
+ [iterator->value addObject:argument.get()];
+}
+
+Ref<GPUBindGroupLayout> GPUBindGroupLayout::create(const GPUDevice& device, GPUBindGroupLayoutDescriptor&& descriptor)
+{
+ ArgumentArraysMap argumentArraysMap;
+
+ for (const auto& binding : descriptor.bindings) {
+
+ RetainPtr<MTLArgumentDescriptor> mtlArgument;
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ mtlArgument = adoptNS([MTLArgumentDescriptor new]);
+ END_BLOCK_OBJC_EXCEPTIONS;
+
+ mtlArgument.get().dataType = MTLDataTypeForBindingType(binding.type);
+ mtlArgument.get().index = binding.binding;
+
+ if (binding.visibility & GPUShaderStageBit::VERTEX)
+ appendArgumentToArrayInMap(argumentArraysMap, GPUShaderStageBit::VERTEX, mtlArgument);
+ if (binding.visibility & GPUShaderStageBit::FRAGMENT)
+ appendArgumentToArrayInMap(argumentArraysMap, GPUShaderStageBit::FRAGMENT, mtlArgument);
+ if (binding.visibility & GPUShaderStageBit::COMPUTE)
+ appendArgumentToArrayInMap(argumentArraysMap, GPUShaderStageBit::COMPUTE, mtlArgument);
+ }
+
+ ArgumentsMap argumentsMap;
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+
+ for (const auto& argumentArrayPair : argumentArraysMap) {
+ auto mtlArgumentEncoder = adoptNS([device.platformDevice() newArgumentEncoderWithArguments:argumentArrayPair.value.get()]);
+ argumentsMap.set(argumentArrayPair.key, mtlArgumentEncoder);
+ }
+
+ END_BLOCK_OBJC_EXCEPTIONS;
+
+ return adoptRef(*new GPUBindGroupLayout(WTFMove(argumentsMap)));
+}
+
+GPUBindGroupLayout::GPUBindGroupLayout(ArgumentsMap&& map)
+ : m_argumentsMap(map)
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)
Modified: trunk/Source/WebKit/Configurations/FeatureDefines.xcconfig (239494 => 239495)
--- trunk/Source/WebKit/Configurations/FeatureDefines.xcconfig 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebKit/Configurations/FeatureDefines.xcconfig 2018-12-21 03:04:52 UTC (rev 239495)
@@ -373,10 +373,12 @@
ENABLE_WEBGL2 = ENABLE_WEBGL2;
ENABLE_WEBGPU = $(ENABLE_WEBGPU_$(WK_PLATFORM_NAME));
-ENABLE_WEBGPU_iphoneos = ENABLE_WEBGPU;
+ENABLE_WEBGPU_iphoneos = $(ENABLE_WEBGPU$(WK_IOS_1100));
+ENABLE_WEBGPU_IOS_SINCE_1100 = ENABLE_WEBGPU;
ENABLE_WEBGPU_watchos = ENABLE_WEBGPU;
ENABLE_WEBGPU_appletvos = ENABLE_WEBGPU;
-ENABLE_WEBGPU_macosx = ENABLE_WEBGPU;
+ENABLE_WEBGPU_macosx = $(ENABLE_WEBGPU$(WK_MACOS_1013));
+ENABLE_WEBGPU_MACOS_SINCE_1013 = ENABLE_WEBGPU;
ENABLE_WEBMETAL = $(ENABLE_WEBMETAL_$(WK_PLATFORM_NAME));
ENABLE_WEBMETAL_iphoneos = ENABLE_WEBMETAL;
Modified: trunk/Source/WebKitLegacy/mac/Configurations/FeatureDefines.xcconfig (239494 => 239495)
--- trunk/Source/WebKitLegacy/mac/Configurations/FeatureDefines.xcconfig 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Source/WebKitLegacy/mac/Configurations/FeatureDefines.xcconfig 2018-12-21 03:04:52 UTC (rev 239495)
@@ -373,10 +373,12 @@
ENABLE_WEBGL2 = ENABLE_WEBGL2;
ENABLE_WEBGPU = $(ENABLE_WEBGPU_$(WK_PLATFORM_NAME));
-ENABLE_WEBGPU_iphoneos = ENABLE_WEBGPU;
+ENABLE_WEBGPU_iphoneos = $(ENABLE_WEBGPU$(WK_IOS_1100));
+ENABLE_WEBGPU_IOS_SINCE_1100 = ENABLE_WEBGPU;
ENABLE_WEBGPU_watchos = ENABLE_WEBGPU;
ENABLE_WEBGPU_appletvos = ENABLE_WEBGPU;
-ENABLE_WEBGPU_macosx = ENABLE_WEBGPU;
+ENABLE_WEBGPU_macosx = $(ENABLE_WEBGPU$(WK_MACOS_1013));
+ENABLE_WEBGPU_MACOS_SINCE_1013 = ENABLE_WEBGPU;
ENABLE_WEBMETAL = $(ENABLE_WEBMETAL_$(WK_PLATFORM_NAME));
ENABLE_WEBMETAL_iphoneos = ENABLE_WEBMETAL;
Modified: trunk/Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig (239494 => 239495)
--- trunk/Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig 2018-12-21 02:57:27 UTC (rev 239494)
+++ trunk/Tools/TestWebKitAPI/Configurations/FeatureDefines.xcconfig 2018-12-21 03:04:52 UTC (rev 239495)
@@ -373,10 +373,12 @@
ENABLE_WEBGL2 = ENABLE_WEBGL2;
ENABLE_WEBGPU = $(ENABLE_WEBGPU_$(WK_PLATFORM_NAME));
-ENABLE_WEBGPU_iphoneos = ENABLE_WEBGPU;
+ENABLE_WEBGPU_iphoneos = $(ENABLE_WEBGPU$(WK_IOS_1100));
+ENABLE_WEBGPU_IOS_SINCE_1100 = ENABLE_WEBGPU;
ENABLE_WEBGPU_watchos = ENABLE_WEBGPU;
ENABLE_WEBGPU_appletvos = ENABLE_WEBGPU;
-ENABLE_WEBGPU_macosx = ENABLE_WEBGPU;
+ENABLE_WEBGPU_macosx = $(ENABLE_WEBGPU$(WK_MACOS_1013));
+ENABLE_WEBGPU_MACOS_SINCE_1013 = ENABLE_WEBGPU;
ENABLE_WEBMETAL = $(ENABLE_WEBMETAL_$(WK_PLATFORM_NAME));
ENABLE_WEBMETAL_iphoneos = ENABLE_WEBMETAL;