Commit e17acfe5 by Ben Clayton

SpirvShader: Implement GLSLstd450Log2

Bug: b/126873455 Tests: dEQP-VK.glsl.builtin.precision.log2.* Change-Id: I1a6a4e1fbf41ccd7aacf2fa7fbe8b8e7c6d28f3b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28443Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent f40b56c4
......@@ -3441,7 +3441,11 @@ namespace sw
}
case GLSLstd450Log2:
{
UNIMPLEMENTED("GLSLstd450Log2");
auto val = GenericValue(this, routine, insn.word(5));
for (auto i = 0u; i < type.sizeInComponents; i++)
{
dst.move(i, Log2(val.Float(i)));
}
break;
}
case GLSLstd450Sqrt:
......
......@@ -570,6 +570,7 @@ namespace rr
func_.emplace("expf", reinterpret_cast<void*>(expf));
func_.emplace("logf", reinterpret_cast<void*>(logf));
func_.emplace("exp2f", reinterpret_cast<void*>(exp2f));
func_.emplace("log2f", reinterpret_cast<void*>(log2f));
#ifdef __APPLE__
// LLVM uses this function on macOS for tan.
......@@ -3203,6 +3204,12 @@ namespace rr
return RValue<Float4>(V(::builder->CreateCall(func, { V(v.value) })));
}
RValue<Float4> Log2(RValue<Float4> v)
{
auto func = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::log2, { 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));
......
......@@ -2228,6 +2228,7 @@ namespace rr
RValue<Float4> Exp(RValue<Float4> x);
RValue<Float4> Log(RValue<Float4> x);
RValue<Float4> Exp2(RValue<Float4> x);
RValue<Float4> Log2(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