Diff
Modified: trunk/Source/WebCore/ChangeLog (242765 => 242766)
--- trunk/Source/WebCore/ChangeLog 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/ChangeLog 2019-03-12 03:19:10 UTC (rev 242766)
@@ -1,3 +1,67 @@
+2019-03-11 Justin Fan <justin_...@apple.com>
+
+ [Web GPU] BindGroups/Argument buffers: Move MTLBuffer creation from and GPUBindGroup validation to GPUDevice.createBindGroup
+ https://bugs.webkit.org/show_bug.cgi?id=195519
+ <rdar://problem/48781297>
+
+ Reviewed by Myles C. Maxfield.
+
+ Metal's Argument Buffers should not be tied directly to GPUBindGroupLayout; rather, create the MTLBuffer
+ in GPUBindGroup creation process.
+ Move GPUBindGroup validation out of setBindGroup and to GPUBindGroup creation for performance.
+
+ Covered by existing tests. No behavior change.
+
+ * Modules/webgpu/WebGPUDevice.cpp:
+ (WebCore::WebGPUDevice::createBindGroup const):
+ * Sources.txt:
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/graphics/gpu/GPUBindGroup.cpp: Removed.
+ * platform/graphics/gpu/GPUBindGroup.h:
+ (WebCore::GPUBindGroup::vertexArgsBuffer): A buffer that arguments will be encoded into during setBindGroup.
+ (WebCore::GPUBindGroup::fragmentArgsBuffer): Ditto.
+ (WebCore::GPUBindGroup::boundBuffers const): A list of resources that are bound by this GPUBindGroup.
+ (WebCore::GPUBindGroup::boundTextures const): Ditto.
+ (WebCore::GPUBindGroup::layout const): Deleted.
+ (WebCore::GPUBindGroup::bindings const): Deleted.
+ * platform/graphics/gpu/GPUBindGroupLayout.h: No longer creating and retaining MTLBuffers.
+ (WebCore::GPUBindGroupLayout::vertexEncoder const):
+ (WebCore::GPUBindGroupLayout::fragmentEncoder const):
+ (WebCore::GPUBindGroupLayout::computeEncoder const):
+ (WebCore::GPUBindGroupLayout::ArgumentEncoderBuffer::isValid const): Deleted.
+ (WebCore::GPUBindGroupLayout::vertexArguments const): Deleted.
+ (WebCore::GPUBindGroupLayout::fragmentArguments const): Deleted.
+ (WebCore::GPUBindGroupLayout::computeArguments const): Deleted.
+ * platform/graphics/gpu/GPUProgrammablePassEncoder.h:
+ * platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm:
+ (WebCore::tryCreateMtlArgumentEncoder):
+ (WebCore::GPUBindGroupLayout::tryCreate):
+ (WebCore::GPUBindGroupLayout::GPUBindGroupLayout):
+ (WebCore::tryCreateArgumentEncoderAndBuffer): Deleted.
+ * platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm: Added.
+ (WebCore::tryCreateArgumentBuffer): Create and associate the MTLBuffer that backs the MTLArgumentEncoder.
+ (WebCore::tryGetResourceAsBufferBinding): Validate a GPUBindingResource.
+ (WebCore::trySetBufferOnEncoder): Encodes a GPUBufferBinding's MTLBuffer on a MTLArgumentEncoder.
+ (WebCore::tryGetResourceAsSampler): Ditto, for GPUSamplers.
+ (WebCore::trySetSamplerOnEncoder):
+ (WebCore::tryGetResourceAsTexture): Ditto, for GPUTextures.
+ (WebCore::trySetTextureOnEncoder):
+ (WebCore::GPUBindGroup::tryCreate): Most setBindGroup validation moved here.
+ (WebCore::GPUBindGroup::GPUBindGroup): Retains the resource references needed for setBindGroup.
+ * platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm:
+ (WebCore::GPUProgrammablePassEncoder::setBindGroup): Most validation moved to GPUBindGroup::tryCreate().
+ (WebCore::GPUProgrammablePassEncoder::setResourceAsBufferOnEncoder): Deleted.
+ (WebCore::GPUProgrammablePassEncoder::setResourceAsSamplerOnEncoder): Deleted.
+ (WebCore::GPUProgrammablePassEncoder::setResourceAsTextureOnEncoder): Deleted.
+ * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm:
+ (WebCore::GPURenderPassEncoder::useResource):
+ (WebCore::GPURenderPassEncoder::setVertexBuffer):
+ (WebCore::GPURenderPassEncoder::setFragmentBuffer):
+
+ Misc:
+ * platform/graphics/gpu/GPUCommandBuffer.cpp/h: Move missing includes to header.
+
2019-03-11 Zalan Bujtas <za...@apple.com>
[Synthetic Click] Dispatch mouseout soon after mouseup
Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (242765 => 242766)
--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp 2019-03-12 03:19:10 UTC (rev 242766)
@@ -116,7 +116,7 @@
if (!gpuDescriptor)
return WebGPUBindGroup::create(nullptr);
- auto bindGroup = GPUBindGroup::create(WTFMove(*gpuDescriptor));
+ auto bindGroup = GPUBindGroup::tryCreate(*gpuDescriptor);
return WebGPUBindGroup::create(WTFMove(bindGroup));
}
Modified: trunk/Source/WebCore/Sources.txt (242765 => 242766)
--- trunk/Source/WebCore/Sources.txt 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/Sources.txt 2019-03-12 03:19:10 UTC (rev 242766)
@@ -1813,7 +1813,6 @@
platform/graphics/filters/SourceGraphic.cpp
platform/graphics/filters/SpotLightSource.cpp
-platform/graphics/gpu/GPUBindGroup.cpp
platform/graphics/gpu/GPUDevice.cpp
platform/graphics/gpu/GPUPipelineLayout.cpp
platform/graphics/gpu/GPUProgrammablePassEncoder.cpp
Modified: trunk/Source/WebCore/SourcesCocoa.txt (242765 => 242766)
--- trunk/Source/WebCore/SourcesCocoa.txt 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2019-03-12 03:19:10 UTC (rev 242766)
@@ -317,6 +317,7 @@
platform/graphics/cv/TextureCacheCV.mm
platform/graphics/cv/VideoTextureCopierCV.cpp
+platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm
platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm
platform/graphics/gpu/cocoa/GPUBufferMetal.mm
platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (242765 => 242766)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-03-12 03:19:10 UTC (rev 242766)
@@ -14094,6 +14094,7 @@
D084033D221E186400007205 /* WebGPUBindGroupDescriptor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUBindGroupDescriptor.cpp; sourceTree = "<group>"; };
D0843A4A20FEBE3D00FE860E /* GraphicsContext3DManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GraphicsContext3DManager.h; sourceTree = "<group>"; };
D0843A4C20FEC16500FE860E /* GraphicsContext3DManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContext3DManager.cpp; sourceTree = "<group>"; };
+ D085E64A2236DEAE00C3E1E2 /* GPUBindGroupMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUBindGroupMetal.mm; sourceTree = "<group>"; };
D086FE9609D53AAB005BC74D /* UnlinkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkCommand.h; sourceTree = "<group>"; };
D086FE9709D53AAB005BC74D /* UnlinkCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnlinkCommand.cpp; sourceTree = "<group>"; };
D087CE3821ACA94200BDE174 /* GPUCommandBufferMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUCommandBufferMetal.mm; sourceTree = "<group>"; };
@@ -14142,7 +14143,6 @@
D0BE105221E6AA0D00E42A89 /* WebGPUBindGroupDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUBindGroupDescriptor.h; sourceTree = "<group>"; };
D0BE105321E6AA0D00E42A89 /* WebGPUBindGroupDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBindGroupDescriptor.idl; sourceTree = "<group>"; };
D0BE105E21E6BAD300E42A89 /* GPUBindGroup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBindGroup.h; sourceTree = "<group>"; };
- D0BE105F21E6BAD300E42A89 /* GPUBindGroup.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUBindGroup.cpp; sourceTree = "<group>"; };
D0BE106021E6C0EB00E42A89 /* WebGPUBindGroup.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUBindGroup.h; sourceTree = "<group>"; };
D0BE106121E6C0EB00E42A89 /* WebGPUBindGroup.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUBindGroup.cpp; sourceTree = "<group>"; };
D0BE106221E6C0EB00E42A89 /* WebGPUBindGroup.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUBindGroup.idl; sourceTree = "<group>"; };
@@ -18491,7 +18491,6 @@
children = (
D087CE3721ACA94200BDE174 /* cocoa */,
312FF8CE21A4C33F00EB199D /* legacy */,
- D0BE105F21E6BAD300E42A89 /* GPUBindGroup.cpp */,
D0BE105E21E6BAD300E42A89 /* GPUBindGroup.h */,
D0BE104E21E695E200E42A89 /* GPUBindGroupBinding.h */,
D0BE105121E6A70E00E42A89 /* GPUBindGroupDescriptor.h */,
@@ -26225,6 +26224,7 @@
isa = PBXGroup;
children = (
D0232B5821CB49B7009483B9 /* GPUBindGroupLayoutMetal.mm */,
+ D085E64A2236DEAE00C3E1E2 /* GPUBindGroupMetal.mm */,
D0D8649121B760C4003C983C /* GPUBufferMetal.mm */,
D087CE3821ACA94200BDE174 /* GPUCommandBufferMetal.mm */,
D087CE3C21ACA94200BDE174 /* GPUDeviceMetal.mm */,
Deleted: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.cpp (242765 => 242766)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.cpp 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.cpp 2019-03-12 03:19:10 UTC (rev 242766)
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2019 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "GPUBindGroup.h"
-
-#if ENABLE(WEBGPU)
-
-#include "GPUBindGroupBinding.h"
-#include "GPUBindGroupDescriptor.h"
-
-namespace WebCore {
-
-Ref<GPUBindGroup> GPUBindGroup::create(GPUBindGroupDescriptor&& descriptor)
-{
- // FIXME: Unfinished stub.
- return adoptRef(*new GPUBindGroup(WTFMove(descriptor)));
-}
-
-GPUBindGroup::GPUBindGroup(GPUBindGroupDescriptor&& descriptor)
- : m_layout(WTFMove(descriptor.layout))
- , m_bindings(WTFMove(descriptor.bindings))
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGPU)
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h (242765 => 242766)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h 2019-03-12 03:19:10 UTC (rev 242766)
@@ -27,28 +27,40 @@
#if ENABLE(WEBGPU)
-#include "GPUBindGroupBinding.h"
-#include "GPUBindGroupLayout.h"
-#include <wtf/Ref.h>
#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/RetainPtr.h>
#include <wtf/Vector.h>
+OBJC_PROTOCOL(MTLBuffer);
+
namespace WebCore {
+class GPUBuffer;
+class GPUTexture;
+
struct GPUBindGroupDescriptor;
class GPUBindGroup : public RefCounted<GPUBindGroup> {
public:
- static Ref<GPUBindGroup> create(GPUBindGroupDescriptor&&);
+ static RefPtr<GPUBindGroup> tryCreate(const GPUBindGroupDescriptor&);
+
+#if USE(METAL)
+ MTLBuffer *vertexArgsBuffer() { return m_vertexArgsBuffer.get(); }
+ MTLBuffer *fragmentArgsBuffer() { return m_fragmentArgsBuffer.get(); }
+#endif
+ const Vector<Ref<GPUBuffer>>& boundBuffers() const { return m_boundBuffers; }
+ const Vector<Ref<GPUTexture>>& boundTextures() const { return m_boundTextures; }
- const GPUBindGroupLayout& layout() const { return m_layout.get(); }
- const Vector<GPUBindGroupBinding>& bindings() const { return m_bindings; }
-
private:
- explicit GPUBindGroup(GPUBindGroupDescriptor&&);
-
- Ref<GPUBindGroupLayout> m_layout;
- Vector<GPUBindGroupBinding> m_bindings;
+#if USE(METAL)
+ GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, Vector<Ref<GPUBuffer>>&&, Vector<Ref<GPUTexture>>&&);
+
+ RetainPtr<MTLBuffer> m_vertexArgsBuffer;
+ RetainPtr<MTLBuffer> m_fragmentArgsBuffer;
+#endif
+ Vector<Ref<GPUBuffer>> m_boundBuffers;
+ Vector<Ref<GPUTexture>> m_boundTextures;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.h (242765 => 242766)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.h 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupLayout.h 2019-03-12 03:19:10 UTC (rev 242766)
@@ -50,24 +50,18 @@
using BindingsMapType = HashMap<unsigned long long, GPUBindGroupLayoutBinding, WTF::IntHash<unsigned long long>, WTF::UnsignedWithZeroKeyHashTraits<unsigned long long>>;
const BindingsMapType& bindingsMap() const { return m_bindingsMap; }
#if USE(METAL)
- struct ArgumentEncoderBuffer {
- RetainPtr<MTLArgumentEncoder> encoder;
- RetainPtr<MTLBuffer> buffer;
-
- bool isValid() const { return encoder && buffer; }
- };
- const ArgumentEncoderBuffer& vertexArguments() const { return m_vertexArguments; }
- const ArgumentEncoderBuffer& fragmentArguments() const { return m_fragmentArguments; }
- const ArgumentEncoderBuffer& computeArguments() const { return m_computeArguments; }
+ MTLArgumentEncoder *vertexEncoder() const { return m_vertexEncoder.get(); }
+ MTLArgumentEncoder *fragmentEncoder() const { return m_fragmentEncoder.get(); }
+ MTLArgumentEncoder *computeEncoder() const { return m_computeEncoder.get(); }
#endif // USE(METAL)
private:
#if USE(METAL)
- GPUBindGroupLayout(BindingsMapType&&, ArgumentEncoderBuffer&& vertex, ArgumentEncoderBuffer&& fragment, ArgumentEncoderBuffer&& compute);
+ GPUBindGroupLayout(BindingsMapType&&, RetainPtr<MTLArgumentEncoder>&& vertex, RetainPtr<MTLArgumentEncoder>&& fragment, RetainPtr<MTLArgumentEncoder>&& compute);
- ArgumentEncoderBuffer m_vertexArguments;
- ArgumentEncoderBuffer m_fragmentArguments;
- ArgumentEncoderBuffer m_computeArguments;
+ RetainPtr<MTLArgumentEncoder> m_vertexEncoder;
+ RetainPtr<MTLArgumentEncoder> m_fragmentEncoder;
+ RetainPtr<MTLArgumentEncoder> m_computeEncoder;
#endif // USE(METAL)
const BindingsMapType m_bindingsMap;
};
Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUProgrammablePassEncoder.h (242765 => 242766)
--- trunk/Source/WebCore/platform/graphics/gpu/GPUProgrammablePassEncoder.h 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUProgrammablePassEncoder.h 2019-03-12 03:19:10 UTC (rev 242766)
@@ -30,12 +30,11 @@
#include "GPUBindGroupBinding.h"
#include <wtf/RefCounted.h>
-OBJC_PROTOCOL(MTLArgumentEncoder);
#if USE(METAL)
OBJC_PROTOCOL(MTLBuffer);
OBJC_PROTOCOL(MTLCommandEncoder);
OBJC_PROTOCOL(MTLResource);
-#endif // USE(METAL)
+#endif
namespace WebCore {
@@ -61,9 +60,6 @@
private:
#if USE(METAL)
- void setResourceAsBufferOnEncoder(MTLArgumentEncoder *, const GPUBindGroupBinding&, const char* const);
- void setResourceAsSamplerOnEncoder(MTLArgumentEncoder *, const GPUBindGroupBinding&, const char* const);
- void setResourceAsTextureOnEncoder(MTLArgumentEncoder *, const GPUBindGroupBinding&, const char* const);
virtual void useResource(MTLResource *, unsigned) = 0;
// Render command encoder methods.
Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm (242765 => 242766)
--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupLayoutMetal.mm 2019-03-12 03:19:10 UTC (rev 242766)
@@ -63,28 +63,18 @@
END_BLOCK_OBJC_EXCEPTIONS;
}
-static GPUBindGroupLayout::ArgumentEncoderBuffer tryCreateArgumentEncoderAndBuffer(const GPUDevice& device, ArgumentArray array)
+static RetainPtr<MTLArgumentEncoder> tryCreateMtlArgumentEncoder(const GPUDevice& device, ArgumentArray array)
{
- GPUBindGroupLayout::ArgumentEncoderBuffer args;
+ RetainPtr<MTLArgumentEncoder> encoder;
BEGIN_BLOCK_OBJC_EXCEPTIONS;
- args.encoder = adoptNS([device.platformDevice() newArgumentEncoderWithArguments:array.get()]);
+ encoder = adoptNS([device.platformDevice() newArgumentEncoderWithArguments:array.get()]);
END_BLOCK_OBJC_EXCEPTIONS;
- if (!args.encoder) {
+ if (!encoder) {
LOG(WebGPU, "GPUBindGroupLayout::tryCreate(): Unable to create MTLArgumentEncoder!");
- return { };
+ return nullptr;
}
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- args.buffer = adoptNS([device.platformDevice() newBufferWithLength:args.encoder.get().encodedLength options:0]);
- [args.encoder setArgumentBuffer:args.buffer.get() offset:0];
- END_BLOCK_OBJC_EXCEPTIONS;
- if (!args.buffer) {
- LOG(WebGPU, "GPUBindGroupLayout::tryCreate(): Unable to create MTLBuffer from MTLArgumentEncoder!");
- return { };
- }
-
- return args;
+ return encoder;
};
RefPtr<GPUBindGroupLayout> GPUBindGroupLayout::tryCreate(const GPUDevice& device, const GPUBindGroupLayoutDescriptor& descriptor)
@@ -108,14 +98,13 @@
BEGIN_BLOCK_OBJC_EXCEPTIONS;
mtlArgument = adoptNS([MTLArgumentDescriptor new]);
END_BLOCK_OBJC_EXCEPTIONS;
-
if (!mtlArgument) {
LOG(WebGPU, "GPUBindGroupLayout::tryCreate(): Unable to create MTLArgumentDescriptor for binding %lu!", binding.binding);
return nullptr;
}
- mtlArgument.get().dataType = MTLDataTypeForBindingType(binding.type);
- mtlArgument.get().index = binding.binding;
+ [mtlArgument setDataType:MTLDataTypeForBindingType(binding.type)];
+ [mtlArgument setIndex:binding.binding];
if (binding.visibility & GPUShaderStageBit::Flags::Vertex)
appendArgumentToArray(vertexArgsArray, mtlArgument);
@@ -125,18 +114,18 @@
appendArgumentToArray(computeArgsArray, mtlArgument);
}
- ArgumentEncoderBuffer vertex, fragment, compute;
+ RetainPtr<MTLArgumentEncoder> vertex, fragment, compute;
if (vertexArgsArray) {
- if (!(vertex = tryCreateArgumentEncoderAndBuffer(device, vertexArgsArray)).isValid())
+ if (!(vertex = tryCreateMtlArgumentEncoder(device, vertexArgsArray)))
return nullptr;
}
if (fragmentArgsArray) {
- if (!(fragment = tryCreateArgumentEncoderAndBuffer(device, fragmentArgsArray)).isValid())
+ if (!(fragment = tryCreateMtlArgumentEncoder(device, fragmentArgsArray)))
return nullptr;
}
if (computeArgsArray) {
- if (!(compute = tryCreateArgumentEncoderAndBuffer(device, computeArgsArray)).isValid())
+ if (!(compute = tryCreateMtlArgumentEncoder(device, computeArgsArray)))
return nullptr;
}
@@ -143,10 +132,10 @@
return adoptRef(new GPUBindGroupLayout(WTFMove(bindingsMap), WTFMove(vertex), WTFMove(fragment), WTFMove(compute)));
}
-GPUBindGroupLayout::GPUBindGroupLayout(BindingsMapType&& bindingsMap, ArgumentEncoderBuffer&& vertex, ArgumentEncoderBuffer&& fragment, ArgumentEncoderBuffer&& compute)
- : m_vertexArguments(WTFMove(vertex))
- , m_fragmentArguments(WTFMove(fragment))
- , m_computeArguments(WTFMove(compute))
+GPUBindGroupLayout::GPUBindGroupLayout(BindingsMapType&& bindingsMap, RetainPtr<MTLArgumentEncoder>&& vertex, RetainPtr<MTLArgumentEncoder>&& fragment, RetainPtr<MTLArgumentEncoder>&& compute)
+ : m_vertexEncoder(WTFMove(vertex))
+ , m_fragmentEncoder(WTFMove(fragment))
+ , m_computeEncoder(WTFMove(compute))
, m_bindingsMap(WTFMove(bindingsMap))
{
}
Added: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm (0 => 242766)
--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm 2019-03-12 03:19:10 UTC (rev 242766)
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "GPUBindGroup.h"
+
+#if ENABLE(WEBGPU)
+
+#import "GPUBindGroupBinding.h"
+#import "GPUBindGroupDescriptor.h"
+#import "GPUBindGroupLayout.h"
+#import "GPUBuffer.h"
+#import "GPUSampler.h"
+#import "GPUTexture.h"
+#import "Logging.h"
+#import <wtf/BlockObjCExceptions.h>
+#import <wtf/Optional.h>
+
+namespace WebCore {
+
+static RetainPtr<MTLBuffer> tryCreateArgumentBuffer(MTLArgumentEncoder *encoder)
+{
+ RetainPtr<MTLBuffer> buffer;
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ buffer = adoptNS([encoder.device newBufferWithLength:encoder.encodedLength options:0]);
+ [encoder setArgumentBuffer:buffer.get() offset:0];
+ END_BLOCK_OBJC_EXCEPTIONS;
+ return buffer;
+}
+
+static Optional<GPUBufferBinding> tryGetResourceAsBufferBinding(const GPUBindingResource& resource, const char* const functionName)
+{
+#if LOG_DISABLED
+ UNUSED_PARAM(functionName);
+#endif
+ if (!WTF::holds_alternative<GPUBufferBinding>(resource)) {
+ LOG(WebGPU, "%s: Resource is not a buffer type!", functionName);
+ return WTF::nullopt;
+ }
+ auto& bufferBinding = WTF::get<GPUBufferBinding>(resource);
+ if (!bufferBinding.buffer->platformBuffer()) {
+ LOG(WebGPU, "%s: Invalid MTLBuffer in GPUBufferBinding!", functionName);
+ return WTF::nullopt;
+ }
+ return GPUBufferBinding { bufferBinding.buffer.copyRef(), bufferBinding.offset, bufferBinding.size };
+}
+
+static void setBufferOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBufferBinding& bufferBinding, unsigned index)
+{
+ ASSERT(argumentEncoder && bufferBinding.buffer->platformBuffer());
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ [argumentEncoder setBuffer:bufferBinding.buffer->platformBuffer() offset:bufferBinding.offset atIndex:index];
+ END_BLOCK_OBJC_EXCEPTIONS;
+}
+
+static RefPtr<GPUSampler> tryGetResourceAsSampler(const GPUBindingResource& resource, const char* const functionName)
+{
+#if LOG_DISABLED
+ UNUSED_PARAM(functionName);
+#endif
+ if (!WTF::holds_alternative<Ref<GPUSampler>>(resource)) {
+ LOG(WebGPU, "%s: Resource is not a GPUSampler!", functionName);
+ return nullptr;
+ }
+ auto& samplerRef = WTF::get<Ref<GPUSampler>>(resource);
+ if (!samplerRef->platformSampler()) {
+ LOG(WebGPU, "%s: Invalid MTLSamplerState in GPUSampler binding!", functionName);
+ return nullptr;
+ }
+ return samplerRef.copyRef();
+}
+
+static void setSamplerOnEncoder(MTLArgumentEncoder *argumentEncoder, MTLSamplerState *sampler, unsigned index)
+{
+ ASSERT(argumentEncoder && sampler);
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ [argumentEncoder setSamplerState:sampler atIndex:index];
+ END_BLOCK_OBJC_EXCEPTIONS;
+}
+
+static RefPtr<GPUTexture> tryGetResourceAsTexture(const GPUBindingResource& resource, const char* const functionName)
+ {
+#if LOG_DISABLED
+ UNUSED_PARAM(functionName);
+#endif
+ if (!WTF::holds_alternative<Ref<GPUTexture>>(resource)) {
+ LOG(WebGPU, "%s: Resource is not a GPUTextureView!", functionName);
+ return nullptr;
+ }
+ auto& textureRef = WTF::get<Ref<GPUTexture>>(resource);
+ if (!textureRef->platformTexture()) {
+ LOG(WebGPU, "%s: Invalid MTLTexture in GPUTextureView binding!", functionName);
+ return nullptr;
+ }
+ return textureRef.copyRef();
+}
+
+static void setTextureOnEncoder(MTLArgumentEncoder *argumentEncoder, MTLTexture *texture, unsigned index)
+{
+ ASSERT(argumentEncoder && texture);
+
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
+ [argumentEncoder setTexture:texture atIndex:index];
+ END_BLOCK_OBJC_EXCEPTIONS;
+}
+
+RefPtr<GPUBindGroup> GPUBindGroup::tryCreate(const GPUBindGroupDescriptor& descriptor)
+{
+ const char* const functionName = "GPUBindGroup::tryCreate()";
+
+ MTLArgumentEncoder *vertexEncoder = descriptor.layout->vertexEncoder();
+ MTLArgumentEncoder *fragmentEncoder = descriptor.layout->fragmentEncoder();
+ // FIXME: Finish support for compute.
+
+ RetainPtr<MTLBuffer> vertexArgsBuffer;
+ if (vertexEncoder && !(vertexArgsBuffer = tryCreateArgumentBuffer(vertexEncoder))) {
+ LOG(WebGPU, "%s: Unable to create MTLBuffer for vertex argument buffer!", functionName);
+ return nullptr;
+ }
+ RetainPtr<MTLBuffer> fragmentArgsBuffer;
+ if (fragmentEncoder && !(fragmentArgsBuffer = tryCreateArgumentBuffer(fragmentEncoder))) {
+ LOG(WebGPU, "%s: Unable to create MTLBuffer for fragment argument buffer!", functionName);
+ return nullptr;
+ }
+
+ Vector<Ref<GPUBuffer>> boundBuffers;
+ Vector<Ref<GPUTexture>> boundTextures;
+
+ // Set each resource on each MTLArgumentEncoder it should be visible on.
+ const auto& layoutBindingsMap = descriptor.layout->bindingsMap();
+ for (const auto& resourceBinding : descriptor.bindings) {
+ auto layoutIterator = layoutBindingsMap.find(resourceBinding.binding);
+ if (layoutIterator == layoutBindingsMap.end()) {
+ LOG(WebGPU, "%s: GPUBindGroupBinding %lu not found in GPUBindGroupLayout!", functionName, resourceBinding.binding);
+ return nullptr;
+ }
+ auto layoutBinding = layoutIterator->value;
+ if (layoutBinding.visibility == GPUShaderStageBit::Flags::None)
+ continue;
+ if ((layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex) && !vertexEncoder) {
+ LOG(WebGPU, "%s: No vertex encoder found for binding %lu!", functionName, resourceBinding.binding);
+ return nullptr;
+ }
+ if ((layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment) && !fragmentEncoder) {
+ LOG(WebGPU, "%s: No fragment encoder found for binding %lu!", functionName, resourceBinding.binding);
+ return nullptr;
+ }
+
+ switch (layoutBinding.type) {
+ // FIXME: Support more resource types.
+ case GPUBindGroupLayoutBinding::BindingType::UniformBuffer:
+ case GPUBindGroupLayoutBinding::BindingType::StorageBuffer: {
+ auto bufferResource = tryGetResourceAsBufferBinding(resourceBinding.resource, functionName);
+ if (!bufferResource)
+ return nullptr;
+ if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
+ setBufferOnEncoder(vertexEncoder, *bufferResource, resourceBinding.binding);
+ if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
+ setBufferOnEncoder(fragmentEncoder, *bufferResource, resourceBinding.binding);
+ boundBuffers.append(bufferResource->buffer.copyRef());
+ break;
+ }
+ case GPUBindGroupLayoutBinding::BindingType::Sampler: {
+ auto samplerResource = tryGetResourceAsSampler(resourceBinding.resource, functionName);
+ if (!samplerResource)
+ return nullptr;
+ if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
+ setSamplerOnEncoder(vertexEncoder, samplerResource->platformSampler(), resourceBinding.binding);
+ if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
+ setSamplerOnEncoder(fragmentEncoder, samplerResource->platformSampler(), resourceBinding.binding);
+ break;
+ }
+ case GPUBindGroupLayoutBinding::BindingType::SampledTexture: {
+ auto textureResource = tryGetResourceAsTexture(resourceBinding.resource, functionName);
+ if (!textureResource)
+ return nullptr;
+ if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
+ setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), resourceBinding.binding);
+ if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
+ setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), resourceBinding.binding);
+ boundTextures.append(textureResource.releaseNonNull());
+ break;
+ }
+ default:
+ LOG(WebGPU, "%s: Resource type not yet implemented.", functionName);
+ return nullptr;
+ }
+ }
+
+ return adoptRef(new GPUBindGroup(WTFMove(vertexArgsBuffer), WTFMove(fragmentArgsBuffer), WTFMove(boundBuffers), WTFMove(boundTextures)));
+}
+
+GPUBindGroup::GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, Vector<Ref<GPUBuffer>>&& buffers, Vector<Ref<GPUTexture>>&& textures)
+ : m_vertexArgsBuffer(WTFMove(vertexBuffer))
+ , m_fragmentArgsBuffer(WTFMove(fragmentBuffer))
+ , m_boundBuffers(WTFMove(buffers))
+ , m_boundTextures(WTFMove(textures))
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBPGU)
Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm (242765 => 242766)
--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm 2019-03-12 03:19:10 UTC (rev 242766)
@@ -29,7 +29,6 @@
#if ENABLE(WEBGPU)
#import "GPUBindGroup.h"
-#import "GPUBindGroupLayoutBinding.h"
#import "GPUCommandBuffer.h"
#import "Logging.h"
#import <Metal/Metal.h>
@@ -50,162 +49,26 @@
void GPUProgrammablePassEncoder::setBindGroup(unsigned index, GPUBindGroup& bindGroup)
{
- const char* const functionName = "GPUProgrammablePassEncoder::setBindGroup()";
-
if (!platformPassEncoder()) {
- LOG(WebGPU, "%s: Invalid operation: Encoding is ended!");
+ LOG(WebGPU, "GPUProgrammablePassEncoder::setBindGroup(): Invalid operation: Encoding is ended!");
return;
}
+
+ if (bindGroup.vertexArgsBuffer())
+ setVertexBuffer(bindGroup.vertexArgsBuffer(), 0, index);
+ if (bindGroup.fragmentArgsBuffer())
+ setFragmentBuffer(bindGroup.fragmentArgsBuffer(), 0, index);
- const auto& vertexArgs = bindGroup.layout().vertexArguments();
- const auto& fragmentArgs = bindGroup.layout().fragmentArguments();
- // FIXME: Finish support for compute.
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- if (vertexArgs.buffer)
- setVertexBuffer(vertexArgs.buffer.get(), 0, index);
- if (fragmentArgs.buffer)
- setFragmentBuffer(fragmentArgs.buffer.get(), 0, index);
-
- END_BLOCK_OBJC_EXCEPTIONS;
-
- // Set each resource on each MTLArgumentEncoder it should be visible on.
- const auto& layoutBindingsMap = bindGroup.layout().bindingsMap();
- for (const auto& resourceBinding : bindGroup.bindings()) {
- auto layoutIterator = layoutBindingsMap.find(resourceBinding.binding);
- if (layoutIterator == layoutBindingsMap.end()) {
- LOG(WebGPU, "%s: GPUBindGroupBinding %lu not found in GPUBindGroupLayout!", functionName, resourceBinding.binding);
- return;
- }
- auto layoutBinding = layoutIterator->value;
-
- switch (layoutBinding.type) {
- // FIXME: Support more resource types.
- case GPUBindGroupLayoutBinding::BindingType::UniformBuffer:
- case GPUBindGroupLayoutBinding::BindingType::StorageBuffer: {
- if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
- setResourceAsBufferOnEncoder(vertexArgs.encoder.get(), resourceBinding, functionName);
- if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
- setResourceAsBufferOnEncoder(fragmentArgs.encoder.get(), resourceBinding, functionName);
- break;
- }
- case GPUBindGroupLayoutBinding::BindingType::Sampler: {
- if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
- setResourceAsSamplerOnEncoder(vertexArgs.encoder.get(), resourceBinding, functionName);
- if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
- setResourceAsSamplerOnEncoder(fragmentArgs.encoder.get(), resourceBinding, functionName);
- break;
- }
- case GPUBindGroupLayoutBinding::BindingType::SampledTexture: {
- if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
- setResourceAsTextureOnEncoder(vertexArgs.encoder.get(), resourceBinding, functionName);
- if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
- setResourceAsTextureOnEncoder(fragmentArgs.encoder.get(), resourceBinding, functionName);
- break;
- }
- default:
- LOG(WebGPU, "%s: Resource type not yet implemented.", functionName);
- return;
- }
+ for (auto& bufferRef : bindGroup.boundBuffers()) {
+ useResource(bufferRef->platformBuffer(), bufferRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite);
+ m_commandBuffer->useBuffer(bufferRef.copyRef());
}
-}
-
-void GPUProgrammablePassEncoder::setResourceAsBufferOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBindGroupBinding& binding, const char* const functionName)
-{
-#if LOG_DISABLED
- UNUSED_PARAM(functionName);
-#endif
- if (!argumentEncoder) {
- LOG(WebGPU, "%s: No argument encoder for requested stage found!", functionName);
- return;
+ for (auto& textureRef : bindGroup.boundTextures()) {
+ useResource(textureRef->platformTexture(), textureRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite);
+ m_commandBuffer->useTexture(textureRef.copyRef());
}
-
- if (!WTF::holds_alternative<GPUBufferBinding>(binding.resource)) {
- LOG(WebGPU, "%s: Resource is not a buffer type!", functionName);
- return;
- }
-
- auto& bufferBinding = WTF::get<GPUBufferBinding>(binding.resource);
- auto& bufferRef = bufferBinding.buffer;
- auto mtlBuffer = bufferRef->platformBuffer();
-
- if (!mtlBuffer) {
- LOG(WebGPU, "%s: Invalid MTLBuffer in GPUBufferBinding!", functionName);
- return;
- }
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- [argumentEncoder setBuffer:mtlBuffer offset:bufferBinding.offset atIndex:binding.binding];
- useResource(mtlBuffer, bufferRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite);
-
- END_BLOCK_OBJC_EXCEPTIONS;
-
- m_commandBuffer->useBuffer(bufferRef.copyRef());
}
-void GPUProgrammablePassEncoder::setResourceAsSamplerOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBindGroupBinding& binding, const char *const functionName)
-{
-#if LOG_DISABLED
- UNUSED_PARAM(functionName);
-#endif
- if (!argumentEncoder) {
- LOG(WebGPU, "%s: No argument encoder for requested stage found!", functionName);
- return;
- }
-
- if (!WTF::holds_alternative<Ref<GPUSampler>>(binding.resource)) {
- LOG(WebGPU, "%s: Resource is not a GPUSampler!", functionName);
- return;
- }
-
- auto& samplerRef = WTF::get<Ref<GPUSampler>>(binding.resource);
- auto mtlSampler = samplerRef->platformSampler();
-
- if (!mtlSampler) {
- LOG(WebGPU, "%s: Invalid MTLSamplerState in GPUSampler binding!", functionName);
- return;
- }
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
- [argumentEncoder setSamplerState:mtlSampler atIndex:binding.binding];
- END_BLOCK_OBJC_EXCEPTIONS;
-}
-
-void GPUProgrammablePassEncoder::setResourceAsTextureOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBindGroupBinding& binding, const char* const functionName)
-{
-#if LOG_DISABLED
- UNUSED_PARAM(functionName);
-#endif
- if (!argumentEncoder) {
- LOG(WebGPU, "%s: No argument encoder for requested stage found!", functionName);
- return;
- }
-
- if (!WTF::holds_alternative<Ref<GPUTexture>>(binding.resource)) {
- LOG(WebGPU, "%s: Resource is not a GPUTextureView!", functionName);
- return;
- }
-
- auto& textureRef = WTF::get<Ref<GPUTexture>>(binding.resource);
- auto mtlTexture = textureRef->platformTexture();
-
- if (!mtlTexture) {
- LOG(WebGPU, "%s: Invalid MTLTexture in GPUTextureView binding!", functionName);
- return;
- }
-
- BEGIN_BLOCK_OBJC_EXCEPTIONS;
-
- [argumentEncoder setTexture:mtlTexture atIndex:binding.binding];
- useResource(mtlTexture, textureRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite);
-
- END_BLOCK_OBJC_EXCEPTIONS;
-
- m_commandBuffer->useTexture(textureRef.copyRef());
-}
-
} // namespace WebCore
#endif // ENABLE(WEBGPU)
Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm (242765 => 242766)
--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm 2019-03-12 02:54:07 UTC (rev 242765)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm 2019-03-12 03:19:10 UTC (rev 242766)
@@ -277,8 +277,9 @@
LOG(WebGPU, "GPURenderPassEncoder: Invalid operation: Encoding is ended!");
return;
}
-
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
[m_platformRenderPassEncoder useResource:resource usage:usage];
+ END_BLOCK_OBJC_EXCEPTIONS;
}
void GPURenderPassEncoder::setVertexBuffer(MTLBuffer *buffer, unsigned offset, unsigned index)
@@ -287,8 +288,9 @@
LOG(WebGPU, "GPURenderPassEncoder: Invalid operation: Encoding is ended!");
return;
}
-
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
[m_platformRenderPassEncoder setVertexBuffer:buffer offset:offset atIndex:index];
+ END_BLOCK_OBJC_EXCEPTIONS;
}
void GPURenderPassEncoder::setFragmentBuffer(MTLBuffer *buffer, unsigned offset, unsigned index)
@@ -297,8 +299,9 @@
LOG(WebGPU, "GPURenderPassEncoder: Invalid operation: Encoding is ended!");
return;
}
-
+ BEGIN_BLOCK_OBJC_EXCEPTIONS;
[m_platformRenderPassEncoder setFragmentBuffer:buffer offset:offset atIndex:index];
+ END_BLOCK_OBJC_EXCEPTIONS;
}
#endif // USE(METAL)