Changeset 247397 in webkit
- Timestamp:
- Jul 12, 2019 2:07:49 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r247395 r247397 1 2019-07-12 Justin Fan <justin_fan@apple.com> 2 3 [WebGPU] Move error scopes out of GPUDevice for more portable error generation 4 https://bugs.webkit.org/show_bug.cgi?id=199740 5 6 Reviewed by Myles C. Maxfield. 7 8 Move error generation into a separate RefCounted class to allow GPU objects to generate 9 errors independent of any GPUDevice. 10 Create GPUObjectBase to delegate error generation and refactor GPUBuffer to inherit from GPUObjectBase. 11 12 No behavior change or new tests. Error scopes covered by error-scopes-test.html. 13 14 * Modules/webgpu/WebGPUDevice.cpp: 15 (WebCore::WebGPUDevice::WebGPUDevice): Now creates a GPUErrorGenerator. 16 (WebCore::WebGPUDevice::createBuffer const): Pass the GPUErrorGenerator to any created GPUBuffer. 17 (WebCore::WebGPUDevice::createBufferMapped const): Ditto. 18 (WebCore::WebGPUDevice::popErrorScope): Shouldn't be const. Can just ask for the GPUError rather than passing a lambda. 19 (WebCore::WebGPUDevice::pushErrorScope const): Deleted. 20 (WebCore::WebGPUDevice::popErrorScope const): Deleted. 21 * Modules/webgpu/WebGPUDevice.h: 22 (WebCore::WebGPUDevice::pushErrorScope): 23 * Sources.txt: 24 * WebCore.xcodeproj/project.pbxproj: 25 * platform/graphics/gpu/GPUBuffer.h: Now inherits from GPUObjectBase for error generation ease. 26 * platform/graphics/gpu/GPUDevice.cpp: 27 (WebCore::GPUDevice::tryCreateBuffer): Ensure GPUBuffers reference the GPUErrorGenerator. 28 (WebCore::GPUDevice::pushErrorScope): Deleted. No longer needed here. 29 (WebCore::GPUDevice::popErrorScope): Deleted. 30 (WebCore::GPUDevice::registerError): Deleted. 31 * platform/graphics/gpu/GPUDevice.h: Move error scope logic out. 32 * platform/graphics/gpu/GPUErrorGenerator.cpp: Added. 33 (WebCore::GPUErrorGenerator::pushErrorScope): 34 (WebCore::GPUErrorGenerator::popErrorScope): 35 (WebCore::GPUErrorGenerator::generateError): 36 * platform/graphics/gpu/GPUErrorGenerator.h: Added. 37 (WebCore::GPUErrorGenerator::create): 38 * platform/graphics/gpu/GPUObjectBase.h: Added. 39 (WebCore::GPUObjectBase::generateError): 40 (WebCore::GPUObjectBase::GPUObjectBase): 41 * platform/graphics/gpu/cocoa/GPUBufferMetal.mm: Use the GPUErrorGenerator directly during buffer creation. 42 (WebCore::GPUBuffer::validateBufferUsage): 43 (WebCore::GPUBuffer::tryCreate): 44 (WebCore::GPUBuffer::GPUBuffer): 45 * platform/graphics/gpu/cocoa/GPUQueueMetal.mm: 46 (WebCore::GPUQueue::submit): Prevent possible null dereference. 47 1 48 2019-07-12 Youenn Fablet <youenn@apple.com> 2 49 -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
r247366 r247397 68 68 #include "WebGPUTexture.h" 69 69 #include <wtf/Optional.h> 70 #include <wtf/text/WTFString.h> 70 71 71 72 namespace WebCore { … … 81 82 : m_adapter(WTFMove(adapter)) 82 83 , m_device(WTFMove(device)) 84 , m_errorScopes(GPUErrorScopes::create()) 83 85 { 84 86 } … … 86 88 Ref<WebGPUBuffer> WebGPUDevice::createBuffer(const GPUBufferDescriptor& descriptor) const 87 89 { 88 auto buffer = m_device->tryCreateBuffer(descriptor );90 auto buffer = m_device->tryCreateBuffer(descriptor, GPUBufferMappedOption::NotMapped, m_errorScopes.copyRef()); 89 91 return WebGPUBuffer::create(WTFMove(buffer)); 90 92 } … … 94 96 JSC::JSValue wrappedArrayBuffer = JSC::jsNull(); 95 97 96 auto buffer = m_device->tryCreateBuffer(descriptor, true);98 auto buffer = m_device->tryCreateBuffer(descriptor, GPUBufferMappedOption::IsMapped, m_errorScopes.copyRef()); 97 99 if (buffer) { 98 100 auto arrayBuffer = buffer->mapOnCreation(); … … 185 187 } 186 188 187 void WebGPUDevice::pushErrorScope(GPUErrorFilter filter) const 188 { 189 m_device->pushErrorScope(filter); 190 } 191 192 void 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 }); 189 void WebGPUDevice::popErrorScope(ErrorPromise&& promise) 190 { 191 String failMessage; 192 Optional<GPUError> error = m_errorScopes->popErrorScope(failMessage); 193 if (failMessage.isEmpty()) 194 promise.resolve(error); 195 else 196 promise.reject(Exception { OperationError, "GPUDevice::popErrorScope(): " + failMessage }); 200 197 } 201 198 -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h
r247366 r247397 29 29 30 30 #include "GPUDevice.h" 31 #include "GPUErrorScopes.h" 31 32 #include "JSDOMPromiseDeferred.h" 32 33 #include "WebGPUAdapter.h" … … 100 101 Ref<WebGPUQueue> getQueue() const; 101 102 102 void pushErrorScope(GPUErrorFilter ) const;103 void popErrorScope(ErrorPromise&&) const;103 void pushErrorScope(GPUErrorFilter filter) { m_errorScopes->pushErrorScope(filter); } 104 void popErrorScope(ErrorPromise&&); 104 105 105 106 private: … … 109 110 Ref<GPUDevice> m_device; 110 111 mutable RefPtr<WebGPUQueue> m_queue; 112 113 Ref<GPUErrorScopes> m_errorScopes; 111 114 }; 112 115 -
trunk/Source/WebCore/Sources.txt
r247366 r247397 1830 1830 platform/graphics/gpu/GPUDevice.cpp 1831 1831 platform/graphics/gpu/GPUError.cpp 1832 platform/graphics/gpu/GPUErrorScopes.cpp 1832 1833 platform/graphics/gpu/GPUValidationError.cpp 1833 1834 platform/graphics/gpu/GPUPipelineLayout.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r247366 r247397 13955 13955 D03211CF21AC954E00763CF2 /* GPUProgrammablePassEncoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUProgrammablePassEncoder.h; sourceTree = "<group>"; }; 13956 13956 D03211D021AC954F00763CF2 /* GPURenderPassDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPURenderPassDescriptor.h; sourceTree = "<group>"; }; 13957 D03586B122D7F2EA00DA0284 /* GPUErrorScopes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUErrorScopes.h; sourceTree = "<group>"; }; 13958 D03586B222D7F2EA00DA0284 /* GPUErrorScopes.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUErrorScopes.cpp; sourceTree = "<group>"; }; 13957 13959 D036DD8D208FFC0C00F9F4B2 /* WebGLCompressedTextureASTC.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGLCompressedTextureASTC.idl; sourceTree = "<group>"; }; 13958 13960 D03C849A21FFC6670002227F /* GPUDepthStencilStateDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUDepthStencilStateDescriptor.h; sourceTree = "<group>"; }; … … 14032 14034 D09AFB1922D6698A00C4538C /* GPUOutOfMemoryError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUOutOfMemoryError.h; sourceTree = "<group>"; }; 14033 14035 D09AFB2D22D6C01400C4538C /* GPUError.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUError.cpp; sourceTree = "<group>"; }; 14036 D09AFB3722D7D5C600C4538C /* GPUObjectBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUObjectBase.h; sourceTree = "<group>"; }; 14034 14037 D0A20D542092A0A600E0C259 /* WebGLCompressedTextureASTC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLCompressedTextureASTC.h; sourceTree = "<group>"; }; 14035 14038 D0A20D562092A0A600E0C259 /* WebGLCompressedTextureASTC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLCompressedTextureASTC.cpp; sourceTree = "<group>"; }; … … 18338 18341 D09AFB0722D5391B00C4538C /* GPUError.h */, 18339 18342 D09AFB0222D0471900C4538C /* GPUErrorFilter.h */, 18343 D03586B222D7F2EA00DA0284 /* GPUErrorScopes.cpp */, 18344 D03586B122D7F2EA00DA0284 /* GPUErrorScopes.h */, 18340 18345 D026F47D220A2AC600AC5F49 /* GPUExtent3D.h */, 18341 18346 D0F7559F2203BA1400118058 /* GPULimits.h */, 18342 18347 D08AA02F220D0BD50058C502 /* GPULoadOp.h */, 18348 D09AFB3722D7D5C600C4538C /* GPUObjectBase.h */, 18343 18349 D09AFB1922D6698A00C4538C /* GPUOutOfMemoryError.h */, 18344 18350 312FF8C421A4C2F400EB199D /* GPUPipelineDescriptorBase.h */, -
trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h
r247366 r247397 30 30 #include "DeferrableTask.h" 31 31 #include "GPUBufferUsage.h" 32 #include "GPUObjectBase.h" 32 33 #include <wtf/Function.h> 33 34 #include <wtf/OptionSet.h> … … 52 53 struct GPUBufferDescriptor; 53 54 55 enum class GPUBufferMappedOption; 56 54 57 #if USE(METAL) 55 58 using PlatformBuffer = MTLBuffer; … … 59 62 using PlatformBufferSmartPtr = RetainPtr<PlatformBuffer>; 60 63 61 class GPUBuffer : public RefCounted<GPUBuffer>{64 class GPUBuffer : public GPUObjectBase { 62 65 public: 63 66 enum class State { … … 69 72 ~GPUBuffer(); 70 73 71 static RefPtr<GPUBuffer> tryCreate(Ref<GPUDevice>&&, const GPUBufferDescriptor&, bool isMappedOnCreation);74 static RefPtr<GPUBuffer> tryCreate(Ref<GPUDevice>&&, const GPUBufferDescriptor&, GPUBufferMappedOption, Ref<GPUErrorScopes>&&); 72 75 73 76 PlatformBuffer *platformBuffer() const { return m_platformBuffer.get(); } … … 108 111 }; 109 112 110 GPUBuffer(PlatformBufferSmartPtr&&, Ref<GPUDevice>&&, size_t, OptionSet<GPUBufferUsage::Flags>, bool);111 static bool validateBufferUsage(GPUDevice&, OptionSet<GPUBufferUsage::Flags> );113 GPUBuffer(PlatformBufferSmartPtr&&, Ref<GPUDevice>&&, size_t, OptionSet<GPUBufferUsage::Flags>, GPUBufferMappedOption, Ref<GPUErrorScopes>&&); 114 static bool validateBufferUsage(GPUDevice&, OptionSet<GPUBufferUsage::Flags>, GPUErrorScopes&); 112 115 113 116 JSC::ArrayBuffer* stagingBufferForRead(); -
trunk/Source/WebCore/platform/graphics/gpu/GPUBufferDescriptor.h
r243658 r247397 37 37 }; 38 38 39 enum class GPUBufferMappedOption { 40 IsMapped, 41 NotMapped 42 }; 43 39 44 } // namespace WebCore 40 45 -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp
r247366 r247397 36 36 #include "GPUComputePipeline.h" 37 37 #include "GPUComputePipelineDescriptor.h" 38 #include "GPUErrorScopes.h" 38 39 #include "GPUPipelineLayout.h" 39 40 #include "GPUPipelineLayoutDescriptor.h" … … 52 53 namespace WebCore { 53 54 54 RefPtr<GPUBuffer> GPUDevice::tryCreateBuffer(const GPUBufferDescriptor& descriptor, bool isMappedOnCreation)55 RefPtr<GPUBuffer> GPUDevice::tryCreateBuffer(const GPUBufferDescriptor& descriptor, GPUBufferMappedOption isMapped, Ref<GPUErrorScopes>&& errorScopes) 55 56 { 56 return GPUBuffer::tryCreate(makeRef(*this), descriptor, isMapped OnCreation);57 return GPUBuffer::tryCreate(makeRef(*this), descriptor, isMapped, WTFMove(errorScopes)); 57 58 } 58 59 … … 110 111 } 111 112 112 void GPUDevice::pushErrorScope(GPUErrorFilter filter)113 {114 m_errorScopes.append(ErrorScope { filter, WTF::nullopt });115 }116 117 void 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 129 void 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 146 113 } // namespace WebCore 147 114 -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h
r247366 r247397 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUError.h"31 #include "GPUErrorFilter.h"32 30 #include "GPUQueue.h" 33 31 #include "GPUSwapChain.h" … … 36 34 #include <wtf/RefCounted.h> 37 35 #include <wtf/RetainPtr.h> 38 #include <wtf/Vector.h>39 36 #include <wtf/WeakPtr.h> 40 #include <wtf/text/WTFString.h>41 37 42 38 OBJC_PROTOCOL(MTLDevice); … … 48 44 class GPUCommandBuffer; 49 45 class GPUComputePipeline; 46 class GPUErrorScopes; 50 47 class GPUPipelineLayout; 51 48 class GPURenderPipeline; … … 65 62 struct GPUTextureDescriptor; 66 63 64 enum class GPUBufferMappedOption; 65 67 66 using PlatformDevice = MTLDevice; 68 67 using PlatformDeviceSmartPtr = RetainPtr<MTLDevice>; … … 72 71 static RefPtr<GPUDevice> tryCreate(const Optional<GPURequestAdapterOptions>&); 73 72 74 RefPtr<GPUBuffer> tryCreateBuffer(const GPUBufferDescriptor&, bool isMappedOnCreation = false);73 RefPtr<GPUBuffer> tryCreateBuffer(const GPUBufferDescriptor&, GPUBufferMappedOption, Ref<GPUErrorScopes>&&); 75 74 RefPtr<GPUTexture> tryCreateTexture(const GPUTextureDescriptor&) const; 76 75 RefPtr<GPUSampler> tryCreateSampler(const GPUSamplerDescriptor&) const; … … 91 90 void setSwapChain(RefPtr<GPUSwapChain>&&); 92 91 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 99 92 private: 100 struct ErrorScope {101 const GPUErrorFilter filter;102 Optional<GPUError> error;103 };104 105 93 explicit GPUDevice(PlatformDeviceSmartPtr&&); 106 94 … … 108 96 mutable RefPtr<GPUQueue> m_queue; 109 97 RefPtr<GPUSwapChain> m_swapChain; 110 111 Vector<ErrorScope> m_errorScopes;112 98 }; 113 99 -
trunk/Source/WebCore/platform/graphics/gpu/GPUErrorScopes.cpp
r247396 r247397 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "GPUErrorScopes.h" 27 28 28 29 #if ENABLE(WEBGPU) 29 30 30 #include "GPUBufferUsage.h"31 32 31 namespace WebCore { 33 32 34 struct GPUBufferDescriptor { 35 uint64_t size; 36 GPUBufferUsageFlags usage; 37 }; 33 void GPUErrorScopes::pushErrorScope(GPUErrorFilter filter) 34 { 35 m_errorScopes.append(ErrorScope { filter, WTF::nullopt }); 36 } 37 38 Optional<GPUError> GPUErrorScopes::popErrorScope(String& failMessage) 39 { 40 if (m_errorScopes.isEmpty()) { 41 failMessage = "No error scope exists!"; 42 return WTF::nullopt; 43 } 44 45 auto scope = m_errorScopes.takeLast(); 46 return scope.filter == GPUErrorFilter::None ? WTF::nullopt : scope.error; 47 } 48 49 void GPUErrorScopes::generateError(const String& message, GPUErrorFilter filter) 50 { 51 auto iterator = std::find_if(m_errorScopes.rbegin(), m_errorScopes.rend(), [filter](const ErrorScope& scope) { 52 return scope.filter == GPUErrorFilter::None || scope.filter == filter; 53 }); 54 55 // FIXME: https://webkit.org/b/199676 Uncaptured errors need to be fired as GPUUncapturedErrorEvents. 56 if (iterator == m_errorScopes.rend()) 57 return; 58 59 // If the scope has already captured an error, ignore this new one. 60 if (iterator->error) 61 return; 62 63 iterator->error = createError(filter, message); 64 } 38 65 39 66 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/gpu/GPUErrorScopes.h
r247396 r247397 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUBufferUsage.h" 30 #include "GPUError.h" 31 #include "GPUErrorFilter.h" 32 #include <wtf/Optional.h> 33 #include <wtf/Ref.h> 34 #include <wtf/RefCounted.h> 35 #include <wtf/Vector.h> 36 #include <wtf/text/WTFString.h> 31 37 32 38 namespace WebCore { 33 39 34 struct GPUBufferDescriptor { 35 uint64_t size; 36 GPUBufferUsageFlags usage; 40 class GPUErrorScopes : public RefCounted<GPUErrorScopes> { 41 public: 42 static Ref<GPUErrorScopes> create() { return adoptRef(*new GPUErrorScopes); } 43 44 void pushErrorScope(GPUErrorFilter); 45 Optional<GPUError> popErrorScope(String& failMessage); 46 void generateError(const String&, GPUErrorFilter = GPUErrorFilter::Validation); 47 48 private: 49 struct ErrorScope { 50 const GPUErrorFilter filter; 51 Optional<GPUError> error; 52 }; 53 54 GPUErrorScopes() = default; 55 56 Vector<ErrorScope> m_errorScopes; 37 57 }; 38 58 -
trunk/Source/WebCore/platform/graphics/gpu/GPUObjectBase.h
r247396 r247397 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUBufferUsage.h" 30 #include "GPUErrorScopes.h" 31 #include <wtf/RefCounted.h> 31 32 32 33 namespace WebCore { 33 34 34 struct GPUBufferDescriptor { 35 uint64_t size; 36 GPUBufferUsageFlags usage; 35 class GPUObjectBase : public RefCounted<GPUObjectBase> { 36 public: 37 void generateError(const String& message, GPUErrorFilter filter = GPUErrorFilter::Validation) 38 { 39 m_errorScopes->generateError(message, filter); 40 } 41 42 protected: 43 GPUObjectBase(Ref<GPUErrorScopes>&& reporter) 44 : m_errorScopes(WTFMove(reporter)) { } 45 46 private: 47 Ref<GPUErrorScopes> m_errorScopes; 37 48 }; 38 49 -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm
r247366 r247397 43 43 44 44 45 bool GPUBuffer::validateBufferUsage(GPUDevice& device, OptionSet<GPUBufferUsage::Flags> usage )45 bool GPUBuffer::validateBufferUsage(GPUDevice& device, OptionSet<GPUBufferUsage::Flags> usage, GPUErrorScopes& errorScopes) 46 46 { 47 47 if (!device.platformDevice()) { … … 51 51 52 52 if (usage.containsAll({ GPUBufferUsage::Flags::MapWrite, GPUBufferUsage::Flags::MapRead })) { 53 device.registerError("GPUBuffer::tryCreate(): Buffer cannot have both MAP_READ and MAP_WRITE usage!");53 errorScopes.generateError("GPUBuffer::tryCreate(): Buffer cannot have both MAP_READ and MAP_WRITE usage!"); 54 54 return false; 55 55 } … … 63 63 } 64 64 65 RefPtr<GPUBuffer> GPUBuffer::tryCreate(Ref<GPUDevice>&& device, const GPUBufferDescriptor& descriptor, bool isMappedOnCreation)65 RefPtr<GPUBuffer> GPUBuffer::tryCreate(Ref<GPUDevice>&& device, const GPUBufferDescriptor& descriptor, GPUBufferMappedOption isMapped, Ref<GPUErrorScopes>&& errorScopes) 66 66 { 67 67 // MTLBuffer size (NSUInteger) is 32 bits on some platforms. 68 68 NSUInteger size = 0; 69 69 if (!WTF::convertSafely(descriptor.size, size)) { 70 device->registerError("", GPUErrorFilter::OutOfMemory);70 errorScopes->generateError("", GPUErrorFilter::OutOfMemory); 71 71 return nullptr; 72 72 } 73 73 74 74 auto usage = OptionSet<GPUBufferUsage::Flags>::fromRaw(descriptor.usage); 75 if (!validateBufferUsage(device.get(), usage ))75 if (!validateBufferUsage(device.get(), usage, errorScopes)) 76 76 return nullptr; 77 77 … … 79 79 // copyBufferToBuffer calls require 4-byte alignment. "Unmapping" a mapped-on-creation GPUBuffer 80 80 // that is otherwise unmappable requires such a copy to upload data. 81 if (isMapped OnCreation81 if (isMapped == GPUBufferMappedOption::IsMapped 82 82 && !usage.containsAny({ GPUBufferUsage::Flags::MapWrite, GPUBufferUsage::Flags::MapRead }) 83 83 && descriptor.size % 4) { … … 103 103 104 104 if (!mtlBuffer) { 105 device->registerError("", GPUErrorFilter::OutOfMemory); 106 return nullptr; 107 } 108 109 return adoptRef(*new GPUBuffer(WTFMove(mtlBuffer), WTFMove(device), size, usage, isMappedOnCreation)); 110 } 111 112 GPUBuffer::GPUBuffer(RetainPtr<MTLBuffer>&& buffer, Ref<GPUDevice>&& device, size_t size, OptionSet<GPUBufferUsage::Flags> usage, bool isMapped) 113 : m_platformBuffer(WTFMove(buffer)) 105 errorScopes->generateError("", GPUErrorFilter::OutOfMemory); 106 return nullptr; 107 } 108 109 return adoptRef(*new GPUBuffer(WTFMove(mtlBuffer), WTFMove(device), size, usage, isMapped, WTFMove(errorScopes))); 110 } 111 112 GPUBuffer::GPUBuffer(RetainPtr<MTLBuffer>&& buffer, Ref<GPUDevice>&& device, size_t size, OptionSet<GPUBufferUsage::Flags> usage, GPUBufferMappedOption isMapped, Ref<GPUErrorScopes>&& errorScopes) 113 : GPUObjectBase(WTFMove(errorScopes)) 114 , m_platformBuffer(WTFMove(buffer)) 114 115 , m_device(WTFMove(device)) 115 116 , m_byteLength(size) 116 117 , m_usage(usage) 117 , m_isMappedFromCreation(isMapped )118 , m_isMappedFromCreation(isMapped == GPUBufferMappedOption::IsMapped) 118 119 { 119 120 } -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUQueueMetal.mm
r242759 r247397 97 97 } 98 98 99 if (m_presentTask.hasPendingTask() || !m_device ->swapChain())99 if (m_presentTask.hasPendingTask() || !m_device || !m_device->swapChain()) 100 100 return; 101 101
Note: See TracChangeset
for help on using the changeset viewer.