Commit bfe94f02 by Ben Clayton

SpirvShader: Implement GLSLstd450Pow

Bug: b/126873455 Tests: dEQP-VK.glsl.builtin.precision.pow.* Change-Id: I74797e69adc78e4c06ec4a8b2923b78166afbc18 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28439Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent a520c3e2
......@@ -3404,7 +3404,12 @@ namespace sw
}
case GLSLstd450Pow:
{
UNIMPLEMENTED("GLSLstd450Pow");
auto x = GenericValue(this, routine, insn.word(5));
auto y = GenericValue(this, routine, insn.word(6));
for (auto i = 0u; i < type.sizeInComponents; i++)
{
dst.move(i, Pow(x.Float(i), y.Float(i)));
}
break;
}
case GLSLstd450Exp:
......
......@@ -566,6 +566,7 @@ namespace rr
func_.emplace("acoshf", reinterpret_cast<void*>(acoshf));
func_.emplace("atanhf", reinterpret_cast<void*>(atanhf));
func_.emplace("atan2f", reinterpret_cast<void*>(atan2f));
func_.emplace("powf", reinterpret_cast<void*>(powf));
#ifdef __APPLE__
// LLVM uses this function on macOS for tan.
......@@ -3174,6 +3175,13 @@ namespace rr
return RValue<Float4>(V(out));
}
RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y)
{
auto func = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::pow,
{ T(Float4::getType()), T(Float4::getType()) } );
return RValue<Float4>(V(::builder->CreateCall(func, { V(x.value), V(y.value) })));
}
Type *Float4::getType()
{
return T(llvm::VectorType::get(T(Float::getType()), 4));
......
......@@ -2222,6 +2222,10 @@ namespace rr
RValue<Float4> Atanh(RValue<Float4> x);
RValue<Float4> Atan2(RValue<Float4> x, RValue<Float4> y);
// Exponential functions
// TODO: Currentlhy unimplemented for Subzero.
RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y);
template<class T>
class Pointer : public LValue<Pointer<T>>
{
......
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