Use pixel centers for non-multisampled rasterization

Previously the rasterizer was just using sample location 0. The Vulkan
1.1.130 spec states that "When VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT
lines are being rasterized, sample locations may all be treated as being
at the pixel center". And also "Do we need to support Bresenham-style
and smooth lines with more than one rasterization sample? RESOLVED: Yes.
For simplicity, Bresenham line rasterization carries forward a few
restrictions from OpenGL, such as not supporting per-sample shading,
alpha to coverage, or alpha to one."

Bug: b/142965928
Change-Id: I586ffbaa92d506595d6fecfa2dbd64f10bdee0c8
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40188
Presubmit-Ready: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Device/SetupProcessor.cpp b/src/Device/SetupProcessor.cpp
index f9b2ca3..030343d 100644
--- a/src/Device/SetupProcessor.cpp
+++ b/src/Device/SetupProcessor.cpp
@@ -79,6 +79,8 @@
 	state.cullMode = context->cullMode;
 
 	state.multiSampleCount = context->sampleCount;
+	state.enableMultiSampling = (state.multiSampleCount > 1) &&
+	                            !(context->isDrawLine(true) && (context->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT));
 	state.rasterizerDiscard = context->rasterizerDiscard;
 
 	state.numClipDistances = context->vertexShader->getNumOutputClipDistances();
diff --git a/src/Device/SetupProcessor.hpp b/src/Device/SetupProcessor.hpp
index c583c27..9089b79 100644
--- a/src/Device/SetupProcessor.hpp
+++ b/src/Device/SetupProcessor.hpp
@@ -52,6 +52,7 @@
 		VkFrontFace frontFace : BITS(VK_FRONT_FACE_MAX_ENUM);
 		VkCullModeFlags cullMode : BITS(VK_CULL_MODE_FLAG_BITS_MAX_ENUM);
 		unsigned int multiSampleCount : 3;  // 1, 2 or 4
+		bool enableMultiSampling : 1;
 		bool rasterizerDiscard : 1;
 		unsigned int numClipDistances : 4;  // [0 - 8]
 		unsigned int numCullDistances : 4;  // [0 - 8]
diff --git a/src/Pipeline/SetupRoutine.cpp b/src/Pipeline/SetupRoutine.cpp
index 9c86104..84073e2 100644
--- a/src/Pipeline/SetupRoutine.cpp
+++ b/src/Pipeline/SetupRoutine.cpp
@@ -166,7 +166,7 @@
 		constexpr int subPixM = vk::SUBPIXEL_PRECISION_MASK;
 		constexpr float subPixF = vk::SUBPIXEL_PRECISION_FACTOR;
 
-		if(state.multiSampleCount > 1)
+		if(state.enableMultiSampling)
 		{
 			yMin = (yMin + Constants::yMinMultiSampleOffset) >> subPixB;
 			yMax = (yMax + Constants::yMaxMultiSampleOffset) >> subPixB;
@@ -200,7 +200,7 @@
 				Xq[i] = X[i];
 				Yq[i] = Y[i];
 
-				if(state.multiSampleCount > 1)
+				if(state.enableMultiSampling)
 				{
 					Xq[i] = Xq[i] + *Pointer<Int>(constants + OFFSET(Constants, Xf) + q * sizeof(int));
 					Yq[i] = Yq[i] + *Pointer<Int>(constants + OFFSET(Constants, Yf) + q * sizeof(int));
@@ -213,7 +213,7 @@
 			Pointer<Byte> leftEdge = Pointer<Byte>(primitive + OFFSET(Primitive, outline->left)) + q * sizeof(Primitive);
 			Pointer<Byte> rightEdge = Pointer<Byte>(primitive + OFFSET(Primitive, outline->right)) + q * sizeof(Primitive);
 
-			if(state.multiSampleCount > 1)
+			if(state.enableMultiSampling)
 			{
 				Int xMin = *Pointer<Int>(data + OFFSET(DrawData, scissorX0));
 				Int xMax = *Pointer<Int>(data + OFFSET(DrawData, scissorX1));
@@ -242,7 +242,7 @@
 				Until(i >= n);
 			}
 
-			if(state.multiSampleCount == 1)
+			if(!state.enableMultiSampling)
 			{
 				For(, yMin < yMax && *Pointer<Short>(leftEdge + yMin * sizeof(Primitive::Span)) == *Pointer<Short>(rightEdge + yMin * sizeof(Primitive::Span)), yMin++)
 				{