Commit a2c8b778 by Ben Clayton

SpirvShader: Implement GLSLstd450Sin

Bug: b/126873455 Tests: dEQP-VK.glsl.builtin.precision.sin.* Change-Id: Iec96b2a235534fbc5b76c699a6b62679b75582ca Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28668Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 251bc28f
...@@ -3284,6 +3284,15 @@ namespace sw ...@@ -3284,6 +3284,15 @@ namespace sw
} }
break; break;
} }
case GLSLstd450Sin:
{
auto radians = GenericValue(this, routine, insn.word(5));
for (auto i = 0u; i < type.sizeInComponents; i++)
{
dst.move(i, Sin(radians.Float(i)));
}
break;
}
default: default:
UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex); UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex);
} }
......
...@@ -554,6 +554,7 @@ namespace rr ...@@ -554,6 +554,7 @@ namespace rr
func_.emplace("printf", reinterpret_cast<void*>(printf)); func_.emplace("printf", reinterpret_cast<void*>(printf));
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));
} }
void *findSymbol(const std::string &name) const void *findSymbol(const std::string &name) const
...@@ -3063,6 +3064,12 @@ namespace rr ...@@ -3063,6 +3064,12 @@ namespace rr
} }
} }
RValue<Float4> Sin(RValue<Float4> v)
{
auto func = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::sin, { 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));
......
...@@ -2206,6 +2206,10 @@ namespace rr ...@@ -2206,6 +2206,10 @@ namespace rr
RValue<Float4> Floor(RValue<Float4> x); RValue<Float4> Floor(RValue<Float4> x);
RValue<Float4> Ceil(RValue<Float4> x); RValue<Float4> Ceil(RValue<Float4> x);
// Trigonometric functions
// TODO: Currentlhy unimplemented for Subzero.
RValue<Float4> Sin(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