Changeset 243755 in webkit
- Timestamp:
- Apr 2, 2019, 12:59:55 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 20 edited
- 4 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/webgpu/blend-triangle-strip-expected.html (added)
-
LayoutTests/webgpu/blend-triangle-strip.html (added)
-
LayoutTests/webgpu/buffer-command-buffer-races.html (modified) (1 diff)
-
LayoutTests/webgpu/buffer-resource-triangles.html (modified) (1 diff)
-
LayoutTests/webgpu/color-write-mask-triangle-strip-expected.html (added)
-
LayoutTests/webgpu/color-write-mask-triangle-strip.html (added)
-
LayoutTests/webgpu/depth-enabled-triangle-strip.html (modified) (1 diff)
-
LayoutTests/webgpu/js/webgpu-functions.js (modified) (3 diffs)
-
LayoutTests/webgpu/render-pipelines.html (modified) (1 diff)
-
LayoutTests/webgpu/texture-triangle-strip.html (modified) (1 diff)
-
LayoutTests/webgpu/vertex-buffer-triangle-strip.html (modified) (1 diff)
-
LayoutTests/webgpu/whlsl.html (modified) (1 diff)
-
Source/WebCore/CMakeLists.txt (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/DerivedSources-input.xcfilelist (modified) (2 diffs)
-
Source/WebCore/DerivedSources-output.xcfilelist (modified) (2 diffs)
-
Source/WebCore/DerivedSources.make (modified) (1 diff)
-
Source/WebCore/Modules/webgpu/GPUBlendDescriptor.idl (copied) (copied from trunk/Source/WebCore/Modules/webgpu/GPUColorStateDescriptor.idl ) (1 diff)
-
Source/WebCore/Modules/webgpu/GPUColorStateDescriptor.idl (modified) (2 diffs)
-
Source/WebCore/Modules/webgpu/GPUColorWriteBits.idl (copied) (copied from trunk/Source/WebCore/Modules/webgpu/GPUColorStateDescriptor.idl ) (1 diff)
-
Source/WebCore/Sources.txt (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (5 diffs)
-
Source/WebCore/bindings/js/WebCoreBuiltinNames.h (modified) (1 diff)
-
Source/WebCore/platform/graphics/gpu/GPUBlendDescriptor.h (copied) (copied from trunk/Source/WebCore/platform/graphics/gpu/GPUColorStateDescriptor.h ) (1 diff)
-
Source/WebCore/platform/graphics/gpu/GPUColorStateDescriptor.h (modified) (2 diffs)
-
Source/WebCore/platform/graphics/gpu/GPUColorWriteBits.h (copied) (copied from trunk/Source/WebCore/platform/graphics/gpu/GPUColorStateDescriptor.h ) (1 diff)
-
Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243752 r243755 1 2019-04-02 Justin Fan <justin_fan@apple.com> 2 3 [Web GPU] Implement blend states and color write mask for GPUColorStateDescriptor 4 https://bugs.webkit.org/show_bug.cgi?id=196474 5 6 Reviewed by Myles C. Maxfield. 7 8 Add blend-triangle-strip to test color blending and color-write-mask-triangle-strip.html to test color write mask. 9 Update other tests to specify blend states when creating a GPURenderPipeline. 10 11 * webgpu/blend-triangle-strip-expected.html: Added. 12 * webgpu/blend-triangle-strip.html: Added. 13 * webgpu/buffer-command-buffer-races.html: 14 * webgpu/buffer-resource-triangles.html: 15 * webgpu/color-write-mask-triangle-strip-expected.html: Added. 16 * webgpu/color-write-mask-triangle-strip.html: Added. 17 * webgpu/depth-enabled-triangle-strip.html: 18 * webgpu/js/webgpu-functions.js: 19 * webgpu/render-pipelines.html: 20 * webgpu/texture-triangle-strip.html: 21 * webgpu/vertex-buffer-triangle-strip.html: 22 * webgpu/whlsl.html: 23 1 24 2019-04-02 Zalan Bujtas <zalan@apple.com> 2 25 -
trunk/LayoutTests/webgpu/buffer-command-buffer-races.html
r243089 r243755 93 93 const shaderModule = device.createShaderModule({ code: shaderCode }); 94 94 const inputStateDescriptor = createInputStateDescriptor(); 95 const pipeline = createBasicPipeline(shaderModule, device, null, inputStateDescriptor);95 const pipeline = createBasicPipeline(shaderModule, device, null, null, inputStateDescriptor); 96 96 97 97 const upperLeftBuffer = createAndSetVertexBuffer(device, [-1, 1, -1, -1, 0, 1]); -
trunk/LayoutTests/webgpu/buffer-resource-triangles.html
r242974 r243755 166 166 // WebGPUPipelineLayout and WebGPURenderPipeline 167 167 const pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [leftTriangleBGLayout, rightTriangleBGLayout] }); 168 const pipeline = createBasicPipeline(shaderModule, device, pipelineLayout, inputState, null, "triangle-list");168 const pipeline = createBasicPipeline(shaderModule, device, null, pipelineLayout, inputState, null, "triangle-list"); 169 169 170 170 // WebGPUBufferBindings -
trunk/LayoutTests/webgpu/depth-enabled-triangle-strip.html
r243089 r243755 89 89 const inputStateDescriptor = createInputStateDescriptor(); 90 90 const depthStateDescriptor = createBasicDepthStateDescriptor(); 91 const pipeline = createBasicPipeline(shaderModule, device, null, inputStateDescriptor, depthStateDescriptor);91 const pipeline = createBasicPipeline(shaderModule, device, null, null, inputStateDescriptor, depthStateDescriptor); 92 92 const commandEncoder = device.createCommandEncoder(); 93 93 -
trunk/LayoutTests/webgpu/js/webgpu-functions.js
r243090 r243755 35 35 } 36 36 37 function createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDescriptor, depthStateDescriptor, primitiveTopology = "triangle-strip") {37 function createBasicPipeline(shaderModule, device, colorStates, pipelineLayout, inputStateDescriptor, depthStateDescriptor, primitiveTopology = "triangle-strip") { 38 38 const vertexStageDescriptor = { 39 39 module: shaderModule, … … 46 46 }; 47 47 48 const basicColorState = { format: "bgra8unorm" }; 48 if (!colorStates) { 49 colorStates = [{ 50 format: "bgra8unorm", 51 alphaBlend: { 52 srcFactor: "one", 53 dstFactor: "zero", 54 operation: "add" 55 }, 56 colorBlend: { 57 srcFactor: "one", 58 dstFactor: "zero", 59 operation: "add" 60 }, 61 writeMask: GPUColorWriteBits.ALL 62 }]; 63 } 49 64 50 65 const pipelineDescriptor = { … … 52 67 fragmentStage: fragmentStageDescriptor, 53 68 primitiveTopology: primitiveTopology, 54 colorStates: [basicColorState]69 colorStates: colorStates 55 70 }; 56 71 -
trunk/LayoutTests/webgpu/render-pipelines.html
r243456 r243755 48 48 const pipelineLayout = device.createPipelineLayout({ bindGroupLayouts: [bindGroupLayout] }); 49 49 50 const pipeline = createBasicPipeline(shaderModule, device, pipelineLayout);50 const pipeline = createBasicPipeline(shaderModule, device, null, pipelineLayout); 51 51 assert_true(pipeline instanceof WebGPURenderPipeline, "Successfully created WebGPURenderPipeline"); 52 52 }, "Create basic WebGPURenderPipeline"); -
trunk/LayoutTests/webgpu/texture-triangle-strip.html
r243089 r243755 186 186 187 187 // Pipeline and render 188 const pipeline = createBasicPipeline(shaderModule, device, pipelineLayout, inputStateDescriptor);188 const pipeline = createBasicPipeline(shaderModule, device, null, pipelineLayout, inputStateDescriptor); 189 189 const commandEncoder = device.createCommandEncoder(); 190 190 -
trunk/LayoutTests/webgpu/vertex-buffer-triangle-strip.html
r242974 r243755 91 91 const vertexBuffer = createVertexBuffer(device); 92 92 const inputStateDescriptor = createInputStateDescriptor(); 93 const pipeline = createBasicPipeline(shaderModule, device, null, inputStateDescriptor);93 const pipeline = createBasicPipeline(shaderModule, device, null, null, inputStateDescriptor); 94 94 const commandEncoder = device.createCommandEncoder(); 95 95 const passEncoder = beginBasicRenderPass(swapChain, commandEncoder); -
trunk/LayoutTests/webgpu/whlsl.html
r243627 r243755 24 24 const primitiveTopology = "triangle-strip"; 25 25 const rasterizationState = {frontFace: "cw", cullMode: "none"}; 26 const alphaBlend = {srcFactor: " zero", dstFactor: "one", operation: "add"};27 const colorBlend = {srcFactor: " zero", dstFactor: "one", operation: "add"};26 const alphaBlend = {srcFactor: "one", dstFactor: "zero", operation: "add"}; 27 const colorBlend = {srcFactor: "one", dstFactor: "zero", operation: "add"}; 28 28 const colorStates = [{format: "rgba8unorm", alphaBlend, colorBlend, writeMask: 15}]; // GPUColorWriteBits.ALL 29 29 const depthStencilState = null; -
trunk/Source/WebCore/CMakeLists.txt
r243666 r243755 466 466 Modules/webgpu/GPUBindGroupLayoutBinding.idl 467 467 Modules/webgpu/GPUBindGroupLayoutDescriptor.idl 468 Modules/webgpu/GPUBlendDescriptor.idl 468 469 Modules/webgpu/GPUBufferDescriptor.idl 469 470 Modules/webgpu/GPUBufferUsage.idl … … 471 472 Modules/webgpu/GPUColor.idl 472 473 Modules/webgpu/GPUColorStateDescriptor.idl 474 Modules/webgpu/GPUColorWriteBits.idl 473 475 Modules/webgpu/GPUCompareFunction.idl 474 476 Modules/webgpu/GPUDepthStencilStateDescriptor.idl -
trunk/Source/WebCore/ChangeLog
r243752 r243755 1 2019-04-02 Justin Fan <justin_fan@apple.com> 2 3 [Web GPU] Implement blend states and color write mask for GPUColorStateDescriptor 4 https://bugs.webkit.org/show_bug.cgi?id=196474 5 6 Reviewed by Myles C. Maxfield. 7 8 Blend states and color write masks must now be specified on GPUColorStateDescriptor instead of 9 relying on underlying MTLRenderPipelineColorAttachmentDescriptor defaults. 10 11 Test: webgpu/blend-triangle-strip.html, webgpu/color-write-mask-triangle-strip.html 12 13 * CMakeLists.txt: 14 * DerivedSources-input.xcfilelist: 15 * DerivedSources-output.xcfilelist: 16 * DerivedSources.make: 17 * Modules/webgpu/GPUBlendDescriptor.idl: 18 * Modules/webgpu/GPUColorStateDescriptor.idl: 19 * Modules/webgpu/GPUColorWriteBits.idl: 20 * Sources.txt: 21 * WebCore.xcodeproj/project.pbxproj: 22 * bindings/js/WebCoreBuiltinNames.h: 23 * platform/graphics/gpu/GPUBlendDescriptor.h: 24 * platform/graphics/gpu/GPUColorStateDescriptor.h: 25 * platform/graphics/gpu/GPUColorWriteBits.h: 26 * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm: 27 (WebCore::mtlColorWriteMaskForGPUColorWriteFlags): 28 (WebCore::mtlBlendOperationForGPUBlendOperation): 29 (WebCore::mtlBlendFactorForGPUBlendFactor): 30 (WebCore::setColorStatesForColorAttachmentArray): 31 (WebCore::tryCreateMtlRenderPipelineState): 32 (WebCore::trySetColorStatesForColorAttachmentArray): Deleted. 33 1 34 2019-04-02 Zalan Bujtas <zalan@apple.com> 2 35 -
trunk/Source/WebCore/DerivedSources-input.xcfilelist
r243666 r243755 331 331 $(PROJECT_DIR)/Modules/webgpu/GPUBindGroupLayoutBinding.idl 332 332 $(PROJECT_DIR)/Modules/webgpu/GPUBindGroupLayoutDescriptor.idl 333 $(PROJECT_DIR)/Modules/webgpu/GPUBlendDescriptor.idl 333 334 $(PROJECT_DIR)/Modules/webgpu/GPUBufferDescriptor.idl 334 335 $(PROJECT_DIR)/Modules/webgpu/GPUBufferUsage.idl … … 336 337 $(PROJECT_DIR)/Modules/webgpu/GPUColor.idl 337 338 $(PROJECT_DIR)/Modules/webgpu/GPUColorStateDescriptor.idl 339 $(PROJECT_DIR)/Modules/webgpu/GPUColorWriteBits.idl 338 340 $(PROJECT_DIR)/Modules/webgpu/GPUCompareFunction.idl 339 341 $(PROJECT_DIR)/Modules/webgpu/GPUDepthStencilStateDescriptor.idl -
trunk/Source/WebCore/DerivedSources-output.xcfilelist
r243666 r243755 588 588 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUBindGroupLayoutDescriptor.cpp 589 589 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUBindGroupLayoutDescriptor.h 590 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUBlendDescriptor.cpp 591 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUBlendDescriptor.h 590 592 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUBufferDescriptor.cpp 591 593 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUBufferDescriptor.h … … 598 600 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColorStateDescriptor.cpp 599 601 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColorStateDescriptor.h 602 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColorWriteBits.cpp 603 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUColorWriteBits.h 600 604 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUCompareFunction.cpp 601 605 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSGPUCompareFunction.h -
trunk/Source/WebCore/DerivedSources.make
r243666 r243755 379 379 $(WebCore)/Modules/webgpu/GPUColor.idl \ 380 380 $(WebCore)/Modules/webgpu/GPUColorStateDescriptor.idl \ 381 $(WebCore)/Modules/webgpu/GPUColorWriteBits.idl \ 381 382 $(WebCore)/Modules/webgpu/GPUBindGroupLayoutBinding.idl \ 382 383 $(WebCore)/Modules/webgpu/GPUBindGroupLayoutDescriptor.idl \ 384 $(WebCore)/Modules/webgpu/GPUBlendDescriptor.idl \ 383 385 $(WebCore)/Modules/webgpu/GPUBufferDescriptor.idl \ 384 386 $(WebCore)/Modules/webgpu/GPUBufferUsage.idl \ -
trunk/Source/WebCore/Modules/webgpu/GPUBlendDescriptor.idl
r243754 r243755 26 26 27 27 [ 28 ImplementedAs=GPUBlendFactor 29 ] enum GPUBlendFactor { 30 "zero", 31 "one", 32 "src-color", 33 "one-minus-src-color", 34 "src-alpha", 35 "one-minus-src-alpha", 36 "dst-color", 37 "one-minus-dst-color", 38 "dst-alpha", 39 "one-minus-dst-alpha", 40 "src-alpha-saturated", 41 "blend-color", 42 "one-minus-blend-color" 43 }; 44 45 [ 46 ImplementedAs=GPUBlendOperation 47 ] enum GPUBlendOperation { 48 "add", 49 "subtract", 50 "reverse-subtract", 51 "min", 52 "max" 53 }; 54 55 [ 28 56 Conditional=WEBGPU, 29 57 EnabledAtRuntime=WebGPU 30 ] dictionary GPUColorStateDescriptor { 31 GPUTextureFormat format; 32 33 // Not yet implemented. 34 // GPUBlendDescriptor alphaBlend; 35 // GPUBlendDescriptor colorBlend; 36 // GPUColorWriteFlags writeMask; 58 ] dictionary GPUBlendDescriptor { 59 GPUBlendFactor srcFactor; 60 GPUBlendFactor dstFactor; 61 GPUBlendOperation operation; 37 62 }; -
trunk/Source/WebCore/Modules/webgpu/GPUColorStateDescriptor.idl
r242839 r243755 25 25 // https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl 26 26 27 typedef unsigned long GPUColorWriteFlags; 28 27 29 [ 28 30 Conditional=WEBGPU, … … 31 33 GPUTextureFormat format; 32 34 33 // Not yet implemented. 34 // GPUBlendDescriptor alphaBlend; 35 // GPUBlendDescriptor colorBlend; 36 // GPUColorWriteFlags writeMask; 35 GPUBlendDescriptor alphaBlend; 36 GPUBlendDescriptor colorBlend; 37 GPUColorWriteFlags writeMask; 37 38 }; -
trunk/Source/WebCore/Modules/webgpu/GPUColorWriteBits.idl
r243754 r243755 25 25 // https://github.com/gpuweb/gpuweb/blob/master/design/sketch.webidl 26 26 27 typedef unsigned long u32; 28 27 29 [ 28 30 Conditional=WEBGPU, 29 EnabledAtRuntime=WebGPU 30 ] dictionary GPUColorStateDescriptor { 31 GPUTextureFormat format; 32 33 // Not yet implemented. 34 // GPUBlendDescriptor alphaBlend; 35 // GPUBlendDescriptor colorBlend; 36 // GPUColorWriteFlags writeMask; 31 DoNotCheckConstants, 32 EnabledAtRuntime=WebGPU, 33 ImplementationLacksVTable 34 ] interface GPUColorWriteBits { 35 const u32 NONE = 0; 36 const u32 RED = 1; 37 const u32 GREEN = 2; 38 const u32 BLUE = 4; 39 const u32 ALPHA = 8; 40 const u32 ALL = 15; 37 41 }; -
trunk/Source/WebCore/Sources.txt
r243730 r243755 2721 2721 JSGPUColor.cpp 2722 2722 JSGPUColorStateDescriptor.cpp 2723 JSGPUColorWriteBits.cpp 2723 2724 JSGPUBindGroupLayoutBinding.cpp 2724 2725 JSGPUBindGroupLayoutDescriptor.cpp 2726 JSGPUBlendDescriptor.cpp 2725 2727 JSGPUBufferDescriptor.cpp 2726 2728 JSGPUBufferUsage.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r243730 r243755 13958 13958 D0B0556609C6700100307E43 /* CreateLinkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CreateLinkCommand.h; sourceTree = "<group>"; }; 13959 13959 D0B0556709C6700100307E43 /* CreateLinkCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CreateLinkCommand.cpp; sourceTree = "<group>"; }; 13960 D0B56EAA224EC6240061049C /* GPUBlendDescriptor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBlendDescriptor.h; sourceTree = "<group>"; }; 13961 D0B56EAB224EC6240061049C /* GPUBlendDescriptor.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUBlendDescriptor.idl; sourceTree = "<group>"; }; 13962 D0B56EAD224ECE200061049C /* GPUColorWriteBits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUColorWriteBits.h; sourceTree = "<group>"; }; 13963 D0B56EAE224ECE200061049C /* GPUColorWriteBits.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = GPUColorWriteBits.idl; sourceTree = "<group>"; }; 13960 13964 D0B8BB0121C46E78000C7681 /* GPUBindGroupLayoutBinding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GPUBindGroupLayoutBinding.h; sourceTree = "<group>"; }; 13961 13965 D0BC54481443AC4A00E105DA /* CachedStyleSheetClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedStyleSheetClient.h; sourceTree = "<group>"; }; … … 18214 18218 D0BE105121E6A70E00E42A89 /* GPUBindGroupDescriptor.h */, 18215 18219 D02454D021C4A41C00B73628 /* GPUBindGroupLayout.h */, 18220 D0B56EAA224EC6240061049C /* GPUBlendDescriptor.h */, 18216 18221 D084033A221CBF5400007205 /* GPUBuffer.cpp */, 18217 18222 D0D8649221B760F2003C983C /* GPUBuffer.h */, … … 18221 18226 D001D9AB21B0C7BF0023B9BC /* GPUColor.h */, 18222 18227 D0ADB28B2237842E00A22935 /* GPUColorStateDescriptor.h */, 18228 D0B56EAD224ECE200061049C /* GPUColorWriteBits.h */, 18223 18229 312FF8BD21A4C2F100EB199D /* GPUCommandBuffer.h */, 18224 18230 D03C849C21FFC7FC0002227F /* GPUCompareFunction.h */, … … 25779 25785 D0D69C9C222E00C20032927E /* GPUBindGroupLayoutDescriptor.h */, 25780 25786 D0D69C9D222E00C20032927E /* GPUBindGroupLayoutDescriptor.idl */, 25787 D0B56EAB224EC6240061049C /* GPUBlendDescriptor.idl */, 25781 25788 D01B811922135EB900627B6C /* GPUBufferDescriptor.idl */, 25782 25789 D01B811C2213627300627B6C /* GPUBufferUsage.idl */, … … 25786 25793 D01B811222125AFC00627B6C /* GPUColor.idl */, 25787 25794 D0ADB28C2237842E00A22935 /* GPUColorStateDescriptor.idl */, 25795 D0B56EAE224ECE200061049C /* GPUColorWriteBits.idl */, 25788 25796 D03C849E21FFCF000002227F /* GPUCompareFunction.idl */, 25789 25797 D03C84A221FFD7230002227F /* GPUDepthStencilStateDescriptor.idl */, -
trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h
r243666 r243755 84 84 macro(GPUBufferUsage) \ 85 85 macro(GPUCanvasContext) \ 86 macro(GPU ShaderModule) \86 macro(GPUColorWriteBits) \ 87 87 macro(GPUCommandBuffer) \ 88 88 macro(GPUCommandEncoder) \ 89 89 macro(GPUComputePassEncoder) \ 90 90 macro(GPUComputePipeline) \ 91 macro(GPUShaderModule) \ 91 92 macro(GPUShaderStageBit) \ 92 93 macro(GPUSwapChain) \ -
trunk/Source/WebCore/platform/graphics/gpu/GPUBlendDescriptor.h
r243754 r243755 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUTextureFormat.h"31 32 30 namespace WebCore { 33 31 34 struct GPUColorStateDescriptor { 35 GPUTextureFormat format; 32 enum class GPUBlendFactor { 33 Zero, 34 One, 35 SrcColor, 36 OneMinusSrcColor, 37 SrcAlpha, 38 OneMinusSrcAlpha, 39 DstColor, 40 OneMinusDstColor, 41 DstAlpha, 42 OneMinusDstAlpha, 43 SrcAlphaSaturated, 44 BlendColor, 45 OneMinusBlendColor, 46 }; 47 48 enum class GPUBlendOperation { 49 Add, 50 Subtract, 51 ReverseSubtract, 52 Min, 53 Max, 54 }; 55 56 struct GPUBlendDescriptor { 57 GPUBlendFactor srcFactor; 58 GPUBlendFactor dstFactor; 59 GPUBlendOperation operation; 36 60 }; 37 61 -
trunk/Source/WebCore/platform/graphics/gpu/GPUColorStateDescriptor.h
r242839 r243755 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUBlendDescriptor.h" 31 #include "GPUColorWriteBits.h" 30 32 #include "GPUTextureFormat.h" 31 33 … … 34 36 struct GPUColorStateDescriptor { 35 37 GPUTextureFormat format; 38 39 GPUBlendDescriptor alphaBlend; 40 GPUBlendDescriptor colorBlend; 41 GPUColorWriteFlags writeMask; 36 42 }; 37 43 -
trunk/Source/WebCore/platform/graphics/gpu/GPUColorWriteBits.h
r243754 r243755 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUTextureFormat.h"30 #include <wtf/RefCounted.h> 31 31 32 32 namespace WebCore { 33 33 34 struct GPUColorStateDescriptor { 35 GPUTextureFormat format; 34 using GPUColorWriteFlags = unsigned; 35 36 class GPUColorWriteBits : public RefCounted<GPUColorWriteBits> { 37 public: 38 enum class Flags : GPUColorWriteFlags { 39 None = 0, 40 Red = 1 << 0, 41 Green = 1 << 1, 42 Blue = 1 << 2, 43 Alpha = 1 << 3, 44 All = (1 << 4) - 1, 45 }; 36 46 }; 37 47 -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm
r243636 r243755 37 37 #import <Metal/Metal.h> 38 38 #import <wtf/BlockObjCExceptions.h> 39 #import <wtf/OptionSet.h> 39 40 #import <wtf/Optional.h> 40 41 … … 368 369 } 369 370 370 static bool trySetColorStatesForColorAttachmentArray(MTLRenderPipelineColorAttachmentDescriptorArray* array, const Vector<GPUColorStateDescriptor>& colorStates) 371 { 372 // FIXME: Implement and validate the rest of GPUColorStateDescriptor. 373 for (unsigned i = 0; i < colorStates.size(); ++i) 374 [array[i] setPixelFormat:static_cast<MTLPixelFormat>(platformTextureFormatForGPUTextureFormat(colorStates[i].format))]; 375 376 return true; 371 static MTLColorWriteMask mtlColorWriteMaskForGPUColorWriteFlags(GPUColorWriteFlags flags) 372 { 373 if (flags == static_cast<GPUColorWriteFlags>(GPUColorWriteBits::Flags::All)) 374 return MTLColorWriteMaskAll; 375 376 auto options = OptionSet<GPUColorWriteBits::Flags>::fromRaw(flags); 377 378 MTLColorWriteMask mask = MTLColorWriteMaskNone; 379 if (options & GPUColorWriteBits::Flags::Red) 380 mask |= MTLColorWriteMaskRed; 381 if (options & GPUColorWriteBits::Flags::Green) 382 mask |= MTLColorWriteMaskGreen; 383 if (options & GPUColorWriteBits::Flags::Blue) 384 mask |= MTLColorWriteMaskBlue; 385 if (options & GPUColorWriteBits::Flags::Alpha) 386 mask |= MTLColorWriteMaskAlpha; 387 388 return mask; 389 } 390 391 static MTLBlendOperation mtlBlendOperationForGPUBlendOperation(GPUBlendOperation op) 392 { 393 switch (op) { 394 case GPUBlendOperation::Add: 395 return MTLBlendOperationAdd; 396 case GPUBlendOperation::Subtract: 397 return MTLBlendOperationSubtract; 398 case GPUBlendOperation::ReverseSubtract: 399 return MTLBlendOperationReverseSubtract; 400 case GPUBlendOperation::Min: 401 return MTLBlendOperationMin; 402 case GPUBlendOperation::Max: 403 return MTLBlendOperationMax; 404 } 405 406 ASSERT_NOT_REACHED(); 407 } 408 409 static MTLBlendFactor mtlBlendFactorForGPUBlendFactor(GPUBlendFactor factor) 410 { 411 switch (factor) { 412 case GPUBlendFactor::Zero: 413 return MTLBlendFactorZero; 414 case GPUBlendFactor::One: 415 return MTLBlendFactorOne; 416 case GPUBlendFactor::SrcColor: 417 return MTLBlendFactorSourceColor; 418 case GPUBlendFactor::OneMinusSrcColor: 419 return MTLBlendFactorOneMinusSourceColor; 420 case GPUBlendFactor::SrcAlpha: 421 return MTLBlendFactorSourceAlpha; 422 case GPUBlendFactor::OneMinusSrcAlpha: 423 return MTLBlendFactorOneMinusSourceAlpha; 424 case GPUBlendFactor::DstColor: 425 return MTLBlendFactorDestinationColor; 426 case GPUBlendFactor::OneMinusDstColor: 427 return MTLBlendFactorOneMinusDestinationColor; 428 case GPUBlendFactor::DstAlpha: 429 return MTLBlendFactorDestinationAlpha; 430 case GPUBlendFactor::OneMinusDstAlpha: 431 return MTLBlendFactorOneMinusDestinationAlpha; 432 case GPUBlendFactor::SrcAlphaSaturated: 433 return MTLBlendFactorSourceAlpha; 434 case GPUBlendFactor::BlendColor: 435 return MTLBlendFactorBlendColor; 436 case GPUBlendFactor::OneMinusBlendColor: 437 return MTLBlendFactorOneMinusBlendColor; 438 } 439 440 ASSERT_NOT_REACHED(); 441 } 442 443 static void setColorStatesForColorAttachmentArray(MTLRenderPipelineColorAttachmentDescriptorArray* array, const Vector<GPUColorStateDescriptor>& colorStates) 444 { 445 for (unsigned i = 0; i < colorStates.size(); ++i) { 446 auto& state = colorStates[i]; 447 auto descriptor = retainPtr([array objectAtIndexedSubscript:i]); 448 [descriptor setPixelFormat:static_cast<MTLPixelFormat>(platformTextureFormatForGPUTextureFormat(state.format))]; 449 [descriptor setWriteMask:mtlColorWriteMaskForGPUColorWriteFlags(state.writeMask)]; 450 [descriptor setBlendingEnabled:YES]; 451 [descriptor setAlphaBlendOperation:mtlBlendOperationForGPUBlendOperation(state.alphaBlend.operation)]; 452 [descriptor setRgbBlendOperation:mtlBlendOperationForGPUBlendOperation(state.colorBlend.operation)]; 453 [descriptor setDestinationAlphaBlendFactor:mtlBlendFactorForGPUBlendFactor(state.alphaBlend.dstFactor)]; 454 [descriptor setDestinationRGBBlendFactor:mtlBlendFactorForGPUBlendFactor(state.colorBlend.dstFactor)]; 455 [descriptor setSourceAlphaBlendFactor:mtlBlendFactorForGPUBlendFactor(state.alphaBlend.srcFactor)]; 456 [descriptor setSourceRGBBlendFactor:mtlBlendFactorForGPUBlendFactor(state.colorBlend.srcFactor)]; 457 } 377 458 } 378 459 … … 392 473 } 393 474 394 bool didSetFunctions = false, didSetInputState = false , didSetColorStates = false;475 bool didSetFunctions = false, didSetInputState = false; 395 476 396 477 BEGIN_BLOCK_OBJC_EXCEPTIONS; … … 398 479 didSetFunctions = trySetFunctionsForPipelineDescriptor(functionName, mtlDescriptor.get(), descriptor, device); 399 480 didSetInputState = trySetInputStateForPipelineDescriptor(functionName, mtlDescriptor.get(), descriptor.inputState); 400 didSetColorStates = trySetColorStatesForColorAttachmentArray(mtlDescriptor.get().colorAttachments, descriptor.colorStates);481 setColorStatesForColorAttachmentArray(mtlDescriptor.get().colorAttachments, descriptor.colorStates); 401 482 402 483 END_BLOCK_OBJC_EXCEPTIONS; 403 484 404 if (!didSetFunctions || !didSetInputState || !didSetColorStates)485 if (!didSetFunctions || !didSetInputState) 405 486 return nullptr; 406 487
Note:
See TracChangeset
for help on using the changeset viewer.