Commit b13cf49c by Nicolas Capens

Fix rounding to nearest integer.

Change-Id: I2fbd6524f1975f2c76ae0b5e544f323e7c7e4537 Reviewed-on: https://swiftshader-review.googlesource.com/8269Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 3ea9295f
...@@ -4122,8 +4122,10 @@ namespace sw ...@@ -4122,8 +4122,10 @@ namespace sw
RValue<Int> RoundInt(RValue<Float> cast) RValue<Int> RoundInt(RValue<Float> cast)
{ {
RValue<Float> rounded = Round(cast);
Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32); Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32);
auto round = Ice::InstCast::create(::function, Ice::InstCast::Fptosi, result, cast.value); auto round = Ice::InstCast::create(::function, Ice::InstCast::Fptosi, result, rounded.value);
::basicBlock->appendInst(round); ::basicBlock->appendInst(round);
return RValue<Int>(V(result)); return RValue<Int>(V(result));
...@@ -5336,8 +5338,10 @@ namespace sw ...@@ -5336,8 +5338,10 @@ namespace sw
RValue<Int4> RoundInt(RValue<Float4> cast) RValue<Int4> RoundInt(RValue<Float4> cast)
{ {
RValue<Float4> rounded = Round(cast);
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4i32); Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4i32);
auto round = Ice::InstCast::create(::function, Ice::InstCast::Fptosi, result, cast.value); auto round = Ice::InstCast::create(::function, Ice::InstCast::Fptosi, result, rounded.value);
::basicBlock->appendInst(round); ::basicBlock->appendInst(round);
return RValue<Int4>(V(result)); return RValue<Int4>(V(result));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment