Title: [247892] trunk/Source/WebCore
Revision
247892
Author
justin_...@apple.com
Date
2019-07-27 17:47:00 -0700 (Sat, 27 Jul 2019)

Log Message

[WebGPU] Update GPUComputePipeline errors to match GPURenderPipeline implementation
https://bugs.webkit.org/show_bug.cgi?id=200097

Reviewed by Myles C. Maxfield.

Remove passing around a functionName in GPUComputePipeline creation in favor of setting it on the GPUErrorScopes.
Also, WebGPU objects no longer create new Ref<>s unless object creation succeeds.

No new tests. Covered by existing tests.

* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::WebGPUDevice::createBuffer const):
(WebCore::WebGPUDevice::createBufferMapped const):
(WebCore::WebGPUDevice::createComputePipeline const):
* platform/graphics/gpu/GPUBuffer.h:
* platform/graphics/gpu/GPUComputePipeline.h:
* platform/graphics/gpu/GPUDevice.cpp:
(WebCore::GPUDevice::tryCreateBuffer):
(WebCore::GPUDevice::tryCreateComputePipeline const):
* platform/graphics/gpu/GPUDevice.h:
* platform/graphics/gpu/GPUErrorScopes.cpp:
(WebCore::GPUErrorScopes::generatePrefixedError): Only validaton errors have messages right now.
* platform/graphics/gpu/GPUErrorScopes.h:
* platform/graphics/gpu/cocoa/GPUBufferMetal.mm:
(WebCore::GPUBuffer::validateBufferUsage):
(WebCore::GPUBuffer::tryCreate):
(WebCore::GPUBuffer::GPUBuffer):
* platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm:
(WebCore::trySetMetalFunctions):
(WebCore::trySetFunctions):
(WebCore::convertComputePipelineDescriptor):
(WebCore::tryCreateMTLComputePipelineState):
(WebCore::GPUComputePipeline::tryCreate):
(WebCore::GPUComputePipeline::GPUComputePipeline):
* platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
(WebCore::trySetMetalFunctions):
(WebCore::trySetFunctions):

These classes were made RefCounted in a previous patch; remove their move ctors to fix build.
* Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h:
* Modules/webgpu/WHLSL/AST/WHLSLArrayType.h:
* Modules/webgpu/WHLSL/AST/WHLSLPointerType.h:
* Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h:
* Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h:
* Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (247891 => 247892)


--- trunk/Source/WebCore/ChangeLog	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/ChangeLog	2019-07-28 00:47:00 UTC (rev 247892)
@@ -1,3 +1,51 @@
+2019-07-27  Justin Fan  <justin_...@apple.com>
+
+        [WebGPU] Update GPUComputePipeline errors to match GPURenderPipeline implementation
+        https://bugs.webkit.org/show_bug.cgi?id=200097
+
+        Reviewed by Myles C. Maxfield.
+
+        Remove passing around a functionName in GPUComputePipeline creation in favor of setting it on the GPUErrorScopes.
+        Also, WebGPU objects no longer create new Ref<>s unless object creation succeeds.
+
+        No new tests. Covered by existing tests.
+
+        * Modules/webgpu/WebGPUDevice.cpp:
+        (WebCore::WebGPUDevice::createBuffer const):
+        (WebCore::WebGPUDevice::createBufferMapped const):
+        (WebCore::WebGPUDevice::createComputePipeline const):
+        * platform/graphics/gpu/GPUBuffer.h:
+        * platform/graphics/gpu/GPUComputePipeline.h:
+        * platform/graphics/gpu/GPUDevice.cpp:
+        (WebCore::GPUDevice::tryCreateBuffer):
+        (WebCore::GPUDevice::tryCreateComputePipeline const):
+        * platform/graphics/gpu/GPUDevice.h:
+        * platform/graphics/gpu/GPUErrorScopes.cpp:
+        (WebCore::GPUErrorScopes::generatePrefixedError): Only validaton errors have messages right now.
+        * platform/graphics/gpu/GPUErrorScopes.h:
+        * platform/graphics/gpu/cocoa/GPUBufferMetal.mm:
+        (WebCore::GPUBuffer::validateBufferUsage):
+        (WebCore::GPUBuffer::tryCreate):
+        (WebCore::GPUBuffer::GPUBuffer):
+        * platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm:
+        (WebCore::trySetMetalFunctions):
+        (WebCore::trySetFunctions):
+        (WebCore::convertComputePipelineDescriptor):
+        (WebCore::tryCreateMTLComputePipelineState):
+        (WebCore::GPUComputePipeline::tryCreate):
+        (WebCore::GPUComputePipeline::GPUComputePipeline):
+        * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
+        (WebCore::trySetMetalFunctions):
+        (WebCore::trySetFunctions):
+
+        These classes were made RefCounted in a previous patch; remove their move ctors to fix build.
+        * Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLArrayType.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLPointerType.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h:
+        * Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h:
+
 2019-07-27  Andres Gonzalez  <andresg...@apple.com>
 
         Expose the aria-label attribute for <video> elements.

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h (247891 => 247892)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayReferenceType.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -56,7 +56,6 @@
     virtual ~ArrayReferenceType() = default;
 
     ArrayReferenceType(const ArrayReferenceType&) = delete;
