Changeset 243419 in webkit
- Timestamp:
- Mar 23, 2019, 6:35:13 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 38 edited
- 13 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/webgpu/compute-squares-expected.txt (added)
-
LayoutTests/webgpu/compute-squares.html (added)
-
LayoutTests/webgpu/whlsl.html (modified) (1 diff)
-
Source/WebCore/CMakeLists.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/DerivedSources-input.xcfilelist (modified) (1 diff)
-
Source/WebCore/DerivedSources-output.xcfilelist (modified) (1 diff)
-
Source/WebCore/DerivedSources.make (modified) (1 diff)
-
Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h (modified) (1 diff)
-
Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.h (modified) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.idl (modified) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.cpp (copied) (copied from trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.cpp ) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.h (copied) (copied from trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.h ) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.idl (copied) (copied from trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h ) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp (copied) (copied from trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp ) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h (copied) (copied from trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h ) (3 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUComputePipeline.idl (copied) (copied from trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h ) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.cpp (copied) (copied from trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp ) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.h (copied) (copied from trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h ) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.idl (copied) (copied from trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h ) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUDevice.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUDevice.h (modified) (3 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUDevice.idl (modified) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.cpp (copied) (copied from trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp ) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.h (modified) (3 diffs)
-
Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h (modified) (3 diffs)
-
Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp (modified) (1 diff)
-
Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h (modified) (1 diff)
-
Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.cpp (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (2 diffs)
-
Source/WebCore/SourcesCocoa.txt (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (6 diffs)
-
Source/WebCore/bindings/js/WebCoreBuiltinNames.h (modified) (1 diff)
-
Source/WebCore/platform/cocoa/VideoFullscreenModel.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/gpu/GPUBindGroup.h (modified) (3 diffs)
-
Source/WebCore/platform/graphics/gpu/GPUComputePassEncoder.h (copied) (copied from trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h ) (1 diff)
-
Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h (copied) (copied from trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h ) (2 diffs)
-
Source/WebCore/platform/graphics/gpu/GPUComputePipelineDescriptor.h (copied) (copied from trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h ) (2 diffs)
-
Source/WebCore/platform/graphics/gpu/GPUDevice.cpp (modified) (3 diffs)
-
Source/WebCore/platform/graphics/gpu/GPUDevice.h (modified) (5 diffs)
-
Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/gpu/GPUProgrammablePassEncoder.h (modified) (4 diffs)
-
Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h (modified) (2 diffs)
-
Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm (modified) (10 diffs)
-
Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm (added)
-
Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm (added)
-
Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm (modified) (4 diffs)
-
Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm (modified) (6 diffs)
-
Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm (modified) (2 diffs)
-
Source/WebCore/platform/text/mac/TextEncodingRegistryMac.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243416 r243419 1 2019-03-23 Justin Fan <justin_fan@apple.com> 2 3 [Web GPU] Prototype compute pipeline with MSL 4 https://bugs.webkit.org/show_bug.cgi?id=196107 5 <rdar://problem/46289650> 6 7 Reviewed by Myles Maxfield. 8 9 Add a basic test to create, execute, and verify the results of a Web GPU compute pipeline. 10 11 * webgpu/compute-squares-expected.txt: Added. 12 * webgpu/compute-squares.html: Added. 13 * webgpu/whlsl.html: Update some function names to match API changes. 14 1 15 2019-03-23 Simon Fraser <simon.fraser@apple.com> 2 16 -
trunk/LayoutTests/webgpu/whlsl.html
r243105 r243419 94 94 const swapChain = device.createSwapChain(swapChainDescriptor); 95 95 const outputTexture = swapChain.getCurrentTexture(); 96 const outputTextureView = outputTexture.createDefaultView(); // createDefaultView()96 const outputTextureView = outputTexture.createDefaultView(); 97 97 98 98 const commandEncoder = device.createCommandEncoder(); // {} -
trunk/Source/WebCore/CMakeLists.txt
r243193 r243419 498 498 Modules/webgpu/WebGPUCommandBuffer.idl 499 499 Modules/webgpu/WebGPUCommandEncoder.idl 500 Modules/webgpu/WebGPUComputePassEncoder.idl 501 Modules/webgpu/WebGPUComputePipeline.idl 502 Modules/webgpu/WebGPUComputePipelineDescriptor.idl 500 503 Modules/webgpu/WebGPUDevice.idl 501 504 Modules/webgpu/WebGPUPipelineDescriptorBase.idl -
trunk/Source/WebCore/ChangeLog
r243416 r243419 1 2019-03-23 Justin Fan <justin_fan@apple.com> 2 3 [Web GPU] Prototype compute pipeline with MSL 4 https://bugs.webkit.org/show_bug.cgi?id=196107 5 <rdar://problem/46289650> 6 7 Reviewed by Myles Maxfield. 8 9 Add GPUComputePassEncoder, GPUComputePipeline, and GPUComputePipelineDescriptor. 10 Implement everything needed to prototype a compute pipeline in Web GPU using Metal shaders and bound resources. 11 12 Test: webgpu/compute-squares.html 13 14 Add files and symbols: 15 * CMakeLists.txt: 16 * DerivedSources-input.xcfilelist: 17 * DerivedSources-output.xcfilelist: 18 * DerivedSources.make: 19 * Sources.txt: 20 * SourcesCocoa.txt: 21 * WebCore.xcodeproj/project.pbxproj: 22 * bindings/js/WebCoreBuiltinNames.h: 23 24 Misc fixes: 25 * Modules/webgpu/WHLSL/WHLSLNameResolver.h: Missing include. 26 * Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp: Missing include. 27 * Modules/webgpu/WebGPUPipelineStageDescriptor.cpp: Added. Move pipeline stage validation logic here. 28 (WebCore::WebGPUPipelineStageDescriptor::tryCreateGPUPipelineStageDescriptor const): 29 * Modules/webgpu/WebGPURenderPipeline.cpp: Remove unnecessary include. 30 * Modules/webgpu/WebGPURenderPipeline.h: 31 * Modules/webgpu/WebGPURenderPipelineDescriptor.cpp: Add missing inlcude. 32 (WebCore::WebGPUPipelineStageDescriptor::tryCreateGPUPipelineStageDescriptor const): Moved to WebGPUPipelineStageDescriptor.cpp. 33 * platform/graphics/gpu/GPUPipelineDescriptorBase.h: Add missing include. 34 * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm: Add missing include. 35 (WebCore::GPURenderPipeline::GPURenderPipeline): Remove unecessary ref of GPUPipelineLayout. 36 * platform/text/mac/TextEncodingRegistryMac.mm: Carbon.h was causing ambiguous reference build errors in this file. 37 38 Enable creating a GPUComputePassEncoder from a GPUCommandEncoder: 39 * Modules/webgpu/WebGPUCommandEncoder.cpp: 40 (WebCore::WebGPUCommandEncoder::beginRenderPass): No longer passing this WebGPUCommandEncoder to pass encoders. 41 (WebCore::WebGPUCommandEncoder::beginComputePass): Added. 42 * Modules/webgpu/WebGPUCommandEncoder.h: 43 * Modules/webgpu/WebGPUCommandEncoder.idl: 44 45 Add GPUComputePassEncoder: 46 * Modules/webgpu/WebGPUComputePassEncoder.cpp: Added. 47 (WebCore::WebGPUComputePassEncoder::create): 48 (WebCore::WebGPUComputePassEncoder::WebGPUComputePassEncoder): 49 (WebCore::WebGPUComputePassEncoder::setPipeline): 50 (WebCore::WebGPUComputePassEncoder::dispatch): 51 (WebCore::WebGPUComputePassEncoder::passEncoder): 52 (WebCore::WebGPUComputePassEncoder::passEncoder const): 53 * Modules/webgpu/WebGPUComputePassEncoder.h: Added. 54 * Modules/webgpu/WebGPUComputePassEncoder.idl: Added. 55 * platform/graphics/gpu/GPUComputePassEncoder.h: Added. 56 (WebCore::GPUComputePassEncoder::~GPUComputePassEncoder): 57 * platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm: Added. 58 (WebCore::GPUComputePassEncoder::tryCreate): 59 (WebCore::GPUComputePassEncoder::GPUComputePassEncoder): 60 (WebCore::GPUComputePassEncoder::setPipeline): 61 (WebCore::GPUComputePassEncoder::dispatch): Use a default calculation for threadsPerThreadgroup while MSL is still an accepted shader format. 62 (WebCore::GPUComputePassEncoder::platformPassEncoder const): 63 (WebCore::GPUComputePassEncoder::useResource): 64 (WebCore::GPUComputePassEncoder::setComputeBuffer): 65 66 Add GPUComputePipeline: 67 * Modules/webgpu/WebGPUComputePipeline.cpp: Added. 68 (WebCore::WebGPUComputePipeline::create): 69 (WebCore::WebGPUComputePipeline::WebGPUComputePipeline): 70 * Modules/webgpu/WebGPUComputePipeline.h: Added. 71 (WebCore::WebGPUComputePipeline::computePipeline const): 72 * Modules/webgpu/WebGPUComputePipeline.idl: Added. 73 * Modules/webgpu/WebGPUComputePipelineDescriptor.cpp: Added. 74 (WebCore::WebGPUComputePipelineDescriptor::tryCreateGPUComputePipelineDescriptor const): 75 * Modules/webgpu/WebGPUComputePipelineDescriptor.h: Added. 76 * Modules/webgpu/WebGPUComputePipelineDescriptor.idl: Added. 77 * platform/graphics/gpu/GPUComputePipeline.h: Added. 78 (WebCore::GPUComputePipeline::platformComputePipeline const): 79 * platform/graphics/gpu/GPUComputePipelineDescriptor.h: Added. 80 (WebCore::GPUComputePipelineDescriptor::GPUComputePipelineDescriptor): 81 * platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm: Added. 82 (WebCore::tryCreateMtlComputeFunction): 83 (WebCore::tryCreateMTLComputePipelineState): 84 (WebCore::GPUComputePipeline::tryCreate): 85 (WebCore::GPUComputePipeline::GPUComputePipeline): 86 87 Enable creating a GPUComputePipeline from a GPUDevice: 88 * Modules/webgpu/WebGPUDevice.cpp: 89 (WebCore::WebGPUDevice::createComputePipeline const): 90 * Modules/webgpu/WebGPUDevice.h: 91 * Modules/webgpu/WebGPUDevice.idl: 92 * platform/graphics/gpu/GPUDevice.cpp: 93 (WebCore::GPUDevice::tryCreateComputePipeline const): 94 * platform/graphics/gpu/GPUDevice.h: 95 96 No longer unnecessarily ref the WebGPUCommandEncoder when creating pass encoder: 97 * Modules/webgpu/WebGPUProgrammablePassEncoder.cpp: 98 (WebCore::WebGPUProgrammablePassEncoder::setBindGroup): 99 (WebCore::WebGPUProgrammablePassEncoder::WebGPUProgrammablePassEncoder): Deleted. 100 (WebCore::WebGPUProgrammablePassEncoder::setBindGroup const): Deleted. 101 * Modules/webgpu/WebGPUProgrammablePassEncoder.h: 102 * Modules/webgpu/WebGPURenderPassEncoder.cpp: 103 (WebCore::WebGPURenderPassEncoder::create): 104 (WebCore::WebGPURenderPassEncoder::WebGPURenderPassEncoder): 105 (WebCore::WebGPURenderPassEncoder::setPipeline): 106 (WebCore::WebGPURenderPassEncoder::passEncoder): 107 (WebCore::WebGPURenderPassEncoder::passEncoder const): 108 * Modules/webgpu/WebGPURenderPassEncoder.h: 109 110 Updates to GPUBindGroup and *setBindGroup for compute function arguments: 111 * platform/graphics/gpu/GPUBindGroup.h: 112 (WebCore::GPUBindGroup::vertexArgsBuffer const): 113 (WebCore::GPUBindGroup::fragmentArgsBuffer const): 114 (WebCore::GPUBindGroup::computeArgsBuffer const): 115 (WebCore::GPUBindGroup::vertexArgsBuffer): Deleted. Const-qualified. 116 (WebCore::GPUBindGroup::fragmentArgsBuffer): Ditto. 117 * platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm: 118 (WebCore::tryGetResourceAsMTLSamplerState): Now just returns the MTLSamplerState to reduce reference churning. 119 (WebCore::GPUBindGroup::tryCreate): 120 (WebCore::GPUBindGroup::GPUBindGroup): 121 (WebCore::tryGetResourceAsSampler): Renamed to tryGetResourceAsMTLSamplerState. 122 123 Updates to GPUProgrammablePassEncoder and GPURenderPassEncoder: 124 * platform/graphics/gpu/GPUProgrammablePassEncoder.h: 125 (WebCore::GPUProgrammablePassEncoder::setVertexBuffer): 126 (WebCore::GPUProgrammablePassEncoder::setFragmentBuffer): 127 (WebCore::GPUProgrammablePassEncoder::setComputeBuffer): Added. 128 * platform/graphics/gpu/GPURenderPassEncoder.h: 129 (WebCore::GPURenderPassEncoder::~GPURenderPassEncoder): 130 * platform/graphics/gpu/GPURenderPipeline.h: 131 * platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm: Remove unecessary include. 132 (WebCore::GPUProgrammablePassEncoder::endPass): No longer virtual. Delegates shared behavior for derived classes. 133 (WebCore::GPUProgrammablePassEncoder::setBindGroup): 134 * platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm: 135 (WebCore::GPURenderPassEncoder::platformPassEncoder const): 136 (WebCore::GPURenderPassEncoder::setPipeline): 137 (WebCore::GPURenderPassEncoder::draw): 138 (WebCore::GPURenderPassEncoder::useResource): These private overrides are called only by base after checking for encoder existence. 139 (WebCore::GPURenderPassEncoder::setVertexBuffer): Ditto. 140 (WebCore::GPURenderPassEncoder::setFragmentBuffer): Ditto. 141 (WebCore::GPURenderPassEncoder::endPass): Deleted. Now handled by base class. 142 1 143 2019-03-23 Simon Fraser <simon.fraser@apple.com> 2 144 -
trunk/Source/WebCore/DerivedSources-input.xcfilelist
r243193 r243419 368 368 $(PROJECT_DIR)/Modules/webgpu/WebGPUCommandBuffer.idl 369 369 $(PROJECT_DIR)/Modules/webgpu/WebGPUCommandEncoder.idl 370 $(PROJECT_DIR)/Modules/webgpu/WebGPUComputePassEncoder.idl 371 $(PROJECT_DIR)/Modules/webgpu/WebGPUComputePipeline.idl 372 $(PROJECT_DIR)/Modules/webgpu/WebGPUComputePipelineDescriptor.idl 370 373 $(PROJECT_DIR)/Modules/webgpu/WebGPUDevice.idl 371 374 $(PROJECT_DIR)/Modules/webgpu/WebGPUIndexFormat.idl -
trunk/Source/WebCore/DerivedSources-output.xcfilelist
r243193 r243419 1930 1930 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUCommandEncoder.cpp 1931 1931 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUCommandEncoder.h 1932 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePassEncoder.cpp 1933 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePassEncoder.h 1934 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePipeline.cpp 1935 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePipeline.h 1936 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePipelineDescriptor.cpp 1937 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUComputePipelineDescriptor.h 1932 1938 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUDevice.cpp 1933 1939 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUDevice.h -
trunk/Source/WebCore/DerivedSources.make
r243229 r243419 408 408 $(WebCore)/Modules/webgpu/WebGPUCommandBuffer.idl \ 409 409 $(WebCore)/Modules/webgpu/WebGPUCommandEncoder.idl \ 410 $(WebCore)/Modules/webgpu/WebGPUComputePassEncoder.idl \ 411 $(WebCore)/Modules/webgpu/WebGPUComputePipeline.idl \ 412 $(WebCore)/Modules/webgpu/WebGPUComputePipelineDescriptor.idl \ 410 413 $(WebCore)/Modules/webgpu/WebGPUDevice.idl \ 411 414 $(WebCore)/Modules/webgpu/WebGPUQueue.idl \ -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h
r243091 r243419 30 30 #include "WHLSLNameContext.h" 31 31 #include "WHLSLVisitor.h" 32 #include <wtf/HashSet.h> 32 33 33 34 namespace WebCore { -
trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.cpp
r242974 r243419 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPUComputePassEncoder.h" 31 32 #include "GPURenderPassDescriptor.h" 32 33 #include "GPURenderPassEncoder.h" 33 34 #include "WebGPUBuffer.h" 35 #include "WebGPUComputePassEncoder.h" 34 36 #include "WebGPURenderPassDescriptor.h" 35 37 #include "WebGPURenderPassEncoder.h" … … 77 79 if (!m_commandBuffer) { 78 80 LOG(WebGPU, "WebGPUCommandEncoder::beginRenderPass(): Invalid operation!"); 79 return WebGPURenderPassEncoder::create( *this,nullptr);81 return WebGPURenderPassEncoder::create(nullptr); 80 82 } 81 83 auto gpuDescriptor = descriptor.tryCreateGPURenderPassDescriptor(); 82 84 if (!gpuDescriptor) 83 return WebGPURenderPassEncoder::create( *this,nullptr);85 return WebGPURenderPassEncoder::create(nullptr); 84 86 85 87 auto encoder = GPURenderPassEncoder::tryCreate(makeRef(*m_commandBuffer), WTFMove(*gpuDescriptor)); 86 return WebGPURenderPassEncoder::create(*this, WTFMove(encoder)); 88 return WebGPURenderPassEncoder::create(WTFMove(encoder)); 89 } 90 91 Ref<WebGPUComputePassEncoder> WebGPUCommandEncoder::beginComputePass() 92 { 93 if (!m_commandBuffer) { 94 LOG(WebGPU, "WebGPUCommandEncoder::beginComputePass(): Invalid operation!"); 95 return WebGPUComputePassEncoder::create(nullptr); 96 } 97 auto encoder = GPUComputePassEncoder::tryCreate(makeRef(*m_commandBuffer)); 98 return WebGPUComputePassEncoder::create(WTFMove(encoder)); 87 99 } 88 100 -
trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.h
r242974 r243419 36 36 37 37 class WebGPUBuffer; 38 class WebGPUComputePassEncoder; 38 39 class WebGPURenderPassEncoder; 39 40 class WebGPUTexture; … … 59 60 60 61 Ref<WebGPURenderPassEncoder> beginRenderPass(WebGPURenderPassDescriptor&&); 62 Ref<WebGPUComputePassEncoder> beginComputePass(); 61 63 void copyBufferToBuffer(const WebGPUBuffer&, unsigned long srcOffset, const WebGPUBuffer&, unsigned long dstOffset, unsigned long size); 62 64 void copyBufferToTexture(const WebGPUBufferCopyView&, const WebGPUTextureCopyView&, const GPUExtent3D&); -
trunk/Source/WebCore/Modules/webgpu/WebGPUCommandEncoder.idl
r242974 r243419 57 57 ] interface WebGPUCommandEncoder { 58 58 WebGPURenderPassEncoder beginRenderPass(WebGPURenderPassDescriptor descriptor); 59 WebGPUComputePassEncoder beginComputePass(); 59 60 60 61 void copyBufferToBuffer( … … 81 82 82 83 WebGPUCommandBuffer finish(); 83 84 // Not Yet Implemented85 // WebGPUComputePassEncoder beginComputePass();86 84 }; -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.cpp
r243418 r243419 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 26 26 #include "config.h" 27 #include "WebGPU ProgrammablePassEncoder.h"27 #include "WebGPUComputePassEncoder.h" 28 28 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPUComputePassEncoder.h" 31 32 #include "GPUProgrammablePassEncoder.h" 32 #include "Logging.h" 33 #include "WebGPUBindGroup.h" 34 #include "WebGPURenderPipeline.h" 33 #include "WebGPUComputePipeline.h" 35 34 36 35 namespace WebCore { 37 36 38 WebGPUProgrammablePassEncoder::WebGPUProgrammablePassEncoder(Ref<WebGPUCommandEncoder>&& creator) 39 : m_commandBuffer(WTFMove(creator)) 37 Ref<WebGPUComputePassEncoder> WebGPUComputePassEncoder::create(RefPtr<GPUComputePassEncoder>&& encoder) 38 { 39 return adoptRef(*new WebGPUComputePassEncoder(WTFMove(encoder))); 40 } 41 42 WebGPUComputePassEncoder::WebGPUComputePassEncoder(RefPtr<GPUComputePassEncoder>&& encoder) 43 : m_passEncoder { WTFMove(encoder) } 40 44 { 41 45 } 42 46 43 void WebGPU ProgrammablePassEncoder::endPass()47 void WebGPUComputePassEncoder::setPipeline(const WebGPUComputePipeline& pipeline) 44 48 { 45 if (! passEncoder()) {46 LOG(WebGPU, "GPU ProgrammablePassEncoder::endPass(): Invalid operation!");49 if (!m_passEncoder) { 50 LOG(WebGPU, "GPUComputePassEncoder::setPipeline(): Invalid operation!"); 47 51 return; 48 52 } 49 passEncoder()->endPass(); 53 if (!pipeline.computePipeline()) { 54 LOG(WebGPU, "GPUComputePassEncoder::setPipeline(): Invalid pipeline!"); 55 return; 56 } 57 m_passEncoder->setPipeline(makeRef(*pipeline.computePipeline())); 50 58 } 51 59 52 void WebGPU ProgrammablePassEncoder::setBindGroup(unsigned index, WebGPUBindGroup& bindGroup) const60 void WebGPUComputePassEncoder::dispatch(unsigned x, unsigned y, unsigned z) 53 61 { 54 if (! passEncoder()) {55 LOG(WebGPU, "GPU ProgrammablePassEncoder::setBindGroup(): Invalid operation!");62 if (!m_passEncoder) { 63 LOG(WebGPU, "GPUComputePassEncoder::dispatch(): Invalid operation!"); 56 64 return; 57 65 } 58 // Maximum number of bind groups supported in Web GPU. 59 if (index >= 4) { 60 LOG(WebGPU, "GPUProgrammablePassEncoder::setBindGroup(): Invalid index!"); 61 return; 62 } 63 if (!bindGroup.bindGroup()) { 64 LOG(WebGPU, "GPUProgrammablePassEncoder::setBindGroup(): Invalid WebGPUBindGroup!"); 65 return; 66 } 67 // FIXME: Any validation (e.g. index duplicates, not in pipeline layout). 68 passEncoder()->setBindGroup(index, *bindGroup.bindGroup()); 66 67 // FIXME: Add Web GPU validation. 68 m_passEncoder->dispatch(x, y, z); 69 } 70 71 GPUProgrammablePassEncoder* WebGPUComputePassEncoder::passEncoder() 72 { 73 return m_passEncoder.get(); 74 } 75 76 const GPUProgrammablePassEncoder* WebGPUComputePassEncoder::passEncoder() const 77 { 78 return m_passEncoder.get(); 69 79 } 70 80 -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.h
r243418 r243419 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WebGPU CommandEncoder.h"31 #include <wtf/Ref Counted.h>30 #include "WebGPUProgrammablePassEncoder.h" 31 #include <wtf/RefPtr.h> 32 32 33 33 namespace WebCore { 34 34 35 class GPUComputePassEncoder; 35 36 class GPUProgrammablePassEncoder; 36 class WebGPUBindGroup; 37 class WebGPURenderPipeline; 37 class WebGPUComputePipeline; 38 38 39 class WebGPU ProgrammablePassEncoder : public RefCounted<WebGPUProgrammablePassEncoder>{39 class WebGPUComputePassEncoder : public WebGPUProgrammablePassEncoder { 40 40 public: 41 virtual ~WebGPUProgrammablePassEncoder() = default;41 static Ref<WebGPUComputePassEncoder> create(RefPtr<GPUComputePassEncoder>&&); 42 42 43 void endPass(); 44 void setBindGroup(unsigned, WebGPUBindGroup&) const; 45 46 protected: 47 WebGPUProgrammablePassEncoder(Ref<WebGPUCommandEncoder>&&); 48 49 virtual GPUProgrammablePassEncoder* passEncoder() const = 0; 43 void setPipeline(const WebGPUComputePipeline&); 44 void dispatch(unsigned x, unsigned y, unsigned z); 50 45 51 46 private: 52 Ref<WebGPUCommandEncoder> m_commandBuffer; 47 WebGPUComputePassEncoder(RefPtr<GPUComputePassEncoder>&&); 48 49 GPUProgrammablePassEncoder* passEncoder() final; 50 const GPUProgrammablePassEncoder* passEncoder() const final; 51 52 RefPtr<GPUComputePassEncoder> m_passEncoder; 53 53 }; 54 54 -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePassEncoder.idl
r243418 r243419 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 … … 23 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 // https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl 25 26 26 #pragma once 27 typedef unsigned long u32; 27 28 28 #if ENABLE(WEBGPU) 29 [ 30 Conditional=WEBGPU, 31 EnabledAtRuntime=WebGPU, 32 InterfaceName=GPUComputePassEncoder, 33 JSGenerateToJSObject 34 ] interface WebGPUComputePassEncoder : WebGPUProgrammablePassEncoder { 35 void setPipeline(WebGPUComputePipeline pipeline); 36 void dispatch(u32 x, u32 y, u32 z); 29 37 30 #include "GPUPipelineLayout.h" 31 #include "GPUPipelineStageDescriptor.h" 32 33 #include <wtf/Vector.h> 34 35 namespace WebCore { 36 37 struct GPUPipelineDescriptorBase { 38 RefPtr<GPUPipelineLayout> layout; 38 // TODO add missing commands 39 39 }; 40 41 } // namespace WebCore42 43 #endif // ENABLE(WEBGPU) -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp
r243418 r243419 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 26 26 #include "config.h" 27 #include "WebGPU RenderPipeline.h"27 #include "WebGPUComputePipeline.h" 28 28 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPURenderPipeline.h"32 33 31 namespace WebCore { 34 32 35 Ref<WebGPU RenderPipeline> WebGPURenderPipeline::create(RefPtr<GPURenderPipeline>&& pipeline)33 Ref<WebGPUComputePipeline> WebGPUComputePipeline::create(RefPtr<GPUComputePipeline>&& pipeline) 36 34 { 37 return adoptRef(*new WebGPU RenderPipeline(WTFMove(pipeline)));35 return adoptRef(*new WebGPUComputePipeline(WTFMove(pipeline))); 38 36 } 39 37 40 WebGPU RenderPipeline::WebGPURenderPipeline(RefPtr<GPURenderPipeline>&& pipeline)41 : m_ renderPipeline(WTFMove(pipeline))38 WebGPUComputePipeline::WebGPUComputePipeline(RefPtr<GPUComputePipeline>&& pipeline) 39 : m_computePipeline { WTFMove(pipeline) } 42 40 { 43 41 } -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h
r243418 r243419 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPURenderPipeline.h" 31 30 #include "GPUComputePipeline.h" 32 31 #include <wtf/RefCounted.h> 33 32 #include <wtf/RefPtr.h> … … 35 34 namespace WebCore { 36 35 37 class WebGPU RenderPipeline : public RefCounted<WebGPURenderPipeline> {36 class WebGPUComputePipeline : public RefCounted<WebGPUComputePipeline> { 38 37 public: 39 static Ref<WebGPU RenderPipeline> create(RefPtr<GPURenderPipeline>&&);38 static Ref<WebGPUComputePipeline> create(RefPtr<GPUComputePipeline>&&); 40 39 41 const GPU RenderPipeline* renderPipeline() const { return m_renderPipeline.get(); }40 const GPUComputePipeline* computePipeline() const { return m_computePipeline.get(); } 42 41 43 42 private: 44 WebGPU RenderPipeline(RefPtr<GPURenderPipeline>&&);43 WebGPUComputePipeline(RefPtr<GPUComputePipeline>&&); 45 44 46 RefPtr<GPU RenderPipeline> m_renderPipeline;45 RefPtr<GPUComputePipeline> m_computePipeline; 47 46 }; 48 47 -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.idl
r243418 r243419 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 … … 23 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 // https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl 25 26 26 #pragma once 27 28 #if ENABLE(WEBGPU) 29 30 #include "GPUPipelineLayout.h" 31 #include "GPUPipelineStageDescriptor.h" 32 33 #include <wtf/Vector.h> 34 35 namespace WebCore { 36 37 struct GPUPipelineDescriptorBase { 38 RefPtr<GPUPipelineLayout> layout; 27 [ 28 Conditional=WEBGPU, 29 EnabledAtRuntime=WebGPU, 30 ImplementationLacksVTable, 31 InterfaceName=GPUComputePipeline 32 ] interface WebGPUComputePipeline { 39 33 }; 40 41 } // namespace WebCore42 43 #endif // ENABLE(WEBGPU) -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.cpp
r243418 r243419 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 26 26 #include "config.h" 27 #include "WebGPU RenderPipeline.h"27 #include "WebGPUComputePipelineDescriptor.h" 28 28 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPURenderPipeline.h" 31 #include "GPUComputePipelineDescriptor.h" 32 #include "Logging.h" 32 33 33 34 namespace WebCore { 34 35 35 Ref<WebGPURenderPipeline> WebGPURenderPipeline::create(RefPtr<GPURenderPipeline>&& pipeline) 36 Optional<GPUComputePipelineDescriptor> WebGPUComputePipelineDescriptor::tryCreateGPUComputePipelineDescriptor() const 36 37 { 37 return adoptRef(*new WebGPURenderPipeline(WTFMove(pipeline))); 38 } 38 auto pipelineLayout = layout ? makeRefPtr(layout->pipelineLayout()) : nullptr; 39 39 40 WebGPURenderPipeline::WebGPURenderPipeline(RefPtr<GPURenderPipeline>&& pipeline) 41 : m_renderPipeline(WTFMove(pipeline)) 42 { 40 auto compute = computeStage.tryCreateGPUPipelineStageDescriptor(); 41 if (!compute) { 42 LOG(WebGPU, "GPUDevice::createComputePipeline(): Invalid GPUPipelineStageDescriptor!"); 43 return WTF::nullopt; 44 } 45 46 return GPUComputePipelineDescriptor { WTFMove(pipelineLayout), WTFMove(*compute) }; 43 47 } 44 48 -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.h
r243418 r243419 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUPipelineLayout.h" 31 #include "GPUPipelineStageDescriptor.h" 32 33 #include <wtf/Vector.h> 30 #include "WebGPUPipelineDescriptorBase.h" 31 #include "WebGPUPipelineStageDescriptor.h" 32 #include <wtf/Optional.h> 34 33 35 34 namespace WebCore { 36 35 37 struct GPUPipelineDescriptorBase { 38 RefPtr<GPUPipelineLayout> layout; 36 struct GPUComputePipelineDescriptor; 37 38 struct WebGPUComputePipelineDescriptor : WebGPUPipelineDescriptorBase { 39 Optional<GPUComputePipelineDescriptor> tryCreateGPUComputePipelineDescriptor() const; 40 41 WebGPUPipelineStageDescriptor computeStage; 39 42 }; 40 43 -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipelineDescriptor.idl
r243418 r243419 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 … … 23 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 24 */ 25 // https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl 25 26 26 #pragma once 27 28 #if ENABLE(WEBGPU) 29 30 #include "GPUPipelineLayout.h" 31 #include "GPUPipelineStageDescriptor.h" 32 33 #include <wtf/Vector.h> 34 35 namespace WebCore { 36 37 struct GPUPipelineDescriptorBase { 38 RefPtr<GPUPipelineLayout> layout; 27 [ 28 Conditional=WEBGPU, 29 EnabledAtRuntime=WebGPU 30 ] dictionary WebGPUComputePipelineDescriptor : WebGPUPipelineDescriptorBase { 31 required WebGPUPipelineStageDescriptor computeStage; 39 32 }; 40 41 } // namespace WebCore42 43 #endif // ENABLE(WEBGPU) -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
r243091 r243419 50 50 #include "WebGPUBufferBinding.h" 51 51 #include "WebGPUCommandEncoder.h" 52 #include "WebGPUComputePipeline.h" 53 #include "WebGPUComputePipelineDescriptor.h" 52 54 #include "WebGPUPipelineLayout.h" 53 55 #include "WebGPUPipelineLayoutDescriptor.h" … … 138 140 } 139 141 142 Ref<WebGPUComputePipeline> WebGPUDevice::createComputePipeline(const WebGPUComputePipelineDescriptor& descriptor) const 143 { 144 auto gpuDescriptor = descriptor.tryCreateGPUComputePipelineDescriptor(); 145 if (!gpuDescriptor) 146 return WebGPUComputePipeline::create(nullptr); 147 148 auto pipeline = m_device->tryCreateComputePipeline(*gpuDescriptor); 149 return WebGPUComputePipeline::create(WTFMove(pipeline)); 150 } 151 140 152 Ref<WebGPUCommandEncoder> WebGPUDevice::createCommandEncoder() const 141 153 { -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h
r243090 r243419 43 43 class WebGPUBuffer; 44 44 class WebGPUCommandEncoder; 45 class WebGPUComputePipeline; 45 46 class WebGPUPipelineLayout; 46 47 class WebGPURenderPipeline; … … 55 56 struct GPUTextureDescriptor; 56 57 struct WebGPUBindGroupDescriptor; 58 struct WebGPUComputePipelineDescriptor; 57 59 struct WebGPUPipelineLayoutDescriptor; 58 60 struct WebGPURenderPipelineDescriptor; … … 76 78 RefPtr<WebGPUShaderModule> createShaderModule(WebGPUShaderModuleDescriptor&&) const; 77 79 Ref<WebGPURenderPipeline> createRenderPipeline(const WebGPURenderPipelineDescriptor&) const; 80 Ref<WebGPUComputePipeline> createComputePipeline(const WebGPUComputePipelineDescriptor&) const; 78 81 79 82 Ref<WebGPUCommandEncoder> createCommandEncoder() const; -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl
r242974 r243419 54 54 WebGPUShaderModule createShaderModule(WebGPUShaderModuleDescriptor descriptor); 55 55 WebGPURenderPipeline createRenderPipeline(WebGPURenderPipelineDescriptor descriptor); 56 WebGPUComputePipeline createComputePipeline(WebGPUComputePipelineDescriptor descriptor); 56 57 57 58 // FIXME: Currently, GPUCommandEncoderDescriptor is an empty dictionary. … … 66 67 // readonly attribute WebGPULimits limits; 67 68 68 // WebGPUComputePipeline createComputePipeline(WebGPUComputePipelineDescriptor descriptor);69 69 // WebGPUFence createFence(WebGPUFenceDescriptor descriptor); 70 70 -
trunk/Source/WebCore/Modules/webgpu/WebGPUPipelineStageDescriptor.cpp
r243418 r243419 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 26 26 #include "config.h" 27 #include "WebGPU RenderPipeline.h"27 #include "WebGPUPipelineStageDescriptor.h" 28 28 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPURenderPipeline.h"32 33 31 namespace WebCore { 34 32 35 Ref<WebGPURenderPipeline> WebGPURenderPipeline::create(RefPtr<GPURenderPipeline>&& pipeline) 33 Optional<GPUPipelineStageDescriptor> WebGPUPipelineStageDescriptor::tryCreateGPUPipelineStageDescriptor() const 36 34 { 37 return adoptRef(*new WebGPURenderPipeline(WTFMove(pipeline)));38 } 35 if (!module || !module->module() || entryPoint.isEmpty()) 36 return WTF::nullopt; 39 37 40 WebGPURenderPipeline::WebGPURenderPipeline(RefPtr<GPURenderPipeline>&& pipeline) 41 : m_renderPipeline(WTFMove(pipeline)) 42 { 38 return GPUPipelineStageDescriptor { makeRef(*module->module()), *this }; 43 39 } 44 40 -
trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.cpp
r243089 r243419 32 32 #include "Logging.h" 33 33 #include "WebGPUBindGroup.h" 34 #include "WebGPURenderPipeline.h"35 34 36 35 namespace WebCore { 37 38 WebGPUProgrammablePassEncoder::WebGPUProgrammablePassEncoder(Ref<WebGPUCommandEncoder>&& creator)39 : m_commandBuffer(WTFMove(creator))40 {41 }42 36 43 37 void WebGPUProgrammablePassEncoder::endPass() … … 50 44 } 51 45 52 void WebGPUProgrammablePassEncoder::setBindGroup(unsigned index, WebGPUBindGroup& bindGroup) const46 void WebGPUProgrammablePassEncoder::setBindGroup(unsigned index, WebGPUBindGroup& bindGroup) 53 47 { 54 48 if (!passEncoder()) { -
trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammablePassEncoder.h
r243089 r243419 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WebGPUCommandEncoder.h"31 30 #include <wtf/RefCounted.h> 32 31 … … 35 34 class GPUProgrammablePassEncoder; 36 35 class WebGPUBindGroup; 37 class WebGPURenderPipeline;38 36 39 37 class WebGPUProgrammablePassEncoder : public RefCounted<WebGPUProgrammablePassEncoder> { … … 42 40 43 41 void endPass(); 44 void setBindGroup(unsigned, WebGPUBindGroup&) const;42 void setBindGroup(unsigned, WebGPUBindGroup&); 45 43 46 44 protected: 47 WebGPUProgrammablePassEncoder( Ref<WebGPUCommandEncoder>&&);45 WebGPUProgrammablePassEncoder() = default; 48 46 49 virtual GPUProgrammablePassEncoder* passEncoder() const = 0; 50 51 private: 52 Ref<WebGPUCommandEncoder> m_commandBuffer; 47 virtual GPUProgrammablePassEncoder* passEncoder() = 0; 48 virtual const GPUProgrammablePassEncoder* passEncoder() const = 0; 53 49 }; 54 50 -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.cpp
r243089 r243419 34 34 #include "Logging.h" 35 35 #include "WebGPUBuffer.h" 36 #include "WebGPURenderPipeline.h" 36 37 37 38 namespace WebCore { 38 39 39 Ref<WebGPURenderPassEncoder> WebGPURenderPassEncoder::create(Ref <WebGPUCommandEncoder>&& commandBuffer, RefPtr<GPURenderPassEncoder>&& encoder)40 Ref<WebGPURenderPassEncoder> WebGPURenderPassEncoder::create(RefPtr<GPURenderPassEncoder>&& encoder) 40 41 { 41 return adoptRef(*new WebGPURenderPassEncoder(WTFMove( commandBuffer), WTFMove(encoder)));42 return adoptRef(*new WebGPURenderPassEncoder(WTFMove(encoder))); 42 43 } 43 44 44 WebGPURenderPassEncoder::WebGPURenderPassEncoder(Ref<WebGPUCommandEncoder>&& creator, RefPtr<GPURenderPassEncoder>&& encoder) 45 : WebGPUProgrammablePassEncoder(WTFMove(creator)) 46 , m_passEncoder(WTFMove(encoder)) 45 WebGPURenderPassEncoder::WebGPURenderPassEncoder(RefPtr<GPURenderPassEncoder>&& encoder) 46 : m_passEncoder { WTFMove(encoder) } 47 47 { 48 48 } … … 51 51 { 52 52 if (!m_passEncoder) { 53 LOG(WebGPU, "GPU ProgrammablePassEncoder::setPipeline(): Invalid operation!");53 LOG(WebGPU, "GPURenderPassEncoder::setPipeline(): Invalid operation!"); 54 54 return; 55 55 } 56 56 if (!pipeline.renderPipeline()) { 57 LOG(WebGPU, "GPU ProgrammablePassEncoder::setPipeline(): Invalid pipeline!");57 LOG(WebGPU, "GPURenderPassEncoder::setPipeline(): Invalid pipeline!"); 58 58 return; 59 59 } … … 109 109 } 110 110 111 GPUProgrammablePassEncoder* WebGPURenderPassEncoder::passEncoder() const 111 GPUProgrammablePassEncoder* WebGPURenderPassEncoder::passEncoder() 112 { 113 return m_passEncoder.get(); 114 } 115 116 const GPUProgrammablePassEncoder* WebGPURenderPassEncoder::passEncoder() const 112 117 { 113 118 return m_passEncoder.get(); -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPassEncoder.h
r243089 r243419 29 29 30 30 #include "WebGPUProgrammablePassEncoder.h" 31 32 31 #include <wtf/RefPtr.h> 33 32 #include <wtf/Vector.h> … … 38 37 class GPURenderPassEncoder; 39 38 class WebGPUBuffer; 39 class WebGPURenderPipeline; 40 40 41 41 class WebGPURenderPassEncoder final : public WebGPUProgrammablePassEncoder { 42 42 public: 43 static Ref<WebGPURenderPassEncoder> create(Ref <WebGPUCommandEncoder>&&, RefPtr<GPURenderPassEncoder>&&);43 static Ref<WebGPURenderPassEncoder> create(RefPtr<GPURenderPassEncoder>&&); 44 44 45 45 void setPipeline(const WebGPURenderPipeline&); … … 48 48 49 49 private: 50 WebGPURenderPassEncoder(Ref <WebGPUCommandEncoder>&&, RefPtr<GPURenderPassEncoder>&&);50 WebGPURenderPassEncoder(RefPtr<GPURenderPassEncoder>&&); 51 51 52 GPUProgrammablePassEncoder* passEncoder() const final; 52 GPUProgrammablePassEncoder* passEncoder() final; 53 const GPUProgrammablePassEncoder* passEncoder() const final; 53 54 54 55 RefPtr<GPURenderPassEncoder> m_passEncoder; -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp
r242839 r243419 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPURenderPipeline.h"32 33 31 namespace WebCore { 34 32 -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h
r242839 r243419 29 29 30 30 #include "GPURenderPipeline.h" 31 32 31 #include <wtf/RefCounted.h> 33 32 #include <wtf/RefPtr.h> -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipelineDescriptor.cpp
r242839 r243419 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "Logging.h" 32 31 33 namespace WebCore { 32 33 Optional<GPUPipelineStageDescriptor> WebGPUPipelineStageDescriptor::tryCreateGPUPipelineStageDescriptor() const34 {35 if (!module || !module->module() || entryPoint.isEmpty())36 return WTF::nullopt;37 38 return GPUPipelineStageDescriptor { makeRef(*module->module()), *this };39 }40 34 41 35 Optional<GPURenderPipelineDescriptor> WebGPURenderPipelineDescriptor::tryCreateGPURenderPipelineDescriptor() const -
trunk/Source/WebCore/Sources.txt
r243362 r243419 351 351 Modules/webgpu/WHLSL/WHLSLPrepare.cpp 352 352 Modules/webgpu/WebGPU.cpp 353 Modules/webgpu/WebGPUAdapter.cpp 353 354 Modules/webgpu/WebGPUBindGroup.cpp 354 355 Modules/webgpu/WebGPUBindGroupDescriptor.cpp 356 Modules/webgpu/WebGPUBindGroupLayout.cpp 357 Modules/webgpu/WebGPUBuffer.cpp 355 358 Modules/webgpu/WebGPUCommandBuffer.cpp 356 359 Modules/webgpu/WebGPUCommandEncoder.cpp 357 Modules/webgpu/WebGPU Adapter.cpp358 Modules/webgpu/WebGPU BindGroupLayout.cpp359 Modules/webgpu/WebGPU Buffer.cpp360 Modules/webgpu/WebGPUComputePassEncoder.cpp 361 Modules/webgpu/WebGPUComputePipeline.cpp 362 Modules/webgpu/WebGPUComputePipelineDescriptor.cpp 360 363 Modules/webgpu/WebGPUDevice.cpp 361 364 Modules/webgpu/WebGPUQueue.cpp 362 365 Modules/webgpu/WebGPUPipelineLayout.cpp 366 Modules/webgpu/WebGPUPipelineStageDescriptor.cpp 363 367 Modules/webgpu/WebGPUProgrammablePassEncoder.cpp 364 368 Modules/webgpu/WebGPURenderPassDescriptor.cpp … … 3336 3340 JSWebGPUCommandBuffer.cpp 3337 3341 JSWebGPUCommandEncoder.cpp 3342 JSWebGPUComputePassEncoder.cpp 3343 JSWebGPUComputePipeline.cpp 3344 JSWebGPUComputePipelineDescriptor.cpp 3338 3345 JSWebGPUDevice.cpp 3339 3346 JSWebGPUQueue.cpp -
trunk/Source/WebCore/SourcesCocoa.txt
r243109 r243419 323 323 platform/graphics/gpu/cocoa/GPUBufferMetal.mm 324 324 platform/graphics/gpu/cocoa/GPUCommandBufferMetal.mm 325 platform/graphics/gpu/cocoa/GPUComputePassEncoderMetal.mm 326 platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm 325 327 platform/graphics/gpu/cocoa/GPUDeviceMetal.mm 326 328 platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r243362 r243419 14006 14006 D003288721C9A4E500622AA6 /* GPUPipelineLayout.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUPipelineLayout.cpp; sourceTree = "<group>"; }; 14007 14007 D003914122248D400098998C /* GPUProgrammablePassEncoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GPUProgrammablePassEncoder.cpp; sourceTree = "<group>"; }; 14008 D00D77FD2242ED450043F12C /* WebGPUComputePassEncoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUComputePassEncoder.h; sourceTree = "<group>"; }; 14009 D00D77FE2242ED450043F12C /* WebGPUComputePassEncoder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUComputePassEncoder.cpp; sourceTree = "<group>"; }; 14010 D00D77FF2242ED450043F12C /* WebGPUComputePassEncoder.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUComputePassEncoder.idl; sourceTree = "<group>"; }; 14008 14011 D00F5940216ECC7A000D71DB /* DOMWindowWebGPU.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMWindowWebGPU.h; sourceTree = "<group>"; }; 14009 14012 D00F5941216ECC7A000D71DB /* DOMWindowWebGPU.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowWebGPU.cpp; sourceTree = "<group>"; }; … … 14145 14148 D087CE3F21ACA94200BDE174 /* GPUTextureMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUTextureMetal.mm; sourceTree = "<group>"; }; 14146 14149 D087CE4021ACA94200BDE174 /* GPUShaderModuleMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUShaderModuleMetal.mm; sourceTree = "<group>"; }; 14150 D08903342240601D00F3F440 /* WebGPUComputePipelineDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUComputePipelineDescriptor.h; sourceTree = "<group>"; }; 14151 D08903352240601D00F3F440 /* WebGPUComputePipelineDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUComputePipelineDescriptor.idl; sourceTree = "<group>"; }; 14152 D0890337224061AC00F3F440 /* WebGPUPipelineStageDescriptor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUPipelineStageDescriptor.cpp; sourceTree = "<group>"; }; 14153 D08903382240628900F3F440 /* WebGPUComputePipelineDescriptor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUComputePipelineDescriptor.cpp; sourceTree = "<group>"; }; 14154 D08903392240642D00F3F440 /* GPUComputePipelineDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUComputePipelineDescriptor.h; sourceTree = "<group>"; }; 14155 D089033A224179B500F3F440 /* GPUComputePipeline.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUComputePipeline.h; sourceTree = "<group>"; }; 14156 D089033B224179B500F3F440 /* GPUComputePipelineMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUComputePipelineMetal.mm; sourceTree = "<group>"; }; 14157 D089033C2241A99F00F3F440 /* WebGPUComputePipeline.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUComputePipeline.h; sourceTree = "<group>"; }; 14158 D089033D2241A99F00F3F440 /* WebGPUComputePipeline.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUComputePipeline.cpp; sourceTree = "<group>"; }; 14159 D089033E2241A99F00F3F440 /* WebGPUComputePipeline.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUComputePipeline.idl; sourceTree = "<group>"; }; 14160 D089033F2241CE4600F3F440 /* GPUComputePassEncoder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUComputePassEncoder.h; sourceTree = "<group>"; }; 14161 D08903402241CE4600F3F440 /* GPUComputePassEncoderMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUComputePassEncoderMetal.mm; sourceTree = "<group>"; }; 14147 14162 D08AA02D220D0B9C0058C502 /* GPULoadOp.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPULoadOp.idl; sourceTree = "<group>"; }; 14148 14163 D08AA02F220D0BD50058C502 /* GPULoadOp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPULoadOp.h; sourceTree = "<group>"; }; … … 18590 18605 312FF8BD21A4C2F100EB199D /* GPUCommandBuffer.h */, 18591 18606 D03C849C21FFC7FC0002227F /* GPUCompareFunction.h */, 18607 D089033F2241CE4600F3F440 /* GPUComputePassEncoder.h */, 18608 D089033A224179B500F3F440 /* GPUComputePipeline.h */, 18609 D08903392240642D00F3F440 /* GPUComputePipelineDescriptor.h */, 18592 18610 D03C849A21FFC6670002227F /* GPUDepthStencilStateDescriptor.h */, 18593 18611 312FF8BF21A4C2F100EB199D /* GPUDevice.cpp */, … … 26241 26259 D0EACF7621937228000FA75C /* WebGPUCommandEncoder.h */, 26242 26260 D0EACF7821937228000FA75C /* WebGPUCommandEncoder.idl */, 26261 D00D77FE2242ED450043F12C /* WebGPUComputePassEncoder.cpp */, 26262 D00D77FD2242ED450043F12C /* WebGPUComputePassEncoder.h */, 26263 D00D77FF2242ED450043F12C /* WebGPUComputePassEncoder.idl */, 26264 D089033D2241A99F00F3F440 /* WebGPUComputePipeline.cpp */, 26265 D089033C2241A99F00F3F440 /* WebGPUComputePipeline.h */, 26266 D089033E2241A99F00F3F440 /* WebGPUComputePipeline.idl */, 26267 D08903382240628900F3F440 /* WebGPUComputePipelineDescriptor.cpp */, 26268 D08903342240601D00F3F440 /* WebGPUComputePipelineDescriptor.h */, 26269 D08903352240601D00F3F440 /* WebGPUComputePipelineDescriptor.idl */, 26243 26270 D00F595321701D8C000D71DB /* WebGPUDevice.cpp */, 26244 26271 D00F595221701D8C000D71DB /* WebGPUDevice.h */, … … 26252 26279 D05A99E121C9B50F00032B75 /* WebGPUPipelineLayoutDescriptor.h */, 26253 26280 D05A99E221C9B50F00032B75 /* WebGPUPipelineLayoutDescriptor.idl */, 26281 D0890337224061AC00F3F440 /* WebGPUPipelineStageDescriptor.cpp */, 26254 26282 D0C419EB2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.h */, 26255 26283 D0C419EC2183CFA2009EC1DE /* WebGPUPipelineStageDescriptor.idl */, … … 26301 26329 D0D8649121B760C4003C983C /* GPUBufferMetal.mm */, 26302 26330 D087CE3821ACA94200BDE174 /* GPUCommandBufferMetal.mm */, 26331 D08903402241CE4600F3F440 /* GPUComputePassEncoderMetal.mm */, 26332 D089033B224179B500F3F440 /* GPUComputePipelineMetal.mm */, 26303 26333 D087CE3C21ACA94200BDE174 /* GPUDeviceMetal.mm */, 26304 26334 D087CE3B21ACA94200BDE174 /* GPUProgrammablePassEncoderMetal.mm */, -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r242974 r243419 87 87 macro(GPUCommandBuffer) \ 88 88 macro(GPUCommandEncoder) \ 89 macro(GPUComputePassEncoder) \ 90 macro(GPUComputePipeline) \ 89 91 macro(GPUShaderStageBit) \ 90 92 macro(GPUSwapChain) \ -
trunk/Source/WebCore/platform/cocoa/VideoFullscreenModel.h
r243298 r243419 35 35 #include "PlaybackSessionModel.h" 36 36 #include <wtf/CompletionHandler.h> 37 #include <wtf/WeakPtr.h> 37 38 38 39 #if PLATFORM(IOS_FAMILY) -
trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroup.h
r243006 r243419 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUBuffer.h" 31 #include "GPUTexture.h" 30 32 #include <wtf/RefCounted.h> 31 33 #include <wtf/RefPtr.h> 32 34 #include <wtf/RetainPtr.h> 33 35 #include <wtf/Vector.h> 34 #include "GPUBuffer.h"35 #include "GPUTexture.h"36 36 37 37 OBJC_PROTOCOL(MTLBuffer); … … 46 46 47 47 #if USE(METAL) 48 MTLBuffer *vertexArgsBuffer() { return m_vertexArgsBuffer.get(); } 49 MTLBuffer *fragmentArgsBuffer() { return m_fragmentArgsBuffer.get(); } 48 const MTLBuffer *vertexArgsBuffer() const { return m_vertexArgsBuffer.get(); } 49 const MTLBuffer *fragmentArgsBuffer() const { return m_fragmentArgsBuffer.get(); } 50 const MTLBuffer *computeArgsBuffer() const { return m_computeArgsBuffer.get(); } 50 51 #endif 51 52 const Vector<Ref<GPUBuffer>>& boundBuffers() const { return m_boundBuffers; } … … 54 55 private: 55 56 #if USE(METAL) 56 GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, Vector<Ref<GPUBuffer>>&&, Vector<Ref<GPUTexture>>&&);57 GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, RetainPtr<MTLBuffer>&& computeArgsBuffer, Vector<Ref<GPUBuffer>>&&, Vector<Ref<GPUTexture>>&&); 57 58 58 59 RetainPtr<MTLBuffer> m_vertexArgsBuffer; 59 60 RetainPtr<MTLBuffer> m_fragmentArgsBuffer; 61 RetainPtr<MTLBuffer> m_computeArgsBuffer; 60 62 #endif 61 63 Vector<Ref<GPUBuffer>> m_boundBuffers; -
trunk/Source/WebCore/platform/graphics/gpu/GPUComputePassEncoder.h
r243418 r243419 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUComputePipeline.h" 31 #include "GPUProgrammablePassEncoder.h" 30 32 #include <wtf/RefCounted.h> 31 33 #include <wtf/RefPtr.h> 32 34 #include <wtf/RetainPtr.h> 33 #include <wtf/Vector.h>34 #include "GPUBuffer.h"35 #include "GPUTexture.h"36 35 37 OBJC_PROTOCOL(MTL Buffer);36 OBJC_PROTOCOL(MTLComputeCommandEncoder); 38 37 39 38 namespace WebCore { 40 39 41 struct GPUBindGroupDescriptor; 40 using PlatformComputePassEncoder = MTLComputeCommandEncoder; 41 using PlatformComputePassEncoderSmartPtr = RetainPtr<MTLComputeCommandEncoder>; 42 42 43 class GPU BindGroup : public RefCounted<GPUBindGroup>{43 class GPUComputePassEncoder : public GPUProgrammablePassEncoder { 44 44 public: 45 static RefPtr<GPUBindGroup> tryCreate(const GPUBindGroupDescriptor&); 46 47 #if USE(METAL) 48 MTLBuffer *vertexArgsBuffer() { return m_vertexArgsBuffer.get(); } 49 MTLBuffer *fragmentArgsBuffer() { return m_fragmentArgsBuffer.get(); } 50 #endif 51 const Vector<Ref<GPUBuffer>>& boundBuffers() const { return m_boundBuffers; } 52 const Vector<Ref<GPUTexture>>& boundTextures() const { return m_boundTextures; } 45 static RefPtr<GPUComputePassEncoder> tryCreate(Ref<GPUCommandBuffer>&&); 46 47 void setPipeline(Ref<const GPUComputePipeline>&&); 48 void dispatch(unsigned x, unsigned y, unsigned z); 53 49 54 50 private: 51 GPUComputePassEncoder(Ref<GPUCommandBuffer>&&, PlatformComputePassEncoderSmartPtr&&); 52 ~GPUComputePassEncoder() { endPass(); } 53 54 // GPUProgrammablePassEncoder 55 const PlatformProgrammablePassEncoder* platformPassEncoder() const final; 56 void invalidateEncoder() final { m_platformComputePassEncoder = nullptr; } 55 57 #if USE(METAL) 56 GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, Vector<Ref<GPUBuffer>>&&, Vector<Ref<GPUTexture>>&&); 57 58 RetainPtr<MTLBuffer> m_vertexArgsBuffer; 59 RetainPtr<MTLBuffer> m_fragmentArgsBuffer; 58 void useResource(const MTLResource *, unsigned usage) final; 59 void setComputeBuffer(const MTLBuffer *, unsigned offset, unsigned index) final; 60 60 #endif 61 Vector<Ref<GPUBuffer>> m_boundBuffers; 62 Vector<Ref<GPUTexture>> m_boundTextures; 61 62 PlatformComputePassEncoderSmartPtr m_platformComputePassEncoder; 63 RefPtr<const GPUComputePipeline> m_pipeline; 63 64 }; 64 65 -
trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h
r243418 r243419 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPURenderPipeline.h"31 32 30 #include <wtf/RefCounted.h> 33 31 #include <wtf/RefPtr.h> 32 #include <wtf/RetainPtr.h> 33 34 OBJC_PROTOCOL(MTLComputePipelineState); 34 35 35 36 namespace WebCore { 36 37 37 class WebGPURenderPipeline : public RefCounted<WebGPURenderPipeline> { 38 class GPUDevice; 39 40 struct GPUComputePipelineDescriptor; 41 42 using PlatformComputePipeline = MTLComputePipelineState; 43 using PlatformComputePipelineSmartPtr = RetainPtr<MTLComputePipelineState>; 44 45 class GPUComputePipeline : public RefCounted<GPUComputePipeline> { 38 46 public: 39 static Ref <WebGPURenderPipeline> create(RefPtr<GPURenderPipeline>&&);47 static RefPtr<GPUComputePipeline> tryCreate(const GPUDevice&, const GPUComputePipelineDescriptor&); 40 48 41 const GPURenderPipeline* renderPipeline() const { return m_renderPipeline.get(); }49 const PlatformComputePipeline* platformComputePipeline() const { return m_platformComputePipeline.get(); } 42 50 43 51 private: 44 WebGPURenderPipeline(RefPtr<GPURenderPipeline>&&);52 GPUComputePipeline(PlatformComputePipelineSmartPtr&&); 45 53 46 RefPtr<GPURenderPipeline> m_renderPipeline;54 PlatformComputePipelineSmartPtr m_platformComputePipeline; 47 55 }; 48 56 -
trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipelineDescriptor.h
r243418 r243419 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUPipeline Layout.h"30 #include "GPUPipelineDescriptorBase.h" 31 31 #include "GPUPipelineStageDescriptor.h" 32 33 #include <wtf/Vector.h>34 32 35 33 namespace WebCore { 36 34 37 struct GPUPipelineDescriptorBase { 38 RefPtr<GPUPipelineLayout> layout; 35 struct GPUComputePipelineDescriptor : GPUPipelineDescriptorBase { 36 GPUComputePipelineDescriptor(RefPtr<GPUPipelineLayout>&& layout, GPUPipelineStageDescriptor&& compute) 37 : GPUPipelineDescriptorBase { WTFMove(layout) } 38 , computeStage { WTFMove(compute) } 39 { 40 } 41 42 GPUPipelineStageDescriptor computeStage; 39 43 }; 40 44 -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp
r242974 r243419 34 34 #include "GPUBufferDescriptor.h" 35 35 #include "GPUCommandBuffer.h" 36 #include "GPUComputePipeline.h" 37 #include "GPUComputePipelineDescriptor.h" 36 38 #include "GPUPipelineLayout.h" 37 39 #include "GPUPipelineLayoutDescriptor.h" … … 43 45 #include "GPUShaderModuleDescriptor.h" 44 46 #include "GPUSwapChain.h" 47 #include "GPUSwapChainDescriptor.h" 45 48 #include "GPUTexture.h" 46 49 #include "GPUTextureDescriptor.h" … … 84 87 } 85 88 89 RefPtr<GPUComputePipeline> GPUDevice::tryCreateComputePipeline(const GPUComputePipelineDescriptor& descriptor) const 90 { 91 return GPUComputePipeline::tryCreate(*this, descriptor); 92 } 93 86 94 RefPtr<GPUCommandBuffer> GPUDevice::tryCreateCommandBuffer() const 87 95 { -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h
r243090 r243419 29 29 30 30 #include "GPUQueue.h" 31 #include "GPUSwapChainDescriptor.h"32 31 #include <wtf/RefCounted.h> 33 32 #include <wtf/RetainPtr.h> … … 41 40 class GPUBuffer; 42 41 class GPUCommandBuffer; 42 class GPUComputePipeline; 43 43 class GPUPipelineLayout; 44 44 class GPURenderPipeline; … … 50 50 struct GPUBindGroupLayoutDescriptor; 51 51 struct GPUBufferDescriptor; 52 struct GPUComputePipelineDescriptor; 52 53 struct GPUPipelineLayoutDescriptor; 53 54 struct GPURenderPipelineDescriptor; … … 55 56 struct GPUSamplerDescriptor; 56 57 struct GPUShaderModuleDescriptor; 58 struct GPUSwapChainDescriptor; 57 59 struct GPUTextureDescriptor; 58 60 … … 73 75 RefPtr<GPUShaderModule> createShaderModule(GPUShaderModuleDescriptor&&) const; 74 76 RefPtr<GPURenderPipeline> createRenderPipeline(GPURenderPipelineDescriptor&&) const; 77 RefPtr<GPUComputePipeline> tryCreateComputePipeline(const GPUComputePipelineDescriptor&) const; 75 78 76 79 RefPtr<GPUCommandBuffer> tryCreateCommandBuffer() const; -
trunk/Source/WebCore/platform/graphics/gpu/GPUPipelineDescriptorBase.h
r239744 r243419 30 30 #include "GPUPipelineLayout.h" 31 31 #include "GPUPipelineStageDescriptor.h" 32 32 #include <wtf/RefPtr.h> 33 33 #include <wtf/Vector.h> 34 34 -
trunk/Source/WebCore/platform/graphics/gpu/GPUProgrammablePassEncoder.h
r243089 r243419 29 29 30 30 #include "GPUBindGroupBinding.h" 31 #include "GPUCommandBuffer.h" 31 32 #include <wtf/RefCounted.h> 32 33 … … 40 41 41 42 class GPUBindGroup; 42 class GPUCommandBuffer;43 43 class GPURenderPipeline; 44 44 … … 49 49 virtual ~GPUProgrammablePassEncoder() = default; 50 50 51 v irtual void endPass();51 void endPass(); 52 52 void setBindGroup(unsigned, GPUBindGroup&); 53 53 … … 56 56 57 57 GPUCommandBuffer& commandBuffer() const { return m_commandBuffer.get(); } 58 virtual PlatformProgrammablePassEncoder* platformPassEncoder() const = 0;58 virtual const PlatformProgrammablePassEncoder* platformPassEncoder() const = 0; 59 59 60 60 private: 61 virtual void invalidateEncoder() = 0; 61 62 #if USE(METAL) 62 virtual void useResource( MTLResource *, unsigned) = 0;63 virtual void useResource(const MTLResource *, unsigned) = 0; 63 64 64 65 // Render command encoder methods. 65 virtual void setVertexBuffer(MTLBuffer *, unsigned, unsigned) { } 66 virtual void setFragmentBuffer(MTLBuffer *, unsigned, unsigned) { } 66 virtual void setVertexBuffer(const MTLBuffer *, unsigned, unsigned) { } 67 virtual void setFragmentBuffer(const MTLBuffer *, unsigned, unsigned) { } 68 // Compute. 69 virtual void setComputeBuffer(const MTLBuffer *, unsigned, unsigned) { } 67 70 #endif // USE(METAL) 68 71 -
trunk/Source/WebCore/platform/graphics/gpu/GPURenderPassEncoder.h
r243089 r243419 52 52 static RefPtr<GPURenderPassEncoder> tryCreate(Ref<GPUCommandBuffer>&&, GPURenderPassDescriptor&&); 53 53 54 void endPass() final;55 54 void setPipeline(Ref<const GPURenderPipeline>&&); 56 57 55 void setVertexBuffers(unsigned long, Vector<Ref<GPUBuffer>>&&, Vector<unsigned long long>&&); 58 56 void draw(unsigned long vertexCount, unsigned long instanceCount, unsigned long firstVertex, unsigned long firstInstance); … … 60 58 private: 61 59 GPURenderPassEncoder(Ref<GPUCommandBuffer>&&, PlatformRenderPassEncoderSmartPtr&&); 62 ~GPURenderPassEncoder() { endPass(); } // Ensure that encoding has ended before release.60 ~GPURenderPassEncoder() { endPass(); } 63 61 64 PlatformProgrammablePassEncoder* platformPassEncoder() const final; 65 62 // GPUProgrammablePassEncoder 63 const PlatformProgrammablePassEncoder* platformPassEncoder() const final; 64 void invalidateEncoder() final { m_platformRenderPassEncoder = nullptr; } 66 65 #if USE(METAL) 67 // GPUProgrammablePassEncoder 68 void useResource(MTLResource *, unsigned usage) final; 69 void setVertexBuffer(MTLBuffer *, unsigned offset, unsigned index) final; 70 void setFragmentBuffer(MTLBuffer *, unsigned offset, unsigned index) final; 66 void useResource(const MTLResource *, unsigned usage) final; 67 void setVertexBuffer(const MTLBuffer *, unsigned offset, unsigned index) final; 68 void setFragmentBuffer(const MTLBuffer *, unsigned offset, unsigned index) final; 71 69 #endif // USE(METAL) 72 70 -
trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h
r242839 r243419 62 62 #endif // USE(METAL) 63 63 PlatformRenderPipelineSmartPtr m_platformRenderPipeline; 64 RefPtr<GPUPipelineLayout> m_layout;65 64 GPUPrimitiveTopology m_primitiveTopology; 66 65 }; -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUBindGroupMetal.mm
r243048 r243419 32 32 #import "GPUBindGroupDescriptor.h" 33 33 #import "GPUBindGroupLayout.h" 34 #import "GPUBuffer.h"35 34 #import "GPUSampler.h" 36 #import "GPUTexture.h"37 35 #import "Logging.h" 38 36 #import <Metal/Metal.h> … … 78 76 } 79 77 80 static RefPtr<GPUSampler> tryGetResourceAsSampler(const GPUBindingResource& resource, const char* const functionName)78 static MTLSamplerState *tryGetResourceAsMTLSamplerState(const GPUBindingResource& resource, const char* const functionName) 81 79 { 82 80 #if LOG_DISABLED … … 87 85 return nullptr; 88 86 } 89 auto & samplerRef = WTF::get<Ref<GPUSampler>>(resource);90 if (!sampler Ref->platformSampler()) {87 auto samplerState = WTF::get<Ref<GPUSampler>>(resource)->platformSampler(); 88 if (!samplerState) 91 89 LOG(WebGPU, "%s: Invalid MTLSamplerState in GPUSampler binding!", functionName); 92 return nullptr; 93 } 94 return samplerRef.copyRef(); 90 91 return samplerState; 95 92 } 96 93 … … 136 133 MTLArgumentEncoder *vertexEncoder = descriptor.layout->vertexEncoder(); 137 134 MTLArgumentEncoder *fragmentEncoder = descriptor.layout->fragmentEncoder(); 138 // FIXME: Finish support for compute.135 MTLArgumentEncoder *computeEncoder = descriptor.layout->computeEncoder(); 139 136 140 137 RetainPtr<MTLBuffer> vertexArgsBuffer; … … 148 145 return nullptr; 149 146 } 147 RetainPtr<MTLBuffer> computeArgsBuffer; 148 if (computeEncoder && !(computeArgsBuffer = tryCreateArgumentBuffer(computeEncoder))) { 149 LOG(WebGPU, "%s: Unable to create MTLBuffer for compute argument buffer!", functionName); 150 return nullptr; 151 } 150 152 151 153 Vector<Ref<GPUBuffer>> boundBuffers; … … 155 157 const auto& layoutBindingsMap = descriptor.layout->bindingsMap(); 156 158 for (const auto& resourceBinding : descriptor.bindings) { 157 auto layoutIterator = layoutBindingsMap.find(resourceBinding.binding); 159 auto index = resourceBinding.binding; 160 auto layoutIterator = layoutBindingsMap.find(index); 158 161 if (layoutIterator == layoutBindingsMap.end()) { 159 LOG(WebGPU, "%s: GPUBindGroupBinding %lu not found in GPUBindGroupLayout!", functionName, resourceBinding.binding);162 LOG(WebGPU, "%s: GPUBindGroupBinding %lu not found in GPUBindGroupLayout!", functionName, index); 160 163 return nullptr; 161 164 } … … 163 166 if (layoutBinding.visibility == GPUShaderStageBit::Flags::None) 164 167 continue; 165 if ((layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex) && !vertexEncoder) { 166 LOG(WebGPU, "%s: No vertex encoder found for binding %lu!", functionName, resourceBinding.binding); 167 return nullptr; 168 } 169 if ((layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment) && !fragmentEncoder) { 170 LOG(WebGPU, "%s: No fragment encoder found for binding %lu!", functionName, resourceBinding.binding); 171 return nullptr; 172 } 173 168 169 bool isForVertex = layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex; 170 bool isForFragment = layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment; 171 bool isForCompute = layoutBinding.visibility & GPUShaderStageBit::Flags::Compute; 172 173 if (isForVertex && !vertexEncoder) { 174 LOG(WebGPU, "%s: No vertex argument encoder found for binding %lu!", functionName, index); 175 return nullptr; 176 } 177 if (isForFragment && !fragmentEncoder) { 178 LOG(WebGPU, "%s: No fragment argument encoder found for binding %lu!", functionName, index); 179 return nullptr; 180 } 181 if (isForCompute && !computeEncoder) { 182 LOG(WebGPU, "%s: No compute argument encoder found for binding %lu!", functionName, index); 183 return nullptr; 184 } 185 174 186 switch (layoutBinding.type) { 175 187 // FIXME: Support more resource types. 188 // FIXME: We could avoid this ugly switch-on-type using virtual functions if GPUBindingResource is refactored as a base class rather than a Variant. 176 189 case GPUBindingType::UniformBuffer: 177 190 case GPUBindingType::StorageBuffer: { … … 179 192 if (!bufferResource) 180 193 return nullptr; 181 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex) 182 setBufferOnEncoder(vertexEncoder, *bufferResource, resourceBinding.binding); 183 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment) 184 setBufferOnEncoder(fragmentEncoder, *bufferResource, resourceBinding.binding); 194 if (isForVertex) 195 setBufferOnEncoder(vertexEncoder, *bufferResource, index); 196 if (isForFragment) 197 setBufferOnEncoder(fragmentEncoder, *bufferResource, index); 198 if (isForCompute) 199 setBufferOnEncoder(computeEncoder, *bufferResource, index); 185 200 boundBuffers.append(bufferResource->buffer.copyRef()); 186 201 break; 187 202 } 188 203 case GPUBindingType::Sampler: { 189 auto sampler Resource = tryGetResourceAsSampler(resourceBinding.resource, functionName);190 if (!sampler Resource)204 auto samplerState = tryGetResourceAsMTLSamplerState(resourceBinding.resource, functionName); 205 if (!samplerState) 191 206 return nullptr; 192 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex) 193 setSamplerOnEncoder(vertexEncoder, samplerResource->platformSampler(), resourceBinding.binding); 194 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment) 195 setSamplerOnEncoder(fragmentEncoder, samplerResource->platformSampler(), resourceBinding.binding); 207 if (isForVertex) 208 setSamplerOnEncoder(vertexEncoder, samplerState, index); 209 if (isForFragment) 210 setSamplerOnEncoder(fragmentEncoder, samplerState, index); 211 if (isForCompute) 212 setSamplerOnEncoder(computeEncoder, samplerState, index); 196 213 break; 197 214 } … … 200 217 if (!textureResource) 201 218 return nullptr; 202 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex) 203 setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), resourceBinding.binding); 204 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment) 205 setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), resourceBinding.binding); 219 if (isForVertex) 220 setTextureOnEncoder(vertexEncoder, textureResource->platformTexture(), index); 221 if (isForFragment) 222 setTextureOnEncoder(fragmentEncoder, textureResource->platformTexture(), index); 223 if (isForCompute) 224 setTextureOnEncoder(computeEncoder, textureResource->platformTexture(), index); 206 225 boundTextures.append(textureResource.releaseNonNull()); 207 226 break; … … 213 232 } 214 233 215 return adoptRef(new GPUBindGroup(WTFMove(vertexArgsBuffer), WTFMove(fragmentArgsBuffer), WTFMove( boundBuffers), WTFMove(boundTextures)));216 } 217 218 GPUBindGroup::GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, Vector<Ref<GPUBuffer>>&& buffers, Vector<Ref<GPUTexture>>&& textures)234 return adoptRef(new GPUBindGroup(WTFMove(vertexArgsBuffer), WTFMove(fragmentArgsBuffer), WTFMove(computeArgsBuffer), WTFMove(boundBuffers), WTFMove(boundTextures))); 235 } 236 237 GPUBindGroup::GPUBindGroup(RetainPtr<MTLBuffer>&& vertexBuffer, RetainPtr<MTLBuffer>&& fragmentBuffer, RetainPtr<MTLBuffer>&& computeBuffer, Vector<Ref<GPUBuffer>>&& buffers, Vector<Ref<GPUTexture>>&& textures) 219 238 : m_vertexArgsBuffer(WTFMove(vertexBuffer)) 220 239 , m_fragmentArgsBuffer(WTFMove(fragmentBuffer)) 240 , m_computeArgsBuffer(WTFMove(computeBuffer)) 221 241 , m_boundBuffers(WTFMove(buffers)) 222 242 , m_boundTextures(WTFMove(textures)) -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm
r242766 r243419 30 30 31 31 #import "GPUBindGroup.h" 32 #import "GPUCommandBuffer.h"33 32 #import "Logging.h" 34 33 #import <Metal/Metal.h> … … 39 38 void GPUProgrammablePassEncoder::endPass() 40 39 { 41 ASSERT(platformPassEncoder()); 40 if (!platformPassEncoder()) 41 return; 42 42 43 43 BEGIN_BLOCK_OBJC_EXCEPTIONS; … … 45 45 END_BLOCK_OBJC_EXCEPTIONS; 46 46 47 invalidateEncoder(); 47 48 m_commandBuffer->setIsEncodingPass(false); 48 49 } … … 59 60 if (bindGroup.fragmentArgsBuffer()) 60 61 setFragmentBuffer(bindGroup.fragmentArgsBuffer(), 0, index); 62 if (bindGroup.computeArgsBuffer()) 63 setComputeBuffer(bindGroup.computeArgsBuffer(), 0, index); 61 64 62 65 for (auto& bufferRef : bindGroup.boundBuffers()) { -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm
r242839 r243419 179 179 } 180 180 181 MTLCommandEncoder *GPURenderPassEncoder::platformPassEncoder() const181 const MTLCommandEncoder *GPURenderPassEncoder::platformPassEncoder() const 182 182 { 183 183 return m_platformRenderPassEncoder.get(); 184 }185 186 void GPURenderPassEncoder::endPass()187 {188 if (!m_platformRenderPassEncoder)189 return;190 GPUProgrammablePassEncoder::endPass();191 m_platformRenderPassEncoder = nullptr;192 184 } 193 185 … … 199 191 } 200 192 201 // FIXME: Metal throws an error if the MTLPipelineState's attachment formats do not match the MTLCommandEncoder's attachment formats. Does this have to be validated at the Web GPU level?193 // FIXME: Metal throws an error if the MTLPipelineState's attachment formats do not match the MTLCommandEncoder's attachment formats. 202 194 203 195 BEGIN_BLOCK_OBJC_EXCEPTIONS; … … 266 258 } 267 259 260 BEGIN_BLOCK_OBJC_EXCEPTIONS; 268 261 [m_platformRenderPassEncoder 269 262 drawPrimitives:primitiveTypeForGPUPrimitiveTopology(m_pipeline->primitiveTopology()) … … 272 265 instanceCount:instanceCount 273 266 baseInstance:firstInstance]; 267 END_BLOCK_OBJC_EXCEPTIONS; 274 268 } 275 269 276 270 #if USE(METAL) 277 271 278 void GPURenderPassEncoder::useResource(MTLResource *resource, unsigned usage) 279 { 280 if (!m_platformRenderPassEncoder) { 281 LOG(WebGPU, "GPURenderPassEncoder: Invalid operation: Encoding is ended!"); 282 return; 283 } 272 void GPURenderPassEncoder::useResource(const MTLResource *resource, unsigned usage) 273 { 274 ASSERT(m_platformRenderPassEncoder); 275 284 276 BEGIN_BLOCK_OBJC_EXCEPTIONS; 285 277 [m_platformRenderPassEncoder useResource:resource usage:usage]; … … 287 279 } 288 280 289 void GPURenderPassEncoder::setVertexBuffer(MTLBuffer *buffer, unsigned offset, unsigned index) 290 { 291 if (!m_platformRenderPassEncoder) { 292 LOG(WebGPU, "GPURenderPassEncoder: Invalid operation: Encoding is ended!"); 293 return; 294 } 281 void GPURenderPassEncoder::setVertexBuffer(const MTLBuffer *buffer, unsigned offset, unsigned index) 282 { 283 ASSERT(m_platformRenderPassEncoder); 284 295 285 BEGIN_BLOCK_OBJC_EXCEPTIONS; 296 286 [m_platformRenderPassEncoder setVertexBuffer:buffer offset:offset atIndex:index]; … … 298 288 } 299 289 300 void GPURenderPassEncoder::setFragmentBuffer(MTLBuffer *buffer, unsigned offset, unsigned index) 301 { 302 if (!m_platformRenderPassEncoder) { 303 LOG(WebGPU, "GPURenderPassEncoder: Invalid operation: Encoding is ended!"); 304 return; 305 } 290 void GPURenderPassEncoder::setFragmentBuffer(const MTLBuffer *buffer, unsigned offset, unsigned index) 291 { 292 ASSERT(m_platformRenderPassEncoder); 293 306 294 BEGIN_BLOCK_OBJC_EXCEPTIONS; 307 295 [m_platformRenderPassEncoder setFragmentBuffer:buffer offset:offset atIndex:index]; -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm
r243105 r243419 29 29 #if ENABLE(WEBGPU) 30 30 31 #import "GPUDevice.h" 31 32 #import "GPULimits.h" 32 33 #import "GPUUtils.h" … … 442 443 : m_depthStencilState(WTFMove(depthStencil)) 443 444 , m_platformRenderPipeline(WTFMove(pipeline)) 444 , m_layout(WTFMove(descriptor.layout))445 445 , m_primitiveTopology(descriptor.primitiveTopology) 446 446 { -
trunk/Source/WebCore/platform/text/mac/TextEncodingRegistryMac.mm
r240211 r243419 29 29 #if PLATFORM(MAC) 30 30 31 #import <Carbon/Carbon.h>32 31 #import <wtf/spi/cf/CFStringSPI.h> 33 32
Note:
See TracChangeset
for help on using the changeset viewer.