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/+/28443
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 27d5251..8b3be66 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -570,6 +570,7 @@
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 @@
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));