Title: [213731] trunk/Source/WebCore
Revision
213731
Author
d...@apple.com
Date
2017-03-10 14:56:06 -0800 (Fri, 10 Mar 2017)

Log Message

WebGPU: Backend - Textures and TextureDescriptors
https://bugs.webkit.org/show_bug.cgi?id=169365
<rdar://problem/30928716>

Reviewed by Jon Lee with help from Anders Carlsson.

Backend implementation of textures for WebGPU, which adds
the GPUTexture and GPUTextureDescriptor classes, as well
as a creation method on GPUDevice.

* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
* platform/graphics/cocoa/GPUTextureDescriptorMetal.mm: Added.
(WebCore::GPUTextureDescriptor::GPUTextureDescriptor):
(WebCore::GPUTextureDescriptor::width):
(WebCore::GPUTextureDescriptor::setWidth):
(WebCore::GPUTextureDescriptor::height):
(WebCore::GPUTextureDescriptor::setHeight):
(WebCore::GPUTextureDescriptor::sampleCount):
(WebCore::GPUTextureDescriptor::setSampleCount):
(WebCore::GPUTextureDescriptor::textureType):
(WebCore::GPUTextureDescriptor::setTextureType):
(WebCore::GPUTextureDescriptor::storageMode):
(WebCore::GPUTextureDescriptor::setStorageMode):
(WebCore::GPUTextureDescriptor::usage):
(WebCore::GPUTextureDescriptor::setUsage):
(WebCore::GPUTextureDescriptor::platformTextureDescriptor):
* platform/graphics/cocoa/GPUTextureMetal.mm:
(WebCore::GPUTexture::GPUTexture):
(WebCore::GPUTexture::width):
(WebCore::GPUTexture::height):
(WebCore::GPUTexture::platformTexture):
* platform/graphics/gpu/GPUDevice.cpp:
(WebCore::GPUDevice::createTexture):
* platform/graphics/gpu/GPUDevice.h:
* platform/graphics/gpu/GPUTexture.cpp:
(WebCore::GPUTexture::create):
(WebCore::GPUTexture::createFromExistingTexture):
(WebCore::GPUTexture::~GPUTexture):
(WebCore::GPUTexture::width):
(WebCore::GPUTexture::height):
* platform/graphics/gpu/GPUTexture.h:
* platform/graphics/gpu/GPUTextureDescriptor.cpp:
(WebCore::GPUTextureDescriptor::create):
(WebCore::GPUTextureDescriptor::~GPUTextureDescriptor):
(WebCore::GPUTextureDescriptor::width):
(WebCore::GPUTextureDescriptor::setWidth):
(WebCore::GPUTextureDescriptor::height):
(WebCore::GPUTextureDescriptor::setHeight):
(WebCore::GPUTextureDescriptor::sampleCount):
(WebCore::GPUTextureDescriptor::setSampleCount):
(WebCore::GPUTextureDescriptor::textureType):
(WebCore::GPUTextureDescriptor::setTextureType):
(WebCore::GPUTextureDescriptor::storageMode):
(WebCore::GPUTextureDescriptor::setStorageMode):
(WebCore::GPUTextureDescriptor::usage):
(WebCore::GPUTextureDescriptor::setUsage):
* platform/graphics/gpu/GPUTextureDescriptor.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (213730 => 213731)


