Commit 2c1da722 by Ben Clayton

SpirvShader: Implement GLSLstd450Log

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