-    ArrayReferenceType(ArrayReferenceType&&) = default;
 
     bool isArrayReferenceType() const override { return true; }
 

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h (247891 => 247892)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLArrayType.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -58,7 +58,6 @@
     virtual ~ArrayType() = default;
 
     ArrayType(const ArrayType&) = delete;
-    ArrayType(ArrayType&&) = default;
 
     bool isArrayType() const override { return true; }
 

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h (247891 => 247892)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLPointerType.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -57,7 +57,6 @@
     virtual ~PointerType() = default;
 
     PointerType(const PointerType&) = delete;
-    PointerType(PointerType&&) = default;
 
     bool isPointerType() const override { return true; }
 

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h (247891 => 247892)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLReferenceType.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -54,7 +54,6 @@
     virtual ~ReferenceType() = default;
 
     ReferenceType(const ReferenceType&) = delete;
-    ReferenceType(ReferenceType&&) = default;
 
     bool isReferenceType() const override { return true; }
 

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h (247891 => 247892)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLTypeReference.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -60,7 +60,6 @@
     virtual ~TypeReference() = default;
 
     TypeReference(const TypeReference&) = delete;
-    TypeReference(TypeReference&&) = default;
 
     static Ref<TypeReference> wrap(CodeLocation, NamedType& resolvedType);
 

Modified: trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h (247891 => 247892)


--- trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLUnnamedType.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -51,7 +51,6 @@
     virtual ~UnnamedType() = default;
 
     UnnamedType(const UnnamedType&) = delete;