--- trunk/Source/WebCore/ChangeLog	2017-03-10 22:43:01 UTC (rev 213730)
+++ trunk/Source/WebCore/ChangeLog	2017-03-10 22:56:06 UTC (rev 213731)
@@ -1,3 +1,64 @@
+2017-03-10  Dean Jackson  <d...@apple.com>
+
+        WebGPU: Backend - Textures and TextureDescriptors
+        https://bugs.webkit.org/show_bug.cgi?id=169365
+        <rdar://problem/30928716>
+
+        Reviewed by Jon Lee with help from Anders Carlsson.
+
+        Backend implementation of textures for WebGPU, which adds
+        the GPUTexture and GPUTextureDescriptor classes, as well
+        as a creation method on GPUDevice.
+
+        * PlatformMac.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/graphics/cocoa/GPUTextureDescriptorMetal.mm: Added.
+        (WebCore::GPUTextureDescriptor::GPUTextureDescriptor):
+        (WebCore::GPUTextureDescriptor::width):
+        (WebCore::GPUTextureDescriptor::setWidth):
+        (WebCore::GPUTextureDescriptor::height):
+        (WebCore::GPUTextureDescriptor::setHeight):
+        (WebCore::GPUTextureDescriptor::sampleCount):
+        (WebCore::GPUTextureDescriptor::setSampleCount):
+        (WebCore::GPUTextureDescriptor::textureType):
+        (WebCore::GPUTextureDescriptor::setTextureType):
+        (WebCore::GPUTextureDescriptor::storageMode):
+        (WebCore::GPUTextureDescriptor::setStorageMode):
+        (WebCore::GPUTextureDescriptor::usage):
+        (WebCore::GPUTextureDescriptor::setUsage):
+        (WebCore::GPUTextureDescriptor::platformTextureDescriptor):
+        * platform/graphics/cocoa/GPUTextureMetal.mm:
+        (WebCore::GPUTexture::GPUTexture):
+        (WebCore::GPUTexture::width):
+        (WebCore::GPUTexture::height):
+        (WebCore::GPUTexture::platformTexture):
+        * platform/graphics/gpu/GPUDevice.cpp:
+        (WebCore::GPUDevice::createTexture):
+        * platform/graphics/gpu/GPUDevice.h:
+        * platform/graphics/gpu/GPUTexture.cpp:
+        (WebCore::GPUTexture::create):
+        (WebCore::GPUTexture::createFromExistingTexture):
+        (WebCore::GPUTexture::~GPUTexture):
+        (WebCore::GPUTexture::width):
+        (WebCore::GPUTexture::height):
+        * platform/graphics/gpu/GPUTexture.h:
+        * platform/graphics/gpu/GPUTextureDescriptor.cpp:
+        (WebCore::GPUTextureDescriptor::create):
+        (WebCore::GPUTextureDescriptor::~GPUTextureDescriptor):
+        (WebCore::GPUTextureDescriptor::width):
+        (WebCore::GPUTextureDescriptor::setWidth):
+        (WebCore::GPUTextureDescriptor::height):
+        (WebCore::GPUTextureDescriptor::setHeight):
+        (WebCore::GPUTextureDescriptor::sampleCount):
+        (WebCore::GPUTextureDescriptor::setSampleCount):
+        (WebCore::GPUTextureDescriptor::textureType):
+        (WebCore::GPUTextureDescriptor::setTextureType):
+        (WebCore::GPUTextureDescriptor::storageMode):
+        (WebCore::GPUTextureDescriptor::setStorageMode):
+        (WebCore::GPUTextureDescriptor::usage):
+        (WebCore::GPUTextureDescriptor::setUsage):
+        * platform/graphics/gpu/GPUTextureDescriptor.h:
+
 2017-03-10  Per Arne Vollan  <pvol...@apple.com>
 
         [Win] Scrollbars buttons have incorrect size in HiDPI.

Modified: trunk/Source/WebCore/PlatformMac.cmake (213730 => 213731)


--- trunk/Source/WebCore/PlatformMac.cmake	2017-03-10 22:43:01 UTC (rev 213730)
+++ trunk/Source/WebCore/PlatformMac.cmake	2017-03-10 22:56:06 UTC (rev 213731)
@@ -427,6 +427,8 @@
     platform/graphics/cocoa/GPUDeviceMetal.mm
     platform/graphics/cocoa/GPUFunctionMetal.mm
     platform/graphics/cocoa/GPULibraryMetal.mm
+    platform/graphics/cocoa/GPUTextureDescriptorMetal.mm
+    platform/graphics/cocoa/GPUTextureMetal.mm
     platform/graphics/cocoa/FontCacheCoreText.cpp
     platform/graphics/cocoa/FontCascadeCocoa.mm
     platform/graphics/cocoa/FontCocoa.mm
