Commit f9350d76 by Ben Clayton

SpirvShader: Implement GLSLstd450Asin

Bug: b/126873455 Tests: dEQP-VK.glsl.builtin.precision.asin.* Change-Id: Ifb1e6b5f54b27abfb4324f5d2246717400da639f Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28671Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 14740063
......@@ -3311,6 +3311,15 @@ namespace sw
}
break;
}
case GLSLstd450Asin:
{
auto val = GenericValue(this, routine, insn.word(5));
for (auto i = 0u; i < type.sizeInComponents; i++)
{
dst.move(i, Asin(val.Float(i)));
}
break;
}
default:
UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex);
}
......
......@@ -556,6 +556,7 @@ namespace rr
func_.emplace("fmodf", reinterpret_cast<void*>(fmodf));
func_.emplace("sinf", reinterpret_cast<void*>(sinf));
func_.emplace("cosf", reinterpret_cast<void*>(cosf));
func_.emplace("asinf", reinterpret_cast<void*>(asinf));
#ifdef __APPLE__
// LLVM uses this function on macOS for tan.
......@@ -3089,6 +3090,19 @@ namespace rr
return Sin(v) / Cos(v);
}
RValue<Float4> Asin(RValue<Float4> v)
{
auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), {T(Float::getType())}, false);
auto func = ::module->getOrInsertFunction("asinf", funcTy);
llvm::Value *out = ::llvm::UndefValue::get(T(Float4::getType()));
for (uint64_t i = 0; i < 4; i++)
{
auto el = ::builder->CreateCall(func, ::builder->CreateExtractElement(V(v.value), i));
out = ::builder->CreateInsertElement(out, el, i);
}
return RValue<Float4>(V(out));
}
Type *Float4::getType()
{
return T(llvm::VectorType::get(T(Float::getType()), 4));
......
......@@ -2211,6 +2211,7 @@ namespace rr
RValue<Float4> Sin(RValue<Float4> x);
RValue<Float4> Cos(RValue<Float4> x);
RValue<Float4> Tan(RValue<Float4> x);
RValue<Float4> Asin(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