-    UnnamedType(UnnamedType&&) = default;
 
     bool isUnnamedType() const override { return true; }
     virtual bool isTypeReference() const { return false; }

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (247891 => 247892)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2019-07-28 00:47:00 UTC (rev 247892)
@@ -87,15 +87,19 @@
 
 Ref<WebGPUBuffer> WebGPUDevice::createBuffer(const GPUBufferDescriptor& descriptor) const
 {
-    auto buffer = m_device->tryCreateBuffer(descriptor, GPUBufferMappedOption::NotMapped, m_errorScopes.copyRef());
+    m_errorScopes->setErrorPrefix("GPUDevice.createBuffer(): ");
+
+    auto buffer = m_device->tryCreateBuffer(descriptor, GPUBufferMappedOption::NotMapped, m_errorScopes);
     return WebGPUBuffer::create(WTFMove(buffer));
 }
 
 Vector<JSC::JSValue> WebGPUDevice::createBufferMapped(JSC::ExecState& state, const GPUBufferDescriptor& descriptor) const
 {
+    m_errorScopes->setErrorPrefix("GPUDevice.createBufferMapped(): ");
+
     JSC::JSValue wrappedArrayBuffer = JSC::jsNull();
 
-    auto buffer = m_device->tryCreateBuffer(descriptor, GPUBufferMappedOption::IsMapped, m_errorScopes.copyRef());
+    auto buffer = m_device->tryCreateBuffer(descriptor, GPUBufferMappedOption::IsMapped, m_errorScopes);
     if (buffer) {
         auto arrayBuffer = buffer->mapOnCreation();
         wrappedArrayBuffer = toJS(&state, JSC::jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject()), arrayBuffer);
@@ -166,11 +170,13 @@
 
 Ref<WebGPUComputePipeline> WebGPUDevice::createComputePipeline(const WebGPUComputePipelineDescriptor& descriptor) const
 {
+    m_errorScopes->setErrorPrefix("GPUDevice.createComputePipeline(): ");
+
     auto gpuDescriptor = descriptor.tryCreateGPUComputePipelineDescriptor(m_errorScopes);
     if (!gpuDescriptor)
         return WebGPUComputePipeline::create(nullptr);
 
-    auto pipeline = m_device->tryCreateComputePipeline(*gpuDescriptor, m_errorScopes.copyRef());
+    auto pipeline = m_device->tryCreateComputePipeline(*gpuDescriptor, m_errorScopes);
     return WebGPUComputePipeline::create(WTFMove(pipeline));
 }
 

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h (247891 => 247892)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -71,7 +71,7 @@
 
     ~GPUBuffer();
 
-    static RefPtr<GPUBuffer> tryCreate(Ref<GPUDevice>&&, const GPUBufferDescriptor&, GPUBufferMappedOption, Ref<GPUErrorScopes>&&);
+    static RefPtr<GPUBuffer> tryCreate(GPUDevice&, const GPUBufferDescriptor&, GPUBufferMappedOption, GPUErrorScopes&);
 
     PlatformBuffer *platformBuffer() const { return m_platformBuffer.get(); }
     size_t byteLength() const { return m_byteLength; }
@@ -110,7 +110,7 @@
         PendingMappingCallback(MappingCallback&&);
     };
 
-    GPUBuffer(PlatformBufferSmartPtr&&, Ref<GPUDevice>&&, size_t, OptionSet<GPUBufferUsage::Flags>, GPUBufferMappedOption, Ref<GPUErrorScopes>&&);
+    GPUBuffer(PlatformBufferSmartPtr&&, GPUDevice&, size_t, OptionSet<GPUBufferUsage::Flags>, GPUBufferMappedOption, GPUErrorScopes&);
     static bool validateBufferUsage(const GPUDevice&, OptionSet<GPUBufferUsage::Flags>, GPUErrorScopes&);
 
     JSC::ArrayBuffer* stagingBufferForRead();

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h (247891 => 247892)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -46,7 +46,7 @@
 
 class GPUComputePipeline : public GPUObjectBase {
 public:
-    static RefPtr<GPUComputePipeline> tryCreate(const GPUDevice&, const GPUComputePipelineDescriptor&, Ref<GPUErrorScopes>&&);
+    static RefPtr<GPUComputePipeline> tryCreate(const GPUDevice&, const GPUComputePipelineDescriptor&, GPUErrorScopes&);
 
     const PlatformComputePipeline* platformComputePipeline() const { return m_platformComputePipeline.get(); }
 
@@ -53,7 +53,7 @@
     WHLSL::ComputeDimensions computeDimensions() const { return m_computeDimensions; }
 
 private:
-    GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions, Ref<GPUErrorScopes>&&);
+    GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions, GPUErrorScopes&);
 
     PlatformComputePipelineSmartPtr m_platformComputePipeline;
     WHLSL::ComputeDimensions m_computeDimensions { 0, 0, 0 };

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


--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp	2019-07-28 00:47:00 UTC (rev 247892)
@@ -52,9 +52,9 @@
 
 namespace WebCore {
 
-RefPtr<GPUBuffer> GPUDevice::tryCreateBuffer(const GPUBufferDescriptor& descriptor, GPUBufferMappedOption isMapped, Ref<GPUErrorScopes>&& errorScopes)
+RefPtr<GPUBuffer> GPUDevice::tryCreateBuffer(const GPUBufferDescriptor& descriptor, GPUBufferMappedOption isMapped, GPUErrorScopes& errorScopes)
 {
-    return GPUBuffer::tryCreate(makeRef(*this), descriptor, isMapped, WTFMove(errorScopes));
+    return GPUBuffer::tryCreate(*this, descriptor, isMapped, errorScopes);
 }
 
 RefPtr<GPUTexture> GPUDevice::tryCreateTexture(const GPUTextureDescriptor& descriptor) const
@@ -87,9 +87,9 @@
     return GPURenderPipeline::tryCreate(*this, descriptor, errorScopes);
 }
 
