Commit f40b56c4 by Ben Clayton

SpirvShader: Implement GLSLstd450Exp2

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