Changeset 242974 in webkit
- Timestamp:
- Mar 14, 2019 4:04:18 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 36 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r242971 r242974 1 2019-03-14 Justin Fan <justin_fan@apple.com> 2 3 [Web GPU] Updates to GPUCommandBuffer for new GPUCommandEncoder concept 4 https://bugs.webkit.org/show_bug.cgi?id=195083 5 <rdar://problem/48423591> 6 7 Reviewed by Dean Jackson. 8 9 Fixing build error and re-introducing rolled-out changes. 10 Update existing Web GPU tests for GPUCommandEncoder and new GPUCommandBuffer. 11 12 * webgpu/blit-commands.html: 13 * webgpu/buffer-command-buffer-races.html: 14 * webgpu/buffer-resource-triangles.html: 15 * webgpu/command-buffers-expected.txt: 16 * webgpu/command-buffers.html: 17 * webgpu/depth-enabled-triangle-strip.html: 18 * webgpu/js/webgpu-functions.js: 19 (beginBasicRenderPass): 20 * webgpu/render-command-encoding.html: 21 * webgpu/simple-triangle-strip.html: 22 * webgpu/texture-triangle-strip.html: 23 * webgpu/vertex-buffer-triangle-strip.html: 24 1 25 2019-03-14 Ryan Haddad <ryanhaddad@apple.com> 2 26 -
trunk/LayoutTests/webgpu/blit-commands.html
r242956 r242974 86 86 }; 87 87 88 const commandBuffer = device.createCommandBuffer(); 89 commandBuffer.copyBufferToBuffer(bufferA, 0, bufferB, 0, imageData.data.byteLength); 90 commandBuffer.copyBufferToTexture(bufferViewB, textureViewA, textureSize); 91 commandBuffer.copyTextureToTexture(textureViewA, textureViewB, textureSize); 92 commandBuffer.copyTextureToBuffer(textureViewB, readBufferView, textureSize); 93 device.getQueue().submit([commandBuffer]); 88 const commandEncoder = device.createCommandEncoder(); 89 commandEncoder.copyBufferToBuffer(bufferA, 0, bufferB, 0, imageData.data.byteLength); 90 commandEncoder.copyBufferToTexture(bufferViewB, textureViewA, textureSize); 91 commandEncoder.copyBufferToTexture(bufferViewB, textureViewA, textureSize); 92 commandEncoder.copyTextureToTexture(textureViewA, textureViewB, textureSize); 93 commandEncoder.copyTextureToBuffer(textureViewB, readBufferView, textureSize); 94 device.getQueue().submit([commandEncoder.finish()]); 94 95 bufferA.destroy(); 95 96 bufferB.destroy(); -
trunk/LayoutTests/webgpu/buffer-command-buffer-races.html
r242956 r242974 77 77 78 78 function drawAndSubmitCommands(device, pipeline, attachment, vertexBuffer, colorBuffer) { 79 const command Buffer = device.createCommandBuffer();80 const encoder = command Buffer.beginRenderPass({ colorAttachments: [attachment] });79 const commandEncoder = device.createCommandEncoder(); 80 const encoder = commandEncoder.beginRenderPass({ colorAttachments: [attachment] }); 81 81 encoder.setVertexBuffers(0, [vertexBuffer, colorBuffer], [0, 0]); 82 82 encoder.setPipeline(pipeline); 83 83 encoder.draw(3, 1, 0, 0); 84 84 encoder.endPass(); 85 device.getQueue().submit([command Buffer]);85 device.getQueue().submit([commandEncoder.finish()]); 86 86 } 87 87 -
trunk/LayoutTests/webgpu/buffer-resource-triangles.html
r242956 r242974 195 195 196 196 Promise.all(bufferPromises).then(() => { 197 const command Buffer = device.createCommandBuffer();198 const passEncoder = beginBasicRenderPass(swapChain, command Buffer);197 const commandEncoder = device.createCommandEncoder(); 198 const passEncoder = beginBasicRenderPass(swapChain, commandEncoder); 199 199 passEncoder.setPipeline(pipeline); 200 200 … … 206 206 passEncoder.draw(9, 1, 0, 0); 207 207 208 const endCommandBuffer =passEncoder.endPass();208 passEncoder.endPass(); 209 209 const queue = device.getQueue(); 210 queue.submit([ endCommandBuffer]);210 queue.submit([commandEncoder.finish()]); 211 211 212 212 if (window.testRunner) -
trunk/LayoutTests/webgpu/command-buffers-expected.txt
r242956 r242974 1 1 2 PASS Create a default GPUCommand Buffer.2 PASS Create a default GPUCommandEncoder. 3 3 -
trunk/LayoutTests/webgpu/command-buffers.html
r242956 r242974 7 7 promise_test(async () => { 8 8 const device = await getBasicDevice(); 9 const command Buffer = device.createCommandBuffer();10 assert_true(command Buffer instanceof WebGPUCommandBuffer, "Successfully created GPUCommandBuffer.");11 }, "Create a default GPUCommand Buffer.");9 const commandEncoder = device.createCommandEncoder(); 10 assert_true(commandEncoder instanceof GPUCommandEncoder, "Successfully created GPUCommandEncoder."); 11 }, "Create a default GPUCommandEncoder."); 12 12 13 // FIXME: createCommand Buffer should take a GPUCommandBufferDescriptor, which is currently an empty dictionary.13 // FIXME: createCommandEncoder should take a GPUCommandEncoderDescriptor, which is currently an empty dictionary. 14 14 </script> 15 15 </html> -
trunk/LayoutTests/webgpu/depth-enabled-triangle-strip.html
r242956 r242974 90 90 const depthStateDescriptor = createBasicDepthStateDescriptor(); 91 91 const pipeline = createBasicPipeline(shaderModule, device, null, inputStateDescriptor, depthStateDescriptor); 92 const command Buffer = device.createCommandBuffer();92 const commandEncoder = device.createCommandEncoder(); 93 93 94 94 const basicAttachment = { … … 106 106 }; 107 107 108 const encoder = command Buffer.beginRenderPass({108 const encoder = commandEncoder.beginRenderPass({ 109 109 colorAttachments: [basicAttachment], 110 110 depthStencilAttachment: depthAttachment … … 116 116 encoder.endPass(); 117 117 118 device.getQueue().submit([command Buffer]);118 device.getQueue().submit([commandEncoder.finish()]); 119 119 120 120 if (window.testRunner) -
trunk/LayoutTests/webgpu/js/webgpu-functions.js
r242956 r242974 67 67 } 68 68 69 function beginBasicRenderPass(swapChain, command Buffer) {69 function beginBasicRenderPass(swapChain, commandEncoder) { 70 70 const basicAttachment = { 71 71 attachment: swapChain.getCurrentTexture().createDefaultTextureView(), … … 76 76 77 77 // FIXME: Flesh out the rest of WebGPURenderPassDescriptor. 78 return command Buffer.beginRenderPass({ colorAttachments : [basicAttachment] });78 return commandEncoder.beginRenderPass({ colorAttachments : [basicAttachment] }); 79 79 } 80 80 … … 84 84 renderPassEncoder.setPipeline(renderPipeline); 85 85 renderPassEncoder.draw(4, 1, 0, 0); 86 re turn renderPassEncoder.endPass();86 renderPassEncoder.endPass(); 87 87 } -
trunk/LayoutTests/webgpu/render-command-encoding.html
r242956 r242974 35 35 const pipeline = createBasicPipeline(shaderModule, device); 36 36 37 const command Buffer = device.createCommandBuffer();38 assert_true(command Buffer instanceof WebGPUCommandBuffer, "createCommandBuffer returned a WebGPUCommandBuffer");37 const commandEncoder = device.createCommandEncoder(); 38 assert_true(commandEncoder instanceof GPUCommandEncoder, "createCommandEncoder returned a GPUCommandEncoder"); 39 39 40 const encoder = beginBasicRenderPass(swapChain, command Buffer);40 const encoder = beginBasicRenderPass(swapChain, commandEncoder); 41 41 assert_true(encoder instanceof WebGPURenderPassEncoder, "beginRenderPass() returned a WebGPURenderPassEncoder"); 42 42 43 43 encoder.setPipeline(pipeline); 44 const commandBufferEnd = encoder.endPass(); 45 assert_true(commandBufferEnd instanceof WebGPUCommandBuffer, "endPass() returned a WebGPUCommandBuffer"); 44 encoder.endPass(); 46 45 }, "WebGPURenderPassEncoder created and successfully ended"); 47 46 -
trunk/LayoutTests/webgpu/simple-triangle-strip.html
r242956 r242974 53 53 const shaderModule = device.createShaderModule({ code: shaderCode }); 54 54 const pipeline = createBasicPipeline(shaderModule, device); 55 const command Buffer = device.createCommandBuffer();56 const passEncoder = beginBasicRenderPass(swapChain, command Buffer);57 const endCommandBuffer =encodeBasicCommands(passEncoder, pipeline);55 const commandEncoder = device.createCommandEncoder(); 56 const passEncoder = beginBasicRenderPass(swapChain, commandEncoder); 57 encodeBasicCommands(passEncoder, pipeline); 58 58 const queue = device.getQueue(); 59 59 60 queue.submit([ endCommandBuffer]);60 queue.submit([commandEncoder.finish()]); 61 61 62 62 requestAnimationFrame(() => { -
trunk/LayoutTests/webgpu/texture-triangle-strip.html
r242956 r242974 187 187 // Pipeline and render 188 188 const pipeline = createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDescriptor); 189 const command Buffer = device.createCommandBuffer();189 const commandEncoder = device.createCommandEncoder(); 190 190 191 191 const bufferCopyView = { … … 201 201 origin: { x: 0, y: 0, z: 0 } 202 202 }; 203 command Buffer.copyBufferToTexture(bufferCopyView, textureCopyView, textureSize);204 const passEncoder = beginBasicRenderPass(swapChain, command Buffer);203 commandEncoder.copyBufferToTexture(bufferCopyView, textureCopyView, textureSize); 204 const passEncoder = beginBasicRenderPass(swapChain, commandEncoder); 205 205 passEncoder.setPipeline(pipeline); 206 206 passEncoder.setBindGroup(bindGroupIndex, bindGroup); … … 210 210 211 211 const queue = device.getQueue(); 212 queue.submit([command Buffer]);212 queue.submit([commandEncoder.finish()]); 213 213 positionBuffer.destroy(); 214 214 textureCoordBuffer.destroy(); -
trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip.html
r242956 r242974 92 92 const inputStateDescriptor = createInputStateDescriptor(); 93 93 const pipeline = createBasicPipeline(shaderModule, device, null, inputStateDescriptor); 94 const command Buffer = device.createCommandBuffer();95 const passEncoder = beginBasicRenderPass(swapChain, command Buffer);96 const endCommandBuffer =encodeBasicCommands(passEncoder, pipeline, vertexBuffer);94 const commandEncoder = device.createCommandEncoder(); 95 const passEncoder = beginBasicRenderPass(swapChain, commandEncoder); 96 encodeBasicCommands(passEncoder, pipeline, vertexBuffer); 97 97 const queue = device.getQueue(); 98 queue.submit([ endCommandBuffer]);98 queue.submit([commandEncoder.finish()]); 99 99 vertexBuffer.destroy(); 100 100 -
trunk/Source/WebCore/CMakeLists.txt
r242972 r242974 494 494 Modules/webgpu/WebGPUBufferBinding.idl 495 495 Modules/webgpu/WebGPUCommandBuffer.idl 496 Modules/webgpu/WebGPUCommandEncoder.idl 496 497 Modules/webgpu/WebGPUDevice.idl 497 498 Modules/webgpu/WebGPUPipelineDescriptorBase.idl -
trunk/Source/WebCore/ChangeLog
r242972 r242974 1 2019-03-14 Justin Fan <justin_fan@apple.com> 2 3 [Web GPU] Updates to GPUCommandBuffer for new GPUCommandEncoder concept 4 https://bugs.webkit.org/show_bug.cgi?id=195083 5 <rdar://problem/48423591> 6 7 Reviewed by Dean Jackson. 8 9 Fixing build error and re-introducing rolled-out changes. 10 WebGPUCommandBuffer now represents a completed GPUCommandBuffer that can only be used in queue submits. The previous WebGPUCommandBuffer 11 is now WebGPUCommandEncoder. 12 13 Affected Web GPU tests updated to match new API. 14 15 New files and symbols: 16 * CMakeLists.txt: 17 * DerivedSources.make: 18 * Sources.txt: 19 * WebCore.xcodeproj/project.pbxproj: 20 * bindings/js/WebCoreBuiltinNames.h: 21 22 Implement new WebGPUCommandBuffer, now just a DOM object carrier for a finished GPUCommandBuffer: 23 * Modules/webgpu/WebGPUCommandBuffer.cpp: 24 (WebCore::WebGPUCommandBuffer::create): 25 (WebCore::WebGPUCommandBuffer::WebGPUCommandBuffer): 26 (WebCore::WebGPUBufferCopyView::tryCreateGPUBufferCopyView const): Deleted. 27 (WebCore::WebGPUTextureCopyView::tryCreateGPUTextureCopyView const): Deleted. 28 (WebCore::WebGPUCommandBuffer::beginRenderPass): Deleted. 29 (WebCore::WebGPUCommandBuffer::copyBufferToBuffer): Deleted. 30 (WebCore::WebGPUCommandBuffer::copyBufferToTexture): Deleted. 31 (WebCore::WebGPUCommandBuffer::copyTextureToBuffer): Deleted. 32 (WebCore::WebGPUCommandBuffer::copyTextureToTexture): Deleted. 33 * Modules/webgpu/WebGPUCommandBuffer.h: 34 (WebCore::WebGPUCommandBuffer::commandBuffer): 35 (WebCore::WebGPUCommandBuffer::commandBuffer const): Deleted. 36 * Modules/webgpu/WebGPUCommandBuffer.idl: 37 38 Rename old WebGPUCommandBuffer to WebGPUCommandEncoder: 39 * Modules/webgpu/WebGPUCommandEncoder.cpp: Copied from Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp. 40 (WebCore::WebGPUBufferCopyView::tryCreateGPUBufferCopyView const): 41 (WebCore::WebGPUTextureCopyView::tryCreateGPUTextureCopyView const): 42 (WebCore::WebGPUCommandEncoder::create): 43 (WebCore::WebGPUCommandEncoder::WebGPUCommandEncoder): 44 (WebCore::WebGPUCommandEncoder::beginRenderPass): 45 (WebCore::WebGPUCommandEncoder::copyBufferToBuffer): 46 (WebCore::WebGPUCommandEncoder::copyBufferToTexture): 47 (WebCore::WebGPUCommandEncoder::copyTextureToBuffer): 48 (WebCore::WebGPUCommandEncoder::copyTextureToTexture): 49 (WebCore::WebGPUCommandEncoder::finish): Added. "Completes" this and invalidates it. Returns its GPUCommandBuffer, ready for submission. 50 * Modules/webgpu/WebGPUCommandEncoder.h: Copied from Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.h. 51 * Modules/webgpu/WebGPUCommandEncoder.idl: Copied from Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.idl. 52 * Modules/webgpu/WebGPUDevice.cpp: 53 (WebCore::WebGPUDevice::createCommandEncoder const): Renamed fom createCommandBuffer. Now returns non-nullable. 54 (WebCore::WebGPUDevice::createCommandBuffer const): Deleted. 55 * Modules/webgpu/WebGPUDevice.h: 56 * Modules/webgpu/WebGPUDevice.idl: 57 * Modules/webgpu/WebGPUProgrammablePassEncoder.cpp: 58 (WebCore::WebGPUProgrammablePassEncoder::WebGPUProgrammablePassEncoder): 59 (WebCore::WebGPUProgrammablePassEncoder::endPass): No longer returns the original WebGPUCommandBuffer. 60 (WebCore::WebGPUProgrammablePassEncoder::setBindGroup const): 61 (WebCore::WebGPUProgrammablePassEncoder::setPipeline): 62 * Modules/webgpu/WebGPUProgrammablePassEncoder.h: 63 * Modules/webgpu/WebGPUProgrammablePassEncoder.idl: 64 * Modules/webgpu/WebGPUQueue.cpp: 65 (WebCore::WebGPUQueue::submit): Replace unnecessary rvalue reference parameter. 66 * Modules/webgpu/WebGPUQueue.h: 67 * Modules/webgpu/WebGPUQueue.idl: 68 * Modules/webgpu/WebGPURenderPassEncoder.cpp: 69 (WebCore::WebGPURenderPassEncoder::create): 70 (WebCore::WebGPURenderPassEncoder::WebGPURenderPassEncoder): 71 (WebCore::WebGPURenderPassEncoder::setVertexBuffers): 72 (WebCore::WebGPURenderPassEncoder::draw): 73 (WebCore::WebGPURenderPassEncoder::passEncoder const): Now returns a pointer since it is properly backed by a RefPtr. 74 * Modules/webgpu/WebGPURenderPassEncoder.h: 75 * Modules/webgpu/WebGPUSwapChain.cpp: 76 (WebCore::WebGPUSwapChain::getCurrentTexture): No longer invalidates m_currentTexture. Doh! 77 * platform/graphics/gpu/GPUCommandBuffer.h: Missing includes for the *CopyView structs. 78 * platform/graphics/gpu/GPUDevice.cpp: 79 (WebCore::GPUDevice::tryCreateCommandBuffer const): Renamed from createCommandBuffer. 80 (WebCore::GPUDevice::createCommandBuffer): Deleted. 81 * platform/graphics/gpu/GPUDevice.h: 82 * platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm: 83 (WebCore::GPUCommandBuffer::tryCreate): Renamed from create. 84 (WebCore::GPUCommandBuffer::create): Deleted. 85 1 86 2019-03-14 Justin Fan <justin_fan@apple.com> 2 87 -
trunk/Source/WebCore/DerivedSources.make
r242972 r242974 404 404 $(WebCore)/Modules/webgpu/WebGPUBufferBinding.idl \ 405 405 $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \ 406 $(WebCore)/Modules/webgpu/WebGPUCommandEncoder.idl \ 406 407 $(WebCore)/Modules/webgpu/WebGPUDevice.idl \ 407 408 $(WebCore)/Modules/webgpu/WebGPUQueue.idl \ -
trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.cpp
r242956 r242974 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPURenderPassDescriptor.h"32 #include "GPURenderPassEncoder.h"33 #include "WebGPUBuffer.h"34 #include "WebGPURenderPassDescriptor.h"35 #include "WebGPURenderPassEncoder.h"36 #include "WebGPUTexture.h"37 #include <wtf/Optional.h>38 39 31 namespace WebCore { 40 32 41 Optional<GPUBufferCopyView> WebGPUBufferCopyView::tryCreateGPUBufferCopyView() const 42 { 43 if (!buffer || !buffer->buffer()) { 44 LOG(WebGPU, "GPUCommandEncoder: Invalid buffer for copy!"); 45 return WTF::nullopt; 46 } 47 48 // FIXME: Add Web GPU validation. 49 50 return GPUBufferCopyView { buffer->buffer().releaseNonNull(), *this }; 51 } 52 53 Optional<GPUTextureCopyView> WebGPUTextureCopyView::tryCreateGPUTextureCopyView() const 54 { 55 if (!texture || !texture->texture()) { 56 LOG(WebGPU, "GPUCommandEncoder: Invalid texture for copy!"); 57 return WTF::nullopt; 58 } 59 60 // FIXME: Add Web GPU validation. 61 62 return GPUTextureCopyView { texture->texture().releaseNonNull(), *this }; 63 } 64 65 Ref<WebGPUCommandBuffer> WebGPUCommandBuffer::create(Ref<GPUCommandBuffer>&& buffer) 33 Ref<WebGPUCommandBuffer> WebGPUCommandBuffer::create(RefPtr<GPUCommandBuffer>&& buffer) 66 34 { 67 35 return adoptRef(*new WebGPUCommandBuffer(WTFMove(buffer))); 68 36 } 69 37 70 WebGPUCommandBuffer::WebGPUCommandBuffer(Ref <GPUCommandBuffer>&& buffer)38 WebGPUCommandBuffer::WebGPUCommandBuffer(RefPtr<GPUCommandBuffer>&& buffer) 71 39 : m_commandBuffer(WTFMove(buffer)) 72 40 { 73 }74 75 RefPtr<WebGPURenderPassEncoder> WebGPUCommandBuffer::beginRenderPass(WebGPURenderPassDescriptor&& descriptor)76 {77 auto gpuDescriptor = descriptor.tryCreateGPURenderPassDescriptor();78 if (!gpuDescriptor)79 return nullptr;80 81 if (auto encoder = GPURenderPassEncoder::tryCreate(m_commandBuffer.copyRef(), WTFMove(*gpuDescriptor)))82 return WebGPURenderPassEncoder::create(*this, encoder.releaseNonNull());83 return nullptr;84 }85 86 void WebGPUCommandBuffer::copyBufferToBuffer(const WebGPUBuffer& src, unsigned long srcOffset, const WebGPUBuffer& dst, unsigned long dstOffset, unsigned long size)87 {88 if (!src.buffer() || !dst.buffer()) {89 LOG(WebGPU, "GPUCommandBuffer::copyBufferToBuffer(): Invalid GPUBuffer!");90 return;91 }92 93 // FIXME: Add Web GPU validation.94 95 m_commandBuffer->copyBufferToBuffer(src.buffer().releaseNonNull(), srcOffset, dst.buffer().releaseNonNull(), dstOffset, size);96 }97 98 void WebGPUCommandBuffer::copyBufferToTexture(const WebGPUBufferCopyView& srcBuffer, const WebGPUTextureCopyView& dstTexture, const GPUExtent3D& size)99 {100 auto gpuBufferView = srcBuffer.tryCreateGPUBufferCopyView();101 auto gpuTextureView = dstTexture.tryCreateGPUTextureCopyView();102 103 if (!gpuBufferView || !gpuTextureView)104 return;105 106 // FIXME: Add Web GPU validation.107 108 m_commandBuffer->copyBufferToTexture(WTFMove(*gpuBufferView), WTFMove(*gpuTextureView), size);109 }110 111 void WebGPUCommandBuffer::copyTextureToBuffer(const WebGPUTextureCopyView& srcTexture, const WebGPUBufferCopyView& dstBuffer, const GPUExtent3D& size)112 {113 auto gpuTextureView = srcTexture.tryCreateGPUTextureCopyView();114 auto gpuBufferView = dstBuffer.tryCreateGPUBufferCopyView();115 116 if (!gpuTextureView || !gpuBufferView)117 return;118 119 // FIXME: Add Web GPU validation.120 121 m_commandBuffer->copyTextureToBuffer(WTFMove(*gpuTextureView), WTFMove(*gpuBufferView), size);122 }123 124 void WebGPUCommandBuffer::copyTextureToTexture(const WebGPUTextureCopyView& src, const WebGPUTextureCopyView& dst, const GPUExtent3D& size)125 {126 auto gpuSrcView = src.tryCreateGPUTextureCopyView();127 auto gpuDstView = dst.tryCreateGPUTextureCopyView();128 129 if (!gpuSrcView || !gpuDstView)130 return;131 132 // FIXME: Add Web GPU validation.133 134 m_commandBuffer->copyTextureToTexture(WTFMove(*gpuSrcView), WTFMove(*gpuDstView), size);135 41 } 136 42 -
trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.h
r242956 r242974 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 30 30 #include "GPUCommandBuffer.h" 31 32 31 #include <wtf/RefCounted.h> 32 #include <wtf/RefPtr.h> 33 33 34 34 namespace WebCore { 35 35 36 class WebGPUBuffer;37 class WebGPURenderPassEncoder;38 class WebGPUTexture;39 40 struct GPUExtent3D;41 struct WebGPURenderPassDescriptor;42 43 struct WebGPUBufferCopyView : GPUBufferCopyViewBase {44 Optional<GPUBufferCopyView> tryCreateGPUBufferCopyView() const;45 46 RefPtr<WebGPUBuffer> buffer;47 };48 49 struct WebGPUTextureCopyView : GPUTextureCopyViewBase {50 Optional<GPUTextureCopyView> tryCreateGPUTextureCopyView() const;51 52 RefPtr<WebGPUTexture> texture;53 };54 55 36 class WebGPUCommandBuffer : public RefCounted<WebGPUCommandBuffer> { 56 37 public: 57 static Ref<WebGPUCommandBuffer> create(Ref <GPUCommandBuffer>&&);38 static Ref<WebGPUCommandBuffer> create(RefPtr<GPUCommandBuffer>&&); 58 39 59 GPUCommandBuffer& commandBuffer() const { return m_commandBuffer.get(); } 60 61 RefPtr<WebGPURenderPassEncoder> beginRenderPass(WebGPURenderPassDescriptor&&); 62 void copyBufferToBuffer(const WebGPUBuffer&, unsigned long srcOffset, const WebGPUBuffer&, unsigned long dstOffset, unsigned long size); 63 void copyBufferToTexture(const WebGPUBufferCopyView&, const WebGPUTextureCopyView&, const GPUExtent3D&); 64 void copyTextureToBuffer(const WebGPUTextureCopyView&, const WebGPUBufferCopyView&, const GPUExtent3D&); 65 void copyTextureToTexture(const WebGPUTextureCopyView&, const WebGPUTextureCopyView&, const GPUExtent3D&); 40 GPUCommandBuffer* commandBuffer() { return m_commandBuffer.get(); } 66 41 67 42 private: 68 WebGPUCommandBuffer(Ref <GPUCommandBuffer>&&);43 WebGPUCommandBuffer(RefPtr<GPUCommandBuffer>&&); 69 44 70 Ref <GPUCommandBuffer> m_commandBuffer;45 RefPtr<GPUCommandBuffer> m_commandBuffer; 71 46 }; 72 47 -
trunk/Source/WebCore/Modules/webgpu/WebGPUCommandBuffer.idl
r242956 r242974 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 // https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl 26 26 27 typedef unsigned long u32;28 typedef unsigned long long u64;29 30 27 [ 31 28 Conditional=WEBGPU, 32 29 EnabledAtRuntime=WebGPU, 33 ImplementedAs=WebGPUBufferCopyView 34 ] dictionary GPUBufferCopyView { 35 WebGPUBuffer buffer; 36 u64 offset; 37 u64 rowPitch; 38 u32 imageHeight; 30 ImplementationLacksVTable, 31 InterfaceName=GPUCommandBuffer 32 ] interface WebGPUCommandBuffer { 39 33 }; 40 41 [42 Conditional=WEBGPU,43 EnabledAtRuntime=WebGPU,44 ImplementedAs=WebGPUTextureCopyView45 ] dictionary GPUTextureCopyView {46 WebGPUTexture texture;47 u32 mipLevel;48 u32 arrayLayer;49 GPUOrigin3D origin;50 };51 52 [53 Conditional=WEBGPU,54 EnabledAtRuntime=WebGPU,55 ImplementationLacksVTable56 ] interface WebGPUCommandBuffer {57 WebGPURenderPassEncoder beginRenderPass(WebGPURenderPassDescriptor descriptor);58 59 void copyBufferToBuffer(60 WebGPUBuffer src,61 u64 srcOffset,62 WebGPUBuffer dst,63 u64 dstOffset,64 u64 size);65 66 void copyBufferToTexture(67 GPUBufferCopyView source,68 GPUTextureCopyView destination,69 GPUExtent3D copySize);70 71 void copyTextureToBuffer(72 GPUTextureCopyView source,73 GPUBufferCopyView destination,74 GPUExtent3D copySize);75 76 void copyTextureToTexture(77 GPUTextureCopyView source,78 GPUTextureCopyView destination,79 GPUExtent3D copySize);80 81 // Not Yet Implemented82 // WebGPUComputePassEncoder beginComputePass();83 }; -
trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.cpp
r242973 r242974 25 25 26 26 #include "config.h" 27 #include "WebGPUCommand Buffer.h"27 #include "WebGPUCommandEncoder.h" 28 28 29 29 #if ENABLE(WEBGPU) … … 42 42 { 43 43 if (!buffer || !buffer->buffer()) { 44 LOG(WebGPU, " GPUCommandEncoder: Invalid buffer for copy!");44 LOG(WebGPU, "WebGPUCommandEncoder: Invalid buffer for copy!"); 45 45 return WTF::nullopt; 46 46 } … … 54 54 { 55 55 if (!texture || !texture->texture()) { 56 LOG(WebGPU, " GPUCommandEncoder: Invalid texture for copy!");56 LOG(WebGPU, "WebGPUCommandEncoder: Invalid texture for copy!"); 57 57 return WTF::nullopt; 58 58 } … … 63 63 } 64 64 65 Ref<WebGPUCommand Buffer> WebGPUCommandBuffer::create(Ref<GPUCommandBuffer>&& buffer)65 Ref<WebGPUCommandEncoder> WebGPUCommandEncoder::create(RefPtr<GPUCommandBuffer>&& buffer) 66 66 { 67 return adoptRef(*new WebGPUCommand Buffer(WTFMove(buffer)));67 return adoptRef(*new WebGPUCommandEncoder(WTFMove(buffer))); 68 68 } 69 69 70 WebGPUCommand Buffer::WebGPUCommandBuffer(Ref<GPUCommandBuffer>&& buffer)70 WebGPUCommandEncoder::WebGPUCommandEncoder(RefPtr<GPUCommandBuffer>&& buffer) 71 71 : m_commandBuffer(WTFMove(buffer)) 72 72 { 73 73 } 74 74 75 Ref Ptr<WebGPURenderPassEncoder> WebGPUCommandBuffer::beginRenderPass(WebGPURenderPassDescriptor&& descriptor)75 Ref<WebGPURenderPassEncoder> WebGPUCommandEncoder::beginRenderPass(WebGPURenderPassDescriptor&& descriptor) 76 76 { 77 if (!m_commandBuffer) { 78 LOG(WebGPU, "WebGPUCommandEncoder::beginRenderPass(): Invalid operation!"); 79 return WebGPURenderPassEncoder::create(*this, nullptr); 80 } 77 81 auto gpuDescriptor = descriptor.tryCreateGPURenderPassDescriptor(); 78 82 if (!gpuDescriptor) 79 return nullptr;83 return WebGPURenderPassEncoder::create(*this, nullptr); 80 84 81 if (auto encoder = GPURenderPassEncoder::tryCreate(m_commandBuffer.copyRef(), WTFMove(*gpuDescriptor))) 82 return WebGPURenderPassEncoder::create(*this, encoder.releaseNonNull()); 83 return nullptr; 85 auto encoder = GPURenderPassEncoder::tryCreate(makeRef(*m_commandBuffer), WTFMove(*gpuDescriptor)); 86 return WebGPURenderPassEncoder::create(*this, WTFMove(encoder)); 84 87 } 85 88 86 void WebGPUCommand Buffer::copyBufferToBuffer(const WebGPUBuffer& src, unsigned long srcOffset, const WebGPUBuffer& dst, unsigned long dstOffset, unsigned long size)89 void WebGPUCommandEncoder::copyBufferToBuffer(const WebGPUBuffer& src, unsigned long srcOffset, const WebGPUBuffer& dst, unsigned long dstOffset, unsigned long size) 87 90 { 91 if (!m_commandBuffer) { 92 LOG(WebGPU, "WebGPUCommandEncoder::copyBufferToBuffer(): Invalid operation!"); 93 return; 94 } 88 95 if (!src.buffer() || !dst.buffer()) { 89 LOG(WebGPU, " GPUCommandBuffer::copyBufferToBuffer(): Invalid GPUBuffer!");96 LOG(WebGPU, "WebGPUCommandEncoder::copyBufferToBuffer(): Invalid GPUBuffer!"); 90 97 return; 91 98 } … … 93 100 // FIXME: Add Web GPU validation. 94 101 95 m_commandBuffer->copyBufferToBuffer( src.buffer().releaseNonNull(), srcOffset, dst.buffer().releaseNonNull(), dstOffset, size);102 m_commandBuffer->copyBufferToBuffer(makeRef(*src.buffer()), srcOffset, makeRef(*dst.buffer()), dstOffset, size); 96 103 } 97 104 98 void WebGPUCommand Buffer::copyBufferToTexture(const WebGPUBufferCopyView& srcBuffer, const WebGPUTextureCopyView& dstTexture, const GPUExtent3D& size)105 void WebGPUCommandEncoder::copyBufferToTexture(const WebGPUBufferCopyView& srcBuffer, const WebGPUTextureCopyView& dstTexture, const GPUExtent3D& size) 99 106 { 107 if (!m_commandBuffer) { 108 LOG(WebGPU, "WebGPUCommandEncoder::copyBufferToTexture(): Invalid operation!"); 109 return; 110 } 100 111 auto gpuBufferView = srcBuffer.tryCreateGPUBufferCopyView(); 101 112 auto gpuTextureView = dstTexture.tryCreateGPUTextureCopyView(); … … 109 120 } 110 121 111 void WebGPUCommand Buffer::copyTextureToBuffer(const WebGPUTextureCopyView& srcTexture, const WebGPUBufferCopyView& dstBuffer, const GPUExtent3D& size)122 void WebGPUCommandEncoder::copyTextureToBuffer(const WebGPUTextureCopyView& srcTexture, const WebGPUBufferCopyView& dstBuffer, const GPUExtent3D& size) 112 123 { 124 if (!m_commandBuffer) { 125 LOG(WebGPU, "WebGPUCommandEncoder::copyTextureToBuffer(): Invalid operation!"); 126 return; 127 } 113 128 auto gpuTextureView = srcTexture.tryCreateGPUTextureCopyView(); 114 129 auto gpuBufferView = dstBuffer.tryCreateGPUBufferCopyView(); … … 122 137 } 123 138 124 void WebGPUCommand Buffer::copyTextureToTexture(const WebGPUTextureCopyView& src, const WebGPUTextureCopyView& dst, const GPUExtent3D& size)139 void WebGPUCommandEncoder::copyTextureToTexture(const WebGPUTextureCopyView& src, const WebGPUTextureCopyView& dst, const GPUExtent3D& size) 125 140 { 141 if (!m_commandBuffer) { 142 LOG(WebGPU, "WebGPUCommandEncoder::copyTextureToTexture(): Invalid operation!"); 143 return; 144 } 126 145 auto gpuSrcView = src.tryCreateGPUTextureCopyView(); 127 146 auto gpuDstView = dst.tryCreateGPUTextureCopyView(); … … 134 153 m_commandBuffer->copyTextureToTexture(WTFMove(*gpuSrcView), WTFMove(*gpuDstView), size); 135 154 } 155 156 Ref<WebGPUCommandBuffer> WebGPUCommandEncoder::finish() 157 { 158 if (!m_commandBuffer) { 159 LOG(WebGPU, "WebGPUCommandEncoder::finish(): Invalid operation!"); 160 return WebGPUCommandBuffer::create(nullptr); 161 } 162 // Passes the referenced GPUCommandBuffer to the WebGPUCommandBuffer, invalidating this WebGPUCommandEncoder. 163 return WebGPUCommandBuffer::create(m_commandBuffer.releaseNonNull()); 164 } 136 165 137 166 } // namespace WebCore -
trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.h
r242973 r242974 29 29 30 30 #include "GPUCommandBuffer.h" 31 31 #include "WebGPUCommandBuffer.h" 32 32 #include <wtf/RefCounted.h> 33 #include <wtf/RefPtr.h> 33 34 34 35 namespace WebCore { … … 53 54 }; 54 55 55 class WebGPUCommand Buffer : public RefCounted<WebGPUCommandBuffer> {56 class WebGPUCommandEncoder : public RefCounted<WebGPUCommandEncoder> { 56 57 public: 57 static Ref<WebGPUCommand Buffer> create(Ref<GPUCommandBuffer>&&);58 static Ref<WebGPUCommandEncoder> create(RefPtr<GPUCommandBuffer>&&); 58 59 59 GPUCommandBuffer& commandBuffer() const { return m_commandBuffer.get(); } 60 61 RefPtr<WebGPURenderPassEncoder> beginRenderPass(WebGPURenderPassDescriptor&&); 60 Ref<WebGPURenderPassEncoder> beginRenderPass(WebGPURenderPassDescriptor&&); 62 61 void copyBufferToBuffer(const WebGPUBuffer&, unsigned long srcOffset, const WebGPUBuffer&, unsigned long dstOffset, unsigned long size); 63 62 void copyBufferToTexture(const WebGPUBufferCopyView&, const WebGPUTextureCopyView&, const GPUExtent3D&); 64 63 void copyTextureToBuffer(const WebGPUTextureCopyView&, const WebGPUBufferCopyView&, const GPUExtent3D&); 65 64 void copyTextureToTexture(const WebGPUTextureCopyView&, const WebGPUTextureCopyView&, const GPUExtent3D&); 65 Ref<WebGPUCommandBuffer> finish(); 66 66 67 67 private: 68 WebGPUCommand Buffer(Ref<GPUCommandBuffer>&&);68 WebGPUCommandEncoder(RefPtr<GPUCommandBuffer>&&); 69 69 70 Ref <GPUCommandBuffer> m_commandBuffer;70 RefPtr<GPUCommandBuffer> m_commandBuffer; 71 71 }; 72 72 -
trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.idl
r242973 r242974 53 53 Conditional=WEBGPU, 54 54 EnabledAtRuntime=WebGPU, 55 ImplementationLacksVTable 56 ] interface WebGPUCommandBuffer { 55 ImplementationLacksVTable, 56 InterfaceName=GPUCommandEncoder 57 ] interface WebGPUCommandEncoder { 57 58 WebGPURenderPassEncoder beginRenderPass(WebGPURenderPassDescriptor descriptor); 58 59 … … 79 80 GPUExtent3D copySize); 80 81 82 WebGPUCommandBuffer finish(); 83 81 84 // Not Yet Implemented 82 85 // WebGPUComputePassEncoder beginComputePass(); -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
r242956 r242974 45 45 #include "WebGPUBindGroup.h" 46 46 #include "WebGPUBindGroupBinding.h" 47 #include "WebGPUBindGroupDescriptor.h" 47 48 #include "WebGPUBindGroupLayout.h" 48 49 #include "WebGPUBuffer.h" 49 50 #include "WebGPUBufferBinding.h" 50 #include "WebGPUCommand Buffer.h"51 #include "WebGPUCommandEncoder.h" 51 52 #include "WebGPUPipelineLayout.h" 52 53 #include "WebGPUPipelineLayoutDescriptor.h" … … 138 139 } 139 140 140 Ref Ptr<WebGPUCommandBuffer> WebGPUDevice::createCommandBuffer() const141 Ref<WebGPUCommandEncoder> WebGPUDevice::createCommandEncoder() const 141 142 { 142 if (auto commandBuffer = m_device->createCommandBuffer()) 143 return WebGPUCommandBuffer::create(commandBuffer.releaseNonNull()); 144 return nullptr; 143 auto commandBuffer = m_device->tryCreateCommandBuffer(); 144 return WebGPUCommandEncoder::create(WTFMove(commandBuffer)); 145 145 } 146 146 -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h
r242956 r242974 42 42 class WebGPUBindGroupLayout; 43 43 class WebGPUBuffer; 44 class WebGPUCommand Buffer;44 class WebGPUCommandEncoder; 45 45 class WebGPUPipelineLayout; 46 46 class WebGPURenderPipeline; … … 77 77 Ref<WebGPURenderPipeline> createRenderPipeline(const WebGPURenderPipelineDescriptor&) const; 78 78 79 Ref Ptr<WebGPUCommandBuffer> createCommandBuffer() const;79 Ref<WebGPUCommandEncoder> createCommandEncoder() const; 80 80 81 81 Ref<WebGPUSwapChain> createSwapChain(const WebGPUSwapChainDescriptor&) const; -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl
r242956 r242974 55 55 WebGPURenderPipeline createRenderPipeline(WebGPURenderPipelineDescriptor descriptor); 56 56 57 // FIXME: Currently, WebGPUCommandBufferDescriptor is an empty dictionary.58 WebGPUCommand Buffer createCommandBuffer(/*WebGPUCommandBufferDescriptor descriptor*/);57 // FIXME: Currently, GPUCommandEncoderDescriptor is an empty dictionary. 58 WebGPUCommandEncoder createCommandEncoder(/*GPUCommandEncoderDescriptor descriptor*/); 59 59 60 60 WebGPUSwapChain createSwapChain(WebGPUSwapChainDescriptor descriptor); -
trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.cpp
r242956 r242974 36 36 namespace WebCore { 37 37 38 WebGPUProgrammablePassEncoder::WebGPUProgrammablePassEncoder(Ref<WebGPUCommand Buffer>&& creator)38 WebGPUProgrammablePassEncoder::WebGPUProgrammablePassEncoder(Ref<WebGPUCommandEncoder>&& creator) 39 39 : m_commandBuffer(WTFMove(creator)) 40 40 { 41 41 } 42 42 43 Ref<WebGPUCommandBuffer>WebGPUProgrammablePassEncoder::endPass()43 void WebGPUProgrammablePassEncoder::endPass() 44 44 { 45 passEncoder().endPass(); 46 return m_commandBuffer.copyRef(); 45 if (!passEncoder()) { 46 LOG(WebGPU, "GPUProgrammablePassEncoder::endPass(): Invalid operation!"); 47 return; 48 } 49 passEncoder()->endPass(); 47 50 } 48 51 49 52 void WebGPUProgrammablePassEncoder::setBindGroup(unsigned index, WebGPUBindGroup& bindGroup) const 50 53 { 54 if (!passEncoder()) { 55 LOG(WebGPU, "GPUProgrammablePassEncoder::setBindGroup(): Invalid operation!"); 56 return; 57 } 51 58 // Maximum number of bind groups supported in Web GPU. 52 59 if (index >= 4) { 53 LOG(WebGPU, " WebGPUProgrammablePassEncoder::setBindGroup(): Invalid index!");60 LOG(WebGPU, "GPUProgrammablePassEncoder::setBindGroup(): Invalid index!"); 54 61 return; 55 62 } 56 63 if (!bindGroup.bindGroup()) { 57 LOG(WebGPU, " WebGPUProgrammablePassEncoder::setBindGroup(): Invalid WebGPUBindGroup!");64 LOG(WebGPU, "GPUProgrammablePassEncoder::setBindGroup(): Invalid WebGPUBindGroup!"); 58 65 return; 59 66 } 60 67 // FIXME: Any validation (e.g. index duplicates, not in pipeline layout). 61 passEncoder() .setBindGroup(index, *bindGroup.bindGroup());68 passEncoder()->setBindGroup(index, *bindGroup.bindGroup()); 62 69 } 63 70 64 71 void WebGPUProgrammablePassEncoder::setPipeline(const WebGPURenderPipeline& pipeline) 65 72 { 73 if (!passEncoder()) { 74 LOG(WebGPU, "GPUProgrammablePassEncoder::setPipeline(): Invalid operation!"); 75 return; 76 } 66 77 if (!pipeline.renderPipeline()) { 67 78 LOG(WebGPU, "GPUProgrammablePassEncoder::setPipeline(): Invalid pipeline!"); 68 79 return; 69 80 } 70 passEncoder() .setPipeline(makeRef(*pipeline.renderPipeline()));81 passEncoder()->setPipeline(makeRef(*pipeline.renderPipeline())); 71 82 } 72 83 -
trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.h
r242956 r242974 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WebGPUCommand Buffer.h"30 #include "WebGPUCommandEncoder.h" 31 31 #include <wtf/RefCounted.h> 32 32 … … 41 41 virtual ~WebGPUProgrammablePassEncoder() = default; 42 42 43 Ref<WebGPUCommandBuffer>endPass();43 void endPass(); 44 44 void setBindGroup(unsigned, WebGPUBindGroup&) const; 45 45 void setPipeline(const WebGPURenderPipeline&); 46 46 47 47 protected: 48 WebGPUProgrammablePassEncoder(Ref<WebGPUCommand Buffer>&&);48 WebGPUProgrammablePassEncoder(Ref<WebGPUCommandEncoder>&&); 49 49 50 virtual GPUProgrammablePassEncoder &passEncoder() const = 0;50 virtual GPUProgrammablePassEncoder* passEncoder() const = 0; 51 51 52 52 private: 53 Ref<WebGPUCommand Buffer> m_commandBuffer;53 Ref<WebGPUCommandEncoder> m_commandBuffer; 54 54 }; 55 55 -
trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.idl
r242956 r242974 32 32 SkipVTableValidation 33 33 ] interface WebGPUProgrammablePassEncoder { 34 WebGPUCommandBufferendPass();34 void endPass(); 35 35 void setBindGroup(u32 index, WebGPUBindGroup bindGroup/*, optional sequence<u32> dynamicOffsets*/); 36 36 void setPipeline(WebGPURenderPipeline pipeline); // FIXME: Support WebGPUComputePipelines. -
trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.cpp
r242956 r242974 31 31 #include "GPUCommandBuffer.h" 32 32 #include "GPUQueue.h" 33 #include "Logging.h" 33 34 #include "WebGPUCommandBuffer.h" 34 35 … … 45 46 } 46 47 47 void WebGPUQueue::submit( Vector<RefPtr<WebGPUCommandBuffer>>&& buffers)48 void WebGPUQueue::submit(const Vector<RefPtr<WebGPUCommandBuffer>>& buffers) 48 49 { 49 auto gpuBuffers = buffers.map([] (auto& buffer) -> Ref<GPUCommandBuffer> { 50 return buffer->commandBuffer(); 51 }); 50 Vector<Ref<GPUCommandBuffer>> gpuBuffers; 51 gpuBuffers.reserveCapacity(buffers.size()); 52 53 for (auto& buffer : buffers) { 54 if (!buffer || !buffer->commandBuffer()) { 55 LOG(WebGPU, "GPUQueue::submit(): Invalid GPUCommandBuffer in list!"); 56 return; 57 } 58 gpuBuffers.uncheckedAppend(makeRef(*buffer->commandBuffer())); 59 } 60 52 61 m_queue->submit(WTFMove(gpuBuffers)); 53 62 } -
trunk/Source/WebCore/Modules/webgpu/WebGPUQueue.h
r242956 r242974 42 42 static RefPtr<WebGPUQueue> create(RefPtr<GPUQueue>&&); 43 43 44 void submit( Vector<RefPtr<WebGPUCommandBuffer>>&&);44 void submit(const Vector<RefPtr<WebGPUCommandBuffer>>&); 45 45 46 46 String label() const { return m_queue->label(); } -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp
r242956 r242974 37 37 namespace WebCore { 38 38 39 Ref<WebGPURenderPassEncoder> WebGPURenderPassEncoder::create(Ref<WebGPUCommand Buffer>&& commandBuffer, Ref<GPURenderPassEncoder>&& encoder)39 Ref<WebGPURenderPassEncoder> WebGPURenderPassEncoder::create(Ref<WebGPUCommandEncoder>&& commandBuffer, RefPtr<GPURenderPassEncoder>&& encoder) 40 40 { 41 41 return adoptRef(*new WebGPURenderPassEncoder(WTFMove(commandBuffer), WTFMove(encoder))); 42 42 } 43 43 44 WebGPURenderPassEncoder::WebGPURenderPassEncoder(Ref<WebGPUCommand Buffer>&& creator, Ref<GPURenderPassEncoder>&& encoder)44 WebGPURenderPassEncoder::WebGPURenderPassEncoder(Ref<WebGPUCommandEncoder>&& creator, RefPtr<GPURenderPassEncoder>&& encoder) 45 45 : WebGPUProgrammablePassEncoder(WTFMove(creator)) 46 46 , m_passEncoder(WTFMove(encoder)) … … 53 53 const char* const functionName = "GPURenderPassEncoder::setVertexBuffers()"; 54 54 #endif 55 if (!m_passEncoder) { 56 LOG(WebGPU, "%s: Invalid operation!", functionName); 57 return; 58 } 55 59 if (buffers.isEmpty() || buffers.size() != offsets.size()) { 56 60 LOG(WebGPU, "%s: Invalid number of buffers or offsets!", functionName); 57 61 return; 58 62 } 59 60 63 if (startSlot + buffers.size() > maxVertexBuffers) { 61 64 LOG(WebGPU, "%s: Invalid startSlot %lu for %lu buffers!", functionName, startSlot, buffers.size()); … … 85 88 void WebGPURenderPassEncoder::draw(unsigned long vertexCount, unsigned long instanceCount, unsigned long firstVertex, unsigned long firstInstance) 86 89 { 90 if (!m_passEncoder) { 91 LOG(WebGPU, "GPURenderPassEncoder::draw(): Invalid operation!"); 92 return; 93 } 87 94 // FIXME: What kind of validation do we need to handle here? 88 95 m_passEncoder->draw(vertexCount, instanceCount, firstVertex, firstInstance); 89 96 } 90 97 91 GPUProgrammablePassEncoder &WebGPURenderPassEncoder::passEncoder() const98 GPUProgrammablePassEncoder* WebGPURenderPassEncoder::passEncoder() const 92 99 { 93 100 return m_passEncoder.get(); -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h
r242956 r242974 41 41 class WebGPURenderPassEncoder final : public WebGPUProgrammablePassEncoder { 42 42 public: 43 static Ref<WebGPURenderPassEncoder> create(Ref<WebGPUCommand Buffer>&&, Ref<GPURenderPassEncoder>&&);43 static Ref<WebGPURenderPassEncoder> create(Ref<WebGPUCommandEncoder>&&, RefPtr<GPURenderPassEncoder>&&); 44 44 45 45 void setVertexBuffers(unsigned long, Vector<RefPtr<WebGPUBuffer>>&&, Vector<unsigned long long>&&); … … 47 47 48 48 private: 49 WebGPURenderPassEncoder(Ref<WebGPUCommand Buffer>&&, Ref<GPURenderPassEncoder>&&);49 WebGPURenderPassEncoder(Ref<WebGPUCommandEncoder>&&, RefPtr<GPURenderPassEncoder>&&); 50 50 51 GPUProgrammablePassEncoder &passEncoder() const final;51 GPUProgrammablePassEncoder* passEncoder() const final; 52 52 53 Ref <GPURenderPassEncoder> m_passEncoder;53 RefPtr<GPURenderPassEncoder> m_passEncoder; 54 54 }; 55 55 -
trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.cpp
r242956 r242974 51 51 } 52 52 m_currentTexture = WebGPUTexture::create(m_swapChain->tryGetCurrentTexture()); 53 return m _currentTexture.releaseNonNull();53 return makeRef(*m_currentTexture); 54 54 } 55 55 -
trunk/Source/WebCore/Sources.txt
r242972 r242974 353 353 Modules/webgpu/WebGPUBindGroup.cpp 354 354 Modules/webgpu/WebGPUBindGroupDescriptor.cpp 355 Modules/webgpu/WebGPUCommandBuffer.cpp 356 Modules/webgpu/WebGPUCommandEncoder.cpp 355 357 Modules/webgpu/WebGPUAdapter.cpp 356 358 Modules/webgpu/WebGPUBindGroupLayout.cpp 357 359 Modules/webgpu/WebGPUBuffer.cpp 358 Modules/webgpu/WebGPUCommandBuffer.cpp359 360 Modules/webgpu/WebGPUDevice.cpp 360 361 Modules/webgpu/WebGPUQueue.cpp … … 3339 3340 JSWebGPUBufferBinding.cpp 3340 3341 JSWebGPUCommandBuffer.cpp 3342 JSWebGPUCommandEncoder.cpp 3341 3343 JSWebGPUDevice.cpp 3342 3344 JSWebGPUQueue.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r242972 r242974 14085 14085 D05CED270A40BB2C00C5AF38 /* FormatBlockCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FormatBlockCommand.cpp; sourceTree = "<group>"; }; 14086 14086 D05CED280A40BB2C00C5AF38 /* FormatBlockCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FormatBlockCommand.h; sourceTree = "<group>"; }; 14087 D05DD6DD223884060097A834 /* WebGPUCommandBuffer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUCommandBuffer.cpp; sourceTree = "<group>"; }; 14088 D05DD6DE223884070097A834 /* WebGPUCommandBuffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUCommandBuffer.h; sourceTree = "<group>"; }; 14089 D05DD6DF223884070097A834 /* WebGPUCommandBuffer.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUCommandBuffer.idl; sourceTree = "<group>"; }; 14087 14090 D060D88421825D5F00339318 /* WebGPUShaderModuleDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUShaderModuleDescriptor.idl; sourceTree = "<group>"; }; 14088 14091 D060D8872182697000339318 /* WebGPUShaderModuleDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUShaderModuleDescriptor.h; sourceTree = "<group>"; }; … … 14194 14197 D0DE8FB8222E09E200882550 /* GPUShaderStageBit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUShaderStageBit.h; sourceTree = "<group>"; }; 14195 14198 D0DE8FB9222E09E200882550 /* GPUShaderStageBit.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUShaderStageBit.idl; sourceTree = "<group>"; }; 14196 D0EACF7621937228000FA75C /* WebGPUCommand Buffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUCommandBuffer.h; sourceTree = "<group>"; };14197 D0EACF7721937228000FA75C /* WebGPUCommand Buffer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUCommandBuffer.cpp; sourceTree = "<group>"; };14198 D0EACF7821937228000FA75C /* WebGPUCommand Buffer.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUCommandBuffer.idl; sourceTree = "<group>"; };14199 D0EACF7621937228000FA75C /* WebGPUCommandEncoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUCommandEncoder.h; sourceTree = "<group>"; }; 14200 D0EACF7721937228000FA75C /* WebGPUCommandEncoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUCommandEncoder.cpp; sourceTree = "<group>"; }; 14201 D0EACF7821937228000FA75C /* WebGPUCommandEncoder.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUCommandEncoder.idl; sourceTree = "<group>"; }; 14199 14202 D0EACF842193B02E000FA75C /* WebGPUTexture.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUTexture.h; sourceTree = "<group>"; }; 14200 14203 D0EACF852193B02E000FA75C /* WebGPUTexture.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUTexture.cpp; sourceTree = "<group>"; }; … … 26173 26176 D0BE104C21E68F1500E42A89 /* WebGPUBufferBinding.h */, 26174 26177 D0BE104D21E68F1500E42A89 /* WebGPUBufferBinding.idl */, 26175 D0EACF7721937228000FA75C /* WebGPUCommandBuffer.cpp */, 26176 D0EACF7621937228000FA75C /* WebGPUCommandBuffer.h */, 26177 D0EACF7821937228000FA75C /* WebGPUCommandBuffer.idl */, 26178 D05DD6DD223884060097A834 /* WebGPUCommandBuffer.cpp */, 26179 D05DD6DE223884070097A834 /* WebGPUCommandBuffer.h */, 26180 D05DD6DF223884070097A834 /* WebGPUCommandBuffer.idl */, 26181 D0EACF7721937228000FA75C /* WebGPUCommandEncoder.cpp */, 26182 D0EACF7621937228000FA75C /* WebGPUCommandEncoder.h */, 26183 D0EACF7821937228000FA75C /* WebGPUCommandEncoder.idl */, 26178 26184 D00F595321701D8C000D71DB /* WebGPUDevice.cpp */, 26179 26185 D00F595221701D8C000D71DB /* WebGPUDevice.h */, -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r242956 r242974 85 85 macro(GPUCanvasContext) \ 86 86 macro(GPUShaderModule) \ 87 macro(GPUCommandBuffer) \ 88 macro(GPUCommandEncoder) \ 87 89 macro(GPUShaderStageBit) \ 88 90 macro(GPUSwapChain) \ … … 202 204 macro(WebGPUBindGroupLayout) \ 203 205 macro(WebGPUBuffer) \ 204 macro(WebGPUCommandBuffer) \205 206 macro(WebGPUDevice) \ 206 207 macro(WebGPUIndexFormat) \ -
trunk/Source/WebCore/platform/graphics/gpu/GPUCommandBuffer.h
r242956 r242974 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUBuffer.h" 30 31 #include "GPUOrigin3D.h" 32 #include "GPUTexture.h" 31 33 #include <wtf/RefCounted.h> 32 34 #include <wtf/RefPtr.h> … … 39 41 namespace WebCore { 40 42 41 class GPUBuffer;42 43 class GPUDevice; 43 class GPUTexture;44 44 45 45 struct GPUExtent3D; … … 82 82 class GPUCommandBuffer : public RefCounted<GPUCommandBuffer> { 83 83 public: 84 static RefPtr<GPUCommandBuffer> create(GPUDevice&);84 static RefPtr<GPUCommandBuffer> tryCreate(const GPUDevice&); 85 85 86 86 PlatformCommandBuffer* platformCommandBuffer() const { return m_platformCommandBuffer.get(); } -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp
r242956 r242974 84 84 } 85 85 86 RefPtr<GPUCommandBuffer> GPUDevice:: createCommandBuffer()86 RefPtr<GPUCommandBuffer> GPUDevice::tryCreateCommandBuffer() const 87 87 { 88 return GPUCommandBuffer:: create(*this);88 return GPUCommandBuffer::tryCreate(*this); 89 89 } 90 90 -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h
r242956 r242974 38 38 namespace WebCore { 39 39 40 using PlatformDevice = MTLDevice;41 using PlatformDeviceSmartPtr = RetainPtr<MTLDevice>;42 43 40 class GPUBindGroupLayout; 44 41 class GPUBuffer; … … 59 56 struct GPUShaderModuleDescriptor; 60 57 struct GPUTextureDescriptor; 58 59 using PlatformDevice = MTLDevice; 60 using PlatformDeviceSmartPtr = RetainPtr<MTLDevice>; 61 61 62 62 class GPUDevice : public RefCounted<GPUDevice>, public CanMakeWeakPtr<GPUDevice> { … … 74 74 RefPtr<GPURenderPipeline> createRenderPipeline(GPURenderPipelineDescriptor&&) const; 75 75 76 RefPtr<GPUCommandBuffer> createCommandBuffer();76 RefPtr<GPUCommandBuffer> tryCreateCommandBuffer() const; 77 77 78 78 RefPtr<GPUSwapChain> tryCreateSwapChain(const GPUSwapChainDescriptor&, int width, int height) const; -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm
r242956 r242974 29 29 #if ENABLE(WEBGPU) 30 30 31 #import "GPUBuffer.h"32 31 #import "GPUDevice.h" 33 32 #import "GPUExtent3D.h" 34 33 #import "GPUQueue.h" 35 #import "GPUTexture.h"36 34 #import "Logging.h" 37 35 … … 42 40 namespace WebCore { 43 41 44 RefPtr<GPUCommandBuffer> GPUCommandBuffer:: create(GPUDevice& device)42 RefPtr<GPUCommandBuffer> GPUCommandBuffer::tryCreate(const GPUDevice& device) 45 43 { 46 44 if (!device.platformDevice()) {
Note: See TracChangeset
for help on using the changeset viewer.