Title: [243563] trunk
Revision
243563
Author
justin_...@apple.com
Date
2019-03-27 13:47:55 -0700 (Wed, 27 Mar 2019)

Log Message

[Web GPU] Standardize Web GPU object reference counting and creation logic
https://bugs.webkit.org/show_bug.cgi?id=196183

Reviewed by Dean Jackson.

Source/WebCore:

Make getters return raw refs/pointers and provide const versions if necessary.
All Web GPU objects are non-nullable, but become no-op if invalid, and descriptors are not moved unless needed.

No new tests; no change in behavior.

Getter updates and const qualifications:
* Modules/webgpu/WebGPUAdapter.h:
(WebCore::WebGPUAdapter::options const):
* Modules/webgpu/WebGPUBindGroup.h:
(WebCore::WebGPUBindGroup::bindGroup):
(WebCore::WebGPUBindGroup::bindGroup const): Deleted.
* Modules/webgpu/WebGPUBindGroupDescriptor.cpp:
(WebCore::WebGPUBindGroupDescriptor::tryCreateGPUBindGroupDescriptor const):
* Modules/webgpu/WebGPUBindGroupDescriptor.h:
* Modules/webgpu/WebGPUBindGroupLayout.h:
(WebCore::WebGPUBindGroupLayout::bindGroupLayout const):
* Modules/webgpu/WebGPUBuffer.h:
(WebCore::WebGPUBuffer::buffer):
(WebCore::WebGPUBuffer::buffer const):
* Modules/webgpu/WebGPURenderPassDescriptor.cpp:
(WebCore::WebGPURenderPassDescriptor::tryCreateGPURenderPassDescriptor const):
* Modules/webgpu/WebGPURenderPassEncoder.cpp:
(WebCore::WebGPURenderPassEncoder::setVertexBuffers):
* Modules/webgpu/WebGPUSampler.h:
(WebCore::WebGPUSampler::sampler const):
* Modules/webgpu/WebGPUSwapChain.h:
(WebCore::WebGPUSwapChain::swapChain):
(WebCore::WebGPUSwapChain::swapChain const): Deleted.
* Modules/webgpu/WebGPUTexture.h:
(WebCore::WebGPUTexture::texture):
(WebCore::WebGPUTexture::texture const): Deleted.
* Modules/webgpu/WebGPUTextureView.h:
(WebCore::WebGPUTextureView::texture):
(WebCore::WebGPUTextureView::texture const): Deleted.
* platform/graphics/gpu/GPUBindGroupBinding.h:
* platform/graphics/gpu/GPUBindGroupDescriptor.h:
* platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm:
(WebCore::tryGetResourceAsMTLSamplerState):

Web GPU object creation logic:
* Modules/webgpu/WebGPUCommandEncoder.cpp:
(WebCore::WebGPUBufferCopyView::tryCreateGPUBufferCopyView const):
(WebCore::WebGPUTextureCopyView::tryCreateGPUTextureCopyView const):
(WebCore::WebGPUCommandEncoder::beginRenderPass):
(WebCore::WebGPUCommandEncoder::copyBufferToBuffer):
* Modules/webgpu/WebGPUCommandEncoder.h:
* Modules/webgpu/WebGPUDevice.cpp:
(WebCore::WebGPUDevice::createBuffer const):
(WebCore::WebGPUDevice::createTexture const):
(WebCore::WebGPUDevice::createPipelineLayout const):
(WebCore::WebGPUDevice::createBindGroup const):
(WebCore::WebGPUDevice::createShaderModule const):
(WebCore::WebGPUDevice::createRenderPipeline const):
(WebCore::WebGPUDevice::getQueue const):
* Modules/webgpu/WebGPUDevice.h:
* Modules/webgpu/WebGPUPipelineLayout.cpp:
(WebCore::WebGPUPipelineLayout::create):
(WebCore::WebGPUPipelineLayout::WebGPUPipelineLayout):
* Modules/webgpu/WebGPUPipelineLayout.h:
(WebCore::WebGPUPipelineLayout::pipelineLayout):
* Modules/webgpu/WebGPUPipelineLayoutDescriptor.cpp:
(WebCore::WebGPUPipelineLayoutDescriptor::tryCreateGPUPipelineLayoutDescriptor const):
* Modules/webgpu/WebGPUPipelineLayoutDescriptor.h:
* Modules/webgpu/WebGPUQueue.cpp:
(WebCore::WebGPUQueue::create):
(WebCore::WebGPUQueue::WebGPUQueue):
(WebCore::WebGPUQueue::submit):
* Modules/webgpu/WebGPUQueue.h:
* Modules/webgpu/WebGPUShaderModule.cpp:
(WebCore::WebGPUShaderModule::create):
(WebCore::WebGPUShaderModule::WebGPUShaderModule):
* Modules/webgpu/WebGPUShaderModule.h:
(WebCore::WebGPUShaderModule::module const):
* platform/graphics/gpu/GPUBuffer.h:
* platform/graphics/gpu/GPUDevice.cpp:
(WebCore::GPUDevice::tryCreateBuffer):
(WebCore::GPUDevice::tryCreateTexture const):
(WebCore::GPUDevice::tryCreateShaderModule const):
(WebCore::GPUDevice::tryCreateRenderPipeline const):
(WebCore::GPUDevice::tryGetQueue const):
(WebCore::GPUDevice::createShaderModule const): Deleted.
(WebCore::GPUDevice::createRenderPipeline const): Deleted.
(WebCore::GPUDevice::getQueue const): Deleted.
* platform/graphics/gpu/GPUDevice.h:
* platform/graphics/gpu/GPUPipelineLayout.cpp:
(WebCore::GPUPipelineLayout::create):
(WebCore::GPUPipelineLayout::GPUPipelineLayout):
* platform/graphics/gpu/GPUPipelineLayout.h:
(WebCore::GPUPipelineLayout::bindGroupLayouts const):
* platform/graphics/gpu/GPUPipelineLayoutDescriptor.h:
* platform/graphics/gpu/GPURenderPipeline.h:
* platform/graphics/gpu/GPUShaderModule.h:
* platform/graphics/gpu/cocoa/GPUBufferMetal.mm:
(WebCore::GPUBuffer::tryCreate):
(WebCore::GPUBuffer::GPUBuffer):
(WebCore::GPUBuffer::setSubData):
* platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm:
(WebCore::GPUCommandBuffer::tryCreate):
* platform/graphics/gpu/cocoa/GPUDeviceMetal.mm:
(WebCore::GPUDevice::tryCreate):
* platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
(WebCore::GPURenderPipeline::tryCreate):
(WebCore::GPURenderPipeline::GPURenderPipeline):
(WebCore::GPURenderPipeline::create): Deleted.
* platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm:
(WebCore::GPUShaderModule::tryCreate):
(WebCore::GPUShaderModule::create): Deleted.

Add WebGPUPipelineLayoutDescriptor.cpp to project:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

LayoutTests:

GPUShaderModule is no longer nullable.

* webgpu/shader-modules.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (243562 => 243563)


--- trunk/LayoutTests/ChangeLog	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/LayoutTests/ChangeLog	2019-03-27 20:47:55 UTC (rev 243563)
@@ -1,3 +1,14 @@
+2019-03-27  Justin Fan  <justin_...@apple.com>
+
+        [Web GPU] Standardize Web GPU object reference counting and creation logic
+        https://bugs.webkit.org/show_bug.cgi?id=196183
+
+        Reviewed by Dean Jackson.
+
+        GPUShaderModule is no longer nullable.
+
+        * webgpu/shader-modules.html:
+
 2019-03-27  Shawn Roberts  <srobe...@apple.com>
 
         Unreviewed, rolling out r243346.

Modified: trunk/LayoutTests/webgpu/shader-modules.html (243562 => 243563)


