Fixed some unary operators
There were a few issues in unary operators:
- Many were not compiling because the promote function had not
been adjusted to take the new builtin functions into account
- abs and sign had not been implemented for int
- For the integer abs version, used pabsd. Removed the extra
argument, which seemed unnecessary (abs should have 1 input,
1 output, AFAIK).
Change-Id: If02c5040438e8c45c99fc7b3c55107448c85cf58
Reviewed-on: https://swiftshader-review.googlesource.com/4970
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Shader/ShaderCore.cpp b/src/Shader/ShaderCore.cpp
index f177a68..d06dc9b 100644
--- a/src/Shader/ShaderCore.cpp
+++ b/src/Shader/ShaderCore.cpp
@@ -1357,6 +1357,14 @@
sgn(dst.w, src.w);
}
+ void ShaderCore::isgn(Vector4f &dst, const Vector4f &src)
+ {
+ isgn(dst.x, src.x);
+ isgn(dst.y, src.y);
+ isgn(dst.z, src.z);
+ isgn(dst.w, src.w);
+ }
+
void ShaderCore::abs(Vector4f &dst, const Vector4f &src)
{
dst.x = Abs(src.x);
@@ -1364,7 +1372,15 @@
dst.z = Abs(src.z);
dst.w = Abs(src.w);
}
-
+
+ void ShaderCore::iabs(Vector4f &dst, const Vector4f &src)
+ {
+ dst.x = As<Float4>(Abs(As<Int4>(src.x)));
+ dst.y = As<Float4>(Abs(As<Int4>(src.y)));
+ dst.z = As<Float4>(Abs(As<Int4>(src.z)));
+ dst.w = As<Float4>(Abs(As<Int4>(src.w)));
+ }
+
void ShaderCore::nrm2(Vector4f &dst, const Vector4f &src, bool pp)
{
Float4 dot = dot2(src, src);
@@ -1595,6 +1611,13 @@
dst = As<Float4>(neg | pos);
}
+ void ShaderCore::isgn(Float4 &dst, const Float4 &src)
+ {
+ Int4 neg = CmpLT(As<Int4>(src), Int4(0)) & Int4(-1);
+ Int4 pos = CmpNLE(As<Int4>(src), Int4(0)) & Int4(1);
+ dst = As<Float4>(neg | pos);
+ }
+
void ShaderCore::cmp0(Float4 &dst, const Float4 &src0, const Float4 &src1, const Float4 &src2)
{
Int4 pos = CmpLE(Float4(0.0f), src0);