Fix TextureTestUtil::toRGBA(Masked) behavior with infinities.
authorJarkko Pöyry <jpoyry@google.com>
Mon, 2 Mar 2015 21:51:30 +0000 (13:51 -0800)
committerJarkko Pöyry <jpoyry@google.com>
Mon, 9 Mar 2015 23:40:33 +0000 (16:40 -0700)
- toRGBA(Masked) incorrectly returned 0 for infinity. This change makes
  the functions return 255 as expected.

Change-Id: I7d013d0abb9c395fc5e74b000fec2ae8db32f0d2

modules/glshared/glsTextureTestUtil.hpp

index f918985..69d2b5a 100644 (file)
 #include "tcuPixelFormat.hpp"
 #include "tcuRenderTarget.hpp"
 #include "tcuTestContext.hpp"
-#include "deMath.h"
-#include "deInt32.h"
-#include "gluShaderProgram.hpp"
 #include "tcuTestLog.hpp"
 #include "tcuCompressedTexture.hpp"
+#include "tcuTextureUtil.hpp"
+
+#include "gluShaderProgram.hpp"
 #include "gluShaderUtil.hpp"
 
+#include "deMath.h"
+#include "deInt32.h"
+
 #include <map>
 
 namespace tcu
@@ -239,20 +242,18 @@ public:
 
 inline tcu::RGBA toRGBA (const tcu::Vec4& v)
 {
-       // \todo [2011-10-24 pyry] Rounding mode?
-       return tcu::RGBA(deClamp32(deRoundFloatToInt32(v.x()*255.0f), 0, 255),
-                                        deClamp32(deRoundFloatToInt32(v.y()*255.0f), 0, 255),
-                                        deClamp32(deRoundFloatToInt32(v.z()*255.0f), 0, 255),
-                                        deClamp32(deRoundFloatToInt32(v.w()*255.0f), 0, 255));
+       return tcu::RGBA(tcu::floatToU8(v.x()),
+                                        tcu::floatToU8(v.y()),
+                                        tcu::floatToU8(v.z()),
+                                        tcu::floatToU8(v.w()));
 }
 
 inline tcu::RGBA toRGBAMasked (const tcu::Vec4& v, deUint8 mask)
 {
-       // \todo [2011-10-24 pyry] Rounding mode?
-       return tcu::RGBA((mask&tcu::RGBA::RED_MASK)             ? deClamp32(deRoundFloatToInt32(v.x()*255.0f), 0, 255) : 0,
-                                        (mask&tcu::RGBA::GREEN_MASK)   ? deClamp32(deRoundFloatToInt32(v.y()*255.0f), 0, 255) : 0,
-                                        (mask&tcu::RGBA::BLUE_MASK)    ? deClamp32(deRoundFloatToInt32(v.z()*255.0f), 0, 255) : 0,
-                                        (mask&tcu::RGBA::ALPHA_MASK)   ? deClamp32(deRoundFloatToInt32(v.w()*255.0f), 0, 255) : 0xff);
+       return tcu::RGBA((mask&tcu::RGBA::RED_MASK)             ? tcu::floatToU8(v.x()) : 0,
+                                        (mask&tcu::RGBA::GREEN_MASK)   ? tcu::floatToU8(v.y()) : 0,
+                                        (mask&tcu::RGBA::BLUE_MASK)    ? tcu::floatToU8(v.z()) : 0,
+                                        (mask&tcu::RGBA::ALPHA_MASK)   ? tcu::floatToU8(v.w()) : 0);
 }
 
 inline tcu::Vec4 toVec4 (const tcu::RGBA& c)