Changeset 213731 in webkit


Ignore:
Timestamp:
Mar 10, 2017 2:56:06 PM (7 years ago)
Author:
dino@apple.com
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:
Location:
trunk/Source/WebCore
Files:
1 added
5 edited
5 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r213727 r213731  
     12017-03-10  Dean Jackson  <dino@apple.com>
     2
     3        WebGPU: Backend - Textures and TextureDescriptors
     4        https://bugs.webkit.org/show_bug.cgi?id=169365
     5        <rdar://problem/30928716>
     6
     7        Reviewed by Jon Lee with help from Anders Carlsson.
     8
     9        Backend implementation of textures for WebGPU, which adds
     10        the GPUTexture and GPUTextureDescriptor classes, as well
     11        as a creation method on GPUDevice.
     12
     13        * PlatformMac.cmake:
     14        * WebCore.xcodeproj/project.pbxproj:
     15        * platform/graphics/cocoa/GPUTextureDescriptorMetal.mm: Added.
     16        (WebCore::GPUTextureDescriptor::GPUTextureDescriptor):
     17        (WebCore::GPUTextureDescriptor::width):
     18        (WebCore::GPUTextureDescriptor::setWidth):
     19        (WebCore::GPUTextureDescriptor::height):
     20        (WebCore::GPUTextureDescriptor::setHeight):
     21        (WebCore::GPUTextureDescriptor::sampleCount):
     22        (WebCore::GPUTextureDescriptor::setSampleCount):
     23        (WebCore::GPUTextureDescriptor::textureType):
     24        (WebCore::GPUTextureDescriptor::setTextureType):
     25        (WebCore::GPUTextureDescriptor::storageMode):
     26        (WebCore::GPUTextureDescriptor::setStorageMode):
     27        (WebCore::GPUTextureDescriptor::usage):
     28        (WebCore::GPUTextureDescriptor::setUsage):
     29        (WebCore::GPUTextureDescriptor::platformTextureDescriptor):
     30        * platform/graphics/cocoa/GPUTextureMetal.mm:
     31        (WebCore::GPUTexture::GPUTexture):
     32        (WebCore::GPUTexture::width):
     33        (WebCore::GPUTexture::height):
     34        (WebCore::GPUTexture::platformTexture):
     35        * platform/graphics/gpu/GPUDevice.cpp:
     36        (WebCore::GPUDevice::createTexture):
     37        * platform/graphics/gpu/GPUDevice.h:
     38        * platform/graphics/gpu/GPUTexture.cpp:
     39        (WebCore::GPUTexture::create):
     40        (WebCore::GPUTexture::createFromExistingTexture):
     41        (WebCore::GPUTexture::~GPUTexture):
     42        (WebCore::GPUTexture::width):
     43        (WebCore::GPUTexture::height):
     44        * platform/graphics/gpu/GPUTexture.h:
     45        * platform/graphics/gpu/GPUTextureDescriptor.cpp:
     46        (WebCore::GPUTextureDescriptor::create):
     47        (WebCore::GPUTextureDescriptor::~GPUTextureDescriptor):
     48        (WebCore::GPUTextureDescriptor::width):
     49        (WebCore::GPUTextureDescriptor::setWidth):
     50        (WebCore::GPUTextureDescriptor::height):
     51        (WebCore::GPUTextureDescriptor::setHeight):
     52        (WebCore::GPUTextureDescriptor::sampleCount):
     53        (WebCore::GPUTextureDescriptor::setSampleCount):
     54        (WebCore::GPUTextureDescriptor::textureType):
     55        (WebCore::GPUTextureDescriptor::setTextureType):
     56        (WebCore::GPUTextureDescriptor::storageMode):
     57        (WebCore::GPUTextureDescriptor::setStorageMode):
     58        (WebCore::GPUTextureDescriptor::usage):
     59        (WebCore::GPUTextureDescriptor::setUsage):
     60        * platform/graphics/gpu/GPUTextureDescriptor.h:
     61
    1622017-03-10  Per Arne Vollan  <pvollan@apple.com>
    263
  • trunk/Source/WebCore/PlatformMac.cmake

    r213699 r213731  
    428428    platform/graphics/cocoa/GPUFunctionMetal.mm
    429429    platform/graphics/cocoa/GPULibraryMetal.mm
     430    platform/graphics/cocoa/GPUTextureDescriptorMetal.mm
     431    platform/graphics/cocoa/GPUTextureMetal.mm
    430432    platform/graphics/cocoa/FontCacheCoreText.cpp
    431433    platform/graphics/cocoa/FontCascadeCocoa.mm
     
    446448    platform/graphics/gpu/GPUFunction.cpp
    447449    platform/graphics/gpu/GPULibrary.cpp
     450    platform/graphics/gpu/GPUTexture.cpp
     451    platform/graphics/gpu/GPUTextureDescriptor.cpp
    448452
    449453    platform/graphics/mac/ColorMac.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r213684 r213731  
    13751375                316BDBA91E71FA9300DE0D5A /* GPUBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */; };
    13761376                316BDBAA1E71FA9300DE0D5A /* GPUBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1377                316BDBAE1E73549C00DE0D5A /* GPUTextureMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */; };
     1378                316BDBB11E7354BB00DE0D5A /* GPUTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBAF1E7354BB00DE0D5A /* GPUTexture.cpp */; };
     1379                316BDBB21E7354BB00DE0D5A /* GPUTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB01E7354BB00DE0D5A /* GPUTexture.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1380                316BDBB41E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */; };
     1381                316BDBB71E7357CB00DE0D5A /* GPUTextureDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBB51E7357CB00DE0D5A /* GPUTextureDescriptor.cpp */; };
     1382                316BDBB81E7357CB00DE0D5A /* GPUTextureDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13771383                316FE0710E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */; };
    13781384                316FE0720E6CCBEE00BF6088 /* JSCSSKeyframeRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */; };
     
    87408746                316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUBuffer.cpp; sourceTree = "<group>"; };
    87418747                316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUBuffer.h; sourceTree = "<group>"; };
     8748                316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUTextureMetal.mm; sourceTree = "<group>"; };
     8749                316BDBAF1E7354BB00DE0D5A /* GPUTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUTexture.cpp; sourceTree = "<group>"; };
     8750                316BDBB01E7354BB00DE0D5A /* GPUTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUTexture.h; sourceTree = "<group>"; };
     8751                316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUTextureDescriptorMetal.mm; sourceTree = "<group>"; };
     8752                316BDBB51E7357CB00DE0D5A /* GPUTextureDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUTextureDescriptor.cpp; sourceTree = "<group>"; };
     8753                316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUTextureDescriptor.h; sourceTree = "<group>"; };
    87428754                316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSKeyframeRule.cpp; sourceTree = "<group>"; };
    87438755                316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSKeyframeRule.h; sourceTree = "<group>"; };
     
    1756417576                                316BDB981E70CBBF00DE0D5A /* GPULibrary.cpp */,
    1756517577                                316BDB991E70CBBF00DE0D5A /* GPULibrary.h */,
     17578                                316BDBB51E7357CB00DE0D5A /* GPUTextureDescriptor.cpp */,
     17579                                316BDBB61E7357CB00DE0D5A /* GPUTextureDescriptor.h */,
     17580                                316BDBAF1E7354BB00DE0D5A /* GPUTexture.cpp */,
     17581                                316BDBB01E7354BB00DE0D5A /* GPUTexture.h */,
    1756617582                                498770D71242C535002226BA /* Texture.cpp */,
    1756717583                                498770D81242C535002226BA /* Texture.h */,
     
    2265922675                                316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */,
    2266022676                                316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */,
     22677                                316BDBB31E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm */,
     22678                                316BDBAD1E73549C00DE0D5A /* GPUTextureMetal.mm */,
    2266122679                                2D0B4AA918DA1CCD00434DE1 /* IOSurface.h */,
    2266222680                                2D0B4AAA18DA1CCD00434DE1 /* IOSurface.mm */,
     
    2857828596                                BC2272870E82E70700E7F975 /* StyleReflection.h in Headers */,
    2857928597                                E461802D1C8DD2900026C02C /* StyleRelations.h in Headers */,
     28598                                316BDBB81E7357CB00DE0D5A /* GPUTextureDescriptor.h in Headers */,
    2858028599                                5750A9751E68D00000705C4A /* CryptoKeyEC.h in Headers */,
    2858128600                                E4D58EB517B4DBDC00CBDCA8 /* StyleResolveForDocument.h in Headers */,
     
    2929029309                                E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
    2929129310                                977E2E0F12F0FC9C00C13379 /* XSSAuditor.h in Headers */,
     29311                                316BDBB21E7354BB00DE0D5A /* GPUTexture.h in Headers */,
    2929229312                                977E2E0F12F0FC9C00C13380 /* XSSAuditorDelegate.h in Headers */,
    2929329313                                A5416FE618810EF80009FC5F /* YouTubeEmbedShadowElement.h in Headers */,
     
    3015430174                                49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */,
    3015530175                                2D29ECC7192ECC8300984B78 /* DisplayRefreshMonitorManager.cpp in Sources */,
     30176                                316BDBAE1E73549C00DE0D5A /* GPUTextureMetal.mm in Sources */,
    3015630177                                CD52481A18E200ED0008A07D /* DisplaySleepDisabler.cpp in Sources */,
    3015730178                                5D8C4DBF1428222C0026CE72 /* DisplaySleepDisablerCocoa.cpp in Sources */,
     
    3067930700                                4F6FDD641341DEDD001F8EE3 /* InspectorPageAgent.cpp in Sources */,
    3068030701                                99CC0B6618BE9F15006CEBCC /* InspectorReplayAgent.cpp in Sources */,
     30702                                316BDBB41E7357B000DE0D5A /* GPUTextureDescriptorMetal.mm in Sources */,
    3068130703                                82AB1773125C826700C5069D /* InspectorStyleSheet.cpp in Sources */,
    3068230704                                754133AA102E00F400075D00 /* InspectorTimelineAgent.cpp in Sources */,
     
    3186631888                                1AF8E1C3125673E000230FF7 /* ProxyServerCFNet.cpp in Sources */,
    3186731889                                FF945ECB161F7F3600971BC8 /* PseudoElement.cpp in Sources */,
     31890                                316BDBB11E7354BB00DE0D5A /* GPUTexture.cpp in Sources */,
    3186831891                                0081FEFF16B0A2B6008AAA7A /* PublicSuffixMac.mm in Sources */,
    3186931892                                CDEE393717974259001D7580 /* PublicURLManager.cpp in Sources */,
     
    3266932692                                AA478A8016CD70C3007D1BB4 /* WebAccessibilityObjectWrapperMac.mm in Sources */,
    3267032693                                2D3EF4491917915C00034184 /* WebActionDisablingCALayerDelegate.mm in Sources */,
     32694                                316BDBB71E7357CB00DE0D5A /* GPUTextureDescriptor.cpp in Sources */,
    3267132695                                120DE3ED1C86CA3E00B6D4DD /* WebAnimation.cpp in Sources */,
    3267232696                                CDE667A41E4BBF1500E8154A /* WebAudioBufferList.cpp in Sources */,
  • trunk/Source/WebCore/platform/graphics/cocoa/GPUTextureMetal.mm

    r213730 r213731  
    2525
    2626#include "config.h"
    27 #include "GPUDevice.h"
     27#include "GPUTexture.h"
    2828
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "GPUBuffer.h"
    32 #include "GPULibrary.h"
    33 #include "Logging.h"
     31#import "GPUDevice.h"
     32#import "GPUTextureDescriptor.h"
     33#import "Logging.h"
     34
     35#import <Metal/Metal.h>
    3436
    3537namespace WebCore {
    3638
    37 RefPtr<GPUDevice> GPUDevice::create()
     39GPUTexture::GPUTexture(GPUDevice* device, GPUTextureDescriptor* descriptor)
    3840{
    39     RefPtr<GPUDevice> device = adoptRef(new GPUDevice());
     41    LOG(WebGPU, "GPUTexture::GPUTexture()");
    4042
    41 #if PLATFORM(COCOA)
    42     if (!device->platformDevice()) {
    43         LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device");
    44         return nullptr;
    45     }
    46 #endif
     43    if (!device || !device->platformDevice() || !descriptor || !descriptor->platformTextureDescriptor())
     44        return;
    4745
    48     LOG(WebGPU, "GPUDevice::create() device is %p", device.get());
    49     return device;
     46    m_texture = (MTLTexture*)[device->platformDevice() newTextureWithDescriptor:descriptor->platformTextureDescriptor()];
    5047}
    5148
    52 GPUDevice::~GPUDevice()
     49GPUTexture::GPUTexture(GPUTexture* other)
    5350{
    54     LOG(WebGPU, "GPUDevice::~GPUDevice()");
     51    LOG(WebGPU, "GPUTexture::GPUTexture()");
     52
     53    if (!other || !other->platformTexture())
     54        return;
     55
     56    m_texture = other->platformTexture();
    5557}
    5658
    57 RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode)
     59unsigned long GPUTexture::width() const
    5860{
    59     return GPULibrary::create(this, sourceCode);
     61    if (!m_texture)
     62        return 0;
     63
     64    id<MTLTexture> texture = static_cast<id<MTLTexture>>(m_texture.get());
     65    return texture.width;
    6066}
    6167
    62 RefPtr<GPUBuffer> GPUDevice::createBufferFromData(ArrayBufferView* data)
     68unsigned long GPUTexture::height() const
    6369{
    64     return GPUBuffer::create(this, data);
     70    if (!m_texture)
     71        return 0;
     72
     73    id<MTLTexture> texture = static_cast<id<MTLTexture>>(m_texture.get());
     74    return texture.height;
    6575}
    6676
    67 #if !PLATFORM(COCOA)
    68 
    69 GPUDevice::GPUDevice()
     77MTLTexture* GPUTexture::platformTexture()
    7078{
    71 
     79    return m_texture.get();
    7280}
    73 
    74 void GPUDevice::reshape(int, int)
    75 {
    76 }
    77 
    78 #endif
    7981
    8082} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp

    r213684 r213731  
    3131#include "GPUBuffer.h"
    3232#include "GPULibrary.h"
     33#include "GPUTexture.h"
     34#include "GPUTextureDescriptor.h"
    3335#include "Logging.h"
    3436
     
    6567}
    6668
     69RefPtr<GPUTexture> GPUDevice::createTexture(GPUTextureDescriptor* descriptor)
     70{
     71    return GPUTexture::create(this, descriptor);
     72}
     73
    6774#if !PLATFORM(COCOA)
    6875
  • trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h

    r213684 r213731  
    4949class GPUBuffer;
    5050class GPULibrary;
     51class GPUTexture;
     52class GPUTextureDescriptor;
    5153
    5254class GPUDevice : public RefCounted<GPUDevice> {
     
    6668    WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode);
    6769    WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data);
     70    WEBCORE_EXPORT RefPtr<GPUTexture> createTexture(GPUTextureDescriptor*);
    6871
    6972private:
  • trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.cpp

    r213730 r213731  
    2525
    2626#include "config.h"
    27 #include "GPUDevice.h"
     27#include "GPUTexture.h"
    2828
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "GPUBuffer.h"
    32 #include "GPULibrary.h"
    33 #include "Logging.h"
     31#import "GPUDevice.h"
     32#import "Logging.h"
    3433
    3534namespace WebCore {
    3635
    37 RefPtr<GPUDevice> GPUDevice::create()
     36RefPtr<GPUTexture> GPUTexture::create(GPUDevice* device, GPUTextureDescriptor* descriptor)
    3837{
    39     RefPtr<GPUDevice> device = adoptRef(new GPUDevice());
    40 
    41 #if PLATFORM(COCOA)
    42     if (!device->platformDevice()) {
    43         LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device");
    44         return nullptr;
    45     }
    46 #endif
    47 
    48     LOG(WebGPU, "GPUDevice::create() device is %p", device.get());
    49     return device;
     38    RefPtr<GPUTexture> texture = adoptRef(new GPUTexture(device, descriptor));
     39    return texture;
    5040}
    5141
    52 GPUDevice::~GPUDevice()
     42RefPtr<GPUTexture> GPUTexture::createFromExistingTexture(GPUTexture* other)
    5343{
    54     LOG(WebGPU, "GPUDevice::~GPUDevice()");
     44    RefPtr<GPUTexture> texture = adoptRef(new GPUTexture(other));
     45    return texture;
    5546}
    5647
    57 RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode)
     48GPUTexture::~GPUTexture()
    5849{
    59     return GPULibrary::create(this, sourceCode);
    60 }
    61 
    62 RefPtr<GPUBuffer> GPUDevice::createBufferFromData(ArrayBufferView* data)
    63 {
    64     return GPUBuffer::create(this, data);
     50    LOG(WebGPU, "GPUTexture::~GPUTexture()");
    6551}
    6652
    6753#if !PLATFORM(COCOA)
    68 
    69 GPUDevice::GPUDevice()
     54unsigned long GPUTexture::width() const
    7055{
    71 
     56    return 0;
    7257}
    7358
    74 void GPUDevice::reshape(int, int)
     59unsigned long GPUTexture::height() const
    7560{
     61    return 0;
    7662}
    77 
    7863#endif
    7964
  • trunk/Source/WebCore/platform/graphics/gpu/GPUTexture.h

    r213730 r213731  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "PlatformLayer.h"
    31 #include <runtime/ArrayBufferView.h>
    3230#include <wtf/RefCounted.h>
    33 
    34 #if USE(CA)
    35 #include "PlatformCALayer.h"
    36 #endif
     31#include <wtf/RefPtr.h>
     32#include <wtf/RetainPtr.h>
    3733
    3834#if PLATFORM(COCOA)
    39 typedef struct objc_object* id;
    40 OBJC_CLASS CALayer;
    41 OBJC_CLASS WebGPULayer;
    42 #else
    43 class WebGPULayer;
    44 typedef void PlatformGPUDevice;
     35OBJC_CLASS MTLTexture;
    4536#endif
    4637
    4738namespace WebCore {
    4839
    49 class GPUBuffer;
    50 class GPULibrary;
     40class GPUDevice;
     41class GPUTextureDescriptor;
    5142
    52 class GPUDevice : public RefCounted<GPUDevice> {
     43class GPUTexture : public RefCounted<GPUTexture> {
    5344public:
    54     WEBCORE_EXPORT static RefPtr<GPUDevice> create();
    55     WEBCORE_EXPORT ~GPUDevice();
     45    static RefPtr<GPUTexture> create(GPUDevice*, GPUTextureDescriptor*);
     46    static RefPtr<GPUTexture> createFromExistingTexture(GPUTexture*);
     47    WEBCORE_EXPORT ~GPUTexture();
    5648
    57     void reshape(int width, int height);
     49    WEBCORE_EXPORT unsigned long width() const;
     50    WEBCORE_EXPORT unsigned long height() const;
    5851
    5952#if PLATFORM(COCOA)
    60     CALayer* platformLayer() const { return reinterpret_cast<CALayer*>(m_layer.get()); }
    61     WEBCORE_EXPORT id platformDevice();
     53    WEBCORE_EXPORT MTLTexture* platformTexture();
    6254#endif
    6355
    64     WebGPULayer* layer() { return m_layer.get(); }
    65 
    66     WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode);
    67     WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data);
    68 
    6956private:
    70     GPUDevice();
    71 
    72     RetainPtr<WebGPULayer> m_layer;
     57    GPUTexture(GPUDevice*, GPUTextureDescriptor*);
     58    GPUTexture(GPUTexture*);
     59   
    7360#if PLATFORM(COCOA)
    74     RetainPtr<id> m_device;
     61    RetainPtr<MTLTexture> m_texture;
    7562#endif
    7663};
    77 
     64   
    7865} // namespace WebCore
    79 
    8066#endif
  • trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.cpp

    r213730 r213731  
    2525
    2626#include "config.h"
    27 #include "GPUDevice.h"
     27#include "GPUTextureDescriptor.h"
    2828
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "GPUBuffer.h"
    32 #include "GPULibrary.h"
    33 #include "Logging.h"
     31#import "Logging.h"
    3432
    3533namespace WebCore {
    3634
    37 RefPtr<GPUDevice> GPUDevice::create()
     35RefPtr<GPUTextureDescriptor> GPUTextureDescriptor::create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped)
    3836{
    39     RefPtr<GPUDevice> device = adoptRef(new GPUDevice());
    40 
    41 #if PLATFORM(COCOA)
    42     if (!device->platformDevice()) {
    43         LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device");
    44         return nullptr;
    45     }
    46 #endif
    47 
    48     LOG(WebGPU, "GPUDevice::create() device is %p", device.get());
    49     return device;
     37    RefPtr<GPUTextureDescriptor> descriptor = adoptRef(new GPUTextureDescriptor(pixelFormat, width, height, mipmapped));
     38    return descriptor;
    5039}
    5140
    52 GPUDevice::~GPUDevice()
     41GPUTextureDescriptor::~GPUTextureDescriptor()
    5342{
    54     LOG(WebGPU, "GPUDevice::~GPUDevice()");
    55 }
    56 
    57 RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode)
    58 {
    59     return GPULibrary::create(this, sourceCode);
    60 }
    61 
    62 RefPtr<GPUBuffer> GPUDevice::createBufferFromData(ArrayBufferView* data)
    63 {
    64     return GPUBuffer::create(this, data);
     43    LOG(WebGPU, "GPUTextureDescriptor::~GPUTextureDescriptor()");
    6544}
    6645
    6746#if !PLATFORM(COCOA)
    68 
    69 GPUDevice::GPUDevice()
     47unsigned long GPUTextureDescriptor::width() const
    7048{
    71 
     49    return 0;
    7250}
    7351
    74 void GPUDevice::reshape(int, int)
     52void GPUTextureDescriptor::setWidth(unsigned long)
    7553{
    7654}
    7755
     56unsigned long GPUTextureDescriptor::height() const
     57{
     58    return 0;
     59}
     60
     61void GPUTextureDescriptor::setHeight(unsigned long)
     62{
     63}
     64
     65unsigned long GPUTextureDescriptor::sampleCount() const
     66{
     67    return 0;
     68}
     69
     70void GPUTextureDescriptor::setSampleCount(unsigned long)
     71{
     72}
     73
     74unsigned long GPUTextureDescriptor::textureType() const
     75{
     76    return 0;
     77}
     78
     79void GPUTextureDescriptor::setTextureType(unsigned long)
     80{
     81}
     82
     83unsigned long GPUTextureDescriptor::storageMode() const
     84{
     85    return 0;
     86}
     87
     88void GPUTextureDescriptor::setStorageMode(unsigned long)
     89{
     90}
     91
     92unsigned long GPUTextureDescriptor::usage() const
     93{
     94    return 0;
     95}
     96
     97void GPUTextureDescriptor::setUsage(unsigned long)
     98{
     99}
    78100#endif
    79101
  • trunk/Source/WebCore/platform/graphics/gpu/GPUTextureDescriptor.h

    r213730 r213731  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "PlatformLayer.h"
    31 #include <runtime/ArrayBufferView.h>
    3230#include <wtf/RefCounted.h>
    33 
    34 #if USE(CA)
    35 #include "PlatformCALayer.h"
    36 #endif
     31#include <wtf/RefPtr.h>
     32#include <wtf/RetainPtr.h>
    3733
    3834#if PLATFORM(COCOA)
    39 typedef struct objc_object* id;
    40 OBJC_CLASS CALayer;
    41 OBJC_CLASS WebGPULayer;
    42 #else
    43 class WebGPULayer;
    44 typedef void PlatformGPUDevice;
     35OBJC_CLASS MTLTextureDescriptor;
    4536#endif
    4637
    4738namespace WebCore {
    4839
    49 class GPUBuffer;
    50 class GPULibrary;
     40class GPUTextureDescriptor : public RefCounted<GPUTextureDescriptor> {
     41public:
     42    static RefPtr<GPUTextureDescriptor> create(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped);
     43    WEBCORE_EXPORT ~GPUTextureDescriptor();
    5144
    52 class GPUDevice : public RefCounted<GPUDevice> {
    53 public:
    54     WEBCORE_EXPORT static RefPtr<GPUDevice> create();
    55     WEBCORE_EXPORT ~GPUDevice();
     45    WEBCORE_EXPORT unsigned long width() const;
     46    WEBCORE_EXPORT void setWidth(unsigned long);
    5647
    57     void reshape(int width, int height);
     48    WEBCORE_EXPORT unsigned long height() const;
     49    WEBCORE_EXPORT void setHeight(unsigned long);
     50
     51    WEBCORE_EXPORT unsigned long sampleCount() const;
     52    WEBCORE_EXPORT void setSampleCount(unsigned long);
     53
     54    WEBCORE_EXPORT unsigned long textureType() const;
     55    WEBCORE_EXPORT void setTextureType(unsigned long);
     56
     57    WEBCORE_EXPORT unsigned long storageMode() const;
     58    WEBCORE_EXPORT void setStorageMode(unsigned long);
     59
     60    WEBCORE_EXPORT unsigned long usage() const;
     61    WEBCORE_EXPORT void setUsage(unsigned long);
    5862
    5963#if PLATFORM(COCOA)
    60     CALayer* platformLayer() const { return reinterpret_cast<CALayer*>(m_layer.get()); }
    61     WEBCORE_EXPORT id platformDevice();
     64    WEBCORE_EXPORT MTLTextureDescriptor* platformTextureDescriptor();
    6265#endif
    6366
    64     WebGPULayer* layer() { return m_layer.get(); }
     67private:
     68    GPUTextureDescriptor(unsigned long pixelFormat, unsigned long width, unsigned long height, bool mipmapped);
    6569
    66     WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode);
    67     WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data);
    68 
    69 private:
    70     GPUDevice();
    71 
    72     RetainPtr<WebGPULayer> m_layer;
    7370#if PLATFORM(COCOA)
    74     RetainPtr<id> m_device;
     71    RetainPtr<MTLTextureDescriptor> m_textureDescriptor;
    7572#endif
    7673};
    77 
     74   
    7875} // namespace WebCore
    79 
    8076#endif
Note: See TracChangeset for help on using the changeset viewer.