Commit 1b6f8c7d by Ben Clayton

SpirvShader: Implement GLSLstd450Cos

Bug: b/126873455 Tests: dEQP-VK.glsl.builtin.precision.cos.* Change-Id: I4b5fe36487f0832ad21f3e78df9ba133284cffbd Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28669Tested-by: 's avatarBen Clayton <bclayton@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent a2c8b778
...@@ -3293,6 +3293,15 @@ namespace sw ...@@ -3293,6 +3293,15 @@ namespace sw
} }
break; break;
} }
case GLSLstd450Cos:
{
auto radians = GenericValue(this, routine, insn.word(5));
for (auto i = 0u; i < type.sizeInComponents; i++)
{
dst.move(i, Cos(radians.Float(i)));
}
break;
}
default: default:
UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex); UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex);
} }
......
...@@ -555,6 +555,7 @@ namespace rr ...@@ -555,6 +555,7 @@ namespace rr
func_.emplace("puts", reinterpret_cast<void*>(puts)); func_.emplace("puts", reinterpret_cast<void*>(puts));
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));
} }
void *findSymbol(const std::string &name) const void *findSymbol(const std::string &name) const
...@@ -3070,6 +3071,12 @@ namespace rr ...@@ -3070,6 +3071,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> Cos(RValue<Float4> v)
{
auto func = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::cos, { V(v.value)->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));
......
...@@ -2209,6 +2209,7 @@ namespace rr ...@@ -2209,6 +2209,7 @@ namespace rr
// Trigonometric functions // Trigonometric functions
// 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);
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