Remove blendEnabled in BlendStateDescriptor, in order to match web idl

BUG=dawn:32

Change-Id: I7225d919ca1a9c1c848050ad3b9e8832725f0af6
Reviewed-on: https://dawn-review.googlesource.com/c/4460
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/dawn.json b/dawn.json
index d978107..84c8dbe 100644
--- a/dawn.json
+++ b/dawn.json
@@ -124,7 +124,6 @@
         "category": "structure",
         "extensible": true,
         "members": [
-            {"name": "blend enabled", "type": "bool"},
             {"name": "alpha blend", "type": "blend descriptor"},
             {"name": "color blend", "type": "blend descriptor"},
             {"name": "color write mask", "type": "color write mask"}
diff --git a/examples/CHelloTriangle.cpp b/examples/CHelloTriangle.cpp
index d677305..ac6f99d 100644
--- a/examples/CHelloTriangle.cpp
+++ b/examples/CHelloTriangle.cpp
@@ -93,7 +93,6 @@
         blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE;
         dawnBlendStateDescriptor blendStateDescriptor;
         blendStateDescriptor.nextInChain = nullptr;
-        blendStateDescriptor.blendEnabled = false;
         blendStateDescriptor.alphaBlend = blendDescriptor;
         blendStateDescriptor.colorBlend = blendDescriptor;
         blendStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
diff --git a/src/dawn_native/RenderPipeline.cpp b/src/dawn_native/RenderPipeline.cpp
index 7eb1cd3..b760939 100644
--- a/src/dawn_native/RenderPipeline.cpp
+++ b/src/dawn_native/RenderPipeline.cpp
@@ -169,6 +169,15 @@
                mDepthStencilState->stencilFront.passOp != dawn::StencilOperation::Keep;
     }
 
+    bool BlendEnabled(const BlendStateDescriptor* mBlendState) {
+        return mBlendState->alphaBlend.operation != dawn::BlendOperation::Add ||
+               mBlendState->alphaBlend.srcFactor != dawn::BlendFactor::One ||
+               mBlendState->alphaBlend.dstFactor != dawn::BlendFactor::Zero ||
+               mBlendState->colorBlend.operation != dawn::BlendOperation::Add ||
+               mBlendState->colorBlend.srcFactor != dawn::BlendFactor::One ||
+               mBlendState->colorBlend.dstFactor != dawn::BlendFactor::Zero;
+    }
+
     // RenderPipelineBase
 
     RenderPipelineBase::RenderPipelineBase(DeviceBase* device,
diff --git a/src/dawn_native/RenderPipeline.h b/src/dawn_native/RenderPipeline.h
index 2ede129..03d7df8 100644
--- a/src/dawn_native/RenderPipeline.h
+++ b/src/dawn_native/RenderPipeline.h
@@ -30,6 +30,7 @@
     MaybeError ValidateRenderPipelineDescriptor(DeviceBase* device,
                                                 const RenderPipelineDescriptor* descriptor);
     bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState);