-RefPtr<GPUComputePipeline> GPUDevice::tryCreateComputePipeline(const GPUComputePipelineDescriptor& descriptor, Ref<GPUErrorScopes>&& errorScopes) const
+RefPtr<GPUComputePipeline> GPUDevice::tryCreateComputePipeline(const GPUComputePipelineDescriptor& descriptor, GPUErrorScopes& errorScopes) const
 {
-    return GPUComputePipeline::tryCreate(*this, descriptor, WTFMove(errorScopes));
+    return GPUComputePipeline::tryCreate(*this, descriptor, errorScopes);
 }
 
 RefPtr<GPUCommandBuffer> GPUDevice::tryCreateCommandBuffer() const

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


--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -70,7 +70,7 @@
 public:
     static RefPtr<GPUDevice> tryCreate(const Optional<GPURequestAdapterOptions>&);
 
-    RefPtr<GPUBuffer> tryCreateBuffer(const GPUBufferDescriptor&, GPUBufferMappedOption, Ref<GPUErrorScopes>&&);
+    RefPtr<GPUBuffer> tryCreateBuffer(const GPUBufferDescriptor&, GPUBufferMappedOption, GPUErrorScopes&);
     RefPtr<GPUTexture> tryCreateTexture(const GPUTextureDescriptor&) const;
     RefPtr<GPUSampler> tryCreateSampler(const GPUSamplerDescriptor&) const;
 
@@ -79,7 +79,7 @@
 
     RefPtr<GPUShaderModule> tryCreateShaderModule(const GPUShaderModuleDescriptor&) const;
     RefPtr<GPURenderPipeline> tryCreateRenderPipeline(const GPURenderPipelineDescriptor&, GPUErrorScopes&) const;
-    RefPtr<GPUComputePipeline> tryCreateComputePipeline(const GPUComputePipelineDescriptor&, Ref<GPUErrorScopes>&&) const;
+    RefPtr<GPUComputePipeline> tryCreateComputePipeline(const GPUComputePipelineDescriptor&, GPUErrorScopes&) const;
 
     RefPtr<GPUCommandBuffer> tryCreateCommandBuffer() const;
 

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUErrorScopes.cpp (247891 => 247892)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUErrorScopes.cpp	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUErrorScopes.cpp	2019-07-28 00:47:00 UTC (rev 247892)
@@ -63,9 +63,9 @@
     iterator->error = createError(filter, message);
 }
 
-void GPUErrorScopes::generatePrefixedError(const String& message, GPUErrorFilter filter)
+void GPUErrorScopes::generatePrefixedError(const String& message)
 {
-    generateError(m_prefix + message, filter);
+    generateError(m_prefix + message, GPUErrorFilter::Validation);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUErrorScopes.h (247891 => 247892)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUErrorScopes.h	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUErrorScopes.h	2019-07-28 00:47:00 UTC (rev 247892)
@@ -45,7 +45,7 @@
     Optional<GPUError> popErrorScope(String& failMessage);
 
     void generateError(const String&, GPUErrorFilter = GPUErrorFilter::Validation);
-    void generatePrefixedError(const String&, GPUErrorFilter = GPUErrorFilter::Validation);
+    void generatePrefixedError(const String&);
     void setErrorPrefix(const String& prefix) { m_prefix = prefix; }
 
 private:

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm (247891 => 247892)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm	2019-07-28 00:47:00 UTC (rev 247892)
@@ -50,7 +50,7 @@
     }
 
     if (usage.containsAll({ GPUBufferUsage::Flags::MapWrite, GPUBufferUsage::Flags::MapRead })) {
-        errorScopes.generateError("GPUBuffer::tryCreate(): Buffer cannot have both MAP_READ and MAP_WRITE usage!");
+        errorScopes.generatePrefixedError("Buffer cannot have both MAP_READ and MAP_WRITE usage!");
         return false;
     }
 
@@ -62,17 +62,17 @@
     return true;
 }
 
