Changeset 242615 in webkit
- Timestamp:
- Mar 7, 2019 3:03:53 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 30 edited
- 6 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r242612 r242615 1 2019-03-07 Justin Fan <justin_fan@apple.com> 2 3 [Web GPU] GPUSampler implementation 4 https://bugs.webkit.org/show_bug.cgi?id=195427 5 <rdar://problem/48686011> 6 7 Reviewed by Dean Jackson. 8 9 Update texture-triangle-strip to use a GPUSampler provided through bindings instead of creating one in shader. 10 11 * webgpu/texture-triangle-strip.html: 12 1 13 2019-03-07 Youenn Fablet <youenn@apple.com> 2 14 -
trunk/LayoutTests/webgpu/texture-triangle-strip.html
r242575 r242615 11 11 testRunner.waitUntilDone(); 12 12 13 const positionBufferIndex = 0; 14 const texCoordsBufferIndex = 1; 15 const positionAttributeNum = 0; 16 const texCoordsAttributeNum = 1; 17 const bindGroupIndex = 0; 18 const textureBindingNum = 0; 19 const samplerBindingNum = 1; 20 13 21 const shaderCode = ` 14 22 #include <metal_stdlib> … … 18 26 struct VertexIn 19 27 { 20 float4 position [[attribute( 0)]];21 float2 texCoords [[attribute( 1)]];28 float4 position [[attribute(${positionAttributeNum})]]; 29 float2 texCoords [[attribute(${texCoordsAttributeNum})]]; 22 30 }; 23 31 … … 36 44 } 37 45 38 struct Texture 39 { 40 texture2d<float> image [[id(0)]]; 46 struct TextureSampler 47 { 48 texture2d<float> t [[id(${textureBindingNum})]]; 49 sampler s [[id(${samplerBindingNum})]]; 41 50 }; 42 51 43 fragment float4 fragment_main(VertexOut v [[stage_in]], const device Texture& t [[buffer(0)]]) 44 { 45 constexpr sampler s(coord::normalized, address::clamp_to_zero, filter::nearest); 46 return t.image.sample(s, v.texCoords); 52 fragment float4 fragment_main(VertexOut v [[stage_in]], const device TextureSampler& args [[buffer(${bindGroupIndex})]]) 53 { 54 return args.t.sample(args.s, v.texCoords); 47 55 } 48 56 ` … … 52 60 indexFormat: WebGPUIndexFormat.UINT32, 53 61 attributes: [{ 54 shaderLocation: 0,55 inputSlot: 0,62 shaderLocation: positionAttributeNum, 63 inputSlot: positionBufferIndex, 56 64 offset: 0, 57 65 format: WebGPUVertexFormat.FLOAT_R32_G32_B32_A32 58 66 }, { 59 shaderLocation: 1,60 inputSlot: 1,67 shaderLocation: texCoordsAttributeNum, 68 inputSlot: texCoordsBufferIndex, 61 69 offset: 0, 62 70 format: WebGPUVertexFormat.FLOAT_R32_G32 63 71 }], 64 72 inputs: [{ 65 inputSlot: 0,73 inputSlot: positionBufferIndex, 66 74 stride: 4 * 4, 67 75 stepMode: WebGPUInputStepMode.VERTEX 68 76 }, { 69 inputSlot: 1,77 inputSlot: texCoordsBufferIndex, 70 78 stride: 4 * 2, 71 79 stepMode: WebGPUInputStepMode.VERTEX … … 81 89 const shaderModule = device.createShaderModule({ code: shaderCode }); 82 90 83 const vertexArray = new Float32Array([91 const positionArray = new Float32Array([ 84 92 // float4 xyzw 85 93 -1, 1, 0, 1, … … 88 96 1, -1, 0, 1 89 97 ]); 90 const vertexBuffer = device.createBuffer({ size: vertexArray.byteLength, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.TRANSFER_DST });91 vertexBuffer.setSubData(0, vertexArray.buffer);92 93 const tex tureCoordArray = new Float32Array([98 const positionBuffer = device.createBuffer({ size: positionArray.byteLength, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.TRANSFER_DST }); 99 positionBuffer.setSubData(0, positionArray.buffer); 100 101 const texCoordsArray = new Float32Array([ 94 102 // float2 texCoords 95 103 0, 0, … … 98 106 1, 1 99 107 ]); 100 const textureCoordBuffer = device.createBuffer({ size: tex tureCoordArray.byteLength, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.TRANSFER_DST });101 textureCoordBuffer.setSubData(0, tex tureCoordArray.buffer);108 const textureCoordBuffer = device.createBuffer({ size: texCoordsArray.byteLength, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.TRANSFER_DST }); 109 textureCoordBuffer.setSubData(0, texCoordsArray.buffer); 102 110 103 111 const inputStateDescriptor = createInputStateDescriptor(); … … 144 152 const texture = device.createTexture(textureDescriptor); 145 153 146 // Bind texture to pipeline 147 const textureBindingNum = 0; 154 // Bind texture and a sampler to pipeline 155 const textureLayoutBinding = { 156 binding: textureBindingNum, 157 visibility: GPUShaderStageBit.FRAGMENT, 158 type: "sampled-texture" 159 }; 160 const samplerLayoutBinding = { 161 binding: samplerBindingNum, 162 visibility: GPUShaderStageBit.FRAGMENT, 163 type: "sampler" 164 }; 165 148 166 const bindGroupLayoutDescriptor = { 149 bindings: [ { binding: textureBindingNum, visibility: GPUShaderStageBit.FRAGMENT, type: "sampled-texture" }]167 bindings: [textureLayoutBinding, samplerLayoutBinding] 150 168 }; 151 169 bindGroupLayout = device.createBindGroupLayout(bindGroupLayoutDescriptor); 152 170 const pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [bindGroupLayout] }); 153 171 172 const textureBinding = { 173 binding: textureBindingNum, 174 resource: texture.createDefaultTextureView() 175 }; 176 const samplerBinding = { 177 binding: samplerBindingNum, 178 resource: device.createSampler({ minFilter: "nearest", magFilter: "nearest" }) 179 }; 180 154 181 const bindGroupDescriptor = { 155 182 layout: bindGroupLayout, 156 bindings: [ { binding: textureBindingNum, resource: texture.createDefaultTextureView() }]183 bindings: [textureBinding, samplerBinding] 157 184 }; 158 185 const bindGroup = device.createBindGroup(bindGroupDescriptor); … … 177 204 const passEncoder = beginBasicRenderPass(context, commandBuffer); 178 205 passEncoder.setPipeline(pipeline); 179 passEncoder.setBindGroup( 0, bindGroup);180 passEncoder.setVertexBuffers( 0, [vertexBuffer, textureCoordBuffer], [0, 0]);206 passEncoder.setBindGroup(bindGroupIndex, bindGroup); 207 passEncoder.setVertexBuffers(positionBufferIndex, [positionBuffer, textureCoordBuffer], [0, 0]); 181 208 passEncoder.draw(4, 1, 0, 0); 182 209 passEncoder.endPass(); … … 184 211 const queue = device.getQueue(); 185 212 queue.submit([commandBuffer]); 186 vertexBuffer.destroy();213 positionBuffer.destroy(); 187 214 textureCoordBuffer.destroy(); 188 215 texture.destroy(); -
trunk/Source/WebCore/CMakeLists.txt
r242575 r242615 474 474 Modules/webgpu/GPUOrigin3D.idl 475 475 Modules/webgpu/GPURequestAdapterOptions.idl 476 Modules/webgpu/GPUSamplerDescriptor.idl 476 477 Modules/webgpu/GPUShaderStageBit.idl 477 478 Modules/webgpu/GPUStoreOp.idl … … 504 505 Modules/webgpu/WebGPURenderPipelineDescriptor.idl 505 506 Modules/webgpu/WebGPURenderingContext.idl 507 Modules/webgpu/WebGPUSampler.idl 506 508 Modules/webgpu/WebGPUShaderModule.idl 507 509 Modules/webgpu/WebGPUShaderModuleDescriptor.idl -
trunk/Source/WebCore/ChangeLog
r242609 r242615 1 2019-03-07 Justin Fan <justin_fan@apple.com> 2 3 [Web GPU] GPUSampler implementation 4 https://bugs.webkit.org/show_bug.cgi?id=195427 5 <rdar://problem/48686011> 6 7 Reviewed by Dean Jackson. 8 9 Implement ability to create GPUSamplers and use them as pipeline resource bindings. 10 11 Test: texture-triangle-strip.html updated. 12 13 Add symbols to project: 14 * CMakeLists.txt: 15 * DerivedSources-input.xcfilelist: 16 * DerivedSources-output.xcfilelist: 17 * DerivedSources.make: 18 * Sources.txt: 19 * SourcesCocoa.txt: 20 * WebCore.xcodeproj/project.pbxproj: 21 * bindings/js/WebCoreBuiltinNames.h: 22 23 GPUSampler creation: 24 * Modules/webgpu/GPUSamplerDescriptor.idl: Added. 25 * Modules/webgpu/WebGPUDevice.cpp: 26 (WebCore::WebGPUDevice::createSampler const): Added. 27 * Modules/webgpu/WebGPUDevice.h: 28 * Modules/webgpu/WebGPUDevice.idl: 29 * Modules/webgpu/WebGPUSampler.cpp: Added. 30 (WebCore::WebGPUSampler::create): 31 (WebCore::WebGPUSampler::WebGPUSampler): 32 * Modules/webgpu/WebGPUSampler.h: Added. 33 (WebCore::WebGPUSampler::sampler const): 34 * Modules/webgpu/WebGPUSampler.idl: Added. 35 * platform/graphics/gpu/GPUDevice.cpp: 36 (WebCore::GPUDevice::tryCreateSampler const): Added. 37 * platform/graphics/gpu/GPUDevice.h: 38 * platform/graphics/gpu/GPUSampler.h: Added. 39 (WebCore::GPUSampler::platformSampler const): 40 * platform/graphics/gpu/GPUSamplerDescriptor.h: Added. 41 * platform/graphics/gpu/cocoa/GPUSamplerMetal.mm: Added. 42 (WebCore::mtlAddressModeForAddressMode): 43 (WebCore::mtlBorderColorForBorderColor): 44 (WebCore::mtlMinMagFilterForFilterMode): 45 (WebCore::mtlMipFilterForFilterMode): 46 (WebCore::tryCreateMtlSamplerState): 47 (WebCore::GPUSampler::tryCreate): 48 (WebCore::GPUSampler::GPUSampler): 49 50 Move GPUCompareFunction to Utils for shared use. 51 * platform/graphics/gpu/GPUCompareFunction.h: 52 * platform/graphics/gpu/GPUUtils.h: 53 * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm: 54 (WebCore::tryCreateMtlDepthStencilState): 55 (WebCore::validateAndConvertDepthCompareFunctionToMtl): Deleted. 56 * platform/graphics/gpu/cocoa/GPUUtilsMetal.mm: 57 (WebCore::platformTextureFormatForGPUTextureFormat): 58 (WebCore::platformCompareFunctionForGPUCompareFunction): 59 60 Expand bind groups to accept GPUSamplers: 61 * Modules/webgpu/WebGPUBindGroupBinding.h: 62 * Modules/webgpu/WebGPUBindGroupBinding.idl: 63 * Modules/webgpu/WebGPUBindGroupDescriptor.cpp: 64 (WebCore::WebGPUBindGroupDescriptor::asGPUBindGroupDescriptor const): 65 * platform/graphics/gpu/GPUBindGroupBinding.h: 66 * platform/graphics/gpu/GPUProgrammablePassEncoder.h: 67 * platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm: 68 (WebCore::GPUProgrammablePassEncoder::setBindGroup): 69 (WebCore::GPUProgrammablePassEncoder::setResourceAsBufferOnEncoder): 70 (WebCore::GPUProgrammablePassEncoder::setResourceAsSamplerOnEncoder): Added. 71 (WebCore::GPUProgrammablePassEncoder::setResourceAsTextureOnEncoder): 72 73 Misc: 74 * Modules/webgpu/WebGPUTexture.cpp: Missing includes. 75 * Modules/webgpu/WebGPUTexture.h: 76 * Modules/webgpu/WebGPUSwapChain.cpp: Removed extra include. 77 1 78 2019-03-07 Commit Queue <commit-queue@webkit.org> 2 79 -
trunk/Source/WebCore/DerivedSources-input.xcfilelist
r242575 r242615 333 333 $(PROJECT_DIR)/Modules/webgpu/GPUOrigin3D.idl 334 334 $(PROJECT_DIR)/Modules/webgpu/GPURequestAdapterOptions.idl 335 $(PROJECT_DIR)/Modules/webgpu/GPUSamplerDescriptor.idl 335 336 $(PROJECT_DIR)/Modules/webgpu/GPUShaderStageBit.idl 336 337 $(PROJECT_DIR)/Modules/webgpu/GPUStoreOp.idl … … 370 371 $(PROJECT_DIR)/Modules/webgpu/WebGPURenderPipelineDescriptor.idl 371 372 $(PROJECT_DIR)/Modules/webgpu/WebGPURenderingContext.idl 373 $(PROJECT_DIR)/Modules/webgpu/WebGPUSampler.idl 372 374 $(PROJECT_DIR)/Modules/webgpu/WebGPUShaderModule.idl 373 375 $(PROJECT_DIR)/Modules/webgpu/WebGPUShaderModuleDescriptor.idl -
trunk/Source/WebCore/DerivedSources-output.xcfilelist
r242575 r242615 600 600 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURequestAdapterOptions.cpp 601 601 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPURequestAdapterOptions.h 602 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUSamplerDescriptor.cpp 603 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUSamplerDescriptor.h 602 604 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUShaderStageBit.cpp 603 605 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUShaderStageBit.h … … 1934 1936 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPURenderingContext.cpp 1935 1937 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPURenderingContext.h 1938 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUSampler.cpp 1939 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUSampler.h 1936 1940 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUShaderModule.cpp 1937 1941 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSWebGPUShaderModule.h -
trunk/Source/WebCore/DerivedSources.make
r242575 r242615 384 384 $(WebCore)/Modules/webgpu/GPUOrigin3D.idl \ 385 385 $(WebCore)/Modules/webgpu/GPURequestAdapterOptions.idl \ 386 $(WebCore)/Modules/webgpu/GPUSamplerDescriptor.idl \ 386 387 $(WebCore)/Modules/webgpu/GPUShaderStageBit.idl \ 387 388 $(WebCore)/Modules/webgpu/GPUStoreOp.idl \ … … 414 415 $(WebCore)/Modules/webgpu/WebGPURenderPipelineDescriptor.idl \ 415 416 $(WebCore)/Modules/webgpu/WebGPURenderingContext.idl \ 417 $(WebCore)/Modules/webgpu/WebGPUSampler.idl \ 416 418 $(WebCore)/Modules/webgpu/WebGPUShaderModule.idl \ 417 419 $(WebCore)/Modules/webgpu/WebGPUShaderModuleDescriptor.idl \ -
trunk/Source/WebCore/Modules/webgpu/GPUSamplerDescriptor.idl
r242614 r242615 26 26 27 27 typedef unsigned long u32; 28 typedef (/*WebGPUSampler or */WebGPUTextureView or WebGPUBufferBinding) WebGPUBindingResource; 28 29 enum GPUAddressMode { 30 "clamp-to-edge", 31 "repeat", 32 "mirror-repeat", 33 "clamp-to-border-color" 34 }; 35 36 enum GPUFilterMode { 37 "nearest", 38 "linear" 39 }; 40 41 enum GPUBorderColor { 42 "transparent-black", 43 "opaque-black", 44 "opaque-white" 45 }; 29 46 30 47 [ 31 48 Conditional=WEBGPU, 32 49 EnabledAtRuntime=WebGPU 33 ] dictionary WebGPUBindGroupBinding { 34 u32 binding; 35 WebGPUBindingResource resource; 50 ] dictionary GPUSamplerDescriptor { 51 GPUAddressMode addressModeU = "clampToEdge"; 52 GPUAddressMode addressModeV = "clampToEdge"; 53 GPUAddressMode addressModeW = "clampToEdge"; 54 GPUFilterMode magFilter = "nearest"; 55 GPUFilterMode minFilter = "nearest"; 56 GPUFilterMode mipmapFilter = "nearest"; 57 float lodMinClamp = 0; 58 float lodMaxClamp = 0xffffffff; // TODO: What should this be? Was Number.MAX_VALUE. 59 u32 maxAnisotropy = 1; 60 GPUCompareFunction compareFunction = "never"; 61 GPUBorderColor borderColor = "transparentBlack"; 36 62 }; -
trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupBinding.h
r239837 r242615 29 29 30 30 #include "WebGPUBufferBinding.h" 31 #include "WebGPUSampler.h" 31 32 #include "WebGPUTextureView.h" 32 33 #include <wtf/Variant.h> … … 34 35 namespace WebCore { 35 36 36 using WebGPUBindingResource = Variant<RefPtr<WebGPU TextureView>, WebGPUBufferBinding>;37 using WebGPUBindingResource = Variant<RefPtr<WebGPUSampler>, RefPtr<WebGPUTextureView>, WebGPUBufferBinding>; 37 38 38 39 struct WebGPUBindGroupBinding { -
trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupBinding.idl
r239837 r242615 26 26 27 27 typedef unsigned long u32; 28 typedef ( /*WebGPUSampler or */WebGPUTextureView or WebGPUBufferBinding) WebGPUBindingResource;28 typedef (WebGPUSampler or WebGPUTextureView or WebGPUBufferBinding) WebGPUBindingResource; 29 29 30 30 [ -
trunk/Source/WebCore/Modules/webgpu/WebGPUBindGroupDescriptor.cpp
r242575 r242615 89 89 const auto layoutBinding = iterator->value; 90 90 91 auto bindingResourceVisitor = WTF::makeVisitor([](const RefPtr<WebGPUTextureView>& view) -> Optional<GPUBindingResource> { 91 auto bindingResourceVisitor = WTF::makeVisitor([](const RefPtr<WebGPUSampler>& sampler) -> Optional<GPUBindingResource> { 92 if (!sampler) 93 return WTF::nullopt; 94 auto gpuSampler = sampler->sampler(); 95 if (!gpuSampler) 96 return WTF::nullopt; 97 98 return static_cast<GPUBindingResource>(makeRef(*gpuSampler)); 99 }, [](const RefPtr<WebGPUTextureView>& view) -> Optional<GPUBindingResource> { 92 100 if (!view) 93 101 return WTF::nullopt; -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
r242575 r242615 38 38 #include "GPUPipelineStageDescriptor.h" 39 39 #include "GPURenderPipelineDescriptor.h" 40 #include "GPUSampler.h" 41 #include "GPUSamplerDescriptor.h" 40 42 #include "GPUShaderModuleDescriptor.h" 41 43 #include "GPUTextureDescriptor.h" … … 53 55 #include "WebGPURenderPipeline.h" 54 56 #include "WebGPURenderPipelineDescriptor.h" 57 #include "WebGPUSampler.h" 55 58 #include "WebGPUShaderModule.h" 56 59 #include "WebGPUShaderModuleDescriptor.h" … … 83 86 auto texture = m_device->tryCreateTexture(WTFMove(descriptor)); 84 87 return WebGPUTexture::create(WTFMove(texture)); 88 } 89 90 Ref<WebGPUSampler> WebGPUDevice::createSampler(const GPUSamplerDescriptor& descriptor) const 91 { 92 auto sampler = m_device->tryCreateSampler(descriptor); 93 return WebGPUSampler::create(WTFMove(sampler)); 85 94 } 86 95 -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h
r242575 r242615 45 45 class WebGPUPipelineLayout; 46 46 class WebGPURenderPipeline; 47 class WebGPUSampler; 47 48 class WebGPUShaderModule; 48 49 class WebGPUTexture; … … 50 51 struct GPUBindGroupLayoutDescriptor; 51 52 struct GPUBufferDescriptor; 53 struct GPUSamplerDescriptor; 52 54 struct GPUTextureDescriptor; 53 55 struct WebGPUBindGroupDescriptor; … … 65 67 Ref<WebGPUBuffer> createBuffer(GPUBufferDescriptor&&) const; 66 68 Ref<WebGPUTexture> createTexture(GPUTextureDescriptor&&) const; 69 Ref<WebGPUSampler> createSampler(const GPUSamplerDescriptor&) const; 67 70 68 71 Ref<WebGPUBindGroupLayout> createBindGroupLayout(const GPUBindGroupLayoutDescriptor&) const; -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.idl
r242575 r242615 34 34 WebGPUBuffer createBuffer(GPUBufferDescriptor descriptor); 35 35 WebGPUTexture createTexture(GPUTextureDescriptor descriptor); 36 WebGPUSampler createSampler(GPUSamplerDescriptor descriptor); 36 37 37 38 WebGPUBindGroupLayout createBindGroupLayout(GPUBindGroupLayoutDescriptor descriptor); … … 51 52 // readonly attribute WebGPULimits limits; 52 53 53 // WebGPUSampler createSampler(WebGPUSamplerDescriptor descriptor);54 55 54 // WebGPUComputePipeline createComputePipeline(WebGPUComputePipelineDescriptor descriptor); 56 55 // WebGPUFence createFence(WebGPUFenceDescriptor descriptor); -
trunk/Source/WebCore/Modules/webgpu/WebGPUSampler.cpp
r242614 r242615 24 24 */ 25 25 26 #pragma once 26 #include "config.h" 27 #include "WebGPUSampler.h" 27 28 28 29 #if ENABLE(WEBGPU) 29 30 30 #include "GPUTextureFormat.h"31 32 31 namespace WebCore { 33 32 34 PlatformTextureFormat platformTextureFormatForGPUTextureFormat(GPUTextureFormat); 33 Ref<WebGPUSampler> WebGPUSampler::create(RefPtr<GPUSampler>&& sampler) 34 { 35 return adoptRef(*new WebGPUSampler(WTFMove(sampler))); 36 } 37 38 WebGPUSampler::WebGPUSampler(RefPtr<GPUSampler>&& sampler) 39 : m_sampler(WTFMove(sampler)) 40 { 41 } 35 42 36 43 } // namespace WebCore -
trunk/Source/WebCore/Modules/webgpu/WebGPUSampler.h
r242614 r242615 28 28 #if ENABLE(WEBGPU) 29 29 30 #include " WebGPUBufferBinding.h"31 #include "WebGPUTextureView.h"32 #include <wtf/ Variant.h>30 #include "GPUSampler.h" 31 #include <wtf/RefCounted.h> 32 #include <wtf/RefPtr.h> 33 33 34 34 namespace WebCore { 35 35 36 using WebGPUBindingResource = Variant<RefPtr<WebGPUTextureView>, WebGPUBufferBinding>; 36 class WebGPUSampler : public RefCounted<WebGPUSampler> { 37 public: 38 static Ref<WebGPUSampler> create(RefPtr<GPUSampler>&&); 37 39 38 struct WebGPUBindGroupBinding { 39 unsigned long binding; 40 WebGPUBindingResource resource; 40 GPUSampler* sampler() const { return m_sampler.get(); } 41 42 private: 43 WebGPUSampler(RefPtr<GPUSampler>&&); 44 45 RefPtr<GPUSampler> m_sampler; 41 46 }; 42 47 -
trunk/Source/WebCore/Modules/webgpu/WebGPUSampler.idl
r242614 r242615 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 "GPUTextureFormat.h" 31 32 namespace WebCore { 33 34 PlatformTextureFormat platformTextureFormatForGPUTextureFormat(GPUTextureFormat); 35 36 } // namespace WebCore 37 38 #endif // ENABLE(WEBGPU) 27 [ 28 Conditional=WEBGPU, 29 EnabledAtRuntime=WebGPU, 30 ImplementationLacksVTable 31 ] interface WebGPUSampler { 32 }; -
trunk/Source/WebCore/Modules/webgpu/WebGPUSwapChain.cpp
r241048 r242615 28 28 29 29 #if ENABLE(WEBGPU) 30 31 #include "GPUTextureFormat.h"32 30 33 31 namespace WebCore { -
trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.cpp
r242575 r242615 29 29 #if ENABLE(WEBGPU) 30 30 31 #include " WebGPUTextureView.h"31 #include "Logging.h" 32 32 33 33 namespace WebCore { -
trunk/Source/WebCore/Modules/webgpu/WebGPUTexture.h
r242575 r242615 29 29 30 30 #include "GPUTexture.h" 31 31 #include "WebGPUTextureView.h" 32 32 #include <wtf/RefCounted.h> 33 33 #include <wtf/RefPtr.h> … … 35 35 36 36 namespace WebCore { 37 38 class WebGPUTextureView;39 37 40 38 class WebGPUTexture : public RefCounted<WebGPUTexture> { -
trunk/Source/WebCore/Sources.txt
r242599 r242615 364 364 Modules/webgpu/WebGPURenderPassEncoder.cpp 365 365 Modules/webgpu/WebGPURenderPipeline.cpp 366 Modules/webgpu/WebGPUSampler.cpp 366 367 Modules/webgpu/WebGPUShaderModule.cpp 367 368 Modules/webgpu/WebGPUSwapChain.cpp … … 2783 2784 JSGPUOrigin3D.cpp 2784 2785 JSGPURequestAdapterOptions.cpp 2786 JSGPUSamplerDescriptor.cpp 2785 2787 JSGPUShaderStageBit.cpp 2786 2788 JSGPUStoreOp.cpp … … 3341 3343 JSWebGPURenderPipeline.cpp 3342 3344 JSWebGPURenderPipelineDescriptor.cpp 3345 JSWebGPUSampler.cpp 3343 3346 JSWebGPUShaderModule.cpp 3344 3347 JSWebGPUShaderModuleDescriptor.cpp -
trunk/Source/WebCore/SourcesCocoa.txt
r242359 r242615 326 326 platform/graphics/gpu/cocoa/GPURenderPassEncoderMetal.mm 327 327 platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm 328 platform/graphics/gpu/cocoa/GPUSamplerMetal.mm 328 329 platform/graphics/gpu/cocoa/GPUShaderModuleMetal.mm 329 330 platform/graphics/gpu/cocoa/GPUSwapChainMetal.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r242599 r242615 14106 14106 D0A20D562092A0A600E0C259 /* WebGLCompressedTextureASTC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGLCompressedTextureASTC.cpp; sourceTree = "<group>"; }; 14107 14107 D0A3A7301405A39800FB8ED3 /* ResourceLoaderOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoaderOptions.h; sourceTree = "<group>"; }; 14108 D0ADB26222309D7600A22935 /* GPUSamplerDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUSamplerDescriptor.h; sourceTree = "<group>"; }; 14109 D0ADB26322309D7600A22935 /* GPUSamplerDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUSamplerDescriptor.idl; sourceTree = "<group>"; }; 14110 D0ADB2682230AACB00A22935 /* GPUSampler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUSampler.h; sourceTree = "<group>"; }; 14111 D0ADB26B2230ACC000A22935 /* GPUSamplerMetal.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GPUSamplerMetal.mm; sourceTree = "<group>"; }; 14112 D0ADB26C2230BB8E00A22935 /* WebGPUSampler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebGPUSampler.h; sourceTree = "<group>"; }; 14113 D0ADB26D2230BB8E00A22935 /* WebGPUSampler.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUSampler.cpp; sourceTree = "<group>"; }; 14114 D0ADB26F2230C1F100A22935 /* WebGPUSampler.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebGPUSampler.idl; sourceTree = "<group>"; }; 14108 14115 D0B0556609C6700100307E43 /* CreateLinkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CreateLinkCommand.h; sourceTree = "<group>"; }; 14109 14116 D0B0556709C6700100307E43 /* CreateLinkCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreateLinkCommand.cpp; sourceTree = "<group>"; }; … … 18504 18511 312FF8BC21A4C2F000EB199D /* GPURenderPipelineDescriptor.h */, 18505 18512 D06A9A2122026C7A0083C662 /* GPURequestAdapterOptions.h */, 18513 D0ADB2682230AACB00A22935 /* GPUSampler.h */, 18514 D0ADB26222309D7600A22935 /* GPUSamplerDescriptor.h */, 18506 18515 312FF8BB21A4C2F000EB199D /* GPUShaderModule.h */, 18507 18516 312FF8C021A4C2F200EB199D /* GPUShaderModuleDescriptor.h */, … … 26099 26108 D0CCA94A22299F97006979B6 /* GPUOrigin3D.idl */, 26100 26109 D02C26922181416D00D818E4 /* GPURequestAdapterOptions.idl */, 26110 D0ADB26322309D7600A22935 /* GPUSamplerDescriptor.idl */, 26101 26111 D0DE8FB8222E09E200882550 /* GPUShaderStageBit.h */, 26102 26112 D0DE8FB9222E09E200882550 /* GPUShaderStageBit.idl */, … … 26169 26179 D0C419F22183EFEC009EC1DE /* WebGPURenderPipelineDescriptor.h */, 26170 26180 D0C419F32183EFEC009EC1DE /* WebGPURenderPipelineDescriptor.idl */, 26181 D0ADB26D2230BB8E00A22935 /* WebGPUSampler.cpp */, 26182 D0ADB26C2230BB8E00A22935 /* WebGPUSampler.h */, 26183 D0ADB26F2230C1F100A22935 /* WebGPUSampler.idl */, 26171 26184 D0615FCD217FE5C6008A48A8 /* WebGPUShaderModule.cpp */, 26172 26185 D0615FCC217FE5C6008A48A8 /* WebGPUShaderModule.h */, … … 26204 26217 D087CE3A21ACA94200BDE174 /* GPURenderPassEncoderMetal.mm */, 26205 26218 D087CE3D21ACA94200BDE174 /* GPURenderPipelineMetal.mm */, 26219 D0ADB26B2230ACC000A22935 /* GPUSamplerMetal.mm */, 26206 26220 D087CE4021ACA94200BDE174 /* GPUShaderModuleMetal.mm */, 26207 26221 D087CE3E21ACA94200BDE174 /* GPUSwapChainMetal.mm */, -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r242575 r242615 209 209 macro(WebGPURenderPassEncoder) \ 210 210 macro(WebGPURenderPipeline) \ 211 macro(WebGPUSampler) \ 211 212 macro(WebGPUShaderModule) \ 212 213 macro(WebGPUSwapChain) \ -
trunk/Source/WebCore/platform/graphics/gpu/GPUBindGroupBinding.h
r239837 r242615 29 29 30 30 #include "GPUBufferBinding.h" 31 #include "GPUSampler.h" 31 32 #include "GPUTexture.h" 32 33 #include <wtf/Variant.h> … … 34 35 namespace WebCore { 35 36 36 using GPUBindingResource = Variant<Ref<GPU Texture>, GPUBufferBinding>;37 using GPUBindingResource = Variant<Ref<GPUSampler>, Ref<GPUTexture>, GPUBufferBinding>; 37 38 38 39 struct GPUBindGroupBinding { -
trunk/Source/WebCore/platform/graphics/gpu/GPUBuffer.h
r242404 r242615 134 134 unsigned long m_byteLength; 135 135 OptionSet<GPUBufferUsage::Flags> m_usage; 136 unsigned m_numScheduledCommandBuffers = 0;136 unsigned m_numScheduledCommandBuffers { 0 }; 137 137 }; 138 138 -
trunk/Source/WebCore/platform/graphics/gpu/GPUCompareFunction.h
r240748 r242615 41 41 }; 42 42 43 using PlatformCompareFunction = unsigned; 44 43 45 } // namespace WebCore 44 46 -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.cpp
r242575 r242615 38 38 #include "GPURenderPipeline.h" 39 39 #include "GPURenderPipelineDescriptor.h" 40 #include "GPUSampler.h" 41 #include "GPUSamplerDescriptor.h" 40 42 #include "GPUShaderModule.h" 41 43 #include "GPUShaderModuleDescriptor.h" … … 53 55 { 54 56 return GPUTexture::tryCreate(*this, WTFMove(descriptor)); 57 } 58 59 RefPtr<GPUSampler> GPUDevice::tryCreateSampler(const GPUSamplerDescriptor& descriptor) const 60 { 61 return GPUSampler::tryCreate(*this, descriptor); 55 62 } 56 63 -
trunk/Source/WebCore/platform/graphics/gpu/GPUDevice.h
r242575 r242615 46 46 class GPUPipelineLayout; 47 47 class GPURenderPipeline; 48 class GPUSampler; 48 49 class GPUShaderModule; 49 50 class GPUTexture; … … 54 55 struct GPURenderPipelineDescriptor; 55 56 struct GPURequestAdapterOptions; 57 struct GPUSamplerDescriptor; 56 58 struct GPUShaderModuleDescriptor; 57 59 struct GPUTextureDescriptor; … … 63 65 RefPtr<GPUBuffer> tryCreateBuffer(GPUBufferDescriptor&&); 64 66 RefPtr<GPUTexture> tryCreateTexture(GPUTextureDescriptor&&) const; 67 RefPtr<GPUSampler> tryCreateSampler(const GPUSamplerDescriptor&) const; 65 68 66 69 RefPtr<GPUBindGroupLayout> tryCreateBindGroupLayout(const GPUBindGroupLayoutDescriptor&) const; -
trunk/Source/WebCore/platform/graphics/gpu/GPUProgrammablePassEncoder.h
r242575 r242615 62 62 private: 63 63 #if USE(METAL) 64 void setResourceAsBufferOnEncoder(MTLArgumentEncoder *, const GPUBindingResource&, unsigned, const char* const); 65 void setResourceAsTextureOnEncoder(MTLArgumentEncoder *, const GPUBindingResource&, unsigned, const char* const); 64 void setResourceAsBufferOnEncoder(MTLArgumentEncoder *, const GPUBindGroupBinding&, const char* const); 65 void setResourceAsSamplerOnEncoder(MTLArgumentEncoder *, const GPUBindGroupBinding&, const char* const); 66 void setResourceAsTextureOnEncoder(MTLArgumentEncoder *, const GPUBindGroupBinding&, const char* const); 66 67 virtual void useResource(MTLResource *, unsigned) = 0; 67 68 -
trunk/Source/WebCore/platform/graphics/gpu/GPUSampler.h
r242614 r242615 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 "GPUTexture.h"31 32 30 #include <wtf/RefCounted.h> 33 31 #include <wtf/RefPtr.h> 34 #include <wtf/Vector.h> 32 #include <wtf/RetainPtr.h> 33 34 OBJC_PROTOCOL(MTLSamplerState); 35 35 36 36 namespace WebCore { 37 37 38 class WebGPUTextureView;38 class GPUDevice; 39 39 40 class WebGPUTexture : public RefCounted<WebGPUTexture> { 40 struct GPUSamplerDescriptor; 41 42 using PlatformSampler = MTLSamplerState; 43 using PlatformSamplerSmartPtr = RetainPtr<MTLSamplerState>; 44 45 class GPUSampler : public RefCounted<GPUSampler> { 41 46 public: 42 static Ref <WebGPUTexture> create(RefPtr<GPUTexture>&&);47 static RefPtr<GPUSampler> tryCreate(const GPUDevice&, const GPUSamplerDescriptor&); 43 48 44 RefPtr<GPUTexture> texture() const { return m_texture; } 45 46 Ref<WebGPUTextureView> createDefaultTextureView(); 47 void destroy(); 49 PlatformSampler* platformSampler() const { return m_platformSampler.get(); } 48 50 49 51 private: 50 explicit WebGPUTexture(RefPtr<GPUTexture>&&);52 GPUSampler(PlatformSamplerSmartPtr&&); 51 53 52 RefPtr<GPUTexture> m_texture; 53 Vector<Ref<WebGPUTextureView>> m_textureViews; 54 PlatformSamplerSmartPtr m_platformSampler; 54 55 }; 55 56 -
trunk/Source/WebCore/platform/graphics/gpu/GPUSamplerDescriptor.h
r242614 r242615 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WebGPUBufferBinding.h" 31 #include "WebGPUTextureView.h" 32 #include <wtf/Variant.h> 30 #include "GPUCompareFunction.h" 33 31 34 32 namespace WebCore { 35 33 36 using WebGPUBindingResource = Variant<RefPtr<WebGPUTextureView>, WebGPUBufferBinding>; 34 struct GPUSamplerDescriptor { 35 enum class AddressMode { 36 ClampToEdge, 37 Repeat, 38 MirrorRepeat, 39 ClampToBorderColor, 40 }; 37 41 38 struct WebGPUBindGroupBinding { 39 unsigned long binding; 40 WebGPUBindingResource resource; 42 enum class FilterMode { 43 Nearest, 44 Linear, 45 }; 46 47 enum class BorderColor { 48 TransparentBlack, 49 OpaqueBlack, 50 OpaqueWhite, 51 }; 52 53 AddressMode addressModeU { AddressMode::ClampToEdge }; 54 AddressMode addressModeV { AddressMode::ClampToEdge }; 55 AddressMode addressModeW { AddressMode::ClampToEdge }; 56 FilterMode magFilter { FilterMode::Nearest }; 57 FilterMode minFilter { FilterMode::Nearest }; 58 FilterMode mipmapFilter { FilterMode::Nearest }; 59 float lodMinClamp { 0 }; 60 float lodMaxClamp { 0xffffffff }; 61 unsigned maxAnisotropy { 1 }; 62 GPUCompareFunction compareFunction { GPUCompareFunction::Never }; 63 BorderColor borderColor { BorderColor::TransparentBlack }; 41 64 }; 42 65 -
trunk/Source/WebCore/platform/graphics/gpu/GPUUtils.h
r241181 r242615 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUCompareFunction.h" 30 31 #include "GPUTextureFormat.h" 31 32 … … 33 34 34 35 PlatformTextureFormat platformTextureFormatForGPUTextureFormat(GPUTextureFormat); 36 PlatformCompareFunction platformCompareFunctionForGPUCompareFunction(GPUCompareFunction); 35 37 36 38 } // namespace WebCore -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUProgrammablePassEncoderMetal.mm
r242575 r242615 71 71 72 72 // Set each resource on each MTLArgumentEncoder it should be visible on. 73 const auto& bindingsMap = bindGroup.layout().bindingsMap();74 for (const auto& binding : bindGroup.bindings()) {75 auto iterator = bindingsMap.find(binding.binding);76 if ( iterator == bindingsMap.end()) {77 LOG(WebGPU, "%s: GPUBindGroupBinding %lu not found in GPUBindGroupLayout!", functionName, binding.binding);73 const auto& layoutBindingsMap = bindGroup.layout().bindingsMap(); 74 for (const auto& resourceBinding : bindGroup.bindings()) { 75 auto layoutIterator = layoutBindingsMap.find(resourceBinding.binding); 76 if (layoutIterator == layoutBindingsMap.end()) { 77 LOG(WebGPU, "%s: GPUBindGroupBinding %lu not found in GPUBindGroupLayout!", functionName, resourceBinding.binding); 78 78 return; 79 79 } 80 auto bindGroupLayoutBinding = iterator->value;81 82 switch ( bindGroupLayoutBinding.type) {80 auto layoutBinding = layoutIterator->value; 81 82 switch (layoutBinding.type) { 83 83 // FIXME: Support more resource types. 84 84 case GPUBindGroupLayoutBinding::BindingType::UniformBuffer: 85 85 case GPUBindGroupLayoutBinding::BindingType::StorageBuffer: { 86 if ( bindGroupLayoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)87 setResourceAsBufferOnEncoder(vertexArgs.encoder.get(), binding.resource, binding.binding, functionName);88 if ( bindGroupLayoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)89 setResourceAsBufferOnEncoder(fragmentArgs.encoder.get(), binding.resource, binding.binding, functionName);86 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex) 87 setResourceAsBufferOnEncoder(vertexArgs.encoder.get(), resourceBinding, functionName); 88 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment) 89 setResourceAsBufferOnEncoder(fragmentArgs.encoder.get(), resourceBinding, functionName); 90 90 break; 91 91 } 92 case GPUBindGroupLayoutBinding::BindingType::Sampler: { 93 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex) 94 setResourceAsSamplerOnEncoder(vertexArgs.encoder.get(), resourceBinding, functionName); 95 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment) 96 setResourceAsSamplerOnEncoder(fragmentArgs.encoder.get(), resourceBinding, functionName); 97 break; 98 } 92 99 case GPUBindGroupLayoutBinding::BindingType::SampledTexture: { 93 if ( bindGroupLayoutBinding.visibility & GPUShaderStageBit::Flags::Vertex)94 setResourceAsTextureOnEncoder(vertexArgs.encoder.get(), binding.resource, binding.binding, functionName);95 if ( bindGroupLayoutBinding.visibility & GPUShaderStageBit::Flags::Fragment)96 setResourceAsTextureOnEncoder(fragmentArgs.encoder.get(), binding.resource, binding.binding, functionName);100 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Vertex) 101 setResourceAsTextureOnEncoder(vertexArgs.encoder.get(), resourceBinding, functionName); 102 if (layoutBinding.visibility & GPUShaderStageBit::Flags::Fragment) 103 setResourceAsTextureOnEncoder(fragmentArgs.encoder.get(), resourceBinding, functionName); 97 104 break; 98 105 } … … 104 111 } 105 112 106 void GPUProgrammablePassEncoder::setResourceAsBufferOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBind ingResource& resource, unsigned index, const char* const functionName)113 void GPUProgrammablePassEncoder::setResourceAsBufferOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBindGroupBinding& binding, const char* const functionName) 107 114 { 108 115 #if LOG_DISABLED … … 114 121 } 115 122 116 if (!WTF::holds_alternative<GPUBufferBinding>( resource)) {123 if (!WTF::holds_alternative<GPUBufferBinding>(binding.resource)) { 117 124 LOG(WebGPU, "%s: Resource is not a buffer type!", functionName); 118 125 return; 119 126 } 120 127 121 auto& bufferBinding = WTF::get<GPUBufferBinding>( resource);128 auto& bufferBinding = WTF::get<GPUBufferBinding>(binding.resource); 122 129 auto& bufferRef = bufferBinding.buffer; 123 130 auto mtlBuffer = bufferRef->platformBuffer(); … … 130 137 BEGIN_BLOCK_OBJC_EXCEPTIONS; 131 138 132 [argumentEncoder setBuffer:mtlBuffer offset:bufferBinding.offset atIndex: index];139 [argumentEncoder setBuffer:mtlBuffer offset:bufferBinding.offset atIndex:binding.binding]; 133 140 useResource(mtlBuffer, bufferRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite); 134 141 … … 138 145 } 139 146 140 void GPUProgrammablePassEncoder::setResourceAs TextureOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBindingResource& resource, unsigned index, const char*const functionName)147 void GPUProgrammablePassEncoder::setResourceAsSamplerOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBindGroupBinding& binding, const char *const functionName) 141 148 { 142 149 #if LOG_DISABLED … … 148 155 } 149 156 150 if (!WTF::holds_alternative<Ref<GPUTexture>>(resource)) { 151 LOG(WebGPU, "%s: Resource is not a texture type!", functionName); 152 return; 153 } 154 155 auto& textureRef = WTF::get<Ref<GPUTexture>>(resource); 157 if (!WTF::holds_alternative<Ref<GPUSampler>>(binding.resource)) { 158 LOG(WebGPU, "%s: Resource is not a GPUSampler!", functionName); 159 return; 160 } 161 162 auto& samplerRef = WTF::get<Ref<GPUSampler>>(binding.resource); 163 auto mtlSampler = samplerRef->platformSampler(); 164 165 if (!mtlSampler) { 166 LOG(WebGPU, "%s: Invalid MTLSamplerState in GPUSampler binding!", functionName); 167 return; 168 } 169 170 BEGIN_BLOCK_OBJC_EXCEPTIONS; 171 [argumentEncoder setSamplerState:mtlSampler atIndex:binding.binding]; 172 END_BLOCK_OBJC_EXCEPTIONS; 173 } 174 175 void GPUProgrammablePassEncoder::setResourceAsTextureOnEncoder(MTLArgumentEncoder *argumentEncoder, const GPUBindGroupBinding& binding, const char* const functionName) 176 { 177 #if LOG_DISABLED 178 UNUSED_PARAM(functionName); 179 #endif 180 if (!argumentEncoder) { 181 LOG(WebGPU, "%s: No argument encoder for requested stage found!", functionName); 182 return; 183 } 184 185 if (!WTF::holds_alternative<Ref<GPUTexture>>(binding.resource)) { 186 LOG(WebGPU, "%s: Resource is not a GPUTextureView!", functionName); 187 return; 188 } 189 190 auto& textureRef = WTF::get<Ref<GPUTexture>>(binding.resource); 156 191 auto mtlTexture = textureRef->platformTexture(); 157 192 … … 163 198 BEGIN_BLOCK_OBJC_EXCEPTIONS; 164 199 165 [argumentEncoder setTexture:mtlTexture atIndex: index];200 [argumentEncoder setTexture:mtlTexture atIndex:binding.binding]; 166 201 useResource(mtlTexture, textureRef->isReadOnly() ? MTLResourceUsageRead : MTLResourceUsageRead | MTLResourceUsageWrite); 167 202 -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm
r241310 r242615 30 30 31 31 #import "GPULimits.h" 32 #import "GPUUtils.h" 32 33 #import "Logging.h" 33 34 #import "WHLSLVertexBufferIndexCalculator.h" … … 38 39 namespace WebCore { 39 40 40 static Optional<MTLCompareFunction> validateAndConvertDepthCompareFunctionToMtl(GPUCompareFunction func)41 {42 switch (func) {43 case GPUCompareFunction::Never:44 return MTLCompareFunctionNever;45 case GPUCompareFunction::Less:46 return MTLCompareFunctionLess;47 case GPUCompareFunction::Equal:48 return MTLCompareFunctionEqual;49 case GPUCompareFunction::LessEqual:50 return MTLCompareFunctionLessEqual;51 case GPUCompareFunction::Greater:52 return MTLCompareFunctionGreater;53 case GPUCompareFunction::NotEqual:54 return MTLCompareFunctionNotEqual;55 case GPUCompareFunction::GreaterEqual:56 return MTLCompareFunctionGreaterEqual;57 case GPUCompareFunction::Always:58 return MTLCompareFunctionAlways;59 default:60 return WTF::nullopt;61 }62 }63 64 41 static RetainPtr<MTLDepthStencilState> tryCreateMtlDepthStencilState(const char* const functionName, const GPUDepthStencilStateDescriptor& descriptor, const GPUDevice& device) 65 42 { … … 80 57 } 81 58 82 auto mtlDepthCompare = validateAndConvertDepthCompareFunctionToMtl(descriptor.depthCompare); 83 if (!mtlDepthCompare) { 84 LOG(WebGPU, "%s: Invalid GPUCompareFunction in GPUDepthStencilStateDescriptor!", functionName); 85 return nullptr; 86 } 87 88 [mtlDescriptor setDepthCompareFunction:*mtlDepthCompare]; 59 auto mtlDepthCompare = static_cast<MTLCompareFunction>(platformCompareFunctionForGPUCompareFunction(descriptor.depthCompare)); 60 [mtlDescriptor setDepthCompareFunction:mtlDepthCompare]; 89 61 [mtlDescriptor setDepthWriteEnabled:descriptor.depthWriteEnabled]; 90 62 -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUUtilsMetal.mm
r241181 r242615 45 45 return MTLPixelFormatDepth32Float_Stencil8; 46 46 } 47 48 ASSERT_NOT_REACHED(); 49 } 50 51 PlatformCompareFunction platformCompareFunctionForGPUCompareFunction(GPUCompareFunction func) 52 { 53 switch (func) { 54 case GPUCompareFunction::Never: 55 return MTLCompareFunctionNever; 56 case GPUCompareFunction::Less: 57 return MTLCompareFunctionLess; 58 case GPUCompareFunction::Equal: 59 return MTLCompareFunctionEqual; 60 case GPUCompareFunction::LessEqual: 61 return MTLCompareFunctionLessEqual; 62 case GPUCompareFunction::Greater: 63 return MTLCompareFunctionGreater; 64 case GPUCompareFunction::NotEqual: 65 return MTLCompareFunctionNotEqual; 66 case GPUCompareFunction::GreaterEqual: 67 return MTLCompareFunctionGreaterEqual; 68 case GPUCompareFunction::Always: 69 return MTLCompareFunctionAlways; 70 } 71 72 ASSERT_NOT_REACHED(); 47 73 } 48 74
Note: See TracChangeset
for help on using the changeset viewer.