summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Watry <awatry@gmail.com>2013-04-13 11:32:18 -0500
committerTom Stellard <thomas.stellard@amd.com>2013-04-19 23:27:32 -0400
commit14ba296d8d907a26af95dd6dd9de4a0d9871339a (patch)
tree3de3aceeb6f78dea87d0647c6d2117a7af78c156
parent864f8769e416516eb616ac524a2781560b5c8c54 (diff)
libclc: Add clamp(vec, scalar, scalar) and max(vec, scalar)
For any GENTYPE that isn't scalar, we need to implement a mixed vector/scalar version of clamp/max. This depends on the min() patches I sent to the list a few minutes ago.
-rw-r--r--generic/include/clc/shared/clamp.inc4
-rw-r--r--generic/include/clc/shared/max.inc4
-rw-r--r--generic/lib/shared/clamp.inc6
-rw-r--r--generic/lib/shared/max.inc6
4 files changed, 20 insertions, 0 deletions
diff --git a/generic/include/clc/shared/clamp.inc b/generic/include/clc/shared/clamp.inc
index 3e3a435..67c8142 100644
--- a/generic/include/clc/shared/clamp.inc
+++ b/generic/include/clc/shared/clamp.inc
@@ -1 +1,5 @@
_CLC_OVERLOAD _CLC_DECL GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z);
+
+#ifndef SCALAR
+_CLC_OVERLOAD _CLC_DECL GENTYPE clamp(GENTYPE x, SCALAR_GENTYPE y, SCALAR_GENTYPE z);
+#endif
diff --git a/generic/include/clc/shared/max.inc b/generic/include/clc/shared/max.inc
index ce6c6d0..9fe73c4 100644
--- a/generic/include/clc/shared/max.inc
+++ b/generic/include/clc/shared/max.inc
@@ -1 +1,5 @@
_CLC_OVERLOAD _CLC_DECL GENTYPE max(GENTYPE a, GENTYPE b);
+
+#ifndef SCALAR
+_CLC_OVERLOAD _CLC_DECL GENTYPE max(GENTYPE a, SCALAR_GENTYPE b);
+#endif
diff --git a/generic/lib/shared/clamp.inc b/generic/lib/shared/clamp.inc
index ed49b8e..58370d3 100644
--- a/generic/lib/shared/clamp.inc
+++ b/generic/lib/shared/clamp.inc
@@ -1,3 +1,9 @@
_CLC_OVERLOAD _CLC_DEF GENTYPE clamp(GENTYPE x, GENTYPE y, GENTYPE z) {
return (x > z ? z : (x < y ? y : x));
}
+
+#ifndef SCALAR
+_CLC_OVERLOAD _CLC_DEF GENTYPE clamp(GENTYPE x, SCALAR_GENTYPE y, SCALAR_GENTYPE z) {
+ return (x > (GENTYPE)z ? (GENTYPE)z : (x < (GENTYPE)y ? (GENTYPE)y : x));
+}
+#endif \ No newline at end of file
diff --git a/generic/lib/shared/max.inc b/generic/lib/shared/max.inc
index 37409fc..6a12b6f 100644
--- a/generic/lib/shared/max.inc
+++ b/generic/lib/shared/max.inc
@@ -1,3 +1,9 @@
_CLC_OVERLOAD _CLC_DEF GENTYPE max(GENTYPE a, GENTYPE b) {
return (a > b ? a : b);
}
+
+#ifndef SCALAR
+_CLC_OVERLOAD _CLC_DEF GENTYPE max(GENTYPE a, SCALAR_GENTYPE b) {
+ return (a > (GENTYPE)b ? a : (GENTYPE)b);
+}
+#endif \ No newline at end of file