Perform coordinate clamping on border addressing mode.

The border addressing mode should ideally blend with the border color
when using linear filtering. Until we have a border of pixels around
2D textures, we should probably avoid bleeding pixels from the opposite
edge and just clamp the coordinates.

Change-Id: I7afbb629998732b62413e00ba7bcd55340c7b9bb
Reviewed-on: https://swiftshader-review.googlesource.com/14289
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Shader/SamplerCore.cpp b/src/Shader/SamplerCore.cpp
index b2da001..1c97628 100644
--- a/src/Shader/SamplerCore.cpp
+++ b/src/Shader/SamplerCore.cpp
@@ -2332,7 +2332,7 @@
 		{
 			return Min(Max(Short4(RoundInt(uw)), Short4(0)), *Pointer<Short4>(mipmap + OFFSET(Mipmap, depth)) - Short4(1));
 		}
-		else if(addressingMode == ADDRESSING_CLAMP)
+		else if(addressingMode == ADDRESSING_CLAMP || addressingMode == ADDRESSING_BORDER)
 		{
 			Float4 clamp = Min(Max(uw, Float4(0.0f)), Float4(65535.0f / 65536.0f));
 
@@ -2358,7 +2358,7 @@
 
 			return As<Short4>(Int2(convert)) + Short4(0x8000u);
 		}
-		else   // Wrap (or border)
+		else   // Wrap
 		{
 			return Short4(Int4(uw * Float4(1 << 16)));
 		}
@@ -2392,6 +2392,7 @@
 			switch(addressingMode)
 			{
 			case ADDRESSING_CLAMP:
+			case ADDRESSING_BORDER:
 				{
 					Float4 one = As<Float4>(Int4(oneBits));
 					coord = Min(Max(coord, Float4(0.0f)), one);
@@ -2413,7 +2414,7 @@
 					coord = one - Abs(two * Frac(Min(Max(coord, -one), two) * half) - one);
 				}
 				break;
-			default:   // Wrap (or border)
+			default:   // Wrap
 				coord = Frac(coord);
 				break;
 			}