Refactor high-precision texture coordinate addressing.

Uses 0, -1 offsets instead of 0, 1 to be able to use it as a
mask. Optimize calculation of the integer coordinates and fraction by
always having xyz1 = xyz0 + 1 (before wrap). Optimize the
clamping/wrapping of the integer coordinates. Skip addressing operation
of the third component for cube sampling (since already projected to
2D face).

Change-Id: If2e7c74aac9ae923a0c1ffc278fcdfec00f216f3
Reviewed-on: https://swiftshader-review.googlesource.com/14269
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Renderer/Sampler.cpp b/src/Renderer/Sampler.cpp
index 5bf11c8..71a6eaf 100644
--- a/src/Renderer/Sampler.cpp
+++ b/src/Renderer/Sampler.cpp
@@ -454,7 +454,7 @@
 
 	AddressingMode Sampler::getAddressingModeU() const
 	{
-		if(hasCubeTexture())
+		if(textureType == TEXTURE_CUBE)
 		{
 			return ADDRESSING_CLAMP;
 		}
@@ -464,7 +464,7 @@
 
 	AddressingMode Sampler::getAddressingModeV() const
 	{
-		if(hasCubeTexture())
+		if(textureType == TEXTURE_CUBE)
 		{
 			return ADDRESSING_CLAMP;
 		}
@@ -474,12 +474,9 @@
 
 	AddressingMode Sampler::getAddressingModeW() const
 	{
-		if(hasCubeTexture())
-		{
-			return ADDRESSING_CLAMP;
-		}
-
-		if(textureType == TEXTURE_2D_ARRAY || textureType == TEXTURE_2D)
+		if(textureType == TEXTURE_2D_ARRAY ||
+		   textureType == TEXTURE_2D ||
+		   textureType == TEXTURE_CUBE)
 		{
 			return ADDRESSING_LAYER;
 		}