@@ -445,6 +447,8 @@
     platform/graphics/gpu/GPUDevice.cpp
     platform/graphics/gpu/GPUFunction.cpp
     platform/graphics/gpu/GPULibrary.cpp
+    platform/graphics/gpu/GPUTexture.cpp
+    platform/graphics/gpu/GPUTextureDescriptor.cpp
 
     platform/graphics/mac/ColorMac.mm
     platform/graphics/mac/ComplexTextControllerCoreText.mm

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (213730 => 213731)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-03-10 22:43:01 UTC (rev 213730)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-03-10 22:56:06 UTC (rev 213731)
@@ -1374,6 +1374,12 @@
 		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, ); }; };
+		316BDBAE1E73549C00DE0D5A /* GPUTextureMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */; };
+		316BDBB11E7354BB00DE0D5A /* GPUTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBAF1E7354BB00DE0D5A /* GPUTexture.cpp */; };
+		316BDBB21E7354BB00DE0D5A /* GPUTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB01E7354BB00DE0D5A /* GPUTexture.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		316BDBB41E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */; };
+		316BDBB71E7357CB00DE0D5A /* GPUTextureDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBB51E7357CB00DE0D5A /* GPUTextureDescriptor.cpp */; };
+		316BDBB81E7357CB00DE0D5A /* GPUTextureDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.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 */; };
@@ -8739,6 +8745,12 @@
 		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>"; };
+		316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUTextureMetal.mm; sourceTree = "<group>"; };
+		316BDBAF1E7354BB00DE0D5A /* GPUTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUTexture.cpp; sourceTree = "<group>"; };
+		316BDBB01E7354BB00DE0D5A /* GPUTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUTexture.h; sourceTree = "<group>"; };
+		316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUTextureDescriptorMetal.mm; sourceTree = "<group>"; };
+		316BDBB51E7357CB00DE0D5A /* GPUTextureDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUTextureDescriptor.cpp; sourceTree = "<group>"; };
+		316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUTextureDescriptor.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>"; };
@@ -17563,6 +17575,10 @@
 				316BDB931E70C89700DE0D5A /* GPUFunction.h */,
 				316BDB981E70CBBF00DE0D5A /* GPULibrary.cpp */,
 				316BDB991E70CBBF00DE0D5A /* GPULibrary.h */,
+				316BDBB51E7357CB00DE0D5A /* GPUTextureDescriptor.cpp */,
+				316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */,
+				316BDBAF1E7354BB00DE0D5A /* GPUTexture.cpp */,
+				316BDBB01E7354BB00DE0D5A /* GPUTexture.h */,
 				498770D71242C535002226BA /* Texture.cpp */,
 				498770D81242C535002226BA /* Texture.h */,
 				498770D91242C535002226BA /* TilingData.cpp */,
@@ -22658,6 +22674,8 @@
 				316BDB881E6E141C00DE0D5A /* GPUDeviceMetal.mm */,
 				316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */,
 				316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */,
+				316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */,
+				316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */,
 				2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */,
 				2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
 				AD9FF6E01908391D003B61E0 /* IOSurfacePoolCocoa.mm */,
@@ -28577,6 +28595,7 @@
 				BC2272BD0E82EAAE00E7F975 /* StyleRareNonInheritedData.h in Headers */,
 				BC2272870E82E70700E7F975 /* StyleReflection.h in Headers */,
 				E461802D1C8DD2900026C02C /* StyleRelations.h in Headers */,
+				316BDBB81E7357CB00DE0D5A /* GPUTextureDescriptor.h in Headers */,
 				5750A9751E68D00000705C4A /* CryptoKeyEC.h in Headers */,
 				E4D58EB517B4DBDC00CBDCA8 /* StyleResolveForDocument.h in Headers */,
 				E139866415478474001E3F65 /* StyleResolver.h in Headers */,
@@ -29289,6 +29308,7 @@
 				93F199ED08245E59001E9ABC /* XSLTProcessor.h in Headers */,
 				E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
 				977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