+    bool BlendEnabled(const BlendStateDescriptor* mBlendState);
 
     class RenderPipelineBase : public PipelineBase {
       public:
diff --git a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp
index 7d9c2d2..4b32915 100644
--- a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp
+++ b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp
@@ -129,7 +129,7 @@
 
         D3D12_RENDER_TARGET_BLEND_DESC ComputeBlendDesc(const BlendStateDescriptor* descriptor) {
             D3D12_RENDER_TARGET_BLEND_DESC blendDesc;
-            blendDesc.BlendEnable = descriptor->blendEnabled;
+            blendDesc.BlendEnable = BlendEnabled(descriptor);
             blendDesc.SrcBlend = D3D12Blend(descriptor->colorBlend.srcFactor);
             blendDesc.DestBlend = D3D12Blend(descriptor->colorBlend.dstFactor);
             blendDesc.BlendOp = D3D12BlendOperation(descriptor->colorBlend.operation);
diff --git a/src/dawn_native/metal/RenderPipelineMTL.mm b/src/dawn_native/metal/RenderPipelineMTL.mm
index 9b0ad31..4780e97 100644
--- a/src/dawn_native/metal/RenderPipelineMTL.mm
+++ b/src/dawn_native/metal/RenderPipelineMTL.mm
@@ -130,7 +130,7 @@
 
         void ComputeBlendDesc(MTLRenderPipelineColorAttachmentDescriptor* attachment,
                               const BlendStateDescriptor* descriptor) {
-            attachment.blendingEnabled = descriptor->blendEnabled;
+            attachment.blendingEnabled = BlendEnabled(descriptor);
             attachment.sourceRGBBlendFactor =
                 MetalBlendFactor(descriptor->colorBlend.srcFactor, false);
             attachment.destinationRGBBlendFactor =
diff --git a/src/dawn_native/opengl/RenderPipelineGL.cpp b/src/dawn_native/opengl/RenderPipelineGL.cpp
index 4e45099..a4214bd 100644
--- a/src/dawn_native/opengl/RenderPipelineGL.cpp
+++ b/src/dawn_native/opengl/RenderPipelineGL.cpp
@@ -91,7 +91,7 @@
         }
 
         void ApplyBlendState(uint32_t attachment, const BlendStateDescriptor* descriptor) {
-            if (descriptor->blendEnabled) {
+            if (BlendEnabled(descriptor)) {
                 glEnablei(GL_BLEND, attachment);
                 glBlendEquationSeparatei(attachment, GLBlendMode(descriptor->colorBlend.operation),
                                          GLBlendMode(descriptor->alphaBlend.operation));
diff --git a/src/dawn_native/vulkan/RenderPipelineVk.cpp b/src/dawn_native/vulkan/RenderPipelineVk.cpp
index 4390742..02f12fb 100644
--- a/src/dawn_native/vulkan/RenderPipelineVk.cpp
+++ b/src/dawn_native/vulkan/RenderPipelineVk.cpp
@@ -115,7 +115,7 @@
         VkPipelineColorBlendAttachmentState ComputeBlendDesc(
             const BlendStateDescriptor* descriptor) {
             VkPipelineColorBlendAttachmentState attachment;
-            attachment.blendEnable = descriptor->blendEnabled ? VK_TRUE : VK_FALSE;
+            attachment.blendEnable = BlendEnabled(descriptor) ? VK_TRUE : VK_FALSE;
             attachment.srcColorBlendFactor = VulkanBlendFactor(descriptor->colorBlend.srcFactor);
             attachment.dstColorBlendFactor = VulkanBlendFactor(descriptor->colorBlend.dstFactor);
             attachment.colorBlendOp = VulkanBlendOperation(descriptor->colorBlend.operation);
diff --git a/src/tests/end2end/BlendStateTests.cpp b/src/tests/end2end/BlendStateTests.cpp
index 059826b..9575cd7 100644
--- a/src/tests/end2end/BlendStateTests.cpp
+++ b/src/tests/end2end/BlendStateTests.cpp
@@ -136,7 +136,6 @@
             blend.dstFactor = dawn::BlendFactor::One;
 
             dawn::BlendStateDescriptor descriptor;
-            descriptor.blendEnabled = true;
             descriptor.alphaBlend = blend;
             descriptor.colorBlend = blend;
             descriptor.colorWriteMask = dawn::ColorWriteMask::All;
@@ -161,7 +160,6 @@
             alphaBlend.dstFactor = alphaDstFactor;
 
             dawn::BlendStateDescriptor descriptor;
-            descriptor.blendEnabled = true;
             descriptor.colorBlend = colorBlend;
             descriptor.alphaBlend = alphaBlend;
             descriptor.colorWriteMask = dawn::ColorWriteMask::All;
@@ -281,7 +279,6 @@
     blend.srcFactor = dawn::BlendFactor::One;
     blend.dstFactor = dawn::BlendFactor::Zero;
     dawn::BlendStateDescriptor descriptor;
-    descriptor.blendEnabled = false;
     descriptor.alphaBlend = blend;
     descriptor.colorBlend = blend;
     descriptor.colorWriteMask = dawn::ColorWriteMask::All;
@@ -637,7 +634,6 @@
     blend.dstFactor = dawn::BlendFactor::One;
 
     dawn::BlendStateDescriptor descriptor;
-    descriptor.blendEnabled = true;
     descriptor.colorBlend = blend;
     descriptor.alphaBlend = blend;
     {
@@ -687,7 +683,6 @@
         descriptor.alphaBlend = blend;
         descriptor.colorBlend = blend;
 
-        descriptor.blendEnabled = false;
         descriptor.colorWriteMask = dawn::ColorWriteMask::Red;
         SetupSingleSourcePipelines(descriptor);
 
@@ -799,15 +794,12 @@
     blend3.srcFactor = dawn::BlendFactor::One;
     blend3.dstFactor = dawn::BlendFactor::One;
 
-    testDescriptor.cBlendStates[0].blendEnabled = true;
     testDescriptor.cBlendStates[0].colorBlend = blend1;
     testDescriptor.cBlendStates[0].alphaBlend = blend1;
 
-    testDescriptor.cBlendStates[1].blendEnabled = true;
     testDescriptor.cBlendStates[1].colorBlend = blend2;
     testDescriptor.cBlendStates[1].alphaBlend = blend2;
 
-    testDescriptor.cBlendStates[3].blendEnabled = true;
     testDescriptor.cBlendStates[3].colorBlend = blend3;
     testDescriptor.cBlendStates[3].alphaBlend = blend3;
 
@@ -881,7 +873,6 @@
     blend.operation = dawn::BlendOperation::Add;
     blend.srcFactor = dawn::BlendFactor::BlendColor;
     blend.dstFactor = dawn::BlendFactor::One;
-    testDescriptor.cBlendStates[0].blendEnabled = true;
     testDescriptor.cBlendStates[0].colorBlend = blend;
     testDescriptor.cBlendStates[0].alphaBlend = blend;
 
diff --git a/src/tests/end2end/PushConstantTests.cpp b/src/tests/end2end/PushConstantTests.cpp
index 5d975ee..48f7ef3 100644
--- a/src/tests/end2end/PushConstantTests.cpp
+++ b/src/tests/end2end/PushConstantTests.cpp
@@ -195,7 +195,6 @@
             blend.operation = dawn::BlendOperation::Add;
             blend.srcFactor = dawn::BlendFactor::One;
             blend.dstFactor = dawn::BlendFactor::One;
-            descriptor.cBlendStates[0].blendEnabled = true;
             descriptor.cBlendStates[0].alphaBlend = blend;
             descriptor.cBlendStates[0].colorBlend = blend;
 
diff --git a/src/tests/unittests/WireTests.cpp b/src/tests/unittests/WireTests.cpp
index 72532b0..ccabc40 100644
--- a/src/tests/unittests/WireTests.cpp
+++ b/src/tests/unittests/WireTests.cpp
@@ -347,7 +347,6 @@
     blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE;
     dawnBlendStateDescriptor blendStateDescriptor;
     blendStateDescriptor.nextInChain = nullptr;
-    blendStateDescriptor.blendEnabled = false;
     blendStateDescriptor.alphaBlend = blendDescriptor;
     blendStateDescriptor.colorBlend = blendDescriptor;
     blendStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
diff --git a/src/utils/ComboRenderPipelineDescriptor.cpp b/src/utils/ComboRenderPipelineDescriptor.cpp
index 2feed48..0c8dfbb 100644
--- a/src/utils/ComboRenderPipelineDescriptor.cpp
+++ b/src/utils/ComboRenderPipelineDescriptor.cpp
@@ -61,7 +61,6 @@
             blend.srcFactor = dawn::BlendFactor::One;
             blend.dstFactor = dawn::BlendFactor::Zero;
             dawn::BlendStateDescriptor blendStateDescriptor;
-            blendStateDescriptor.blendEnabled = false;
             blendStateDescriptor.alphaBlend = blend;
             blendStateDescriptor.colorBlend = blend;
             blendStateDescriptor.colorWriteMask = dawn::ColorWriteMask::All;