Make setBlendColor take in a Color instead of 4 floats

BUG=

Change-Id: Ic70d5b664c0ea64c038129cdb83f4ba05fb61830
Reviewed-on: https://dawn-review.googlesource.com/c/4341
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Stephen White <senorblanco@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
diff --git a/dawn.json b/dawn.json
index 7a2ac55..d978107 100644
--- a/dawn.json
+++ b/dawn.json
@@ -815,10 +815,7 @@
             {
                 "name": "set blend color",
                 "args": [
-                    {"name": "r", "type": "float"},
-                    {"name": "g", "type": "float"},
-                    {"name": "b", "type": "float"},
-                    {"name": "a", "type": "float"}
+                    {"name": "color", "type": "color", "annotation": "const*"}
                 ]
             },
             {
diff --git a/src/dawn_native/Commands.h b/src/dawn_native/Commands.h
index 37b2297..cfb2a2c 100644
--- a/src/dawn_native/Commands.h
+++ b/src/dawn_native/Commands.h
@@ -134,7 +134,7 @@
     };
 
     struct SetBlendColorCmd {
-        float r, g, b, a;
+        Color color;
     };
 
     struct SetBindGroupCmd {
diff --git a/src/dawn_native/RenderPassEncoder.cpp b/src/dawn_native/RenderPassEncoder.cpp
index fc8891d..f48b053 100644
--- a/src/dawn_native/RenderPassEncoder.cpp
+++ b/src/dawn_native/RenderPassEncoder.cpp
@@ -90,17 +90,14 @@
         cmd->reference = reference;
     }
 
-    void RenderPassEncoderBase::SetBlendColor(float r, float g, float b, float a) {
+    void RenderPassEncoderBase::SetBlendColor(const Color* color) {
         if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
             return;
         }
 
         SetBlendColorCmd* cmd = mAllocator->Allocate<SetBlendColorCmd>(Command::SetBlendColor);
         new (cmd) SetBlendColorCmd;
-        cmd->r = r;
-        cmd->g = g;
-        cmd->b = b;
-        cmd->a = a;
+        cmd->color = *color;
     }
 
     void RenderPassEncoderBase::SetScissorRect(uint32_t x,
diff --git a/src/dawn_native/RenderPassEncoder.h b/src/dawn_native/RenderPassEncoder.h
index 49d77d4..3e7e415 100644
--- a/src/dawn_native/RenderPassEncoder.h
+++ b/src/dawn_native/RenderPassEncoder.h
@@ -43,7 +43,7 @@
         void SetPipeline(RenderPipelineBase* pipeline);
 
         void SetStencilReference(uint32_t reference);
-        void SetBlendColor(float r, float g, float b, float a);
+        void SetBlendColor(const Color* color);
         void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
 
         template <typename T>
diff --git a/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/src/dawn_native/d3d12/CommandBufferD3D12.cpp
index bff0a4d..c85c8ed 100644
--- a/src/dawn_native/d3d12/CommandBufferD3D12.cpp
+++ b/src/dawn_native/d3d12/CommandBufferD3D12.cpp
@@ -637,7 +637,7 @@
 
                 case Command::SetBlendColor: {
                     SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
-                    commandList->OMSetBlendFactor(static_cast<const FLOAT*>(&cmd->r));
+                    commandList->OMSetBlendFactor(static_cast<const FLOAT*>(&cmd->color.r));
                 } break;
 
                 case Command::SetBindGroup: {
diff --git a/src/dawn_native/metal/CommandBufferMTL.mm b/src/dawn_native/metal/CommandBufferMTL.mm
index 7fd8ad4..410875f 100644
--- a/src/dawn_native/metal/CommandBufferMTL.mm
+++ b/src/dawn_native/metal/CommandBufferMTL.mm
@@ -483,7 +483,10 @@
 
                 case Command::SetBlendColor: {
                     SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
-                    [encoder setBlendColorRed:cmd->r green:cmd->g blue:cmd->b alpha:cmd->a];
+                    [encoder setBlendColorRed:cmd->color.r
+                                        green:cmd->color.g
+                                         blue:cmd->color.b
+                                        alpha:cmd->color.a];
                 } break;
 
                 case Command::SetBindGroup: {
diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp
index d076185..e3d33f6 100644
--- a/src/dawn_native/opengl/CommandBufferGL.cpp
+++ b/src/dawn_native/opengl/CommandBufferGL.cpp
@@ -662,7 +662,7 @@
 
                 case Command::SetBlendColor: {
                     SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
-                    glBlendColor(cmd->r, cmd->g, cmd->b, cmd->a);
+                    glBlendColor(cmd->color.r, cmd->color.g, cmd->color.b, cmd->color.a);
                 } break;
 
                 case Command::SetBindGroup: {
diff --git a/src/dawn_native/vulkan/CommandBufferVk.cpp b/src/dawn_native/vulkan/CommandBufferVk.cpp
index 74e7964..13c818c 100644
--- a/src/dawn_native/vulkan/CommandBufferVk.cpp
+++ b/src/dawn_native/vulkan/CommandBufferVk.cpp
@@ -347,10 +347,10 @@
                 case Command::SetBlendColor: {
                     SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
                     float blendConstants[4] = {
-                        cmd->r,
-                        cmd->g,
-                        cmd->b,
-                        cmd->a,
+                        cmd->color.r,
+                        cmd->color.g,
+                        cmd->color.b,
+                        cmd->color.a,
                     };
                     device->fn.CmdSetBlendConstants(commands, blendConstants);
                 } break;
diff --git a/src/tests/end2end/BlendStateTests.cpp b/src/tests/end2end/BlendStateTests.cpp
index 510b9d0..059826b 100644
--- a/src/tests/end2end/BlendStateTests.cpp
+++ b/src/tests/end2end/BlendStateTests.cpp
@@ -104,6 +104,8 @@
 
         // Test that after drawing a triangle with the base color, and then the given triangle spec, the color is as expected
         void DoSingleSourceTest(RGBA8 base, const TriangleSpec& triangle, const RGBA8& expected) {
+            dawn::Color blendColor{triangle.blendFactor[0], triangle.blendFactor[1], triangle.blendFactor[2], triangle.blendFactor[3]};
+
             dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
             {
                 dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPassInfo);
@@ -115,7 +117,7 @@
                 // Then use the test pipeline to draw the test triangle with blending
                 pass.SetPipeline(testPipeline);
                 pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { triangle.color } })));
-                pass.SetBlendColor(triangle.blendFactor[0], triangle.blendFactor[1], triangle.blendFactor[2], triangle.blendFactor[3]);
+                pass.SetBlendColor(&blendColor);
                 pass.Draw(3, 1, 0, 0);
                 pass.EndPass();
             }