+				316BDBB21E7354BB00DE0D5A /* GPUTexture.h in Headers */,
 				977E2E0F12F0FC9C00C13380 /* XSSAuditorDelegate.h in Headers */,
 				A5416FE618810EF80009FC5F /* YouTubeEmbedShadowElement.h in Headers */,
 				7A5515F5191830A3009687D2 /* YouTubePluginReplacement.h in Headers */,
@@ -30153,6 +30173,7 @@
 				0F97A658155DA81E00FADD4C /* DisplayRefreshMonitorIOS.mm in Sources */,
 				49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */,
 				2D29ECC7192ECC8300984B78 /* DisplayRefreshMonitorManager.cpp in Sources */,
+				316BDBAE1E73549C00DE0D5A /* GPUTextureMetal.mm in Sources */,
 				CD52481A18E200ED0008A07D /* DisplaySleepDisabler.cpp in Sources */,
 				5D8C4DBF1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp in Sources */,
 				FD31609012B026F700C1A359 /* Distance.cpp in Sources */,
@@ -30678,6 +30699,7 @@
 				7C522D4B15B477E8009B7C95 /* InspectorOverlay.cpp in Sources */,
 				4F6FDD641341DEDD001F8EE3 /* InspectorPageAgent.cpp in Sources */,
 				99CC0B6618BE9F15006CEBCC /* InspectorReplayAgent.cpp in Sources */,
+				316BDBB41E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm in Sources */,
 				82AB1773125C826700C5069D /* InspectorStyleSheet.cpp in Sources */,
 				754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */,
 				A54A0C5D1DB6D9C00017A90B /* InspectorWorkerAgent.cpp in Sources */,
@@ -31865,6 +31887,7 @@
 				1AF8E13312565A4400230FF7 /* ProxyServer.cpp in Sources */,
 				1AF8E1C3125673E000230FF7 /* ProxyServerCFNet.cpp in Sources */,
 				FF945ECB161F7F3600971BC8 /* PseudoElement.cpp in Sources */,
+				316BDBB11E7354BB00DE0D5A /* GPUTexture.cpp in Sources */,
 				0081FEFF16B0A2B6008AAA7A /* PublicSuffixMac.mm in Sources */,
 				CDEE393717974259001D7580 /* PublicURLManager.cpp in Sources */,
 				550A0BC9085F6039007353D6 /* QualifiedName.cpp in Sources */,
@@ -32668,6 +32691,7 @@
 				AAA728F816D1D8BC00D3BBC6 /* WebAccessibilityObjectWrapperIOS.mm in Sources */,
 				AA478A8016CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm in Sources */,
 				2D3EF4491917915C00034184 /* WebActionDisablingCALayerDelegate.mm in Sources */,
+				316BDBB71E7357CB00DE0D5A /* GPUTextureDescriptor.cpp in Sources */,
 				120DE3ED1C86CA3E00B6D4DD /* WebAnimation.cpp in Sources */,
 				CDE667A41E4BBF1500E8154A /* WebAudioBufferList.cpp in Sources */,
 				07D637411BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm in Sources */,

Added: trunk/Source/WebCore/platform/graphics/cocoa/GPUTextureDescriptorMetal.mm (0 => 213731)


