Fix color blend state handling for multiple attachments

This was masked by the incorrect assert -- we did the wrong thing in MRT
cases, but the assert intended to protect us would only fire if logic
ops were also enabled.

Fix this properly. We still only have one shared set of blend state, but
each attachment has its masks set now.

Some of the tests exercising this are dubious on a device which doesn't
support independent blending -- the color write masks are technically
part of the state which must be the same across all attachments.

Bug: b/132433217
Test: dEQP-VK.renderpass.*
Change-Id: Ia22f9cbf156a9f3c24d47142211bde67f06a0d46
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/31350
Tested-by: Chris Forbes <chrisforbes@google.com>
Presubmit-Ready: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Vulkan/VkPipeline.cpp b/src/Vulkan/VkPipeline.cpp
index 597002d..3d9040c 100644
--- a/src/Vulkan/VkPipeline.cpp
+++ b/src/Vulkan/VkPipeline.cpp
@@ -398,8 +398,7 @@
 	if(colorBlendState)
 	{
 		if((colorBlendState->flags != 0) ||
-		   ((colorBlendState->logicOpEnable != 0) &&
-			(colorBlendState->attachmentCount > 1)))
+		   ((colorBlendState->logicOpEnable != 0)))
 		{
 			UNIMPLEMENTED("colorBlendState");
 		}
@@ -412,10 +411,15 @@
 			blendConstants.a = colorBlendState->blendConstants[3];
 		}
 
-		if(colorBlendState->attachmentCount == 1)
+		for (auto i = 0u; i < colorBlendState->attachmentCount; i++)
+		{
+			const VkPipelineColorBlendAttachmentState& attachment = colorBlendState->pAttachments[i];
+			context.setColorWriteMask(i, attachment.colorWriteMask);
+		}
+
+		if(colorBlendState->attachmentCount > 0)
 		{
 			const VkPipelineColorBlendAttachmentState& attachment = colorBlendState->pAttachments[0];
-			context.setColorWriteMask(0, attachment.colorWriteMask);
 			context.alphaBlendEnable = (attachment.blendEnable == VK_TRUE);
 			context.blendOperationStateAlpha = attachment.alphaBlendOp;
 			context.blendOperationState = attachment.colorBlendOp;