Commit 14740063 by Ben Clayton

SpirvShader: Implement GLSLstd450Tan

Bug: b/126873455 Tests: dEQP-VK.glsl.builtin.precision.tan.* Change-Id: I229b46b285075bd25272145a562135df08438160 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28670 Presubmit-Ready: Ben Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Tested-by: 's avatarChris Forbes <chrisforbes@google.com>
parent 1b6f8c7d
...@@ -3302,6 +3302,15 @@ namespace sw ...@@ -3302,6 +3302,15 @@ namespace sw
} }
break; break;
} }
case GLSLstd450Tan:
{
auto radians = GenericValue(this, routine, insn.word(5));
for (auto i = 0u; i < type.sizeInComponents; i++)
{
dst.move(i, Tan(radians.Float(i)));
}
break;
}
default: default:
UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex); UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex);
} }
......
...@@ -556,6 +556,13 @@ namespace rr ...@@ -556,6 +556,13 @@ namespace rr
func_.emplace("fmodf", reinterpret_cast<void*>(fmodf)); func_.emplace("fmodf", reinterpret_cast<void*>(fmodf));
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));
#ifdef __APPLE__
// LLVM uses this function on macOS for tan.
func_.emplace("sincosf_stret", reinterpret_cast<void*>(__sincosf_stret));
#elif defined(__linux__)
func_.emplace("sincosf", reinterpret_cast<void*>(sincosf));
#endif // __APPLE__
} }
void *findSymbol(const std::string &name) const void *findSymbol(const std::string &name) const
...@@ -3077,6 +3084,11 @@ namespace rr ...@@ -3077,6 +3084,11 @@ namespace rr
return RValue<Float4>(V(::builder->CreateCall(func, V(v.value)))); return RValue<Float4>(V(::builder->CreateCall(func, V(v.value))));
} }
RValue<Float4> Tan(RValue<Float4> v)
{
return Sin(v) / Cos(v);
}
Type *Float4::getType() Type *Float4::getType()
{ {
return T(llvm::VectorType::get(T(Float::getType()), 4)); return T(llvm::VectorType::get(T(Float::getType()), 4));
......
...@@ -2210,6 +2210,7 @@ namespace rr ...@@ -2210,6 +2210,7 @@ namespace rr
// TODO: Currentlhy unimplemented for Subzero. // TODO: Currentlhy unimplemented for Subzero.
RValue<Float4> Sin(RValue<Float4> x); RValue<Float4> Sin(RValue<Float4> x);
RValue<Float4> Cos(RValue<Float4> x); RValue<Float4> Cos(RValue<Float4> x);
RValue<Float4> Tan(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