Changeset 247366 in webkit


Ignore:
Timestamp:
Jul 11, 2019 2:32:06 PM (5 years ago)
Author:
Justin Fan
Message:

[WebGPU] Implement GPUError and error scopes
https://bugs.webkit.org/show_bug.cgi?id=199655

Reviewed by Myles C. Maxfield.

Source/WebCore:

Add GPUErrorFilter, GPUError, and the ability to push and pop error scopes on a GPUDevice.
This will allow us to check for WebGPU errors from JavaScript.
Currently, only some GPUBuffer creation errors are reported for testing; more errors will follow in later patches.

Test: webgpu/error-scopes-test.html

  • Modules/webgpu/GPUErrorFilter.idl: Added.
  • Modules/webgpu/GPUOutOfMemoryError.idl: Added.
  • Modules/webgpu/GPUValidationError.idl: Added.
  • Modules/webgpu/WebGPUDevice.cpp:

(WebCore::WebGPUDevice::pushErrorScope):
(WebCore::WebGPUDevice::popErrorScope): Resolve the Promise here, since GPUDevice shouldn't worry about DOM layer.

  • Modules/webgpu/WebGPUDevice.h:
  • Modules/webgpu/WebGPUDeviceErrorScopes.cpp: Added.

(WebCore::WebGPUDeviceErrorScopes::pushErrorScope): Delegates to WebGPUDevice.
(WebCore::WebGPUDeviceErrorScopes::popErrorScope): Ditto.

  • Modules/webgpu/WebGPUDeviceErrorScopes.h: Added.
  • Modules/webgpu/WebGPUDeviceErrorScopes.idl: Added.
  • platform/graphics/gpu/GPUBuffer.h:
  • platform/graphics/gpu/GPUDevice.cpp: The actual error stack lives here.

(WebCore::GPUDevice::pushErrorScope):
(WebCore::GPUDevice::popErrorScope): Calls a callback with a GPUError, if any.
(WebCore::GPUDevice::registerError): Actually creates GPUErrors.

  • platform/graphics/gpu/GPUDevice.h:
  • platform/graphics/gpu/GPUError.cpp: Added.

(WebCore::createError): Factory function for various error types.

  • platform/graphics/gpu/GPUError.h: Added.
  • platform/graphics/gpu/GPUErrorFilter.h: Added.
  • platform/graphics/gpu/GPUOutOfMemoryError.h: Added.

(WebCore::GPUOutOfMemoryError::create):

  • platform/graphics/gpu/GPUValidationError.cpp: Added.

(WebCore::GPUValidationError::create):
(WebCore::GPUValidationError::GPUValidationError):

  • platform/graphics/gpu/GPUValidationError.h: Added.

(WebCore::GPUValidationError::message const):

  • platform/graphics/gpu/cocoa/GPUBufferMetal.mm:

(WebCore::GPUBuffer::validateBufferUsage): Create an actual GPUValidationError :)
(WebCore::GPUBuffer::tryCreate): Create GPUOutOfMemoryErrors where appropriate.

Add file/name references:

  • CMakeLists.txt:
  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/js/WebCoreBuiltinNames.h:

Missing includes:

  • Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp:

LayoutTests:

Add a test to cover the cases outlined in the WebGPU error handling design doc.

  • webgpu/error-scopes-test-expected.txt: Added.
  • webgpu/error-scopes-test.html: Added.
