Commit eafae477 by Ben Clayton

SpirvShader: Implement GLSLstd450Acos

Bug: b/126873455 Tests: dEQP-VK.glsl.builtin.precision.acos.* Change-Id: I7f65b398b6dc9ba5daf2df0a98c41b50b9775cd2 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28672Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent f9350d76
...@@ -3320,6 +3320,15 @@ namespace sw ...@@ -3320,6 +3320,15 @@ namespace sw
} }
break; break;
} }
case GLSLstd450Acos:
{
auto val = GenericValue(this, routine, insn.word(5));
for (auto i = 0u; i < type.sizeInComponents; i++)
{
dst.move(i, Acos(val.Float(i)));
}
break;
}
default: default:
UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex); UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex);
} }
......
...@@ -557,6 +557,7 @@ namespace rr ...@@ -557,6 +557,7 @@ namespace rr
func_.emplace("sinf", reinterpret_cast<void*>(sinf)); func_.emplace("sinf", reinterpret_cast<void*>(sinf));
func_.emplace("cosf", reinterpret_cast<void*>(cosf)); func_.emplace("cosf", reinterpret_cast<void*>(cosf));
func_.emplace("asinf", reinterpret_cast<void*>(asinf)); func_.emplace("asinf", reinterpret_cast<void*>(asinf));
func_.emplace("acosf", reinterpret_cast<void*>(acosf));
#ifdef __APPLE__ #ifdef __APPLE__
// LLVM uses this function on macOS for tan. // LLVM uses this function on macOS for tan.
...@@ -3090,10 +3091,10 @@ namespace rr ...@@ -3090,10 +3091,10 @@ namespace rr
return Sin(v) / Cos(v); return Sin(v) / Cos(v);
} }
RValue<Float4> Asin(RValue<Float4> v) static RValue<Float4> TransformFloat4PerElement(RValue<Float4> v, const char* name)
{ {
auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), {T(Float::getType())}, false); auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), {T(Float::getType())}, false);
auto func = ::module->getOrInsertFunction("asinf", funcTy); auto func = ::module->getOrInsertFunction(name, funcTy);
llvm::Value *out = ::llvm::UndefValue::get(T(Float4::getType())); llvm::Value *out = ::llvm::UndefValue::get(T(Float4::getType()));
for (uint64_t i = 0; i < 4; i++) for (uint64_t i = 0; i < 4; i++)
{ {
...@@ -3103,6 +3104,16 @@ namespace rr ...@@ -3103,6 +3104,16 @@ namespace rr
return RValue<Float4>(V(out)); return RValue<Float4>(V(out));
} }
RValue<Float4> Asin(RValue<Float4> v)
{
return TransformFloat4PerElement(v, "asinf");
}
RValue<Float4> Acos(RValue<Float4> v)
{
return TransformFloat4PerElement(v, "acosf");
}
Type *Float4::getType() Type *Float4::getType()
{ {
return T(llvm::VectorType::get(T(Float::getType()), 4)); return T(llvm::VectorType::get(T(Float::getType()), 4));
......
...@@ -2212,6 +2212,7 @@ namespace rr ...@@ -2212,6 +2212,7 @@ namespace rr
RValue<Float4> Cos(RValue<Float4> x); RValue<Float4> Cos(RValue<Float4> x);
RValue<Float4> Tan(RValue<Float4> x); RValue<Float4> Tan(RValue<Float4> x);
RValue<Float4> Asin(RValue<Float4> x); RValue<Float4> Asin(RValue<Float4> x);
RValue<Float4> Acos(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