Changeset 213684 in webkit


Ignore:
Timestamp:
Mar 9, 2017 4:00:41 PM (7 years ago)
Author:
dino@apple.com
Message:

WebGPU: Backend - Buffers
https://bugs.webkit.org/show_bug.cgi?id=169451
<rdar://problem/30959168>

Reviewed by Tim Horton.

Source/WebCore:

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:

Tools:

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:
Location:
trunk
Files:
10 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r213682 r213684  
     12017-03-09  Dean Jackson  <dino@apple.com>
     2
     3        WebGPU: Backend - Buffers
     4        https://bugs.webkit.org/show_bug.cgi?id=169451
     5        <rdar://problem/30959168>
     6
     7        Reviewed by Tim Horton.
     8
     9        Implement the backend for GPUBuffer, which
     10        represents a chunk of memory that can be used
     11        by the GPU. You create one using an ArrayBufferView.
     12
     13        WebKit API Test: GPUBuffer.mm
     14
     15        * PlatformMac.cmake:
     16        * WebCore.xcodeproj/project.pbxproj:
     17        * platform/graphics/cocoa/GPUBufferMetal.mm:
     18        (WebCore::GPUBuffer::GPUBuffer):
     19        (WebCore::GPUBuffer::length):
     20        (WebCore::GPUBuffer::contents):
     21        (WebCore::GPUBuffer::platformBuffer):
     22        * platform/graphics/gpu/GPUBuffer.cpp:
     23        (WebCore::GPUBuffer::create):
     24        (WebCore::GPUBuffer::~GPUBuffer):
     25        (WebCore::GPUBuffer::length):
     26        (WebCore::GPUBuffer::contents):
     27        * platform/graphics/gpu/GPUBuffer.h:
     28        * platform/graphics/gpu/GPUDevice.cpp:
     29        (WebCore::GPUDevice::createBufferFromData):
     30        * platform/graphics/gpu/GPUDevice.h:
     31
    1322017-03-09  Joseph Pecoraro  <pecoraro@apple.com>
    233
  • trunk/Source/WebCore/PlatformMac.cmake

    r213671 r213684  
    420420    platform/graphics/cg/TransformationMatrixCG.cpp
    421421
     422    platform/graphics/cocoa/GPUBufferMetal.mm
    422423    platform/graphics/cocoa/GPUDeviceMetal.mm
    423424    platform/graphics/cocoa/GPUFunctionMetal.mm
     
    436437    platform/graphics/cv/VideoTextureCopierCV.cpp
    437438
     439    platform/graphics/gpu/GPUBuffer.cpp
    438440    platform/graphics/gpu/GPUDevice.cpp
    439441    platform/graphics/gpu/GPUFunction.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r213673 r213684  
    13721372                316BDB9B1E70CBBF00DE0D5A /* GPULibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDB991E70CBBF00DE0D5A /* GPULibrary.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13731373                316BDB9E1E70CD9000DE0D5A /* GPULibraryMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */; };
     1374                316BDBA61E71FA6F00DE0D5A /* GPUBufferMetal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA51E71FA6F00DE0D5A /* GPUBufferMetal.mm */; };
     1375                316BDBA91E71FA9300DE0D5A /* GPUBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */; };
     1376                316BDBAA1E71FA9300DE0D5A /* GPUBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13741377                316FE0710E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */; };
    13751378                316FE0720E6CCBEE00BF6088 /* JSCSSKeyframeRule.h in Headers */ = {isa = PBXBuildFile; fileRef = 316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */; };
     
    87348737                316BDB991E70CBBF00DE0D5A /* GPULibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPULibrary.h; sourceTree = "<group>"; };
    87358738                316BDB9C1E70CD9000DE0D5A /* GPULibraryMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPULibraryMetal.mm; sourceTree = "<group>"; };
     8739                316BDBA51E71FA6F00DE0D5A /* GPUBufferMetal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUBufferMetal.mm; sourceTree = "<group>"; };
     8740                316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUBuffer.cpp; sourceTree = "<group>"; };
     8741                316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUBuffer.h; sourceTree = "<group>"; };
    87368742                316FE06D0E6CCBEE00BF6088 /* JSCSSKeyframeRule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCSSKeyframeRule.cpp; sourceTree = "<group>"; };
    87378743                316FE06E0E6CCBEE00BF6088 /* JSCSSKeyframeRule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCSSKeyframeRule.h; sourceTree = "<group>"; };
     
    1755017556                        isa = PBXGroup;
    1755117557                        children = (
     17558                                316BDBA71E71FA9300DE0D5A /* GPUBuffer.cpp */,
     17559                                316BDBA81E71FA9300DE0D5A /* GPUBuffer.h */,
    1755217560                                316BDB841E6E0A2100DE0D5A /* GPUDevice.cpp */,
    1755317561                                316BDB851E6E0A2100DE0D5A /* GPUDevice.h */,
     
    2264722655                                7C4EDD731A7B607800198C4D /* FontCocoa.mm */,
    2264822656                                B5320D6A122A24E9002D1440 /* FontPlatformDataCocoa.mm */,
     22657                                316BDBA51E71FA6F00DE0D5A /* GPUBufferMetal.mm */,
    2264922658                                316BDB881E6E141C00DE0D5A /* GPUDeviceMetal.mm */,
    2265022659                                316BDB961E70CA2400DE0D5A /* GPUFunctionMetal.mm */,
     
    2792127930                                A80E6CFB0A1989CA007FB8C5 /* Pair.h in Headers */,
    2792227931                                FD3160A312B026F700C1A359 /* Panner.h in Headers */,
     27932                                316BDBAA1E71FA9300DE0D5A /* GPUBuffer.h in Headers */,
    2792327933                                FD31601A12B0267600C1A359 /* PannerNode.h in Headers */,
    2792427934                                A18890AF1AA13F250026C301 /* ParentalControlsContentFilter.h in Headers */,
     
    3070730717                                1AE96A8E1D1A0DDD00B86768 /* JSApplePaySession.cpp in Sources */,
    3070830718                                1AE96A901D1A0DDD00B86768 /* JSApplePayShippingContactSelectedEvent.cpp in Sources */,
     30719                                316BDBA61E71FA6F00DE0D5A /* GPUBufferMetal.mm in Sources */,
    3070930720                                7C6579F31E00856600E3A27A /* JSApplePayShippingMethod.cpp in Sources */,
    3071030721                                1AE96A921D1A0DDD00B86768 /* JSApplePayShippingMethodSelectedEvent.cpp in Sources */,
     
    3131931330                                B2FA3DFA0AB75A6F000E5AC4 /* JSSVGStyleElement.cpp in Sources */,
    3132031331                                B2FA3DFC0AB75A6F000E5AC4 /* JSSVGSVGElement.cpp in Sources */,
     31332                                316BDBA91E71FA9300DE0D5A /* GPUBuffer.cpp in Sources */,
    3132131333                                B2FA3DFE0AB75A6F000E5AC4 /* JSSVGSwitchElement.cpp in Sources */,
    3132231334                                B2FA3E000AB75A6F000E5AC4 /* JSSVGSymbolElement.cpp in Sources */,
  • trunk/Source/WebCore/platform/graphics/cocoa/GPUBufferMetal.mm

    r213683 r213684  
    2525
    2626#include "config.h"
    27 #include "GPUDevice.h"
     27#include "GPUBuffer.h"
    2828
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "GPULibrary.h"
    32 #include "Logging.h"
     31#import "GPUDevice.h"
     32#import "Logging.h"
     33
     34#import <Metal/Metal.h>
    3335
    3436namespace WebCore {
    3537
    36 RefPtr<GPUDevice> GPUDevice::create()
     38GPUBuffer::GPUBuffer(GPUDevice* device, ArrayBufferView* data)
    3739{
    38     RefPtr<GPUDevice> device = adoptRef(new GPUDevice());
     40    LOG(WebGPU, "GPUBuffer::GPUBuffer()");
    3941
    40 #if PLATFORM(COCOA)
    41     if (!device->platformDevice()) {
    42         LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device");
    43         return nullptr;
    44     }
    45 #endif
     42    if (!device || !device->platformDevice() || !data)
     43        return;
    4644
    47     LOG(WebGPU, "GPUDevice::create() device is %p", device.get());
    48     return device;
     45    m_buffer = (MTLBuffer*)[device->platformDevice() newBufferWithBytes:data->baseAddress() length:data->byteLength() options:MTLResourceOptionCPUCacheModeDefault];
    4946}
    5047
    51 GPUDevice::~GPUDevice()
     48unsigned long GPUBuffer::length() const
    5249{
    53     LOG(WebGPU, "GPUDevice::~GPUDevice()");
     50    if (!m_buffer)
     51        return 0;
     52
     53    return [m_buffer length];
    5454}
    5555
    56 RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode)
     56RefPtr<ArrayBuffer> GPUBuffer::contents()
    5757{
    58     return GPULibrary::create(this, sourceCode);
     58    if (m_contents)
     59        return m_contents;
     60
     61    if (!m_buffer)
     62        return nullptr;
     63
     64    m_contents = ArrayBuffer::createFromBytes([m_buffer contents], [m_buffer length], [] (void*) { });
     65    return m_contents;
    5966}
    6067
    61 #if !PLATFORM(COCOA)
    62 
    63 GPUDevice::GPUDevice()
     68MTLBuffer* GPUBuffer::platformBuffer()
    6469{
    65 
     70    return m_buffer.get();
    6671}
    67 
    68 void GPUDevice::reshape(int, int)
    69 {
    70 }
    71 
    72 #endif
    7372
    7473} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/cocoa/GPULibraryMetal.mm

    r213650 r213684  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
  • trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.cpp

    r213683 r213684  
    2525
    2626#include "config.h"
    27 #include "GPUDevice.h"
     27#include "GPUBuffer.h"
    2828
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "GPULibrary.h"
    32 #include "Logging.h"
     31#import "GPUDevice.h"
     32#import "Logging.h"
    3333
    3434namespace WebCore {
    3535
    36 RefPtr<GPUDevice> GPUDevice::create()
     36RefPtr<GPUBuffer> GPUBuffer::create(GPUDevice* device, ArrayBufferView* arrayBuffer)
    3737{
    38     RefPtr<GPUDevice> device = adoptRef(new GPUDevice());
    39 
    40 #if PLATFORM(COCOA)
    41     if (!device->platformDevice()) {
    42         LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device");
    43         return nullptr;
    44     }
    45 #endif
    46 
    47     LOG(WebGPU, "GPUDevice::create() device is %p", device.get());
    48     return device;
     38    RefPtr<GPUBuffer> buffer = adoptRef(new GPUBuffer(device, arrayBuffer));
     39    return buffer;
    4940}
    5041
    51 GPUDevice::~GPUDevice()
     42GPUBuffer::~GPUBuffer()
    5243{
    53     LOG(WebGPU, "GPUDevice::~GPUDevice()");
    54 }
    55 
    56 RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode)
    57 {
    58     return GPULibrary::create(this, sourceCode);
     44    LOG(WebGPU, "GPUBuffer::~GPUBuffer()");
    5945}
    6046
    6147#if !PLATFORM(COCOA)
    62 
    63 GPUDevice::GPUDevice()
     48unsigned long GPUBuffer::length() const
    6449{
    65 
     50    return 0;
    6651}
    6752
    68 void GPUDevice::reshape(int, int)
     53RefPtr<ArrayBuffer> GPUBuffer::contents()
    6954{
     55    if (m_contents)
     56        return m_contents;
     57
     58    m_contents = ArrayBuffer::create(0, 1);
     59    return m_contents;
    7060}
    71 
    7261#endif
    7362
  • trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h

    r213683 r213684  
    2424 */
    2525
    26 #include "config.h"
    27 #include "GPUDevice.h"
     26#pragma once
    2827
    2928#if ENABLE(WEBGPU)
    3029
    31 #include "GPULibrary.h"
    32 #include "Logging.h"
     30#include <runtime/ArrayBufferView.h>
     31#include <wtf/RefPtr.h>
     32#include <wtf/RetainPtr.h>
     33
     34#if PLATFORM(COCOA)
     35OBJC_CLASS MTLBuffer;
     36#endif
    3337
    3438namespace WebCore {
    3539
    36 RefPtr<GPUDevice> GPUDevice::create()
    37 {
    38     RefPtr<GPUDevice> device = adoptRef(new GPUDevice());
     40class GPUDevice;
     41
     42class GPUBuffer : public RefCounted<GPUBuffer> {
     43public:
     44    static RefPtr<GPUBuffer> create(GPUDevice*, ArrayBufferView*);
     45    WEBCORE_EXPORT ~GPUBuffer();
     46
     47    WEBCORE_EXPORT unsigned long length() const;
     48    WEBCORE_EXPORT RefPtr<ArrayBuffer> contents();
    3949
    4050#if PLATFORM(COCOA)
    41     if (!device->platformDevice()) {
    42         LOG(WebGPU, "GPUDevice::create() was unable to create the low-level device");
    43         return nullptr;
    44     }
     51    WEBCORE_EXPORT MTLBuffer* platformBuffer();
    4552#endif
    4653
    47     LOG(WebGPU, "GPUDevice::create() device is %p", device.get());
    48     return device;
    49 }
    50 
    51 GPUDevice::~GPUDevice()
    52 {
    53     LOG(WebGPU, "GPUDevice::~GPUDevice()");
    54 }
    55 
    56 RefPtr<GPULibrary> GPUDevice::createLibrary(const String& sourceCode)
    57 {
    58     return GPULibrary::create(this, sourceCode);
    59 }
    60 
    61 #if !PLATFORM(COCOA)
    62 
    63 GPUDevice::GPUDevice()
    64 {
    65 
    66 }
    67 
    68 void GPUDevice::reshape(int, int)
    69 {
    70 }
    71 
     54private:
     55    GPUBuffer(GPUDevice*, ArrayBufferView*);
     56   
     57#if PLATFORM(COCOA)
     58    RetainPtr<MTLBuffer> m_buffer;
    7259#endif
    73 
     60    RefPtr<ArrayBuffer> m_contents;
     61};
     62   
    7463} // namespace WebCore
    75 
    7664#endif
  • trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp

    r213650 r213684  
    2929#if ENABLE(WEBGPU)
    3030
     31#include "GPUBuffer.h"
    3132#include "GPULibrary.h"
    3233#include "Logging.h"
     
    5960}
    6061
     62RefPtr<GPUBuffer> GPUDevice::createBufferFromData(ArrayBufferView* data)
     63{
     64    return GPUBuffer::create(this, data);
     65}
     66
    6167#if !PLATFORM(COCOA)
    6268
  • trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h

    r213650 r213684  
    4747namespace WebCore {
    4848
     49class GPUBuffer;
    4950class GPULibrary;
    5051
     
    6465
    6566    WEBCORE_EXPORT RefPtr<GPULibrary> createLibrary(const String& sourceCode);
     67    WEBCORE_EXPORT RefPtr<GPUBuffer> createBufferFromData(ArrayBufferView* data);
    6668
    6769private:
  • trunk/Tools/ChangeLog

    r213676 r213684  
     12017-03-09  Dean Jackson  <dino@apple.com>
     2
     3        WebGPU: Backend - Buffers
     4        https://bugs.webkit.org/show_bug.cgi?id=169451
     5        <rdar://problem/30959168>
     6
     7        Reviewed by Tim Horton.
     8
     9        Test for GPUBuffer object.
     10
     11        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     12        * TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm: Added.
     13        (TestWebKitAPI::TEST_F):
     14        * TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm:
     15        * TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm:
     16
    1172017-03-09  Daniel Bates  <dabates@apple.com>
    218
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r213650 r213684  
    9797                316BDBA11E70D71B00DE0D5A /* GPULibrary.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA01E70D6D800DE0D5A /* GPULibrary.mm */; };
    9898                316BDBA41E70EF6800DE0D5A /* GPUFunction.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBA31E70EF5D00DE0D5A /* GPUFunction.mm */; };
     99                316BDBAC1E7207F100DE0D5A /* GPUBuffer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 316BDBAB1E7207F100DE0D5A /* GPUBuffer.mm */; };
    99100                33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; };
    100101                33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33DC890E1419539300747EF7 /* simple-iframe.html */; };
     
    954955                316BDBA21E70DEE500DE0D5A /* GPUTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUTest.h; sourceTree = "<group>"; };
    955956                316BDBA31E70EF5D00DE0D5A /* GPUFunction.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUFunction.mm; sourceTree = "<group>"; };
     957                316BDBAB1E7207F100DE0D5A /* GPUBuffer.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = GPUBuffer.mm; sourceTree = "<group>"; };
    956958                333B9CE11277F23100FEFCE3 /* PreventEmptyUserAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PreventEmptyUserAgent.cpp; sourceTree = "<group>"; };
    957959                33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash.cpp; sourceTree = "<group>"; };
     
    16711673                        isa = PBXGroup;
    16721674                        children = (
     1675                                316BDBAB1E7207F100DE0D5A /* GPUBuffer.mm */,
    16731676                                3162AE9B1E6F2FCE000E4DBC /* GPUDevice.mm */,
    16741677                                316BDBA31E70EF5D00DE0D5A /* GPUFunction.mm */,
     
    27992802                                7CCE7EA61A411A0F00447C4C /* PlatformUtilitiesMac.mm in Sources */,
    28002803                                7CCE7EA71A411A1300447C4C /* PlatformWebViewMac.mm in Sources */,
     2804                                316BDBAC1E7207F100DE0D5A /* GPUBuffer.mm in Sources */,
    28012805                                7CCE7F261A411AF600447C4C /* Preferences.mm in Sources */,
    28022806                                7A909A821D877480007E10F8 /* IntRect.cpp in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUBuffer.mm

    r213683 r213684  
    2929
    3030#import "GPUTest.h"
     31#import <JavaScriptCore/ArrayBuffer.h>
     32#import <JavaScriptCore/ArrayBufferView.h>
     33#import <JavaScriptCore/GenericTypedArrayViewInlines.h>
     34#import <JavaScriptCore/JSCInlines.h>
     35#import <JavaScriptCore/JSGenericTypedArrayViewInlines.h>
     36#import <JavaScriptCore/TypedArrays.h>
    3137#import <Metal/Metal.h>
     38#import <WebCore/GPUBuffer.h>
    3239#import <WebCore/GPUDevice.h>
    33 #import <WebCore/GPULibrary.h>
    34 #import <wtf/MainThread.h>
    3540
    3641using namespace WebCore;
     
    3843namespace TestWebKitAPI {
    3944
    40 TEST_F(GPU, LibraryCreate)
     45TEST_F(GPU, BufferCreate)
    4146{
    4247    auto device = GPUDevice::create();
     
    5055    EXPECT_NOT_NULL(mtlDevice);
    5156
    52     auto library = device->createLibrary(librarySourceCode());
    53     EXPECT_NOT_NULL(library);
    54 }
     57    auto bufferView = JSC::Uint8Array::create(1024);
    5558
    56 TEST_F(GPU, LibrarySetLabel)
    57 {
    58     auto device = GPUDevice::create();
    59     if (!device)
    60         return;
     59    uint8_t* data = bufferView->data();
     60    memset(data, 1, bufferView->byteLength());
    6161
    62     auto library = device->createLibrary(librarySourceCode());
    63     EXPECT_NOT_NULL(library);
     62    auto buffer = device->createBufferFromData(bufferView.get());
     63    EXPECT_NOT_NULL(buffer);
     64    EXPECT_EQ(buffer->length(), static_cast<unsigned long>(1024));
    6465
    65     library->setLabel("TestLabel");
    66     EXPECT_TRUE(library->label() == "TestLabel");
    67 }
     66    auto contents = buffer->contents();
     67    EXPECT_NOT_NULL(contents);
     68    EXPECT_EQ(contents->byteLength(), static_cast<unsigned long>(1024));
    6869
    69 TEST_F(GPU, LibraryFunctionNames)
    70 {
    71     auto device = GPUDevice::create();
    72     if (!device)
    73         return;
     70    uint8_t* contentsData = static_cast<uint8_t*>(contents->data());
     71    EXPECT_NE(contentsData, data);
     72    EXPECT_EQ(contentsData[0], 1);
     73    EXPECT_EQ(contentsData[512], 1);
     74    EXPECT_EQ(contentsData[1023], 1);
    7475
    75     auto library = device->createLibrary(librarySourceCode());
    76     EXPECT_NOT_NULL(library);
     76    MTLBuffer *mtlBuffer = buffer->platformBuffer();
     77    EXPECT_NOT_NULL(mtlBuffer);
    7778
    78     auto functionNames = library->functionNames();
    79     EXPECT_EQ(functionNames.size(), static_cast<unsigned long>(2));
    80     EXPECT_TRUE(functionNames[0] == "vertex_main");
    81     EXPECT_TRUE(functionNames[1] == "fragment_main");
     79
    8280}
    8381
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPUFunction.mm

    r213650 r213684  
    3434#import <WebCore/GPUFunction.h>
    3535#import <WebCore/GPULibrary.h>
    36 #import <wtf/MainThread.h>
    3736
    3837using namespace WebCore;
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/mac/GPULibrary.mm

    r213650 r213684  
    3232#import <WebCore/GPUDevice.h>
    3333#import <WebCore/GPULibrary.h>
    34 #import <wtf/MainThread.h>
    3534
    3635using namespace WebCore;
Note: See TracChangeset for help on using the changeset viewer.