Commit 242f002c by Ben Clayton

SpirvShader: Implement GLSLstd450Exp

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