--- trunk/Source/WebCore/platform/graphics/cocoa/GPUTextureDescriptorMetal.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GPUTextureDescriptorMetal.mm	2017-03-10 22:56:06 UTC (rev 213731)
@@ -0,0 +1,129 @@
+/*
+ * 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 "GPUTextureDescriptor.h"
+
+#if ENABLE(WEBGPU)
+
+#import "Logging.h"
+
+#import <Metal/Metal.h>
+
+namespace WebCore {
+
+GPUTextureDescriptor::GPUTextureDescriptor(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped)
+{
+    LOG(WebGPU, "GPUTextureDescriptor::GPUTextureDescriptor()");
+
+    m_textureDescriptor = (MTLTextureDescriptor*)[MTLTextureDescriptor texture2DDescriptorWithPixelFormat:static_cast<MTLPixelFormat>(pixelFormat) width:width height:height mipmapped:mipmapped];
+}
+
+unsigned long GPUTextureDescriptor::width() const
+{
+    if (!m_textureDescriptor)
+        return 0;
+    return [m_textureDescriptor width];
+}
+
+void GPUTextureDescriptor::setWidth(unsigned long newWidth)
+{
+    ASSERT(m_textureDescriptor);
+    [m_textureDescriptor setWidth:newWidth];
+}
+
+unsigned long GPUTextureDescriptor::height() const
+{
+    if (!m_textureDescriptor)
+        return 0;
+    return [m_textureDescriptor height];
+}
+
+void GPUTextureDescriptor::setHeight(unsigned long newHeight)
+{
+    ASSERT(m_textureDescriptor);
+    [m_textureDescriptor setHeight:newHeight];
+}
+
+unsigned long GPUTextureDescriptor::sampleCount() const
+{
+    if (!m_textureDescriptor)
+        return 0;
+    return [m_textureDescriptor sampleCount];
+}
+
+void GPUTextureDescriptor::setSampleCount(unsigned long newSampleCount)
+{
+    ASSERT(m_textureDescriptor);
+    [m_textureDescriptor setSampleCount:newSampleCount];
+}
+
+unsigned long GPUTextureDescriptor::textureType() const
+{
+    if (!m_textureDescriptor)
+        return 0;
+    return [m_textureDescriptor textureType];
+}
+
+void GPUTextureDescriptor::setTextureType(unsigned long newTextureType)
+{
+    ASSERT(m_textureDescriptor);
+    [m_textureDescriptor setTextureType:static_cast<MTLTextureType>(newTextureType)];
+}
+
+unsigned long GPUTextureDescriptor::storageMode() const
+{
+    if (!m_textureDescriptor)
+        return 0;
+    return [m_textureDescriptor storageMode];
+}
+
+void GPUTextureDescriptor::setStorageMode(unsigned long newStorageMode)
+{
+    ASSERT(m_textureDescriptor);
+    [m_textureDescriptor setStorageMode:static_cast<MTLStorageMode>(newStorageMode)];
+}
+
+unsigned long GPUTextureDescriptor::usage() const
+{
+    if (!m_textureDescriptor)
+        return 0;
+    return [m_textureDescriptor usage];
+}
+
+void GPUTextureDescriptor::setUsage(unsigned long newUsage)
+{
+    ASSERT(m_textureDescriptor);
+    [m_textureDescriptor setUsage:newUsage];
+}
+
+MTLTextureDescriptor* GPUTextureDescriptor::platformTextureDescriptor()
+{
+    return m_textureDescriptor.get();
+}
+
+} // namespace WebCore
+
+#endif

Copied: trunk/Source/WebCore/platform/graphics/cocoa/GPUTextureMetal.mm (from rev 213730, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213731)


--- trunk/Source/WebCore/platform/graphics/cocoa/GPUTextureMetal.mm	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GPUTextureMetal.mm	2017-03-10 22:56:06 UTC (rev 213731)
@@ -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. ``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 "GPUTexture.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUDevice.h"
+#import "GPUTextureDescriptor.h"
+#import "Logging.h"
+
+#import <Metal/Metal.h>
+
+namespace WebCore {
+
+GPUTexture::GPUTexture(GPUDevice* device, GPUTextureDescriptor* descriptor)
+{
+    LOG(WebGPU, "GPUTexture::GPUTexture()");
+
+    if (!device || !device->platformDevice() || !descriptor || !descriptor->platformTextureDescriptor())
+        return;
+
+    m_texture = (MTLTexture*)[device->platformDevice() newTextureWithDescriptor:descriptor->platformTextureDescriptor()];
+}
+
+GPUTexture::GPUTexture(GPUTexture* other)
+{
+    LOG(WebGPU, "GPUTexture::GPUTexture()");
+
+    if (!other || !other->platformTexture())
+        return;
+
+    m_texture = other->platformTexture();
+}
+
+unsigned long GPUTexture::width() const
+{
+    if (!m_texture)
+        return 0;
+
+    id<MTLTexture> texture = static_cast<id<MTLTexture>>(m_texture.get());
+    return texture.width;
+}
+
+unsigned long GPUTexture::height() const
+{
+    if (!m_texture)
+        return 0;
+
+    id<MTLTexture> texture = static_cast<id<MTLTexture>>(m_texture.get());
+    return texture.height;
+}
+
+MTLTexture* GPUTexture::platformTexture()
+{
+    return m_texture.get();
+}
+
+} // namespace WebCore
+
+#endif

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp (213730 => 213731)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp	2017-03-10 22:43:01 UTC (rev 213730)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp	2017-03-10 22:56:06 UTC (rev 213731)
@@ -30,6 +30,8 @@
 
 #include "GPUBuffer.h"
 #include "GPULibrary.h"
+#include "GPUTexture.h"
+#include "GPUTextureDescriptor.h"
 #include "Logging.h"
 
 namespace WebCore {
@@ -64,6 +66,11 @@
     return GPUBuffer::create(this, data);
 }
 
+RefPtr<GPUTexture> GPUDevice::createTexture(GPUTextureDescriptor* descriptor)
+{
+    return GPUTexture::create(this, descriptor);
+}
+
 #if !PLATFORM(COCOA)
 
 GPUDevice::GPUDevice()

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h (213730 => 213731)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h	2017-03-10 22:43:01 UTC (rev 213730)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h	2017-03-10 22:56:06 UTC (rev 213731)
@@ -48,6 +48,8 @@
 
 class GPUBuffer;
 class GPULibrary;
+class GPUTexture;
+class GPUTextureDescriptor;
 
 class GPUDevice : public RefCounted<GPUDevice> {
 public:
@@ -65,6 +67,7 @@
 
     WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode);
     WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data);
+    WEBCORE_EXPORT RefPtr<GPUTexture> createTexture(GPUTextureDescriptor*);
 
 private:
     GPUDevice();

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.cpp (from rev 213730, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213731)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.cpp	2017-03-10 22:56:06 UTC (rev 213731)
@@ -0,0 +1,67 @@
+/*
+ * 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 "GPUTexture.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUDevice.h"
+#import "Logging.h"
+
+namespace WebCore {
+
+RefPtr<GPUTexture> GPUTexture::create(GPUDevice* device, GPUTextureDescriptor* descriptor)
+{
+    RefPtr<GPUTexture> texture = adoptRef(new GPUTexture(device, descriptor));
+    return texture;
+}
+
+RefPtr<GPUTexture> GPUTexture::createFromExistingTexture(GPUTexture* other)
+{
+    RefPtr<GPUTexture> texture = adoptRef(new GPUTexture(other));
+    return texture;
+}
+
+GPUTexture::~GPUTexture()
+{
+    LOG(WebGPU, "GPUTexture::~GPUTexture()");
+}
+
+#if !PLATFORM(COCOA)
+unsigned long GPUTexture::width() const
+{
+    return 0;
+}
+
+unsigned long GPUTexture::height() const
+{
+    return 0;
+}
+#endif
+
+} // namespace WebCore
+
+#endif

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.h (from rev 213730, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h) (0 => 213731)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.h	2017-03-10 22:56:06 UTC (rev 213731)
@@ -0,0 +1,66 @@
+/*
+ * 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 <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+
+#if PLATFORM(COCOA)
+OBJC_CLASS MTLTexture;
+#endif
+
+namespace WebCore {
+
+class GPUDevice;
+class GPUTextureDescriptor;
+
+class GPUTexture : public RefCounted<GPUTexture> {
+public:
+    static RefPtr<GPUTexture> create(GPUDevice*, GPUTextureDescriptor*);
+    static RefPtr<GPUTexture> createFromExistingTexture(GPUTexture*);
+    WEBCORE_EXPORT ~GPUTexture();
+
+    WEBCORE_EXPORT unsigned long width() const;
+    WEBCORE_EXPORT unsigned long height() const;
+
+#if PLATFORM(COCOA)
+    WEBCORE_EXPORT MTLTexture* platformTexture();
+#endif
+
+private:
+    GPUTexture(GPUDevice*, GPUTextureDescriptor*);
+    GPUTexture(GPUTexture*);
+    
+#if PLATFORM(COCOA)
+    RetainPtr<MTLTexture> m_texture;
+#endif
+};
+    
+} // namespace WebCore
+#endif

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.cpp (from rev 213730, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp) (0 => 213731)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.cpp	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.cpp	2017-03-10 22:56:06 UTC (rev 213731)
@@ -0,0 +1,104 @@
+/*
+ * 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 "GPUTextureDescriptor.h"
+
+#if ENABLE(WEBGPU)
+
+#import "Logging.h"
+
+namespace WebCore {
+
+RefPtr<GPUTextureDescriptor> GPUTextureDescriptor::create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped)
+{
+    RefPtr<GPUTextureDescriptor> descriptor = adoptRef(new GPUTextureDescriptor(pixelFormat, width, height, mipmapped));
+    return descriptor;
+}
+
+GPUTextureDescriptor::~GPUTextureDescriptor()
+{
+    LOG(WebGPU, "GPUTextureDescriptor::~GPUTextureDescriptor()");
+}
+
+#if !PLATFORM(COCOA)
+unsigned long GPUTextureDescriptor::width() const
+{
+    return 0;
+}
+
+void GPUTextureDescriptor::setWidth(unsigned long)
+{
+}
+
+unsigned long GPUTextureDescriptor::height() const
+{
+    return 0;
+}
+
+void GPUTextureDescriptor::setHeight(unsigned long)
+{
+}
+
+unsigned long GPUTextureDescriptor::sampleCount() const
+{
+    return 0;
+}
+
+void GPUTextureDescriptor::setSampleCount(unsigned long)
+{
+}
+
+unsigned long GPUTextureDescriptor::textureType() const
+{
+    return 0;
+}
+
+void GPUTextureDescriptor::setTextureType(unsigned long)
+{
+}
+
+unsigned long GPUTextureDescriptor::storageMode() const
+{
+    return 0;
+}
+
+void GPUTextureDescriptor::setStorageMode(unsigned long)
+{
+}
+
+unsigned long GPUTextureDescriptor::usage() const
+{
+    return 0;
+}
+
+void GPUTextureDescriptor::setUsage(unsigned long)
+{
+}
+#endif
+
+} // namespace WebCore
+
+#endif

Copied: trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h (from rev 213730, trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h) (0 => 213731)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h	2017-03-10 22:56:06 UTC (rev 213731)
@@ -0,0 +1,76 @@
+/*
+ * 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 <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
+
+#if PLATFORM(COCOA)
+OBJC_CLASS MTLTextureDescriptor;
+#endif
+
+namespace WebCore {
+
+class GPUTextureDescriptor : public RefCounted<GPUTextureDescriptor> {
+public:
+    static RefPtr<GPUTextureDescriptor> create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped);
+    WEBCORE_EXPORT ~GPUTextureDescriptor();
+
+    WEBCORE_EXPORT unsigned long width() const;
+    WEBCORE_EXPORT void setWidth(unsigned long);
+
+    WEBCORE_EXPORT unsigned long height() const;
+    WEBCORE_EXPORT void setHeight(unsigned long);
+
+    WEBCORE_EXPORT unsigned long sampleCount() const;
+    WEBCORE_EXPORT void setSampleCount(unsigned long);
+
+    WEBCORE_EXPORT unsigned long textureType() const;
+    WEBCORE_EXPORT void setTextureType(unsigned long);
+
+    WEBCORE_EXPORT unsigned long storageMode() const;
+    WEBCORE_EXPORT void setStorageMode(unsigned long);
+
+    WEBCORE_EXPORT unsigned long usage() const;
+    WEBCORE_EXPORT void setUsage(unsigned long);
+
+#if PLATFORM(COCOA)
+    WEBCORE_EXPORT MTLTextureDescriptor* platformTextureDescriptor();
+#endif
+
+private:
+    GPUTextureDescriptor(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped);
+
+#if PLATFORM(COCOA)
+    RetainPtr<MTLTextureDescriptor> m_textureDescriptor;
+#endif
+};
+    
+} // namespace WebCore
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to