-RefPtr<GPUBuffer> GPUBuffer::tryCreate(Ref<GPUDevice>&& device, const GPUBufferDescriptor& descriptor, GPUBufferMappedOption isMapped, Ref<GPUErrorScopes>&& errorScopes)
+RefPtr<GPUBuffer> GPUBuffer::tryCreate(GPUDevice& device, const GPUBufferDescriptor& descriptor, GPUBufferMappedOption isMapped, GPUErrorScopes& errorScopes)
 {
     // MTLBuffer size (NSUInteger) is 32 bits on some platforms.
     NSUInteger size = 0;
     if (!WTF::convertSafely(descriptor.size, size)) {
-        errorScopes->generateError("", GPUErrorFilter::OutOfMemory);
+        errorScopes.generateError("", GPUErrorFilter::OutOfMemory);
         return nullptr;
     }
 
     auto usage = OptionSet<GPUBufferUsage::Flags>::fromRaw(descriptor.usage);
-    if (!validateBufferUsage(device.get(), usage, errorScopes))
+    if (!validateBufferUsage(device, usage, errorScopes))
         return nullptr;
 
 #if PLATFORM(MAC)
@@ -97,22 +97,22 @@
 
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    mtlBuffer = adoptNS([device->platformDevice() newBufferWithLength:static_cast<NSUInteger>(descriptor.size) options:resourceOptions]);
+    mtlBuffer = adoptNS([device.platformDevice() newBufferWithLength:static_cast<NSUInteger>(descriptor.size) options:resourceOptions]);
 
     END_BLOCK_OBJC_EXCEPTIONS;
 
     if (!mtlBuffer) {
-        errorScopes->generateError("", GPUErrorFilter::OutOfMemory);
+        errorScopes.generateError("", GPUErrorFilter::OutOfMemory);
         return nullptr;
     }
 
-    return adoptRef(*new GPUBuffer(WTFMove(mtlBuffer), WTFMove(device), size, usage, isMapped, WTFMove(errorScopes)));
+    return adoptRef(*new GPUBuffer(WTFMove(mtlBuffer), device, size, usage, isMapped, errorScopes));
 }
 
-GPUBuffer::GPUBuffer(RetainPtr<MTLBuffer>&& buffer, Ref<GPUDevice>&& device, size_t size, OptionSet<GPUBufferUsage::Flags> usage, GPUBufferMappedOption isMapped, Ref<GPUErrorScopes>&& errorScopes)
-    : GPUObjectBase(WTFMove(errorScopes))
+GPUBuffer::GPUBuffer(RetainPtr<MTLBuffer>&& buffer, GPUDevice& device, size_t size, OptionSet<GPUBufferUsage::Flags> usage, GPUBufferMappedOption isMapped, GPUErrorScopes& errorScopes)
+    : GPUObjectBase(makeRef(errorScopes))
     , m_platformBuffer(WTFMove(buffer))
-    , m_device(WTFMove(device))
+    , m_device(makeRef(device))
     , m_byteLength(size)
     , m_usage(usage)
     , m_isMappedFromCreation(isMapped == GPUBufferMappedOption::IsMapped)

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm (247891 => 247892)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm	2019-07-28 00:47:00 UTC (rev 247892)
@@ -38,18 +38,18 @@
 
 namespace WebCore {
 
-static bool trySetMetalFunctions(const char* const functionName, MTLLibrary *computeMetalLibrary, MTLComputePipelineDescriptor *mtlDescriptor, const String& computeEntryPointName, GPUErrorScopes& errorScopes)
+static bool trySetMetalFunctions(MTLLibrary *computeMetalLibrary, MTLComputePipelineDescriptor *mtlDescriptor, const String& computeEntryPointName, GPUErrorScopes& errorScopes)
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
     if (!computeMetalLibrary) {
-        errorScopes.generateError(makeString(functionName, ": MTLLibrary for compute stage does not exist!"));
+        errorScopes.generatePrefixedError("MTLLibrary for compute stage does not exist!");
         return false;
     }
 
     auto function = adoptNS([computeMetalLibrary newFunctionWithName:computeEntryPointName]);
     if (!function) {
-        errorScopes.generateError(makeString(functionName, ": Cannot create compute MTLFunction \"", computeEntryPointName, "\"!"));
+        errorScopes.generatePrefixedError(makeString("Cannot create compute MTLFunction '", computeEntryPointName, "'!"));
         return false;
     }
 
@@ -60,7 +60,7 @@
     return true;
 }
 