Location:
trunk
Files:
14 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r247362 r247366  
     12019-07-11  Justin Fan  <justin_fan@apple.com>
     2
     3        [WebGPU] Implement GPUError and error scopes
     4        https://bugs.webkit.org/show_bug.cgi?id=199655
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Add a test to cover the cases outlined in the WebGPU error handling design doc.
     9
     10        * webgpu/error-scopes-test-expected.txt: Added.
     11        * webgpu/error-scopes-test.html: Added.
     12
    1132019-07-11  Commit Queue  <commit-queue@webkit.org>
    214
  • trunk/Source/WebCore/CMakeLists.txt

    r246874 r247366  
    481481    Modules/webgpu/GPUCompareFunction.idl
    482482    Modules/webgpu/GPUDepthStencilStateDescriptor.idl
     483    Modules/webgpu/GPUErrorFilter.idl
    483484    Modules/webgpu/GPUExtent3D.idl
    484485    Modules/webgpu/GPULoadOp.idl
    485486    Modules/webgpu/GPUOrigin3D.idl
     487    Modules/webgpu/GPUOutOfMemoryError.idl
    486488    Modules/webgpu/GPURequestAdapterOptions.idl
    487489    Modules/webgpu/GPUSamplerDescriptor.idl
     
    491493    Modules/webgpu/GPUTextureFormat.idl
    492494    Modules/webgpu/GPUTextureUsage.idl
     495    Modules/webgpu/GPUValidationError.idl
    493496    Modules/webgpu/GPUVertexAttributeDescriptor.idl
    494497    Modules/webgpu/GPUVertexBufferDescriptor.idl
     
    509512    Modules/webgpu/WebGPUComputePipelineDescriptor.idl
    510513    Modules/webgpu/WebGPUDevice.idl
     514    Modules/webgpu/WebGPUDeviceErrorScopes.idl
    511515    Modules/webgpu/WebGPUPipelineDescriptorBase.idl
    512516    Modules/webgpu/WebGPUPipelineLayout.idl
  • trunk/Source/WebCore/ChangeLog

    r247365 r247366  
     12019-07-11  Justin Fan  <justin_fan@apple.com>
     2
     3        [WebGPU] Implement GPUError and error scopes
     4        https://bugs.webkit.org/show_bug.cgi?id=199655
     5
     6        Reviewed by Myles C. Maxfield.
     7
     8        Add GPUErrorFilter, GPUError, and the ability to push and pop error scopes on a GPUDevice.
     9        This will allow us to check for WebGPU errors from JavaScript.
     10        Currently, only some GPUBuffer creation errors are reported for testing; more errors will follow in later patches.
     11
     12        Test: webgpu/error-scopes-test.html
     13
     14        * Modules/webgpu/GPUErrorFilter.idl: Added.
     15        * Modules/webgpu/GPUOutOfMemoryError.idl: Added.
     16        * Modules/webgpu/GPUValidationError.idl: Added.
     17        * Modules/webgpu/WebGPUDevice.cpp:
     18        (WebCore::WebGPUDevice::pushErrorScope):
     19        (WebCore::WebGPUDevice::popErrorScope): Resolve the Promise here, since GPUDevice shouldn't worry about DOM layer.
     20        * Modules/webgpu/WebGPUDevice.h:
     21        * Modules/webgpu/WebGPUDeviceErrorScopes.cpp: Added.
     22        (WebCore::WebGPUDeviceErrorScopes::pushErrorScope): Delegates to WebGPUDevice.
     23        (WebCore::WebGPUDeviceErrorScopes::popErrorScope): Ditto.
     24        * Modules/webgpu/WebGPUDeviceErrorScopes.h: Added.
     25        * Modules/webgpu/WebGPUDeviceErrorScopes.idl: Added.
     26        * platform/graphics/gpu/GPUBuffer.h:
     27        * platform/graphics/gpu/GPUDevice.cpp: The actual error stack lives here.
     28        (WebCore::GPUDevice::pushErrorScope):
     29        (WebCore::GPUDevice::popErrorScope): Calls a callback with a GPUError, if any.
     30        (WebCore::GPUDevice::registerError): Actually creates GPUErrors.
     31        * platform/graphics/gpu/GPUDevice.h:
     32        * platform/graphics/gpu/GPUError.cpp: Added.
     33        (WebCore::createError): Factory function for various error types.
     34        * platform/graphics/gpu/GPUError.h: Added.
     35        * platform/graphics/gpu/GPUErrorFilter.h: Added.
     36        * platform/graphics/gpu/GPUOutOfMemoryError.h: Added.
     37        (WebCore::GPUOutOfMemoryError::create):
     38        * platform/graphics/gpu/GPUValidationError.cpp: Added.
     39        (WebCore::GPUValidationError::create):
     40        (WebCore::GPUValidationError::GPUValidationError):
     41        * platform/graphics/gpu/GPUValidationError.h: Added.
     42        (WebCore::GPUValidationError::message const):
     43        * platform/graphics/gpu/cocoa/GPUBufferMetal.mm:
     44        (WebCore::GPUBuffer::validateBufferUsage): Create an actual GPUValidationError :)
     45        (WebCore::GPUBuffer::tryCreate): Create GPUOutOfMemoryErrors where appropriate.
     46
     47        Add file/name references:
     48        * CMakeLists.txt:
     49        * DerivedSources-input.xcfilelist:
     50        * DerivedSources-output.xcfilelist:
     51        * DerivedSources.make:
     52        * Sources.txt:
     53        * WebCore.xcodeproj/project.pbxproj:
     54        * bindings/js/WebCoreBuiltinNames.h:
     55
     56        Missing includes:
     57        * Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp:
     58
    1592019-07-11  Tim Horton  <timothy_horton@apple.com>
    260
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r247174 r247366  
    331331$(PROJECT_DIR)/Modules/webgpu/GPUCompareFunction.idl
    332332$(PROJECT_DIR)/Modules/webgpu/GPUDepthStencilStateDescriptor.idl
     333$(PROJECT_DIR)/Modules/webgpu/GPUErrorFilter.idl
    333334$(PROJECT_DIR)/Modules/webgpu/GPUExtent3D.idl
    334335$(PROJECT_DIR)/Modules/webgpu/GPUInputStateDescriptor.idl
    335336$(PROJECT_DIR)/Modules/webgpu/GPULoadOp.idl
    336337$(PROJECT_DIR)/Modules/webgpu/GPUOrigin3D.idl
     338$(PROJECT_DIR)/Modules/webgpu/GPUOutOfMemoryError.idl
    337339$(PROJECT_DIR)/Modules/webgpu/GPURequestAdapterOptions.idl
    338340$(PROJECT_DIR)/Modules/webgpu/GPUSamplerDescriptor.idl
     
    342344$(PROJECT_DIR)/Modules/webgpu/GPUTextureFormat.idl
    343345$(PROJECT_DIR)/Modules/webgpu/GPUTextureUsage.idl
     346$(PROJECT_DIR)/Modules/webgpu/GPUValidationError.idl
    344347$(PROJECT_DIR)/Modules/webgpu/GPUVertexAttributeDescriptor.idl
    345348$(PROJECT_DIR)/Modules/webgpu/GPUVertexBufferDescriptor.idl
     
    362365$(PROJECT_DIR)/Modules/webgpu/WebGPUComputePipelineDescriptor.idl
    363366$(PROJECT_DIR)/Modules/webgpu/WebGPUDevice.idl
     367$(PROJECT_DIR)/Modules/webgpu/WebGPUDeviceErrorScopes.idl
    364368$(PROJECT_DIR)/Modules/webgpu/WebGPUPipelineDescriptorBase.idl
    365369$(PROJECT_DIR)/Modules/webgpu/WebGPUPipelineLayout.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r247174 r247366  
    610610$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUDepthStencilStateDescriptor.cpp
    611611$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUDepthStencilStateDescriptor.h
     612$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUErrorFilter.cpp
     613$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUErrorFilter.h
    612614$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUExtent3D.cpp
    613615$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUExtent3D.h
     
    618620$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUOrigin3D.cpp
    619621$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUOrigin3D.h
     622$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUOutOfMemoryError.cpp
     623$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUOutOfMemoryError.h
    620624$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURequestAdapterOptions.cpp
    621625$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURequestAdapterOptions.h
     
    632636$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUTextureUsage.cpp
    633637$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUTextureUsage.h
     638$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUValidationError.cpp
     639$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUValidationError.h
    634640$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUVertexAttributeDescriptor.cpp
    635641$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUVertexAttributeDescriptor.h
     
    19441950$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUDevice.cpp
    19451951$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUDevice.h
     1952$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUDeviceErrorScopes.cpp
     1953$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUDeviceErrorScopes.h
    19461954$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUPipelineDescriptorBase.cpp
    19471955$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUPipelineDescriptorBase.h
  • trunk/Source/WebCore/DerivedSources.make

    r247174 r247366  
    387387    $(WebCore)/Modules/webgpu/GPUCompareFunction.idl \
    388388    $(WebCore)/Modules/webgpu/GPUDepthStencilStateDescriptor.idl \
     389    $(WebCore)/Modules/webgpu/GPUErrorFilter.idl \
    389390    $(WebCore)/Modules/webgpu/GPUExtent3D.idl \
    390391    $(WebCore)/Modules/webgpu/GPULoadOp.idl \
    391392    $(WebCore)/Modules/webgpu/GPUOrigin3D.idl \
     393    $(WebCore)/Modules/webgpu/GPUOutOfMemoryError.idl \
    392394    $(WebCore)/Modules/webgpu/GPURequestAdapterOptions.idl \
    393395    $(WebCore)/Modules/webgpu/GPUSamplerDescriptor.idl \
     
    397399    $(WebCore)/Modules/webgpu/GPUTextureFormat.idl \
    398400    $(WebCore)/Modules/webgpu/GPUTextureUsage.idl \
     401    $(WebCore)/Modules/webgpu/GPUValidationError.idl \
    399402    $(WebCore)/Modules/webgpu/GPUVertexAttributeDescriptor.idl \
    400403    $(WebCore)/Modules/webgpu/GPUVertexBufferDescriptor.idl \
     
    415418    $(WebCore)/Modules/webgpu/WebGPUComputePipelineDescriptor.idl \
    416419    $(WebCore)/Modules/webgpu/WebGPUDevice.idl \
     420        $(WebCore)/Modules/webgpu/WebGPUDeviceErrorScopes.idl \
    417421    $(WebCore)/Modules/webgpu/WebGPUQueue.idl \
    418422    $(WebCore)/Modules/webgpu/WebGPUPipelineDescriptorBase.idl \
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLCheckTextureReferences.cpp

    r246631 r247366  
    2727#include "WHLSLCheckTextureReferences.h"
    2828
     29#if ENABLE(WEBGPU)
     30
     31#include "WHLSLArrayReferenceType.h"
     32#include "WHLSLArrayType.h"
    2933#include "WHLSLInferTypes.h"
    30 
    31 #if ENABLE(WEBGPU)
     34#include "WHLSLNativeTypeDeclaration.h"
     35#include "WHLSLPointerType.h"
     36#include "WHLSLVisitor.h"
    3237
    3338namespace WebCore {
  • trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp

    r246217 r247366  
    2929#if ENABLE(WEBGPU)
    3030
     31#include "Exception.h"
    3132#include "GPUBindGroup.h"
    3233#include "GPUBindGroupBinding.h"
     
    4344#include "GPUTextureDescriptor.h"
    4445#include "JSDOMConvertBufferSource.h"
     46#include "JSGPUOutOfMemoryError.h"
     47#include "JSGPUValidationError.h"
    4548#include "JSWebGPUBuffer.h"
    4649#include "Logging.h"
     
    6467#include "WebGPUSwapChain.h"
    6568#include "WebGPUTexture.h"
     69#include <wtf/Optional.h>
    6670
    6771namespace WebCore {
     
    181185}
    182186
     187void WebGPUDevice::pushErrorScope(GPUErrorFilter filter) const
     188{
     189    m_device->pushErrorScope(filter);
     190}
     191
     192void WebGPUDevice::popErrorScope(ErrorPromise&& promise) const
     193{
     194    m_device->popErrorScope([promise = WTFMove(promise)] (Optional<GPUError>&& error, const String& failMessage) mutable {
     195        if (failMessage.isEmpty())
     196            promise.resolve(error);
     197        else
     198            promise.reject(Exception { OperationError, failMessage });
     199    });
     200}
     201
    183202} // namespace WebCore
    184203
  • trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h

    r246217 r247366  
    2929
    3030#include "GPUDevice.h"
     31#include "JSDOMPromiseDeferred.h"
    3132#include "WebGPUAdapter.h"
    3233#include "WebGPUQueue.h"
     
    4445namespace WebCore {
    4546
     47class GPUOutOfMemoryError;
     48class GPUValidationError;
    4649class ScriptExecutionContext;
    4750class WebGPUBindGroup;
     
    6669struct WebGPURenderPipelineDescriptor;
    6770struct WebGPUShaderModuleDescriptor;
     71
     72enum class GPUErrorFilter;
     73
     74using ErrorIDLUnion = IDLUnion<IDLInterface<GPUOutOfMemoryError>, IDLInterface<GPUValidationError>>;
     75using ErrorPromise = DOMPromiseDeferred<IDLNullable<ErrorIDLUnion>>;
    6876
    6977class WebGPUDevice : public RefCounted<WebGPUDevice> {
     
    92100    Ref<WebGPUQueue> getQueue() const;
    93101
     102    void pushErrorScope(GPUErrorFilter) const;
     103    void popErrorScope(ErrorPromise&&) const;
     104
    94105private:
    95106    WebGPUDevice(Ref<const WebGPUAdapter>&&, Ref<GPUDevice>&&);
  • trunk/Source/WebCore/Sources.txt

    r247174 r247366  
    368368Modules/webgpu/WebGPUComputePipelineDescriptor.cpp
    369369Modules/webgpu/WebGPUDevice.cpp
     370Modules/webgpu/WebGPUDeviceErrorScopes.cpp
    370371Modules/webgpu/WebGPUQueue.cpp
    371372Modules/webgpu/WebGPUPipelineLayout.cpp
     
    18281829
    18291830platform/graphics/gpu/GPUDevice.cpp
     1831platform/graphics/gpu/GPUError.cpp
     1832platform/graphics/gpu/GPUValidationError.cpp
    18301833platform/graphics/gpu/GPUPipelineLayout.cpp
    18311834platform/graphics/gpu/GPUProgrammablePassEncoder.cpp
     
    27572760JSGPUCompareFunction.cpp
    27582761JSGPUDepthStencilStateDescriptor.cpp
     2762JSGPUErrorFilter.cpp
    27592763JSGPUExtent3D.cpp
    27602764JSGPULoadOp.cpp
    27612765JSGPUOrigin3D.cpp
     2766JSGPUOutOfMemoryError.cpp
    27622767JSGPURequestAdapterOptions.cpp
    27632768JSGPUSamplerDescriptor.cpp
     
    27672772JSGPUTextureFormat.cpp
    27682773JSGPUTextureUsage.cpp
     2774JSGPUValidationError.cpp
    27692775JSGPUVertexAttributeDescriptor.cpp
    27702776JSGPUVertexBufferDescriptor.cpp
     
    33193325JSWebGPUComputePipelineDescriptor.cpp
    33203326JSWebGPUDevice.cpp
     3327JSWebGPUDeviceErrorScopes.cpp
    33213328JSWebGPUQueue.cpp
    33223329JSWebGPUPipelineDescriptorBase.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r247282 r247366  
    1401914019                D093D227217951D400329217 /* GPUCanvasContext.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUCanvasContext.idl; sourceTree = "<group>"; };
    1402014020                D093D2292179541600329217 /* GPUCanvasContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUCanvasContext.cpp; sourceTree = "<group>"; };
     14021                D09AFAFF22D02E5300C4538C /* WebGPUDeviceErrorScopes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUDeviceErrorScopes.h; sourceTree = "<group>"; };
     14022                D09AFB0122D02E5300C4538C /* WebGPUDeviceErrorScopes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUDeviceErrorScopes.cpp; sourceTree = "<group>"; };
     14023                D09AFB0222D0471900C4538C /* GPUErrorFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUErrorFilter.h; sourceTree = "<group>"; };
     14024                D09AFB0322D40CC500C4538C /* WebGPUDeviceErrorScopes.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUDeviceErrorScopes.idl; sourceTree = "<group>"; };
     14025                D09AFB0622D417B300C4538C /* GPUErrorFilter.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUErrorFilter.idl; sourceTree = "<group>"; };
     14026                D09AFB0722D5391B00C4538C /* GPUError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUError.h; sourceTree = "<group>"; };
     14027                D09AFB0822D5542800C4538C /* GPUError.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUError.cpp; sourceTree = "<group>"; };
     14028                D09AFB0C22D55E9000C4538C /* GPUValidationError.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUValidationError.idl; sourceTree = "<group>"; };
     14029                D09AFB0D22D55F3B00C4538C /* GPUValidationError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUValidationError.h; sourceTree = "<group>"; };
     14030                D09AFB0E22D55FF500C4538C /* GPUValidationError.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUValidationError.cpp; sourceTree = "<group>"; };
     14031                D09AFB1722D6694E00C4538C /* GPUOutOfMemoryError.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUOutOfMemoryError.idl; sourceTree = "<group>"; };
     14032                D09AFB1922D6698A00C4538C /* GPUOutOfMemoryError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUOutOfMemoryError.h; sourceTree = "<group>"; };
     14033                D09AFB2D22D6C01400C4538C /* GPUError.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUError.cpp; sourceTree = "<group>"; };
    1402114034                D0A20D542092A0A600E0C259 /* WebGLCompressedTextureASTC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLCompressedTextureASTC.h; sourceTree = "<group>"; };
    1402214035                D0A20D562092A0A600E0C259 /* WebGLCompressedTextureASTC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLCompressedTextureASTC.cpp; sourceTree = "<group>"; };
     
    1832118334                                312FF8BF21A4C2F100EB199D /* GPUDevice.cpp */,
    1832218335                                312FF8BE21A4C2F100EB199D /* GPUDevice.h */,
     18336                                D09AFB0822D5542800C4538C /* GPUError.cpp */,
     18337                                D09AFB2D22D6C01400C4538C /* GPUError.cpp */,
     18338                                D09AFB0722D5391B00C4538C /* GPUError.h */,
     18339                                D09AFB0222D0471900C4538C /* GPUErrorFilter.h */,
    1832318340                                D026F47D220A2AC600AC5F49 /* GPUExtent3D.h */,
    1832418341                                D0F7559F2203BA1400118058 /* GPULimits.h */,
    1832518342                                D08AA02F220D0BD50058C502 /* GPULoadOp.h */,
     18343                                D09AFB1922D6698A00C4538C /* GPUOutOfMemoryError.h */,
    1832618344                                312FF8C421A4C2F400EB199D /* GPUPipelineDescriptorBase.h */,
    1832718345                                D003288721C9A4E500622AA6 /* GPUPipelineLayout.cpp */,
     
    1834918367                                D026F485220A477200AC5F49 /* GPUTextureUsage.h */,
    1835018368                                D06EF552220BA26A0018724E /* GPUUtils.h */,
     18369                                D09AFB0E22D55FF500C4538C /* GPUValidationError.cpp */,
     18370                                D09AFB0D22D55F3B00C4538C /* GPUValidationError.h */,
    1835118371                                D0D8649B21BA1C2D003C983C /* GPUVertexAttributeDescriptor.h */,
    1835218372                                D0D8649C21BA1CE8003C983C /* GPUVertexBufferDescriptor.h */,
     
    2593825958                                D03C849E21FFCF000002227F /* GPUCompareFunction.idl */,
    2593925959                                D03C84A221FFD7230002227F /* GPUDepthStencilStateDescriptor.idl */,
     25960                                D09AFB0622D417B300C4538C /* GPUErrorFilter.idl */,
    2594025961                                D026F480220A2B7000AC5F49 /* GPUExtent3D.idl */,
    2594125962                                D08AA02D220D0B9C0058C502 /* GPULoadOp.idl */,
    2594225963                                D0CCA94922299F97006979B6 /* GPUOrigin3D.h */,
    2594325964                                D0CCA94A22299F97006979B6 /* GPUOrigin3D.idl */,
     25965                                D09AFB1722D6694E00C4538C /* GPUOutOfMemoryError.idl */,
    2594425966                                D02C26922181416D00D818E4 /* GPURequestAdapterOptions.idl */,
    2594525967                                D0ADB26322309D7600A22935 /* GPUSamplerDescriptor.idl */,
     
    2595025972                                D0EACFAE219E30FD000FA75C /* GPUTextureFormat.idl */,
    2595125973                                D026F483220A472F00AC5F49 /* GPUTextureUsage.idl */,
     25974                                D09AFB0C22D55E9000C4538C /* GPUValidationError.idl */,
    2595225975                                D0D8649621BA18F4003C983C /* GPUVertexAttributeDescriptor.idl */,
    2595325976                                D0D8649821BA19A7003C983C /* GPUVertexBufferDescriptor.idl */,
     
    2599626019                                D00F595221701D8C000D71DB /* WebGPUDevice.h */,
    2599726020                                D00F595421701D8C000D71DB /* WebGPUDevice.idl */,
     26021                                D09AFB0122D02E5300C4538C /* WebGPUDeviceErrorScopes.cpp */,
     26022                                D09AFAFF22D02E5300C4538C /* WebGPUDeviceErrorScopes.h */,
     26023                                D09AFB0322D40CC500C4538C /* WebGPUDeviceErrorScopes.idl */,
    2599826024                                D0C419F02183EB31009EC1DE /* WebGPUPipelineDescriptorBase.h */,
    2599926025                                D0C419F12183EB31009EC1DE /* WebGPUPipelineDescriptorBase.idl */,
     
    2840128427                                7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */,
    2840228428                                7C1E97281A9F9834007BF0FB /* AutoFillButtonElement.h in Headers */,
     28429                                5CCC270922D5483A00964FA0 /* AutofillElements.h in Headers */,
    2840328430                                C9D467051E60C465008195FB /* AutoplayEvent.h in Headers */,
    2840428431                                45830D4E1679B4F800ACF8C3 /* AutoscrollController.h in Headers */,
     
    3004530072                                A77979290D6B9E64003851B9 /* JSImageData.h in Headers */,
    3004630073                                7C193C011F5E11050088F3E6 /* JSImageSmoothingQuality.h in Headers */,
    30047                                 5CCC270922D5483A00964FA0 /* AutofillElements.h in Headers */,
    3004830074                                A86629D309DA2B48009633A6 /* JSInputEvent.h in Headers */,
    3004930075                                9175CE5E21E281ED00DF2C28 /* JSInspectorAuditAccessibilityObject.h in Headers */,
  • trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h

    r245788 r247366  
    9595    macro(GPUComputePipeline) \
    9696    macro(GPUDevice) \
     97    macro(GPUOutOfMemoryError) \
    9798    macro(GPUPipelineLayout) \
    9899    macro(GPUProgrammablePassEncoder) \
     
    107108    macro(GPUTextureUsage) \
    108109    macro(GPUTextureView) \
     110    macro(GPUValidationError) \
    109111    macro(HTMLAttachmentElement) \
    110112    macro(HTMLAudioElement) \
  • trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h

    r246217 r247366  
    109109
    110110    GPUBuffer(PlatformBufferSmartPtr&&, Ref<GPUDevice>&&, size_t, OptionSet<GPUBufferUsage::Flags>, bool);
    111     static bool validateBufferUsage(const GPUDevice&, OptionSet<GPUBufferUsage::Flags>);
     111    static bool validateBufferUsage(GPUDevice&, OptionSet<GPUBufferUsage::Flags>);
    112112
    113113    JSC::ArrayBuffer* stagingBufferForRead();
  • trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp

    r246217 r247366  
    4747#include "GPUTexture.h"
    4848#include "GPUTextureDescriptor.h"
     49#include <algorithm>
    4950#include <wtf/Optional.h>
    5051
     
    109110}
    110111
     112void GPUDevice::pushErrorScope(GPUErrorFilter filter)
     113{
     114    m_errorScopes.append(ErrorScope { filter, WTF::nullopt });
     115}
     116
     117void GPUDevice::popErrorScope(ErrorCallback&& callback)
     118{
     119    if (!m_platformDevice)
     120        callback(WTF::nullopt, "GPUDevice::popErrorScope(): Invalid GPUDevice!");
     121    else if (m_errorScopes.isEmpty())
     122        callback(WTF::nullopt, "GPUDevice::popErrorScope(): No error scope exists!");
     123    else {
     124        auto scope = m_errorScopes.takeLast();
     125        callback(scope.filter == GPUErrorFilter::None ? WTF::nullopt : WTFMove(scope.error), { });
     126    }
     127}
     128
     129void GPUDevice::registerError(const String& message, GPUErrorFilter filter)
     130{
     131    auto iterator = std::find_if(m_errorScopes.rbegin(), m_errorScopes.rend(), [filter](const ErrorScope& scope) {
     132        return scope.filter == GPUErrorFilter::None || scope.filter == filter;
     133    });
     134
     135    // FIXME: https://webkit.org/b/199676 Uncaptured errors need to be fired as GPUUncapturedErrorEvents.
     136    if (iterator == m_errorScopes.rend())
     137        return;
     138
     139    // If the scope has already captured an error, ignore this new one.
     140    if (iterator->error)
     141        return;
     142
     143    iterator->error = createError(filter, message);
     144}
     145
    111146} // namespace WebCore
    112147
  • trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h

    r246217 r247366  
    2828#if ENABLE(WEBGPU)
    2929
     30#include "GPUError.h"
     31#include "GPUErrorFilter.h"
    3032#include "GPUQueue.h"
    3133#include "GPUSwapChain.h"
     34#include <wtf/Function.h>
     35#include <wtf/Optional.h>
    3236#include <wtf/RefCounted.h>
    3337#include <wtf/RetainPtr.h>
     38#include <wtf/Vector.h>
    3439#include <wtf/WeakPtr.h>
     40#include <wtf/text/WTFString.h>
    3541
    3642OBJC_PROTOCOL(MTLDevice);
     
    5864struct GPUSwapChainDescriptor;
    5965struct GPUTextureDescriptor;
    60    
     66
    6167using PlatformDevice = MTLDevice;
    6268using PlatformDeviceSmartPtr = RetainPtr<MTLDevice>;
     
    8591    void setSwapChain(RefPtr<GPUSwapChain>&&);
    8692
     93    void pushErrorScope(GPUErrorFilter);
     94
     95    using ErrorCallback = WTF::Function<void(Optional<GPUError>&&, const String&)>;
     96    void popErrorScope(ErrorCallback&&);
     97    void registerError(const String&, GPUErrorFilter = GPUErrorFilter::Validation);
     98
    8799private:
     100    struct ErrorScope {
     101        const GPUErrorFilter filter;
     102        Optional<GPUError> error;
     103    };
     104
    88105    explicit GPUDevice(PlatformDeviceSmartPtr&&);
    89106
     
    91108    mutable RefPtr<GPUQueue> m_queue;
    92109    RefPtr<GPUSwapChain> m_swapChain;
     110
     111    Vector<ErrorScope> m_errorScopes;
    93112};
    94113
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm

    r246217 r247366  
    4343
    4444
    45 bool GPUBuffer::validateBufferUsage(const GPUDevice& device, OptionSet<GPUBufferUsage::Flags> usage)
     45bool GPUBuffer::validateBufferUsage(GPUDevice& device, OptionSet<GPUBufferUsage::Flags> usage)
    4646{
    4747    if (!device.platformDevice()) {
     
    5151
    5252    if (usage.containsAll({ GPUBufferUsage::Flags::MapWrite, GPUBufferUsage::Flags::MapRead })) {
    53         LOG(WebGPU, "GPUBuffer::tryCreate(): Buffer cannot have both MAP_READ and MAP_WRITE usage!");
     53        device.registerError("GPUBuffer::tryCreate(): Buffer cannot have both MAP_READ and MAP_WRITE usage!");
    5454        return false;
    5555    }
     
    6868    NSUInteger size = 0;
    6969    if (!WTF::convertSafely(descriptor.size, size)) {
    70         LOG(WebGPU, "GPUBuffer::tryCreate(): Buffer size is too large!");
     70        device->registerError("", GPUErrorFilter::OutOfMemory);
    7171        return nullptr;
    7272    }
     
    103103
    104104    if (!mtlBuffer) {
    105         LOG(WebGPU, "GPUBuffer::tryCreate(): Unable to create MTLBuffer!");
     105        device->registerError("", GPUErrorFilter::OutOfMemory);
    106106        return nullptr;
    107107    }
Note: See TracChangeset for help on using the changeset viewer.