@@ -884,6 +886,7 @@
     testDescriptor.cBlendStates[0].alphaBlend = blend;
 
     testPipeline = device.CreateRenderPipeline(&testDescriptor);
+    constexpr dawn::Color kWhite{1.0f, 1.0f, 1.0f, 1.0f};
 
     // Check that the initial blend color is (0,0,0,0)
     {
@@ -914,7 +917,7 @@
             pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })));
             pass.Draw(3, 1, 0, 0);
             pass.SetPipeline(testPipeline);
-            pass.SetBlendColor(1, 1, 1, 1);
+            pass.SetBlendColor(&kWhite);
             pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(255, 255, 255, 255) } })));
             pass.Draw(3, 1, 0, 0);
             pass.EndPass();
@@ -935,7 +938,7 @@
             pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(0, 0, 0, 0) } })));
             pass.Draw(3, 1, 0, 0);
             pass.SetPipeline(testPipeline);
-            pass.SetBlendColor(1, 1, 1, 1);
+            pass.SetBlendColor(&kWhite);
             pass.SetBindGroup(0, MakeBindGroupForColors(std::array<RGBA8, 1>({ { RGBA8(255, 255, 255, 255) } })));
             pass.Draw(3, 1, 0, 0);
             pass.EndPass();
diff --git a/src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp b/src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp
index 4d1c1ef..b443960 100644
--- a/src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp
+++ b/src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp
@@ -68,7 +68,8 @@
     dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
     {
         dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
-        pass.SetBlendColor(0.0f, 0.0f, 0.0f, 0.0f);
+        constexpr dawn::Color kTransparentBlack{0.0f, 0.0f, 0.0f, 0.0f};
+        pass.SetBlendColor(&kTransparentBlack);
         pass.EndPass();
     }
     builder.GetResult();
@@ -81,7 +82,8 @@
     dawn::CommandBufferBuilder builder = AssertWillBeSuccess(device.CreateCommandBufferBuilder());
     {
         dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass.renderPass);
-        pass.SetBlendColor(-1.0f, 42.0f, -0.0f, 0.0f);
+        constexpr dawn::Color kAnyColorValue{-1.0f, 42.0f, -0.0f, 0.0f};
+        pass.SetBlendColor(&kAnyColorValue);
         pass.EndPass();
     }
     builder.GetResult();
@@ -90,7 +92,7 @@
 class SetStencilReferenceTest : public ValidationTest {
 };
 
-// Test to check basic use of SetBlendColor
+// Test to check basic use of SetStencilReferenceTest
 TEST_F(SetStencilReferenceTest, Success) {
     DummyRenderPass renderPass = CreateDummyRenderPass();