-static Optional<WHLSL::ComputeDimensions> trySetFunctions(const char* const functionName, const GPUPipelineStageDescriptor& computeStage, const GPUDevice& device, MTLComputePipelineDescriptor* mtlDescriptor, Optional<WHLSL::ComputePipelineDescriptor>& whlslDescriptor, GPUErrorScopes& errorScopes)
+static Optional<WHLSL::ComputeDimensions> trySetFunctions(const GPUPipelineStageDescriptor& computeStage, const GPUDevice& device, MTLComputePipelineDescriptor* mtlDescriptor, Optional<WHLSL::ComputePipelineDescriptor>& whlslDescriptor, GPUErrorScopes& errorScopes)
 {
     RetainPtr<MTLLibrary> computeLibrary;
     String computeEntryPoint;
@@ -76,7 +76,7 @@
 
         auto whlslCompileResult = WHLSL::prepare(whlslSource, *whlslDescriptor);
         if (!whlslCompileResult) {
-            errorScopes.generateError(makeString("WHLSL compilation failed. ", whlslCompileResult.error()));
+            errorScopes.generatePrefixedError(makeString("WHLSL compile error: ", whlslCompileResult.error()));
             return WTF::nullopt;
         }
 
@@ -100,7 +100,7 @@
         computeEntryPoint = computeStage.entryPoint;
     }
 
-    if (trySetMetalFunctions(functionName, computeLibrary.get(), mtlDescriptor, computeEntryPoint, errorScopes))
+    if (trySetMetalFunctions(computeLibrary.get(), mtlDescriptor, computeEntryPoint, errorScopes))
         return computeDimensions;
 
     return WTF::nullopt;
@@ -111,7 +111,7 @@
     WHLSL::ComputeDimensions computeDimensions;
 };
 
-static Optional<ConvertResult> convertComputePipelineDescriptor(const char* const functionName, const GPUComputePipelineDescriptor& descriptor, const GPUDevice& device, GPUErrorScopes& errorScopes)
+static Optional<ConvertResult> convertComputePipelineDescriptor(const GPUComputePipelineDescriptor& descriptor, const GPUDevice& device, GPUErrorScopes& errorScopes)
 {
     RetainPtr<MTLComputePipelineDescriptor> mtlDescriptor;
 
@@ -120,7 +120,7 @@
     END_BLOCK_OBJC_EXCEPTIONS;
 
     if (!mtlDescriptor) {
-        errorScopes.generateError(makeString(functionName, ": Error creating MTLDescriptor!"));
+        errorScopes.generatePrefixedError("Error creating MTLComputePipelineDescriptor!");
         return WTF::nullopt;
     }
 
@@ -136,12 +136,12 @@
         if (auto layout = convertLayout(*descriptor.layout))
             whlslDescriptor->layout = WTFMove(*layout);
         else {
-            errorScopes.generateError(makeString(functionName, ": Error converting GPUPipelineLayout!"));
+            errorScopes.generatePrefixedError("Error converting GPUPipelineLayout!");
             return WTF::nullopt;
         }
     }
 
-    if (auto computeDimensions = trySetFunctions(functionName, computeStage, device, mtlDescriptor.get(), whlslDescriptor, errorScopes))
+    if (auto computeDimensions = trySetFunctions(computeStage, device, mtlDescriptor.get(), whlslDescriptor, errorScopes))
         return {{ mtlDescriptor, *computeDimensions }};
 
     return WTF::nullopt;
@@ -152,14 +152,14 @@
     WHLSL::ComputeDimensions computeDimensions;
 };
 
