Commit 2faa24a9 by Logan Chien Committed by Chris Forbes

Reactor: Fix RoundInt generic code generation

This commit fixes `RoundInt(Float)` and `RoundInt(Float4)` generic LLVM code generation. Bug: b/115344057 Test: functional.shaders.builtin_functions.precision.sinh.highp_vertex Test: functional.shaders.builtin_functions.precision.sinh.highp_fragment Test: functional.shaders.builtin_functions.precision.cosh.highp_vertex Test: functional.shaders.builtin_functions.precision.cosh.highp_fragment Change-Id: I35de5cf6bec6607725523a10ebf098333957f39a Reviewed-on: https://swiftshader-review.googlesource.com/20931Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 83fc07ae
...@@ -190,6 +190,11 @@ namespace ...@@ -190,6 +190,11 @@ namespace
return ::builder->CreateCall(nearbyint, ARGS(x)); return ::builder->CreateCall(nearbyint, ARGS(x));
} }
llvm::Value *lowerRoundInt(llvm::Value *x, llvm::Type *ty)
{
return ::builder->CreateFPToSI(lowerRound(x), ty);
}
llvm::Value *lowerFloor(llvm::Value *x) llvm::Value *lowerFloor(llvm::Value *x)
{ {
llvm::Function *floor = llvm::Intrinsic::getDeclaration( llvm::Function *floor = llvm::Intrinsic::getDeclaration(
...@@ -4438,7 +4443,7 @@ namespace sw ...@@ -4438,7 +4443,7 @@ namespace sw
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
return x86::cvtss2si(cast); return x86::cvtss2si(cast);
#else #else
return IfThenElse(cast > 0.0f, Int(cast + 0.5f), Int(cast - 0.5f)); return RValue<Int>(V(lowerRoundInt(V(cast.value), T(Int::getType()))));
#endif #endif
} }
...@@ -5685,7 +5690,7 @@ namespace sw ...@@ -5685,7 +5690,7 @@ namespace sw
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
return x86::cvtps2dq(cast); return x86::cvtps2dq(cast);
#else #else
return As<Int4>(V(::builder->CreateFPToSI(V(cast.value), T(Int4::getType())))); return As<Int4>(V(lowerRoundInt(V(cast.value), T(Int4::getType()))));
#endif #endif
} }
......
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