--- trunk/LayoutTests/webgpu/shader-modules.html	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/LayoutTests/webgpu/shader-modules.html	2019-03-27 20:47:55 UTC (rev 243563)
@@ -27,35 +27,10 @@
 }
 `
 
-const incompleteShaders = `
-#include <metal_stdlib>
-    
-using namespace metal;
-
-vertex Vertex vertex_main(uint vid [[vertex_id]])
-{
-    return Vertex { float4(0, 0, 0, 1) };
-}
-
-fragment float4 fragment_main(Vertex vertexIn [[stage_in]])
-{
-    rreturn vertexIn.position;
-}
-`
-
 promise_test(async () => {
     const device = await getBasicDevice();
 
-    const shaderDescriptor0 = {
-        code : "Hello World"
-    };
-    let shaderModule = device.createShaderModule(shaderDescriptor0);
-    assert_equals(shaderModule, null, "Bad shader code did not create a module.");
-
-    shaderModule = device.createShaderModule({ code: incompleteShaders });
-    assert_equals(shaderModule, null, "Incomplete shader code did not create a module.");
-
-    shaderModule = device.createShaderModule({ code: shaders });
+    let shaderModule = device.createShaderModule({ code: shaders });
     assert_true(shaderModule instanceof GPUShaderModule, "Shader module created successfully.");
 }, "Test shader code validation when creating modules.");
 </script>

Modified: trunk/Source/WebCore/ChangeLog (243562 => 243563)


--- trunk/Source/WebCore/ChangeLog	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/ChangeLog	2019-03-27 20:47:55 UTC (rev 243563)
@@ -1,3 +1,122 @@
+2019-03-27  Justin Fan  <justin_...@apple.com>
+
+        [Web GPU] Standardize Web GPU object reference counting and creation logic
+        https://bugs.webkit.org/show_bug.cgi?id=196183
+
+        Reviewed by Dean Jackson.
+
+        Make getters return raw refs/pointers and provide const versions if necessary.
+        All Web GPU objects are non-nullable, but become no-op if invalid, and descriptors are not moved unless needed.
+
+        No new tests; no change in behavior.
+
+        Getter updates and const qualifications:
+        * Modules/webgpu/WebGPUAdapter.h:
+        (WebCore::WebGPUAdapter::options const):
+        * Modules/webgpu/WebGPUBindGroup.h:
+        (WebCore::WebGPUBindGroup::bindGroup):
+        (WebCore::WebGPUBindGroup::bindGroup const): Deleted.
+        * Modules/webgpu/WebGPUBindGroupDescriptor.cpp:
+        (WebCore::WebGPUBindGroupDescriptor::tryCreateGPUBindGroupDescriptor const):
+        * Modules/webgpu/WebGPUBindGroupDescriptor.h:
+        * Modules/webgpu/WebGPUBindGroupLayout.h:
+        (WebCore::WebGPUBindGroupLayout::bindGroupLayout const):
+        * Modules/webgpu/WebGPUBuffer.h:
+        (WebCore::WebGPUBuffer::buffer):
+        (WebCore::WebGPUBuffer::buffer const):
+        * Modules/webgpu/WebGPURenderPassDescriptor.cpp:
+        (WebCore::WebGPURenderPassDescriptor::tryCreateGPURenderPassDescriptor const):
+        * Modules/webgpu/WebGPURenderPassEncoder.cpp:
+        (WebCore::WebGPURenderPassEncoder::setVertexBuffers):
+        * Modules/webgpu/WebGPUSampler.h:
+        (WebCore::WebGPUSampler::sampler const):
+        * Modules/webgpu/WebGPUSwapChain.h:
+        (WebCore::WebGPUSwapChain::swapChain):
+        (WebCore::WebGPUSwapChain::swapChain const): Deleted.
+        * Modules/webgpu/WebGPUTexture.h:
+        (WebCore::WebGPUTexture::texture):
+        (WebCore::WebGPUTexture::texture const): Deleted.
+        * Modules/webgpu/WebGPUTextureView.h:
+        (WebCore::WebGPUTextureView::texture):
+        (WebCore::WebGPUTextureView::texture const): Deleted.
+        * platform/graphics/gpu/GPUBindGroupBinding.h:
+        * platform/graphics/gpu/GPUBindGroupDescriptor.h:
+        * platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm:
+        (WebCore::tryGetResourceAsMTLSamplerState):
+
+        Web GPU object creation logic:
+        * Modules/webgpu/WebGPUCommandEncoder.cpp:
+        (WebCore::WebGPUBufferCopyView::tryCreateGPUBufferCopyView const):
+        (WebCore::WebGPUTextureCopyView::tryCreateGPUTextureCopyView const):
+        (WebCore::WebGPUCommandEncoder::beginRenderPass):
+        (WebCore::WebGPUCommandEncoder::copyBufferToBuffer):
+        * Modules/webgpu/WebGPUCommandEncoder.h:
+        * Modules/webgpu/WebGPUDevice.cpp:
+        (WebCore::WebGPUDevice::createBuffer const):
+        (WebCore::WebGPUDevice::createTexture const):
+        (WebCore::WebGPUDevice::createPipelineLayout const):
+        (WebCore::WebGPUDevice::createBindGroup const):
+        (WebCore::WebGPUDevice::createShaderModule const):
+        (WebCore::WebGPUDevice::createRenderPipeline const):
+        (WebCore::WebGPUDevice::getQueue const):
+        * Modules/webgpu/WebGPUDevice.h:
+        * Modules/webgpu/WebGPUPipelineLayout.cpp:
+        (WebCore::WebGPUPipelineLayout::create):
+        (WebCore::WebGPUPipelineLayout::WebGPUPipelineLayout):
+        * Modules/webgpu/WebGPUPipelineLayout.h:
+        (WebCore::WebGPUPipelineLayout::pipelineLayout):
+        * Modules/webgpu/WebGPUPipelineLayoutDescriptor.cpp: 
+        (WebCore::WebGPUPipelineLayoutDescriptor::tryCreateGPUPipelineLayoutDescriptor const):
+        * Modules/webgpu/WebGPUPipelineLayoutDescriptor.h:
+        * Modules/webgpu/WebGPUQueue.cpp:
+        (WebCore::WebGPUQueue::create):
+        (WebCore::WebGPUQueue::WebGPUQueue):
+        (WebCore::WebGPUQueue::submit):
+        * Modules/webgpu/WebGPUQueue.h:
+        * Modules/webgpu/WebGPUShaderModule.cpp:
+        (WebCore::WebGPUShaderModule::create):
+        (WebCore::WebGPUShaderModule::WebGPUShaderModule):
+        * Modules/webgpu/WebGPUShaderModule.h:
+        (WebCore::WebGPUShaderModule::module const):
+        * platform/graphics/gpu/GPUBuffer.h:
+        * platform/graphics/gpu/GPUDevice.cpp:
+        (WebCore::GPUDevice::tryCreateBuffer):
+        (WebCore::GPUDevice::tryCreateTexture const):
+        (WebCore::GPUDevice::tryCreateShaderModule const):
+        (WebCore::GPUDevice::tryCreateRenderPipeline const):
+        (WebCore::GPUDevice::tryGetQueue const):
+        (WebCore::GPUDevice::createShaderModule const): Deleted.
+        (WebCore::GPUDevice::createRenderPipeline const): Deleted.
+        (WebCore::GPUDevice::getQueue const): Deleted.
+        * platform/graphics/gpu/GPUDevice.h:
+        * platform/graphics/gpu/GPUPipelineLayout.cpp:
+        (WebCore::GPUPipelineLayout::create):
+        (WebCore::GPUPipelineLayout::GPUPipelineLayout):
+        * platform/graphics/gpu/GPUPipelineLayout.h:
+        (WebCore::GPUPipelineLayout::bindGroupLayouts const):
+        * platform/graphics/gpu/GPUPipelineLayoutDescriptor.h:
+        * platform/graphics/gpu/GPURenderPipeline.h:
+        * platform/graphics/gpu/GPUShaderModule.h:
+        * platform/graphics/gpu/cocoa/GPUBufferMetal.mm:
+        (WebCore::GPUBuffer::tryCreate):
+        (WebCore::GPUBuffer::GPUBuffer):
+        (WebCore::GPUBuffer::setSubData):
+        * platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm:
+        (WebCore::GPUCommandBuffer::tryCreate):
+        * platform/graphics/gpu/cocoa/GPUDeviceMetal.mm:
+        (WebCore::GPUDevice::tryCreate):
+        * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
+        (WebCore::GPURenderPipeline::tryCreate):
+        (WebCore::GPURenderPipeline::GPURenderPipeline):
+        (WebCore::GPURenderPipeline::create): Deleted.
+        * platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm:
+        (WebCore::GPUShaderModule::tryCreate):
+        (WebCore::GPUShaderModule::create): Deleted.
+
+        Add WebGPUPipelineLayoutDescriptor.cpp to project:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        
 2019-03-27  Shawn Roberts  <srobe...@apple.com>
 
         Unreviewed, rolling out r243346.

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUAdapter.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -45,7 +45,7 @@
     using DeviceRequestPromise = DOMPromiseDeferred<IDLInterface<WebGPUDevice>>;
     void requestDevice(DeviceRequestPromise&&) const;
     
-    Optional<GPURequestAdapterOptions> options() const { return m_options; }
+    const Optional<GPURequestAdapterOptions>& options() const { return m_options; }
 
 private:
     explicit WebGPUAdapter(Optional<GPURequestAdapterOptions>&&);

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -37,7 +37,7 @@
 public:
     static Ref<WebGPUBindGroup> create(RefPtr<GPUBindGroup>&&);
 
-    GPUBindGroup* bindGroup() const { return m_bindGroup.get(); }
+    GPUBindGroup* bindGroup() { return m_bindGroup.get(); }
 
 private:
     explicit WebGPUBindGroup(RefPtr<GPUBindGroup>&&);

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupDescriptor.cpp (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupDescriptor.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupDescriptor.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -103,7 +103,7 @@
             if (!texture)
                 return WTF::nullopt;
 
-            return static_cast<GPUBindingResource>(texture.releaseNonNull());
+            return static_cast<GPUBindingResource>(makeRef(*texture));
         }, [&layoutBinding, functionName] (WebGPUBufferBinding bufferBinding) -> Optional<GPUBindingResource> {
             if (!bufferBinding.buffer)
                 return WTF::nullopt;
@@ -111,10 +111,10 @@
             if (!buffer)
                 return WTF::nullopt;
 
-            if (!validateBufferBindingType(buffer.get(), layoutBinding, functionName))
+            if (!validateBufferBindingType(buffer, layoutBinding, functionName))
                 return WTF::nullopt;
 
-            return static_cast<GPUBindingResource>(GPUBufferBinding { buffer.releaseNonNull(), bufferBinding.offset, bufferBinding.size });
+            return static_cast<GPUBindingResource>(GPUBufferBinding { makeRef(*buffer), bufferBinding.offset, bufferBinding.size });
         });
 
         auto bindingResource = WTF::visit(bindingResourceVisitor, binding.resource);
@@ -126,7 +126,7 @@
         bindGroupBindings.uncheckedAppend(GPUBindGroupBinding { binding.binding, WTFMove(bindingResource.value()) });
     }
 
-    return GPUBindGroupDescriptor { layout->bindGroupLayout().releaseNonNull(), WTFMove(bindGroupBindings) };
+    return GPUBindGroupDescriptor { makeRef(*layout->bindGroupLayout()), WTFMove(bindGroupBindings) };
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupDescriptor.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupDescriptor.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupDescriptor.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -40,7 +40,7 @@
 struct WebGPUBindGroupDescriptor {
     Optional<GPUBindGroupDescriptor> tryCreateGPUBindGroupDescriptor() const;
 
-    RefPtr<WebGPUBindGroupLayout> layout;
+    RefPtr<const WebGPUBindGroupLayout> layout;
     Vector<WebGPUBindGroupBinding> bindings;
 };
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupLayout.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupLayout.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupLayout.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -28,7 +28,6 @@
 #if ENABLE(WEBGPU)
 
 #include "GPUBindGroupLayout.h"
-
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
@@ -38,7 +37,7 @@
 public:
     static Ref<WebGPUBindGroupLayout> create(RefPtr<GPUBindGroupLayout>&&);
 
-    RefPtr<GPUBindGroupLayout> bindGroupLayout() const { return m_bindGroupLayout; }
+    const GPUBindGroupLayout* bindGroupLayout() const { return m_bindGroupLayout.get(); }
 
 private:
     explicit WebGPUBindGroupLayout(RefPtr<GPUBindGroupLayout>&&);

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUBuffer.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -45,7 +45,8 @@
 public:
     static Ref<WebGPUBuffer> create(RefPtr<GPUBuffer>&&);
 
-    RefPtr<GPUBuffer> buffer() const { return m_buffer; }
+    GPUBuffer* buffer() { return m_buffer.get(); }
+    const GPUBuffer* buffer() const { return m_buffer.get(); }
 
     void setSubData(unsigned long long, const JSC::ArrayBuffer&);
     using BufferMappingPromise = DOMPromiseDeferred<IDLInterface<JSC::ArrayBuffer>>;

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.cpp (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -47,7 +47,7 @@
 
     // FIXME: Add Web GPU validation.
 
-    return GPUBufferCopyView { buffer->buffer().releaseNonNull(), *this };
+    return GPUBufferCopyView { makeRef(*buffer->buffer()), *this };
 }
 
 Optional<GPUTextureCopyView> WebGPUTextureCopyView::tryCreateGPUTextureCopyView() const
@@ -59,7 +59,7 @@
 
     // FIXME: Add Web GPU validation.
 
-    return GPUTextureCopyView { texture->texture().releaseNonNull(), *this };
+    return GPUTextureCopyView { makeRef(*texture->texture()), *this };
 }
 
 Ref<WebGPUCommandEncoder> WebGPUCommandEncoder::create(RefPtr<GPUCommandBuffer>&& buffer)
@@ -72,7 +72,7 @@
 {
 }
 
-Ref<WebGPURenderPassEncoder> WebGPUCommandEncoder::beginRenderPass(WebGPURenderPassDescriptor&& descriptor)
+Ref<WebGPURenderPassEncoder> WebGPUCommandEncoder::beginRenderPass(const WebGPURenderPassDescriptor& descriptor)
 {
     if (!m_commandBuffer) {
         LOG(WebGPU, "WebGPUCommandEncoder::beginRenderPass(): Invalid operation!");
@@ -86,7 +86,7 @@
     return WebGPURenderPassEncoder::create(*this, WTFMove(encoder));
 }
 
-void WebGPUCommandEncoder::copyBufferToBuffer(const WebGPUBuffer& src, unsigned long srcOffset, const WebGPUBuffer& dst, unsigned long dstOffset, unsigned long size)
+void WebGPUCommandEncoder::copyBufferToBuffer(WebGPUBuffer& src, unsigned long srcOffset, WebGPUBuffer& dst, unsigned long dstOffset, unsigned long size)
 {
     if (!m_commandBuffer) {
         LOG(WebGPU, "WebGPUCommandEncoder::copyBufferToBuffer(): Invalid operation!");

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -57,8 +57,8 @@
 public:
     static Ref<WebGPUCommandEncoder> create(RefPtr<GPUCommandBuffer>&&);
 
-    Ref<WebGPURenderPassEncoder> beginRenderPass(WebGPURenderPassDescriptor&&);
-    void copyBufferToBuffer(const WebGPUBuffer&, unsigned long srcOffset, const WebGPUBuffer&, unsigned long dstOffset, unsigned long size);
+    Ref<WebGPURenderPassEncoder> beginRenderPass(const WebGPURenderPassDescriptor&);
+    void copyBufferToBuffer(WebGPUBuffer&, unsigned long srcOffset, WebGPUBuffer&, unsigned long dstOffset, unsigned long size);
     void copyBufferToTexture(const WebGPUBufferCopyView&, const WebGPUTextureCopyView&, const GPUExtent3D&);
     void copyTextureToBuffer(const WebGPUTextureCopyView&, const WebGPUBufferCopyView&, const GPUExtent3D&);
     void copyTextureToTexture(const WebGPUTextureCopyView&, const WebGPUTextureCopyView&, const GPUExtent3D&);

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -76,15 +76,15 @@
 {
 }
 
-Ref<WebGPUBuffer> WebGPUDevice::createBuffer(GPUBufferDescriptor&& descriptor) const
+Ref<WebGPUBuffer> WebGPUDevice::createBuffer(const GPUBufferDescriptor& descriptor) const
 {
-    auto buffer = m_device->tryCreateBuffer(WTFMove(descriptor));
+    auto buffer = m_device->tryCreateBuffer(descriptor);
     return WebGPUBuffer::create(WTFMove(buffer));
 }
 
-Ref<WebGPUTexture> WebGPUDevice::createTexture(GPUTextureDescriptor&& descriptor) const
+Ref<WebGPUTexture> WebGPUDevice::createTexture(const GPUTextureDescriptor& descriptor) const
 {
-    auto texture = m_device->tryCreateTexture(WTFMove(descriptor));
+    auto texture = m_device->tryCreateTexture(descriptor);
     return WebGPUTexture::create(WTFMove(texture));
 }
 
@@ -100,16 +100,17 @@
     return WebGPUBindGroupLayout::create(WTFMove(layout));
 }
 
-Ref<WebGPUPipelineLayout> WebGPUDevice::createPipelineLayout(WebGPUPipelineLayoutDescriptor&& descriptor) const
+Ref<WebGPUPipelineLayout> WebGPUDevice::createPipelineLayout(const WebGPUPipelineLayoutDescriptor& descriptor) const
 {
-    auto bindGroupLayouts = descriptor.bindGroupLayouts.map([] (const auto& layout) -> RefPtr<const GPUBindGroupLayout> {
-        return layout->bindGroupLayout();
-    });
-    auto layout = m_device->createPipelineLayout(GPUPipelineLayoutDescriptor { WTFMove(bindGroupLayouts) });
+    auto gpuDescriptor = descriptor.tryCreateGPUPipelineLayoutDescriptor();
+    if (!gpuDescriptor)
+        return WebGPUPipelineLayout::create(nullptr);
+    
+    auto layout = m_device->createPipelineLayout(WTFMove(*gpuDescriptor));
     return WebGPUPipelineLayout::create(WTFMove(layout));
 }
 
-Ref<WebGPUBindGroup> WebGPUDevice::createBindGroup(WebGPUBindGroupDescriptor&& descriptor) const
+Ref<WebGPUBindGroup> WebGPUDevice::createBindGroup(const WebGPUBindGroupDescriptor& descriptor) const
 {
     auto gpuDescriptor = descriptor.tryCreateGPUBindGroupDescriptor();
     if (!gpuDescriptor)
@@ -119,12 +120,11 @@
     return WebGPUBindGroup::create(WTFMove(bindGroup));
 }
 
-RefPtr<WebGPUShaderModule> WebGPUDevice::createShaderModule(WebGPUShaderModuleDescriptor&& descriptor) const
+Ref<WebGPUShaderModule> WebGPUDevice::createShaderModule(const WebGPUShaderModuleDescriptor& descriptor) const
 {
     // FIXME: What can be validated here?
-    if (auto module = m_device->createShaderModule(GPUShaderModuleDescriptor { descriptor.code, descriptor.isWHLSL }))
-        return WebGPUShaderModule::create(module.releaseNonNull());
-    return nullptr;
+    auto module = m_device->tryCreateShaderModule(GPUShaderModuleDescriptor { descriptor.code, descriptor.isWHLSL });
+    return WebGPUShaderModule::create(WTFMove(module));
 }
 
 Ref<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(const WebGPURenderPipelineDescriptor& descriptor) const
@@ -133,7 +133,7 @@
     if (!gpuDescriptor)
         return WebGPURenderPipeline::create(nullptr);
 
-    auto pipeline = m_device->createRenderPipeline(WTFMove(*gpuDescriptor));
+    auto pipeline = m_device->tryCreateRenderPipeline(*gpuDescriptor);
     return WebGPURenderPipeline::create(WTFMove(pipeline));
 }
 
@@ -157,12 +157,12 @@
     return newSwapChain;
 }
 
-RefPtr<WebGPUQueue> WebGPUDevice::getQueue() const
+Ref<WebGPUQueue> WebGPUDevice::getQueue() const
 {
     if (!m_queue)
-        m_queue = WebGPUQueue::create(m_device->getQueue());
+        m_queue = WebGPUQueue::create(m_device->tryGetQueue());
 
-    return m_queue;
+    return makeRef(*m_queue.get());
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -65,15 +65,15 @@
     const WebGPUAdapter& adapter() const { return m_adapter.get(); }
     const GPUDevice& device() const { return m_device.get(); }
 
-    Ref<WebGPUBuffer> createBuffer(GPUBufferDescriptor&&) const;
-    Ref<WebGPUTexture> createTexture(GPUTextureDescriptor&&) const;
+    Ref<WebGPUBuffer> createBuffer(const GPUBufferDescriptor&) const;
+    Ref<WebGPUTexture> createTexture(const GPUTextureDescriptor&) const;
     Ref<WebGPUSampler> createSampler(const GPUSamplerDescriptor&) const;
 
     Ref<WebGPUBindGroupLayout> createBindGroupLayout(const GPUBindGroupLayoutDescriptor&) const;
-    Ref<WebGPUPipelineLayout> createPipelineLayout(WebGPUPipelineLayoutDescriptor&&) const;
-    Ref<WebGPUBindGroup> createBindGroup(WebGPUBindGroupDescriptor&&) const;
+    Ref<WebGPUPipelineLayout> createPipelineLayout(const WebGPUPipelineLayoutDescriptor&) const;
+    Ref<WebGPUBindGroup> createBindGroup(const WebGPUBindGroupDescriptor&) const;
 
-    RefPtr<WebGPUShaderModule> createShaderModule(WebGPUShaderModuleDescriptor&&) const;
+    Ref<WebGPUShaderModule> createShaderModule(const WebGPUShaderModuleDescriptor&) const;
     Ref<WebGPURenderPipeline> createRenderPipeline(const WebGPURenderPipelineDescriptor&) const;
 
     Ref<WebGPUCommandEncoder> createCommandEncoder() const;
@@ -80,7 +80,7 @@
 
     Ref<WebGPUSwapChain> createSwapChain(const WebGPUSwapChainDescriptor&) const;
 
-    RefPtr<WebGPUQueue> getQueue() const;
+    Ref<WebGPUQueue> getQueue() const;
 
 private:
     WebGPUDevice(Ref<const WebGPUAdapter>&&, Ref<GPUDevice>&&);

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayout.cpp (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayout.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayout.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -30,12 +30,12 @@
 
 namespace WebCore {
 
-Ref<WebGPUPipelineLayout> WebGPUPipelineLayout::create(Ref<GPUPipelineLayout>&& layout)
+Ref<WebGPUPipelineLayout> WebGPUPipelineLayout::create(RefPtr<GPUPipelineLayout>&& layout)
 {
     return adoptRef(*new WebGPUPipelineLayout(WTFMove(layout)));
 }
 
-WebGPUPipelineLayout::WebGPUPipelineLayout(Ref<GPUPipelineLayout>&& layout)
+WebGPUPipelineLayout::WebGPUPipelineLayout(RefPtr<GPUPipelineLayout>&& layout)
     : m_pipelineLayout(WTFMove(layout))
 {
 }

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayout.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayout.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayout.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -36,14 +36,14 @@
 
 class WebGPUPipelineLayout : public RefCounted<WebGPUPipelineLayout> {
 public:
-    static Ref<WebGPUPipelineLayout> create(Ref<GPUPipelineLayout>&&);
+    static Ref<WebGPUPipelineLayout> create(RefPtr<GPUPipelineLayout>&&);
 
-    GPUPipelineLayout& pipelineLayout() { return m_pipelineLayout.get(); }
+    GPUPipelineLayout* pipelineLayout() { return m_pipelineLayout.get(); }
 
 private:
-    explicit WebGPUPipelineLayout(Ref<GPUPipelineLayout>&&);
+    explicit WebGPUPipelineLayout(RefPtr<GPUPipelineLayout>&&);
 
-    Ref<GPUPipelineLayout> m_pipelineLayout;
+    RefPtr<GPUPipelineLayout> m_pipelineLayout;
 };
 
 } // namespace WebCore

Copied: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayoutDescriptor.cpp (from rev 243561, trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroup.h) (0 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayoutDescriptor.cpp	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayoutDescriptor.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -0,0 +1,55 @@
+/*
+ * 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 "WebGPUPipelineLayoutDescriptor.h"
+
+#if ENABLE(WEBGPU)
+
+#include "GPUPipelineLayoutDescriptor.h"
+#include "Logging.h"
+
+namespace WebCore {
+    
+Optional<GPUPipelineLayoutDescriptor> WebGPUPipelineLayoutDescriptor::tryCreateGPUPipelineLayoutDescriptor() const
+{
+    Vector<Ref<const GPUBindGroupLayout>> gpuLayouts;
+    gpuLayouts.reserveCapacity(bindGroupLayouts.size());
+    
+    for (const auto& layout : bindGroupLayouts) {
+        if (!layout || !layout->bindGroupLayout()) {
+            LOG(WebGPU, "GPUDevice::createPipelineLayout(): Invalid GPUBindGroupLayout!");
+            return WTF::nullopt;
+        }
+        
+        gpuLayouts.uncheckedAppend(makeRef(*layout->bindGroupLayout()));
+    }
+    
+    return GPUPipelineLayoutDescriptor { WTFMove(gpuLayouts) };
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEBGPU)

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayoutDescriptor.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayoutDescriptor.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineLayoutDescriptor.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -28,13 +28,17 @@
 #if ENABLE(WEBGPU)
 
 #include "WebGPUBindGroupLayout.h"
-
+#include <wtf/Optional.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
+    
+struct GPUPipelineLayoutDescriptor;
 
 struct WebGPUPipelineLayoutDescriptor {
+    Optional<GPUPipelineLayoutDescriptor> tryCreateGPUPipelineLayoutDescriptor() const;
+
     Vector<RefPtr<WebGPUBindGroupLayout>> bindGroupLayouts;
 };
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.cpp (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -35,12 +35,12 @@
 
 namespace WebCore {
 
-RefPtr<WebGPUQueue> WebGPUQueue::create(RefPtr<GPUQueue>&& queue)
+Ref<WebGPUQueue> WebGPUQueue::create(RefPtr<GPUQueue>&& queue)
 {
-    return queue ? adoptRef(new WebGPUQueue(queue.releaseNonNull())) : nullptr;
+    return adoptRef(*new WebGPUQueue(WTFMove(queue)));
 }
 
-WebGPUQueue::WebGPUQueue(Ref<GPUQueue>&& queue)
+WebGPUQueue::WebGPUQueue(RefPtr<GPUQueue>&& queue)
     : m_queue(WTFMove(queue))
 {
 }
@@ -47,6 +47,10 @@
 
 void WebGPUQueue::submit(const Vector<RefPtr<WebGPUCommandBuffer>>& buffers)
 {
+    if (!m_queue) {
+        LOG(WebGPU, "GPUQueue::submit(): Invalid operation!");
+        return;
+    }
     Vector<Ref<GPUCommandBuffer>> gpuBuffers;
     gpuBuffers.reserveCapacity(buffers.size());
     

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -39,7 +39,7 @@
 
 class WebGPUQueue : public RefCounted<WebGPUQueue> {
 public:
-    static RefPtr<WebGPUQueue> create(RefPtr<GPUQueue>&&);
+    static Ref<WebGPUQueue> create(RefPtr<GPUQueue>&&);
 
     void submit(const Vector<RefPtr<WebGPUCommandBuffer>>&);
 
@@ -47,9 +47,9 @@
     void setLabel(const String& label) { m_queue->setLabel(label); }
 
 private:
-    WebGPUQueue(Ref<GPUQueue>&&);
+    WebGPUQueue(RefPtr<GPUQueue>&&);
 
-    Ref<GPUQueue> m_queue;
+    RefPtr<GPUQueue> m_queue;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassDescriptor.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -62,7 +62,7 @@
             LOG(WebGPU, "GPURenderPassDescriptor: Invalid attachment in GPURenderPassColorAttachmentDescriptor!");
             return WTF::nullopt;
         }
-        gpuColorAttachments.append(GPURenderPassColorAttachmentDescriptor { colorAttachment.attachment->texture().releaseNonNull(), colorAttachment });
+        gpuColorAttachments.append(GPURenderPassColorAttachmentDescriptor { makeRef(*colorAttachment.attachment->texture()), colorAttachment });
     }
 
     Optional<GPURenderPassDepthStencilAttachmentDescriptor> gpuDepthAttachment;
@@ -74,7 +74,7 @@
             LOG(WebGPU, "GPURenderPassDescriptor: Invalid attachment in GPURenderPassDepthStencilAttachmentDescriptor!");
             return WTF::nullopt;
         }
-        gpuDepthAttachment = GPURenderPassDepthStencilAttachmentDescriptor { depthStencilAttachment->attachment->texture().releaseNonNull(), *depthStencilAttachment };
+        gpuDepthAttachment = GPURenderPassDepthStencilAttachmentDescriptor { makeRef(*depthStencilAttachment->attachment->texture()), *depthStencilAttachment };
     }
 
     return GPURenderPassDescriptor { WTFMove(gpuColorAttachments), WTFMove(gpuDepthAttachment) };

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -92,7 +92,7 @@
             return;
         }
 
-        gpuBuffers.uncheckedAppend(buffer->buffer().releaseNonNull());
+        gpuBuffers.uncheckedAppend(makeRef(*buffer->buffer()));
     }
 
     m_passEncoder->setVertexBuffers(startSlot, WTFMove(gpuBuffers), WTFMove(offsets));

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUSampler.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUSampler.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSampler.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -37,7 +37,7 @@
 public:
     static Ref<WebGPUSampler> create(RefPtr<GPUSampler>&&);
 
-    GPUSampler* sampler() const { return m_sampler.get(); }
+    const GPUSampler* sampler() const { return m_sampler.get(); }
 
 private:
     WebGPUSampler(RefPtr<GPUSampler>&&);

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.cpp (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -30,15 +30,14 @@
 
 namespace WebCore {
 
-Ref<WebGPUShaderModule> WebGPUShaderModule::create(Ref<GPUShaderModule>&& module)
+Ref<WebGPUShaderModule> WebGPUShaderModule::create(RefPtr<GPUShaderModule>&& module)
 {
     return adoptRef(*new WebGPUShaderModule(WTFMove(module)));
 }
 
-WebGPUShaderModule::WebGPUShaderModule(Ref<GPUShaderModule>&& module)
+WebGPUShaderModule::WebGPUShaderModule(RefPtr<GPUShaderModule>&& module)
     : m_module(WTFMove(module))
 {
-    UNUSED_PARAM(m_module);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -36,14 +36,14 @@
 
 class WebGPUShaderModule : public RefCounted<WebGPUShaderModule> {
 public:
-    static Ref<WebGPUShaderModule> create(Ref<GPUShaderModule>&&);
+    static Ref<WebGPUShaderModule> create(RefPtr<GPUShaderModule>&&);
 
-    const GPUShaderModule* module() const { return m_module.ptr(); }
+    const GPUShaderModule* module() const { return m_module.get(); }
 
 private:
-    WebGPUShaderModule(Ref<GPUShaderModule>&&);
+    WebGPUShaderModule(RefPtr<GPUShaderModule>&&);
 
-    Ref<GPUShaderModule> m_module;
+    RefPtr<GPUShaderModule> m_module;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -40,7 +40,7 @@
 public:
     static Ref<WebGPUSwapChain> create(RefPtr<GPUSwapChain>&&);
 
-    GPUSwapChain* swapChain() const { return m_swapChain.get(); }
+    GPUSwapChain* swapChain() { return m_swapChain.get(); }
 
     Ref<WebGPUTexture> getCurrentTexture();
 

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -39,7 +39,7 @@
 public:
     static Ref<WebGPUTexture> create(RefPtr<GPUTexture>&&);
 
-    RefPtr<GPUTexture> texture() const { return m_texture; }
+    GPUTexture* texture() { return m_texture.get(); }
 
     Ref<WebGPUTextureView> createDefaultView();
     void destroy();

Modified: trunk/Source/WebCore/Modules/webgpu/WebGPUTextureView.h (243562 => 243563)


--- trunk/Source/WebCore/Modules/webgpu/WebGPUTextureView.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Modules/webgpu/WebGPUTextureView.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -38,7 +38,7 @@
     static Ref<WebGPUTextureView> create(RefPtr<GPUTexture>&&);
     ~WebGPUTextureView() { destroy(); }
 
-    RefPtr<GPUTexture> texture() const { return m_texture; }
+    GPUTexture* texture() { return m_texture.get(); }
 
     void destroy();
 private:

Modified: trunk/Source/WebCore/Sources.txt (243562 => 243563)


--- trunk/Source/WebCore/Sources.txt	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/Sources.txt	2019-03-27 20:47:55 UTC (rev 243563)
@@ -358,6 +358,7 @@
 Modules/webgpu/WebGPUDevice.cpp
 Modules/webgpu/WebGPUQueue.cpp
 Modules/webgpu/WebGPUPipelineLayout.cpp
+Modules/webgpu/WebGPUPipelineLayoutDescriptor.cpp
 Modules/webgpu/WebGPUProgrammablePassEncoder.cpp
 Modules/webgpu/WebGPURenderPassDescriptor.cpp
 Modules/webgpu/WebGPURenderPassEncoder.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (243562 => 243563)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2019-03-27 20:47:55 UTC (rev 243563)
@@ -13930,6 +13930,7 @@
 		D003288621C9A4E500622AA6 /* GPUPipelineLayout.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUPipelineLayout.h; sourceTree = "<group>"; };
 		D003288721C9A4E500622AA6 /* GPUPipelineLayout.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUPipelineLayout.cpp; sourceTree = "<group>"; };
 		D003914122248D400098998C /* GPUProgrammablePassEncoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUProgrammablePassEncoder.cpp; sourceTree = "<group>"; };
+		D00487D222457BEA00EED7D9 /* WebGPUPipelineLayoutDescriptor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUPipelineLayoutDescriptor.cpp; sourceTree = "<group>"; };
 		D00F5940216ECC7A000D71DB /* DOMWindowWebGPU.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMWindowWebGPU.h; sourceTree = "<group>"; };
 		D00F5941216ECC7A000D71DB /* DOMWindowWebGPU.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowWebGPU.cpp; sourceTree = "<group>"; };
 		D00F5942216ECC7A000D71DB /* DOMWindowWebGPU.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMWindowWebGPU.idl; sourceTree = "<group>"; };
@@ -26135,6 +26136,7 @@
 				D05A99E521C9BF2C00032B75 /* WebGPUPipelineLayout.cpp */,
 				D05A99E421C9BF2C00032B75 /* WebGPUPipelineLayout.h */,
 				D05A99E621C9BF2C00032B75 /* WebGPUPipelineLayout.idl */,
+				D00487D222457BEA00EED7D9 /* WebGPUPipelineLayoutDescriptor.cpp */,
 				D05A99E121C9B50F00032B75 /* WebGPUPipelineLayoutDescriptor.h */,
 				D05A99E221C9B50F00032B75 /* WebGPUPipelineLayoutDescriptor.idl */,
 				D0C419EB2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.h */,
@@ -26175,6 +26177,7 @@
 				D0EACF882193EE4E000FA75C /* WebGPUTextureView.cpp */,
 				D0EACF872193EE4E000FA75C /* WebGPUTextureView.h */,
 				D0EACF892193EE4E000FA75C /* WebGPUTextureView.idl */,
+				D00487D222457BEA00EED7D9 /* WebGPUPipelineLayoutDescriptor.cpp */,
 			);
 			path = webgpu;
 			sourceTree = "<group>";

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupBinding.h (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupBinding.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupBinding.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-using GPUBindingResource = Variant<Ref<GPUSampler>, Ref<GPUTexture>, GPUBufferBinding>;
+using GPUBindingResource = Variant<Ref<const GPUSampler>, Ref<GPUTexture>, GPUBufferBinding>;
 
 struct GPUBindGroupBinding {
     unsigned long binding;

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupDescriptor.h (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupDescriptor.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupDescriptor.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -35,7 +35,7 @@
 namespace WebCore {
 
 struct GPUBindGroupDescriptor {
-    Ref<GPUBindGroupLayout> layout;
+    Ref<const GPUBindGroupLayout> layout;
     Vector<GPUBindGroupBinding> bindings;
 };
 

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


--- trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -68,7 +68,7 @@
 
     ~GPUBuffer();
 
-    static RefPtr<GPUBuffer> tryCreate(Ref<GPUDevice>&&, GPUBufferDescriptor&&);
+    static RefPtr<GPUBuffer> tryCreate(Ref<GPUDevice>&&, const GPUBufferDescriptor&);
 
     PlatformBuffer *platformBuffer() const { return m_platformBuffer.get(); }
     unsigned long byteLength() const { return m_byteLength; }
@@ -109,7 +109,7 @@
 
     static bool validateBufferUsage(const GPUDevice&, OptionSet<GPUBufferUsage::Flags>);
 
-    GPUBuffer(PlatformBufferSmartPtr&&, const GPUBufferDescriptor&, OptionSet<GPUBufferUsage::Flags>, Ref<GPUDevice>&&);
+    GPUBuffer(PlatformBufferSmartPtr&&, unsigned long, OptionSet<GPUBufferUsage::Flags>, Ref<GPUDevice>&&);
 
     JSC::ArrayBuffer* stagingBufferForRead();
     JSC::ArrayBuffer* stagingBufferForWrite();

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


--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -48,14 +48,14 @@
 
 namespace WebCore {
 
-RefPtr<GPUBuffer> GPUDevice::tryCreateBuffer(GPUBufferDescriptor&& descriptor)
+RefPtr<GPUBuffer> GPUDevice::tryCreateBuffer(const GPUBufferDescriptor& descriptor)
 {
-    return GPUBuffer::tryCreate(makeRef(*this), WTFMove(descriptor));
+    return GPUBuffer::tryCreate(makeRef(*this), descriptor);
 }
 
-RefPtr<GPUTexture> GPUDevice::tryCreateTexture(GPUTextureDescriptor&& descriptor) const
+RefPtr<GPUTexture> GPUDevice::tryCreateTexture(const GPUTextureDescriptor& descriptor) const
 {
-    return GPUTexture::tryCreate(*this, WTFMove(descriptor));
+    return GPUTexture::tryCreate(*this, descriptor);
 }
 
 RefPtr<GPUSampler> GPUDevice::tryCreateSampler(const GPUSamplerDescriptor& descriptor) const
@@ -73,14 +73,14 @@
     return GPUPipelineLayout::create(WTFMove(descriptor));
 }
 
-RefPtr<GPUShaderModule> GPUDevice::createShaderModule(GPUShaderModuleDescriptor&& descriptor) const
+RefPtr<GPUShaderModule> GPUDevice::tryCreateShaderModule(const GPUShaderModuleDescriptor& descriptor) const
 {
-    return GPUShaderModule::create(*this, WTFMove(descriptor));
+    return GPUShaderModule::tryCreate(*this, descriptor);
 }
 
-RefPtr<GPURenderPipeline> GPUDevice::createRenderPipeline(GPURenderPipelineDescriptor&& descriptor) const
+RefPtr<GPURenderPipeline> GPUDevice::tryCreateRenderPipeline(const GPURenderPipelineDescriptor& descriptor) const
 {
-    return GPURenderPipeline::create(*this, WTFMove(descriptor));
+    return GPURenderPipeline::tryCreate(*this, descriptor);
 }
 
 RefPtr<GPUCommandBuffer> GPUDevice::tryCreateCommandBuffer() const
@@ -94,7 +94,7 @@
     return m_swapChain;
 }
 
-RefPtr<GPUQueue> GPUDevice::getQueue() const
+RefPtr<GPUQueue> GPUDevice::tryGetQueue() const
 {
     if (!m_queue)
         m_queue = GPUQueue::tryCreate(*this);

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


--- trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -61,28 +61,28 @@
 
 class GPUDevice : public RefCounted<GPUDevice>, public CanMakeWeakPtr<GPUDevice> {
 public:
-    static RefPtr<GPUDevice> tryCreate(Optional<GPURequestAdapterOptions>&&);
+    static RefPtr<GPUDevice> tryCreate(const Optional<GPURequestAdapterOptions>&);
 
-    RefPtr<GPUBuffer> tryCreateBuffer(GPUBufferDescriptor&&);
-    RefPtr<GPUTexture> tryCreateTexture(GPUTextureDescriptor&&) const;
+    RefPtr<GPUBuffer> tryCreateBuffer(const GPUBufferDescriptor&);
+    RefPtr<GPUTexture> tryCreateTexture(const GPUTextureDescriptor&) const;
     RefPtr<GPUSampler> tryCreateSampler(const GPUSamplerDescriptor&) const;
 
     RefPtr<GPUBindGroupLayout> tryCreateBindGroupLayout(const GPUBindGroupLayoutDescriptor&) const;
     Ref<GPUPipelineLayout> createPipelineLayout(GPUPipelineLayoutDescriptor&&) const;
 
-    RefPtr<GPUShaderModule> createShaderModule(GPUShaderModuleDescriptor&&) const;
-    RefPtr<GPURenderPipeline> createRenderPipeline(GPURenderPipelineDescriptor&&) const;
+    RefPtr<GPUShaderModule> tryCreateShaderModule(const GPUShaderModuleDescriptor&) const;
+    RefPtr<GPURenderPipeline> tryCreateRenderPipeline(const GPURenderPipelineDescriptor&) const;
 
     RefPtr<GPUCommandBuffer> tryCreateCommandBuffer() const;
 
     RefPtr<GPUSwapChain> tryCreateSwapChain(const GPUSwapChainDescriptor&, int width, int height) const;
 
-    RefPtr<GPUQueue> getQueue() const;
+    RefPtr<GPUQueue> tryGetQueue() const;
     PlatformDevice* platformDevice() const { return m_platformDevice.get(); }
     GPUSwapChain* swapChain() const { return m_swapChain.get(); }
 
 private:
-    GPUDevice(PlatformDeviceSmartPtr&&);
+    explicit GPUDevice(PlatformDeviceSmartPtr&&);
 
     PlatformDeviceSmartPtr m_platformDevice;
     mutable RefPtr<GPUQueue> m_queue;

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.cpp (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.cpp	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.cpp	2019-03-27 20:47:55 UTC (rev 243563)
@@ -32,11 +32,11 @@
 
 Ref<GPUPipelineLayout> GPUPipelineLayout::create(GPUPipelineLayoutDescriptor&& descriptor)
 {
-    return adoptRef(*new GPUPipelineLayout(WTFMove(descriptor)));
+    return adoptRef(*new GPUPipelineLayout(WTFMove(descriptor.bindGroupLayouts)));
 }
 
-GPUPipelineLayout::GPUPipelineLayout(GPUPipelineLayoutDescriptor&& descriptor)
-    : m_bindGroupLayouts(WTFMove(descriptor.bindGroupLayouts))
+GPUPipelineLayout::GPUPipelineLayout(Vector<Ref<const GPUBindGroupLayout>>&& layouts)
+    : m_bindGroupLayouts(WTFMove(layouts))
 {
 }
 

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.h (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayout.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -28,7 +28,6 @@
 #if ENABLE(WEBGPU)
 
 #include "GPUPipelineLayoutDescriptor.h"
-
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 
@@ -38,12 +37,12 @@
 public:
     static Ref<GPUPipelineLayout> create(GPUPipelineLayoutDescriptor&&);
 
-    const Vector<RefPtr<const GPUBindGroupLayout>>& bindGroupLayouts() const { return m_bindGroupLayouts; }
+    const Vector<Ref<const GPUBindGroupLayout>>& bindGroupLayouts() const { return m_bindGroupLayouts; }
 
 private:
-    explicit GPUPipelineLayout(GPUPipelineLayoutDescriptor&&);
+    explicit GPUPipelineLayout(Vector<Ref<const GPUBindGroupLayout>>&&);
 
-    Vector<RefPtr<const GPUBindGroupLayout>> m_bindGroupLayouts;
+    Vector<Ref<const GPUBindGroupLayout>> m_bindGroupLayouts;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayoutDescriptor.h (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayoutDescriptor.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineLayoutDescriptor.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -34,7 +34,7 @@
 namespace WebCore {
 
 struct GPUPipelineLayoutDescriptor {
-    Vector<RefPtr<const GPUBindGroupLayout>> bindGroupLayouts;
+    Vector<Ref<const GPUBindGroupLayout>> bindGroupLayouts;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -46,7 +46,7 @@
 
 class GPURenderPipeline : public RefCounted<GPURenderPipeline> {
 public:
-    static RefPtr<GPURenderPipeline> create(const GPUDevice&, GPURenderPipelineDescriptor&&);
+    static RefPtr<GPURenderPipeline> tryCreate(const GPUDevice&, const GPURenderPipelineDescriptor&);
 
 #if USE(METAL)
     MTLDepthStencilState *depthStencilState() const { return m_depthStencilState.get(); }
@@ -56,7 +56,7 @@
 
 private:
 #if USE(METAL)
-    GPURenderPipeline(RetainPtr<MTLDepthStencilState>&&, PlatformRenderPipelineSmartPtr&&, GPURenderPipelineDescriptor&&);
+    GPURenderPipeline(RetainPtr<MTLDepthStencilState>&&, PlatformRenderPipelineSmartPtr&&, GPUPrimitiveTopology);
 
     RetainPtr<MTLDepthStencilState> m_depthStencilState;
 #endif // USE(METAL)

Modified: trunk/Source/WebCore/platform/graphics/gpu/GPUShaderModule.h (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/GPUShaderModule.h	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/GPUShaderModule.h	2019-03-27 20:47:55 UTC (rev 243563)
@@ -44,7 +44,7 @@
 
 class GPUShaderModule : public RefCounted<GPUShaderModule> {
 public:
-    static RefPtr<GPUShaderModule> create(const GPUDevice&, GPUShaderModuleDescriptor&&);
+    static RefPtr<GPUShaderModule> tryCreate(const GPUDevice&, const GPUShaderModuleDescriptor&);
 
     PlatformShaderModule* platformShaderModule() const { return m_whlslSource.isNull() ? m_platformShaderModule.get() : nullptr; }
     const String& whlslSource() const { return m_whlslSource; }

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm	2019-03-27 20:47:55 UTC (rev 243563)
@@ -77,21 +77,21 @@
     END_BLOCK_OBJC_EXCEPTIONS;
 }
     
-static RefPtr<GPUSampler> tryGetResourceAsSampler(const GPUBindingResource& resource, const char* const functionName)
+static MTLSamplerState *tryGetResourceAsMtlSampler(const GPUBindingResource& resource, const char* const functionName)
 {
 #if LOG_DISABLED
     UNUSED_PARAM(functionName);
 #endif
-    if (!WTF::holds_alternative<Ref<GPUSampler>>(resource)) {
+    if (!WTF::holds_alternative<Ref<const GPUSampler>>(resource)) {
         LOG(WebGPU, "%s: Resource is not a GPUSampler!", functionName);
         return nullptr;
     }
-    auto& samplerRef = WTF::get<Ref<GPUSampler>>(resource);
-    if (!samplerRef->platformSampler()) {
+    auto samplerState = WTF::get<Ref<const GPUSampler>>(resource)->platformSampler();
+    if (!samplerState) {
         LOG(WebGPU, "%s: Invalid MTLSamplerState in GPUSampler binding!", functionName);
         return nullptr;
     }
-    return samplerRef.copyRef();
+    return samplerState;
 }
 
 static void setSamplerOnEncoder(MTLArgumentEncoder *argumentEncoder, MTLSamplerState *sampler, unsigned index)
@@ -186,13 +186,13 @@
             break;
         }
         case GPUBindingType::Sampler: {
-            auto samplerResource = tryGetResourceAsSampler(resourceBinding.resource, functionName);
-            if (!samplerResource)
+            auto sampler = tryGetResourceAsMtlSampler(resourceBinding.resource, functionName);
+            if (!sampler)
                 return nullptr;
             if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)
-                setSamplerOnEncoder(vertexEncoder, samplerResource->platformSampler(), resourceBinding.binding);
+                setSamplerOnEncoder(vertexEncoder, sampler, resourceBinding.binding);
             if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)
-                setSamplerOnEncoder(fragmentEncoder, samplerResource->platformSampler(), resourceBinding.binding);
+                setSamplerOnEncoder(fragmentEncoder, sampler, resourceBinding.binding);
             break;
         }
         case GPUBindingType::SampledTexture: {

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


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBufferMetal.mm	2019-03-27 20:47:55 UTC (rev 243563)
@@ -62,7 +62,7 @@
     return true;
 }
 
-RefPtr<GPUBuffer> GPUBuffer::tryCreate(Ref<GPUDevice>&& device, GPUBufferDescriptor&& descriptor)
+RefPtr<GPUBuffer> GPUBuffer::tryCreate(Ref<GPUDevice>&& device, const GPUBufferDescriptor& descriptor)
 {
     auto usage = OptionSet<GPUBufferUsage::Flags>::fromRaw(descriptor.usage);
     if (!validateBufferUsage(device.get(), usage))
@@ -88,13 +88,13 @@
         return nullptr;
     }
 
-    return adoptRef(*new GPUBuffer(WTFMove(mtlBuffer), descriptor, usage, WTFMove(device)));
+    return adoptRef(*new GPUBuffer(WTFMove(mtlBuffer), descriptor.size, usage, WTFMove(device)));
 }
 
-GPUBuffer::GPUBuffer(RetainPtr<MTLBuffer>&& buffer, const GPUBufferDescriptor& descriptor, OptionSet<GPUBufferUsage::Flags> usage, Ref<GPUDevice>&& device)
+GPUBuffer::GPUBuffer(RetainPtr<MTLBuffer>&& buffer, unsigned long size, OptionSet<GPUBufferUsage::Flags> usage, Ref<GPUDevice>&& device)
     : m_platformBuffer(WTFMove(buffer))
     , m_device(WTFMove(device))
-    , m_byteLength(descriptor.size)
+    , m_byteLength(size)
     , m_usage(usage)
 {
 }
@@ -121,6 +121,10 @@
 
 void GPUBuffer::setSubData(unsigned long offset, const JSC::ArrayBuffer& data)
 {
+    MTLCommandQueue *queue;
+    if (!m_device->tryGetQueue() || !(queue = m_device->tryGetQueue()->platformQueue()))
+        return;
+    
     if (!isTransferDestination() || state() != State::Unmapped) {
         LOG(WebGPU, "GPUBuffer::setSubData(): Invalid operation!");
         return;
@@ -156,7 +160,7 @@
 
     BEGIN_BLOCK_OBJC_EXCEPTIONS;
 
-    auto commandBuffer = retainPtr([m_device->getQueue()->platformQueue() commandBuffer]);
+    auto commandBuffer = retainPtr([queue commandBuffer]);
     auto blitEncoder = retainPtr([commandBuffer blitCommandEncoder]);
 
     [blitEncoder copyFromBuffer:stagingMtlBuffer.get() sourceOffset:0 toBuffer:m_platformBuffer.get() destinationOffset:offset size:stagingMtlBuffer.get().length];

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm	2019-03-27 20:47:55 UTC (rev 243563)
@@ -46,7 +46,7 @@
         return nullptr;
     }
 
-    auto gpuCommandQueue = device.getQueue();
+    auto gpuCommandQueue = device.tryGetQueue();
     if (!gpuCommandQueue)
         return nullptr;
 

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUDeviceMetal.mm	2019-03-27 20:47:55 UTC (rev 243563)
@@ -36,7 +36,7 @@
 
 namespace WebCore {
 
-RefPtr<GPUDevice> GPUDevice::tryCreate(Optional<GPURequestAdapterOptions>&& options)
+RefPtr<GPUDevice> GPUDevice::tryCreate(const Optional<GPURequestAdapterOptions>& options)
 {
     RetainPtr<MTLDevice> devicePtr;
 

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


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm	2019-03-27 20:47:55 UTC (rev 243563)
@@ -417,7 +417,7 @@
     return pipeline;
 }
 
-RefPtr<GPURenderPipeline> GPURenderPipeline::create(const GPUDevice& device, GPURenderPipelineDescriptor&& descriptor)
+RefPtr<GPURenderPipeline> GPURenderPipeline::tryCreate(const GPUDevice& device, const GPURenderPipelineDescriptor& descriptor)
 {
     const char* const functionName = "GPURenderPipeline::create()";
 
@@ -435,14 +435,13 @@
     if (!pipeline)
         return nullptr;
 
-    return adoptRef(new GPURenderPipeline(WTFMove(depthStencil), WTFMove(pipeline), WTFMove(descriptor)));
+    return adoptRef(new GPURenderPipeline(WTFMove(depthStencil), WTFMove(pipeline), descriptor.primitiveTopology));
 }
 
-GPURenderPipeline::GPURenderPipeline(RetainPtr<MTLDepthStencilState>&& depthStencil, RetainPtr<MTLRenderPipelineState>&& pipeline, GPURenderPipelineDescriptor&& descriptor)
+GPURenderPipeline::GPURenderPipeline(RetainPtr<MTLDepthStencilState>&& depthStencil, RetainPtr<MTLRenderPipelineState>&& pipeline, GPUPrimitiveTopology topology)
     : m_depthStencilState(WTFMove(depthStencil))
     , m_platformRenderPipeline(WTFMove(pipeline))
-    , m_layout(WTFMove(descriptor.layout))
-    , m_primitiveTopology(descriptor.primitiveTopology)
+    , m_primitiveTopology(topology)
 {
 }
 

Modified: trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm (243562 => 243563)


--- trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm	2019-03-27 20:47:52 UTC (rev 243562)
+++ trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm	2019-03-27 20:47:55 UTC (rev 243563)
@@ -37,7 +37,7 @@
 
 namespace WebCore {
 
-RefPtr<GPUShaderModule> GPUShaderModule::create(const GPUDevice& device, GPUShaderModuleDescriptor&& descriptor)
+RefPtr<GPUShaderModule> GPUShaderModule::tryCreate(const GPUDevice& device, const GPUShaderModuleDescriptor& descriptor)
 {
     if (!device.platformDevice()) {
         LOG(WebGPU, "GPUShaderModule::create(): Invalid GPUDevice!");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to