-static Optional<CreateResult> tryCreateMTLComputePipelineState(const char* const functionName, const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor, GPUErrorScopes& errorScopes)
+static Optional<CreateResult> tryCreateMTLComputePipelineState(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor, GPUErrorScopes& errorScopes)
 {
     if (!device.platformDevice()) {
-        errorScopes.generateError(makeString(functionName, ": Invalid GPUDevice!"));
+        errorScopes.generatePrefixedError("Invalid GPUDevice!");
         return WTF::nullopt;
     }
 
-    auto convertResult = convertComputePipelineDescriptor(functionName, descriptor, device, errorScopes);
+    auto convertResult = convertComputePipelineDescriptor(descriptor, device, errorScopes);
     if (!convertResult)
         return WTF::nullopt;
     ASSERT(convertResult->pipelineDescriptor);
@@ -172,7 +172,7 @@
     NSError *error = nil;
     pipeline = adoptNS([device.platformDevice() newComputePipelineStateWithDescriptor:mtlDescriptor.get() options:MTLPipelineOptionNone reflection:nil error:&error]);
     if (!pipeline) {
-        errorScopes.generateError(makeString(functionName, ": ", (error ? error.localizedDescription.UTF8String : "Unable to create MTLComputePipelineState!")));
+        errorScopes.generatePrefixedError(error ? error.localizedDescription.UTF8String : "Unable to create MTLComputePipelineState!");
         return WTF::nullopt;
     }
 
@@ -181,19 +181,17 @@
     return {{ pipeline, convertResult->computeDimensions }};
 }
 
-RefPtr<GPUComputePipeline> GPUComputePipeline::tryCreate(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor, Ref<GPUErrorScopes>&& errorScopes)
+RefPtr<GPUComputePipeline> GPUComputePipeline::tryCreate(const GPUDevice& device, const GPUComputePipelineDescriptor& descriptor, GPUErrorScopes& errorScopes)
 {
-    const char* const functionName = "GPUComputePipeline::tryCreate()";
-
-    auto createResult = tryCreateMTLComputePipelineState(functionName, device, descriptor, errorScopes);
+    auto createResult = tryCreateMTLComputePipelineState(device, descriptor, errorScopes);
     if (!createResult)
         return nullptr;
 
-    return adoptRef(new GPUComputePipeline(WTFMove(createResult->pipelineState), createResult->computeDimensions, WTFMove(errorScopes)));
+    return adoptRef(new GPUComputePipeline(WTFMove(createResult->pipelineState), createResult->computeDimensions, errorScopes));
 }
 
-GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline, WHLSL::ComputeDimensions computeDimensions, Ref<GPUErrorScopes>&& errorScopes)
-    : GPUObjectBase(WTFMove(errorScopes))
+GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline, WHLSL::ComputeDimensions computeDimensions, GPUErrorScopes& errorScopes)
+    : GPUObjectBase(makeRef(errorScopes))
     , m_platformComputePipeline(WTFMove(pipeline))
     , m_computeDimensions(computeDimensions)
 {

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm (247891 => 247892)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2019-07-28 00:42:36 UTC (rev 247891)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2019-07-28 00:47:00 UTC (rev 247892)
@@ -344,7 +344,7 @@
 
         auto function = adoptNS([vertexMetalLibrary newFunctionWithName:vertexEntryPointName]);
         if (!function) {
-            errorScopes.generatePrefixedError(makeString("Cannot create vertex MTLFunction \"", vertexEntryPointName, "\"!"));
+            errorScopes.generatePrefixedError(makeString("Cannot create vertex MTLFunction '", vertexEntryPointName, "'!"));
             return false;
         }
 
@@ -363,7 +363,7 @@
         auto function = adoptNS([fragmentMetalLibrary newFunctionWithName:fragmentEntryPointName]);
 
         if (!function) {
-            errorScopes.generatePrefixedError(makeString("Cannot create fragment MTLFunction \"", fragmentEntryPointName, "\"!"));
+            errorScopes.generatePrefixedError(makeString("Cannot create fragment MTLFunction '", fragmentEntryPointName, "'!"));
             return false;
         }
 
@@ -392,7 +392,7 @@
 
         auto whlslCompileResult = WHLSL::prepare(whlslSource, *whlslDescriptor);
         if (!whlslCompileResult) {
-            errorScopes.generatePrefixedError("WHLSL compilation failed!");
+            errorScopes.generatePrefixedError(makeString("WHLSL compile error: ", whlslCompileResult.error()));
             return false;
         }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to