OSDN Git Service

Added UInt to FP cast
authorAlexis Hetu <sugoi@google.com>
Mon, 24 Jul 2017 18:44:33 +0000 (14:44 -0400)
committerAlexis Hétu <sugoi@google.com>
Mon, 24 Jul 2017 18:55:53 +0000 (18:55 +0000)
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>
src/Reactor/LLVMReactor.cpp
src/Reactor/Reactor.hpp
src/Reactor/SubzeroReactor.cpp
src/Renderer/Blitter.cpp

index d8bda70..c3a59ff 100644 (file)
@@ -5595,6 +5595,14 @@ namespace sw
                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));
index b02c6be..186f739 100644 (file)
@@ -1535,6 +1535,7 @@ namespace sw
        {
        public:
                explicit Float(RValue<Int> cast);
+               explicit Float(RValue<UInt> cast);
 
                Float() = default;
                Float(float x);
index fb116a3..9f01b2a 100644 (file)
@@ -5715,6 +5715,14 @@ namespace sw
                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));
index c93b09f..0c4a160 100644 (file)
@@ -260,11 +260,11 @@ namespace sw
                        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 @@ namespace sw
                        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 @@ namespace sw
                        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;