Diff
Modified: trunk/Source/WebCore/ChangeLog (213683 => 213684)
--- trunk/Source/WebCore/ChangeLog 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Source/WebCore/ChangeLog 2017-03-10 00:00:41 UTC (rev 213684)
@@ -1,3 +1,34 @@
+2017-03-09 Dean Jackson <[email protected]>
+
+ WebGPU: Backend - Buffers
+ https://bugs.webkit.org/show_bug.cgi?id=169451
+ <rdar://problem/30959168>
+
+ Reviewed by Tim Horton.
+
+ Implement the backend for GPUBuffer, which
+ represents a chunk of memory that can be used
+ by the GPU. You create one using an ArrayBufferView.
+
+ WebKit API Test: GPUBuffer.mm
+
+ * PlatformMac.cmake:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/cocoa/GPUBufferMetal.mm:
+ (WebCore::GPUBuffer::GPUBuffer):
+ (WebCore::GPUBuffer::length):
+ (WebCore::GPUBuffer::contents):
+ (WebCore::GPUBuffer::platformBuffer):
+ * platform/graphics/gpu/GPUBuffer.cpp:
+ (WebCore::GPUBuffer::create):
+ (WebCore::GPUBuffer::~GPUBuffer):
+ (WebCore::GPUBuffer::length):
+ (WebCore::GPUBuffer::contents):
+ * platform/graphics/gpu/GPUBuffer.h:
+ * platform/graphics/gpu/GPUDevice.cpp:
+ (WebCore::GPUDevice::createBufferFromData):
+ * platform/graphics/gpu/GPUDevice.h:
+
2017-03-09 Joseph Pecoraro <[email protected]>
Web Inspector: Show HTTP protocol version and other Network Load Metrics (IP Address, Priority, Connection ID)
Modified: trunk/Source/WebCore/PlatformMac.cmake (213683 => 213684)
--- trunk/Source/WebCore/PlatformMac.cmake 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Source/WebCore/PlatformMac.cmake 2017-03-10 00:00:41 UTC (rev 213684)
@@ -419,6 +419,7 @@
platform/graphics/cg/SubimageCacheWithTimer.cpp
platform/graphics/cg/TransformationMatrixCG.cpp
+ platform/graphics/cocoa/GPUBufferMetal.mm
platform/graphics/cocoa/GPUDeviceMetal.mm
platform/graphics/cocoa/GPUFunctionMetal.mm
platform/graphics/cocoa/GPULibraryMetal.mm
@@ -435,6 +436,7 @@
platform/graphics/cv/TextureCacheCV.mm
platform/graphics/cv/VideoTextureCopierCV.cpp
+ platform/graphics/gpu/GPUBuffer.cpp
platform/graphics/gpu/GPUDevice.cpp
platform/graphics/gpu/GPUFunction.cpp
platform/graphics/gpu/GPULibrary.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (213683 => 213684)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-03-10 00:00:41 UTC (rev 213684)
@@ -1371,6 +1371,9 @@
316BDB9A1E70CBBF00DE0D5A /* GPULibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDB981E70CBBF00DE0D5A /* GPULibrary.cpp */; };
316BDB9B1E70CBBF00DE0D5A /* GPULibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDB991E70CBBF00DE0D5A /* GPULibrary.h */; settings = {ATTRIBUTES = (Private, ); }; };
316BDB9E1E70CD9000DE0D5A /* GPULibraryMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */; };
+ 316BDBA61E71FA6F00DE0D5A /* GPUBufferMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA51E71FA6F00DE0D5A /* GPUBufferMetal.mm */; };
+ 316BDBA91E71FA9300DE0D5A /* GPUBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */; };
+ 316BDBAA1E71FA9300DE0D5A /* GPUBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
316FE0710E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */; };
316FE0720E6CCBEE00BF6088 /* JSCSSKeyframeRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */; };
316FE0730E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06F0E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp */; };
@@ -8733,6 +8736,9 @@
316BDB981E70CBBF00DE0D5A /* GPULibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPULibrary.cpp; sourceTree = "<group>"; };
316BDB991E70CBBF00DE0D5A /* GPULibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPULibrary.h; sourceTree = "<group>"; };
316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPULibraryMetal.mm; sourceTree = "<group>"; };
+ 316BDBA51E71FA6F00DE0D5A /* GPUBufferMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUBufferMetal.mm; sourceTree = "<group>"; };
+ 316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUBuffer.cpp; sourceTree = "<group>"; };
+ 316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUBuffer.h; sourceTree = "<group>"; };
316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSKeyframeRule.cpp; sourceTree = "<group>"; };
316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSKeyframeRule.h; sourceTree = "<group>"; };
316FE06F0E6CCBEE00BF6088 /* JSCSSKeyframesRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSKeyframesRule.cpp; sourceTree = "<group>"; };
@@ -17549,6 +17555,8 @@
498770C11242C50D002226BA /* gpu */ = {
isa = PBXGroup;
children = (
+ 316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */,
+ 316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */,
316BDB841E6E0A2100DE0D5A /* GPUDevice.cpp */,
316BDB851E6E0A2100DE0D5A /* GPUDevice.h */,
316BDB921E70C89700DE0D5A /* GPUFunction.cpp */,
@@ -22646,6 +22654,7 @@
B2AFFC780D00A5C10030074D /* FontCascadeCocoa.mm */,
7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
+ 316BDBA51E71FA6F00DE0D5A /* GPUBufferMetal.mm */,
316BDB881E6E141C00DE0D5A /* GPUDeviceMetal.mm */,
316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */,
316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */,
@@ -27920,6 +27929,7 @@
0885068011DA045B00182B98 /* PaintPhase.h in Headers */,
A80E6CFB0A1989CA007FB8C5 /* Pair.h in Headers */,
FD3160A312B026F700C1A359 /* Panner.h in Headers */,
+ 316BDBAA1E71FA9300DE0D5A /* GPUBuffer.h in Headers */,
FD31601A12B0267600C1A359 /* PannerNode.h in Headers */,
A18890AF1AA13F250026C301 /* ParentalControlsContentFilter.h in Headers */,
CDCD41E81C3DDB0A00965D99 /* ParsedContentRange.h in Headers */,
@@ -30706,6 +30716,7 @@
7C6579F11E00856600E3A27A /* JSApplePayPaymentRequest.cpp in Sources */,
1AE96A8E1D1A0DDD00B86768 /* JSApplePaySession.cpp in Sources */,
1AE96A901D1A0DDD00B86768 /* JSApplePayShippingContactSelectedEvent.cpp in Sources */,
+ 316BDBA61E71FA6F00DE0D5A /* GPUBufferMetal.mm in Sources */,
7C6579F31E00856600E3A27A /* JSApplePayShippingMethod.cpp in Sources */,
1AE96A921D1A0DDD00B86768 /* JSApplePayShippingMethodSelectedEvent.cpp in Sources */,
1AE96A941D1A0DDD00B86768 /* JSApplePayValidateMerchantEvent.cpp in Sources */,
@@ -31318,6 +31329,7 @@
B2FA3DF80AB75A6F000E5AC4 /* JSSVGStringList.cpp in Sources */,
B2FA3DFA0AB75A6F000E5AC4 /* JSSVGStyleElement.cpp in Sources */,
B2FA3DFC0AB75A6F000E5AC4 /* JSSVGSVGElement.cpp in Sources */,
+ 316BDBA91E71FA9300DE0D5A /* GPUBuffer.cpp in Sources */,
B2FA3DFE0AB75A6F000E5AC4 /* JSSVGSwitchElement.cpp in Sources */,
B2FA3E000AB75A6F000E5AC4 /* JSSVGSymbolElement.cpp in Sources */,
B2FA3E020AB75A6F000E5AC4 /* JSSVGTextContentElement.cpp in Sources */,
Copied: trunk/Source/WebCore/platform/graphics/cocoa/GPUBufferMetal.mm (from rev 213683, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213684)
--- trunk/Source/WebCore/platform/graphics/cocoa/GPUBufferMetal.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GPUBufferMetal.mm 2017-03-10 00:00:41 UTC (rev 213684)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GPUBuffer.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUDevice.h"
+#import "Logging.h"
+
+#import <Metal/Metal.h>
+
+namespace WebCore {
+
+GPUBuffer::GPUBuffer(GPUDevice* device, ArrayBufferView* data)
+{
+ LOG(WebGPU, "GPUBuffer::GPUBuffer()");
+
+ if (!device || !device->platformDevice() || !data)
+ return;
+
+ m_buffer = (MTLBuffer*)[device->platformDevice() newBufferWithBytes:data->baseAddress() length:data->byteLength() options:MTLResourceOptionCPUCacheModeDefault];
+}
+
+unsigned long GPUBuffer::length() const
+{
+ if (!m_buffer)
+ return 0;
+
+ return [m_buffer length];
+}
+
+RefPtr<ArrayBuffer> GPUBuffer::contents()
+{
+ if (m_contents)
+ return m_contents;
+
+ if (!m_buffer)
+ return nullptr;
+
+ m_contents = ArrayBuffer::createFromBytes([m_buffer contents], [m_buffer length], [] (void*) { });
+ return m_contents;
+}
+
+MTLBuffer* GPUBuffer::platformBuffer()
+{
+ return m_buffer.get();
+}
+
+} // namespace WebCore
+
+#endif
Modified: trunk/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm (213683 => 213684)
--- trunk/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm 2017-03-10 00:00:41 UTC (rev 213684)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.cpp (from rev 213683, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213684)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.cpp 2017-03-10 00:00:41 UTC (rev 213684)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "GPUBuffer.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUDevice.h"
+#import "Logging.h"
+
+namespace WebCore {
+
+RefPtr<GPUBuffer> GPUBuffer::create(GPUDevice* device, ArrayBufferView* arrayBuffer)
+{
+ RefPtr<GPUBuffer> buffer = adoptRef(new GPUBuffer(device, arrayBuffer));
+ return buffer;
+}
+
+GPUBuffer::~GPUBuffer()
+{
+ LOG(WebGPU, "GPUBuffer::~GPUBuffer()");
+}
+
+#if !PLATFORM(COCOA)
+unsigned long GPUBuffer::length() const
+{
+ return 0;
+}
+
+RefPtr<ArrayBuffer> GPUBuffer::contents()
+{
+ if (m_contents)
+ return m_contents;
+
+ m_contents = ArrayBuffer::create(0, 1);
+ return m_contents;
+}
+#endif
+
+} // namespace WebCore
+
+#endif
Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h (from rev 213683, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213684)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h 2017-03-10 00:00:41 UTC (rev 213684)
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBGPU)
+
+#include <runtime/ArrayBufferView.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+
+#if PLATFORM(COCOA)
+OBJC_CLASS MTLBuffer;
+#endif
+
+namespace WebCore {
+
+class GPUDevice;
+
+class GPUBuffer : public RefCounted<GPUBuffer> {
+public:
+ static RefPtr<GPUBuffer> create(GPUDevice*, ArrayBufferView*);
+ WEBCORE_EXPORT ~GPUBuffer();
+
+ WEBCORE_EXPORT unsigned long length() const;
+ WEBCORE_EXPORT RefPtr<ArrayBuffer> contents();
+
+#if PLATFORM(COCOA)
+ WEBCORE_EXPORT MTLBuffer* platformBuffer();
+#endif
+
+private:
+ GPUBuffer(GPUDevice*, ArrayBufferView*);
+
+#if PLATFORM(COCOA)
+ RetainPtr<MTLBuffer> m_buffer;
+#endif
+ RefPtr<ArrayBuffer> m_contents;
+};
+
+} // namespace WebCore
+#endif
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp (213683 => 213684)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp 2017-03-10 00:00:41 UTC (rev 213684)
@@ -28,6 +28,7 @@
#if ENABLE(WEBGPU)
+#include "GPUBuffer.h"
#include "GPULibrary.h"
#include "Logging.h"
@@ -58,6 +59,11 @@
return GPULibrary::create(this, sourceCode);
}
+RefPtr<GPUBuffer> GPUDevice::createBufferFromData(ArrayBufferView* data)
+{
+ return GPUBuffer::create(this, data);
+}
+
#if !PLATFORM(COCOA)
GPUDevice::GPUDevice()
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h (213683 => 213684)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h 2017-03-10 00:00:41 UTC (rev 213684)
@@ -46,6 +46,7 @@
namespace WebCore {
+class GPUBuffer;
class GPULibrary;
class GPUDevice : public RefCounted<GPUDevice> {
@@ -63,6 +64,7 @@
WebGPULayer* layer() { return m_layer.get(); }
WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode);
+ WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data);
private:
GPUDevice();
Modified: trunk/Tools/ChangeLog (213683 => 213684)
--- trunk/Tools/ChangeLog 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Tools/ChangeLog 2017-03-10 00:00:41 UTC (rev 213684)
@@ -1,3 +1,19 @@
+2017-03-09 Dean Jackson <[email protected]>
+
+ WebGPU: Backend - Buffers
+ https://bugs.webkit.org/show_bug.cgi?id=169451
+ <rdar://problem/30959168>
+
+ Reviewed by Tim Horton.
+
+ Test for GPUBuffer object.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm: Added.
+ (TestWebKitAPI::TEST_F):
+ * TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm:
+ * TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm:
+
2017-03-09 Daniel Bates <[email protected]>
Guard Credential Management implementation behind a runtime enabled feature flag
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (213683 => 213684)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-03-10 00:00:41 UTC (rev 213684)
@@ -96,6 +96,7 @@
3162AE9C1E6F2FF5000E4DBC /* GPUDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3162AE9B1E6F2FCE000E4DBC /* GPUDevice.mm */; };
316BDBA11E70D71B00DE0D5A /* GPULibrary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA01E70D6D800DE0D5A /* GPULibrary.mm */; };
316BDBA41E70EF6800DE0D5A /* GPUFunction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA31E70EF5D00DE0D5A /* GPUFunction.mm */; };
+ 316BDBAC1E7207F100DE0D5A /* GPUBuffer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBAB1E7207F100DE0D5A /* GPUBuffer.mm */; };
33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; };
33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33DC890E1419539300747EF7 /* simple-iframe.html */; };
33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; };
@@ -953,6 +954,7 @@
316BDBA01E70D6D800DE0D5A /* GPULibrary.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPULibrary.mm; sourceTree = "<group>"; };
316BDBA21E70DEE500DE0D5A /* GPUTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUTest.h; sourceTree = "<group>"; };
316BDBA31E70EF5D00DE0D5A /* GPUFunction.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUFunction.mm; sourceTree = "<group>"; };
+ 316BDBAB1E7207F100DE0D5A /* GPUBuffer.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = GPUBuffer.mm; sourceTree = "<group>"; };
333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; };
33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash.cpp; sourceTree = "<group>"; };
33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash_Bundle.cpp; sourceTree = "<group>"; };
@@ -1670,6 +1672,7 @@
3162AE9A1E6F2F8F000E4DBC /* mac */ = {
isa = PBXGroup;
children = (
+ 316BDBAB1E7207F100DE0D5A /* GPUBuffer.mm */,
3162AE9B1E6F2FCE000E4DBC /* GPUDevice.mm */,
316BDBA31E70EF5D00DE0D5A /* GPUFunction.mm */,
316BDBA01E70D6D800DE0D5A /* GPULibrary.mm */,
@@ -2798,6 +2801,7 @@
0F139E781A423A6B00F590F5 /* PlatformUtilitiesCocoa.mm in Sources */,
7CCE7EA61A411A0F00447C4C /* PlatformUtilitiesMac.mm in Sources */,
7CCE7EA71A411A1300447C4C /* PlatformWebViewMac.mm in Sources */,
+ 316BDBAC1E7207F100DE0D5A /* GPUBuffer.mm in Sources */,
7CCE7F261A411AF600447C4C /* Preferences.mm in Sources */,
7A909A821D877480007E10F8 /* IntRect.cpp in Sources */,
7CCE7F0B1A411AE600447C4C /* PreventEmptyUserAgent.cpp in Sources */,
Copied: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm (from rev 213683, trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm) (0 => 213684)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm 2017-03-10 00:00:41 UTC (rev 213684)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUTest.h"
+#import <_javascript_Core/ArrayBuffer.h>
+#import <_javascript_Core/ArrayBufferView.h>
+#import <_javascript_Core/GenericTypedArrayViewInlines.h>
+#import <_javascript_Core/JSCInlines.h>
+#import <_javascript_Core/JSGenericTypedArrayViewInlines.h>
+#import <_javascript_Core/TypedArrays.h>
+#import <Metal/Metal.h>
+#import <WebCore/GPUBuffer.h>
+#import <WebCore/GPUDevice.h>
+
+using namespace WebCore;
+
+namespace TestWebKitAPI {
+
+TEST_F(GPU, BufferCreate)
+{
+ auto device = GPUDevice::create();
+ // Not all hardware supports Metal, so it is possible
+ // that we were unable to create the MTLDevice object.
+ // In that case, the device should be null.
+ if (!device)
+ return;
+
+ id<MTLDevice> mtlDevice = (id<MTLDevice>)device->platformDevice();
+ EXPECT_NOT_NULL(mtlDevice);
+
+ auto bufferView = JSC::Uint8Array::create(1024);
+
+ uint8_t* data = ""
+ memset(data, 1, bufferView->byteLength());
+
+ auto buffer = device->createBufferFromData(bufferView.get());
+ EXPECT_NOT_NULL(buffer);
+ EXPECT_EQ(buffer->length(), static_cast<unsigned long>(1024));
+
+ auto contents = buffer->contents();
+ EXPECT_NOT_NULL(contents);
+ EXPECT_EQ(contents->byteLength(), static_cast<unsigned long>(1024));
+
+ uint8_t* contentsData = static_cast<uint8_t*>(contents->data());
+ EXPECT_NE(contentsData, data);
+ EXPECT_EQ(contentsData[0], 1);
+ EXPECT_EQ(contentsData[512], 1);
+ EXPECT_EQ(contentsData[1023], 1);
+
+ MTLBuffer *mtlBuffer = buffer->platformBuffer();
+ EXPECT_NOT_NULL(mtlBuffer);
+
+
+}
+
+} // namespace TestWebKitAPI
+
+#endif
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm (213683 => 213684)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm 2017-03-10 00:00:41 UTC (rev 213684)
@@ -33,7 +33,6 @@
#import <WebCore/GPUDevice.h>
#import <WebCore/GPUFunction.h>
#import <WebCore/GPULibrary.h>
-#import <wtf/MainThread.h>
using namespace WebCore;
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm (213683 => 213684)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm 2017-03-09 23:58:02 UTC (rev 213683)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm 2017-03-10 00:00:41 UTC (rev 213684)
@@ -31,7 +31,6 @@
#import <Metal/Metal.h>
#import <WebCore/GPUDevice.h>
#import <WebCore/GPULibrary.h>
-#import <wtf/MainThread.h>
using namespace WebCore;