Added UInt to FP cast

UInt4 -> Float4 already existed, but not UInt -> Float.

Added the scalar conversion code and used it in the
Blitter where appropriate.

Change-Id: I9ebf63fdf8b139b960237b269f2da088f6ecac86
Reviewed-on: https://swiftshader-review.googlesource.com/10888
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index d8bda70..c3a59ff 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -5595,6 +5595,14 @@
 		storeValue(integer);
 	}
 
+	Float::Float(RValue<UInt> cast)
+	{
+		RValue<Float> result = Float(Int(cast & UInt(0x7FFFFFFF))) +
+		                       As<Float>((As<Int>(cast) >> 31) & As<Int>(Float(0x80000000u)));
+
+		storeValue(result.value);
+	}
+
 	Float::Float(float x)
 	{
 		storeValue(Nucleus::createConstantFloat(x));
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp
index b02c6be..186f739 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -1535,6 +1535,7 @@
 	{
 	public:
 		explicit Float(RValue<Int> cast);
+		explicit Float(RValue<UInt> cast);
 
 		Float() = default;
 		Float(float x);
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index fb116a3..9f01b2a 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -5715,6 +5715,14 @@
 		storeValue(integer);
 	}
 
+	Float::Float(RValue<UInt> cast)
+	{
+		RValue<Float> result = Float(Int(cast & UInt(0x7FFFFFFF))) +
+		                       As<Float>((As<Int>(cast) >> 31) & As<Int>(Float(0x80000000u)));
+
+		storeValue(result.value);
+	}
+
 	Float::Float(float x)
 	{
 		storeValue(Nucleus::createConstantFloat(x));
diff --git a/src/Renderer/Blitter.cpp b/src/Renderer/Blitter.cpp
index c93b09f..0c4a160 100644
--- a/src/Renderer/Blitter.cpp
+++ b/src/Renderer/Blitter.cpp
@@ -260,11 +260,11 @@
 			c.w = float(0xFFFF);
 			break;
 		case FORMAT_R32I:
-			c.x = Float(Int(*Pointer<Int>(element)));
+			c.x = Float(*Pointer<Int>(element));
 			c.w = float(0x7FFFFFFF);
 			break;
 		case FORMAT_R32UI:
-			c.x = Float(Int(*Pointer<UInt>(element)));
+			c.x = Float(*Pointer<UInt>(element));
 			c.w = float(0xFFFFFFFF);
 			break;
 		case FORMAT_A8R8G8B8:
@@ -359,13 +359,13 @@
 			c.w = float(0xFFFF);
 			break;
 		case FORMAT_G32R32I:
-			c.x = Float(Int(*Pointer<Int>(element + 0)));
-			c.y = Float(Int(*Pointer<Int>(element + 4)));
+			c.x = Float(*Pointer<Int>(element + 0));
+			c.y = Float(*Pointer<Int>(element + 4));
 			c.w = float(0x7FFFFFFF);
 			break;
 		case FORMAT_G32R32UI:
-			c.x = Float(Int(*Pointer<UInt>(element + 0)));
-			c.y = Float(Int(*Pointer<UInt>(element + 4)));
+			c.x = Float(*Pointer<UInt>(element + 0));
+			c.y = Float(*Pointer<UInt>(element + 4));
 			c.w = float(0xFFFFFFFF);
 			break;
 		case FORMAT_A32B32G32R32F:
@@ -835,24 +835,18 @@
 			c = Insert(c, Int(*Pointer<UShort>(element)), 0);
 			break;
 		case FORMAT_A32B32G32R32I:
+		case FORMAT_A32B32G32R32UI:
 			c = *Pointer<Int4>(element);
 			break;
 		case FORMAT_X32B32G32R32I:
+		case FORMAT_X32B32G32R32UI:
 			c = Insert(c, *Pointer<Int>(element + 8), 2);
 		case FORMAT_G32R32I:
+		case FORMAT_G32R32UI:
 			c = Insert(c, *Pointer<Int>(element + 4), 1);
 		case FORMAT_R32I:
-			c = Insert(c, *Pointer<Int>(element), 0);
-			break;
-		case FORMAT_A32B32G32R32UI:
-			c = *Pointer<UInt4>(element);
-			break;
-		case FORMAT_X32B32G32R32UI:
-			c = Insert(c, Int(*Pointer<UInt>(element + 8)), 2);
-		case FORMAT_G32R32UI:
-			c = Insert(c, Int(*Pointer<UInt>(element + 4)), 1);
 		case FORMAT_R32UI:
-			c = Insert(c, Int(*Pointer<UInt>(element)), 0);
+			c = Insert(c, *Pointer<Int>(element), 0);
 			break;
 		default:
 			return false;